summaryrefslogtreecommitdiff
path: root/mkpasswd.c
diff options
context:
space:
mode:
authorMarco d'Itri <md@linux.it>2018-09-11 01:23:42 +0200
committerMarco d'Itri <md@linux.it>2018-09-20 00:18:06 +0200
commitd4d7cd109615e8ae3d7b3b093fc174b572cae3c2 (patch)
tree69a074f8bdfe04e2b0c50c5d200fa4d928e6be31 /mkpasswd.c
parent22002f67be6bbb6720a277c62c099f841010d68e (diff)
downloadwhois-d4d7cd109615e8ae3d7b3b093fc174b572cae3c2.tar.gz
mkpasswd: fix rounds support for bcrypt 2x and 2y
Diffstat (limited to 'mkpasswd.c')
-rw-r--r--mkpasswd.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/mkpasswd.c b/mkpasswd.c
index 26f28d4..2d474ff 100644
--- a/mkpasswd.c
+++ b/mkpasswd.c
@@ -92,16 +92,16 @@ static const struct crypt_method methods[] = {
#if defined OpenBSD || defined FreeBSD || (defined __SVR4 && defined __sun)
# if (defined OpenBSD && OpenBSD >= 201405)
/* http://marc.info/?l=openbsd-misc&m=139320023202696 */
- { "bf", "$2b$", 22, 22, 1, "Blowfish" },
- { "bfa", "$2a$", 22, 22, 1, "Blowfish (obsolete $2a$ version)" },
+ { "bf", "$2b$", 22, 22, 2, "Blowfish" },
+ { "bfa", "$2a$", 22, 22, 2, "Blowfish (obsolete $2a$ version)" },
# else
- { "bf", "$2a$", 22, 22, 1, "Blowfish" },
+ { "bf", "$2a$", 22, 22, 2, "Blowfish" },
# endif
#endif
#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 */
- { "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
#if defined FreeBSD
{ "nt", "$3$", 0, 0, 0, "NT-Hash" },
@@ -242,11 +242,11 @@ int main(int argc, char *argv[])
if (!salt_prefix) {
/* NULL means that crypt_gensalt will choose one later */
- } else if (streq(salt_prefix, "$2a$") || streq(salt_prefix, "$2b$")) {
- /* OpenBSD Blowfish and derivatives */
+ } else if (rounds_support == 2) {
+ /* bcrypt strings always contain the rounds number */
if (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);
} else if (rounds_support && rounds)
snprintf(rounds_str, sizeof(rounds_str), "rounds=%u$", rounds);