mirror of
https://github.com/rfc1036/whois.git
synced 2026-05-03 06:51:09 +00:00
mkpasswd: fix rounds support for bcrypt 2x and 2y
This commit is contained in:
parent
22002f67be
commit
d4d7cd1096
16
mkpasswd.c
16
mkpasswd.c
@ -92,16 +92,16 @@ static const struct crypt_method methods[] = {
|
|||||||
#if defined OpenBSD || defined FreeBSD || (defined __SVR4 && defined __sun)
|
#if defined OpenBSD || defined FreeBSD || (defined __SVR4 && defined __sun)
|
||||||
# if (defined OpenBSD && OpenBSD >= 201405)
|
# if (defined OpenBSD && OpenBSD >= 201405)
|
||||||
/* http://marc.info/?l=openbsd-misc&m=139320023202696 */
|
/* http://marc.info/?l=openbsd-misc&m=139320023202696 */
|
||||||
{ "bf", "$2b$", 22, 22, 1, "Blowfish" },
|
{ "bf", "$2b$", 22, 22, 2, "Blowfish" },
|
||||||
{ "bfa", "$2a$", 22, 22, 1, "Blowfish (obsolete $2a$ version)" },
|
{ "bfa", "$2a$", 22, 22, 2, "Blowfish (obsolete $2a$ version)" },
|
||||||
# else
|
# else
|
||||||
{ "bf", "$2a$", 22, 22, 1, "Blowfish" },
|
{ "bf", "$2a$", 22, 22, 2, "Blowfish" },
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#if defined HAVE_LINUX_CRYPT_GENSALT
|
#if defined HAVE_LINUX_CRYPT_GENSALT
|
||||||
{ "bf", "$2a$", 22, 22, 1, "Blowfish, system-specific on 8-bit chars" },
|
{ "bf", "$2a$", 22, 22, 2, "Blowfish, system-specific on 8-bit chars" },
|
||||||
/* algorithm 2y fixes CVE-2011-2483 */
|
/* algorithm 2y fixes CVE-2011-2483 */
|
||||||
{ "bfy", "$2y$", 22, 22, 1, "Blowfish, correct handling of 8-bit chars" },
|
{ "bfy", "$2y$", 22, 22, 2, "Blowfish, correct handling of 8-bit chars" },
|
||||||
#endif
|
#endif
|
||||||
#if defined FreeBSD
|
#if defined FreeBSD
|
||||||
{ "nt", "$3$", 0, 0, 0, "NT-Hash" },
|
{ "nt", "$3$", 0, 0, 0, "NT-Hash" },
|
||||||
@ -242,11 +242,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (!salt_prefix) {
|
if (!salt_prefix) {
|
||||||
/* NULL means that crypt_gensalt will choose one later */
|
/* NULL means that crypt_gensalt will choose one later */
|
||||||
} else if (streq(salt_prefix, "$2a$") || streq(salt_prefix, "$2b$")) {
|
} else if (rounds_support == 2) {
|
||||||
/* OpenBSD Blowfish and derivatives */
|
/* bcrypt strings always contain the rounds number */
|
||||||
if (rounds <= 5)
|
if (rounds <= 5)
|
||||||
rounds = 5;
|
rounds = 5;
|
||||||
/* actually for 2a/2y it is the logarithm of the number of rounds */
|
/* actually it is the logarithm of the number of rounds */
|
||||||
snprintf(rounds_str, sizeof(rounds_str), "%02u$", rounds);
|
snprintf(rounds_str, sizeof(rounds_str), "%02u$", rounds);
|
||||||
} else if (rounds_support && rounds)
|
} else if (rounds_support && rounds)
|
||||||
snprintf(rounds_str, sizeof(rounds_str), "rounds=%u$", rounds);
|
snprintf(rounds_str, sizeof(rounds_str), "rounds=%u$", rounds);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user