From 7a3bb4d0ea8166acc539c788a8ce943acf4a6aa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= Date: Sat, 12 Jun 2021 19:05:07 +0200 Subject: [PATCH 1/2] libmisc/salt.c: Use int pointer for YESCRYPT_salt_cost(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The corresponding functions for the other hash methods all take a pointer to an integer value as the only paramater, so this particular function should do so as well. Signed-off-by: Björn Esser --- libmisc/salt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libmisc/salt.c b/libmisc/salt.c index c35c6797..1bfa015b 100644 --- a/libmisc/salt.c +++ b/libmisc/salt.c @@ -34,7 +34,7 @@ static /*@observer@*/const char *BCRYPT_salt_rounds (/*@null@*/int *prefered_rou #endif /* USE_BCRYPT */ #ifdef USE_YESCRYPT static /*@observer@*/const char *gensalt_yescrypt (void); -static /*@observer@*/const char *YESCRYPT_salt_cost (/*@null@*/long *prefered_rounds); +static /*@observer@*/const char *YESCRYPT_salt_cost (/*@null@*/int *prefered_cost); #endif /* USE_YESCRYPT */ #ifndef HAVE_L64A @@ -277,7 +277,7 @@ static /*@observer@*/const char *gensalt_bcrypt (void) /* * Return a salt prefix specifying the cost for the YESCRYPT method. */ -static /*@observer@*/const char *YESCRYPT_salt_cost (/*@null@*/long *prefered_cost) +static /*@observer@*/const char *YESCRYPT_salt_cost (/*@null@*/int *prefered_cost) { static char cost_prefix[5]; long cost; From 738d92a4bd99a2038aa5f97b2fc85daa7011e403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= Date: Sat, 12 Jun 2021 13:54:14 +0200 Subject: [PATCH 2/2] libmisc/salt.c: bcrypt should use $2b$ as prefix for setting. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This prefix is the recommended one for new bcrypt hashes for a long time. Signed-off-by: Björn Esser --- libmisc/salt.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libmisc/salt.c b/libmisc/salt.c index 1bfa015b..5dc521ef 100644 --- a/libmisc/salt.c +++ b/libmisc/salt.c @@ -90,12 +90,8 @@ static void seedRNG (void) */ #define MAGNUM(array,ch) (array)[0]=(array)[2]='$',(array)[1]=(ch),(array)[3]='\0' #ifdef USE_BCRYPT -/* - * Using the Prefix $2a$ to enable an anti-collision safety measure in musl libc. - * Negatively affects a subset of passwords containing the '\xff' character, - * which is not valid UTF-8 (so "unlikely to cause much annoyance"). - */ -#define BCRYPTMAGNUM(array) (array)[0]=(array)[3]='$',(array)[1]='2',(array)[2]='a',(array)[4]='\0' +/* Use $2b$ as prefix for compatibility with OpenBSD's bcrypt. */ +#define BCRYPTMAGNUM(array) (array)[0]=(array)[3]='$',(array)[1]='2',(array)[2]='b',(array)[4]='\0' #endif /* USE_BCRYPT */ #if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT)