diff --git a/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/crypto_scrypt-common.c b/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/crypto_scrypt-common.c index 2101e7e9..16abcad5 100644 --- a/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/crypto_scrypt-common.c +++ b/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/crypto_scrypt-common.c @@ -26,11 +26,6 @@ #include "runtime.h" #include "utils.h" -#define BYTES2CHARS(bytes) \ - ((((bytes) * 8) + 5) / 6) - -#define HASH_LEN BYTES2CHARS(crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES) /* base-64 chars */ - static const char * const itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; @@ -153,7 +148,8 @@ escrypt_r(escrypt_local_t * local, const uint8_t * passwd, size_t passwdlen, } else { saltlen = strlen((char *)salt); } - need = prefixlen + saltlen + 1 + HASH_LEN + 1; + need = prefixlen + saltlen + 1 + + crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES_ENCODED + 1; if (need > buflen || need < saltlen) { return NULL; } diff --git a/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/crypto_scrypt.h b/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/crypto_scrypt.h index 073a52bc..b53e7337 100644 --- a/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/crypto_scrypt.h +++ b/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/crypto_scrypt.h @@ -32,6 +32,15 @@ #include +#define crypto_pwhash_scryptxsalsa208sha256_STRPREFIXBYTES 14 +#define crypto_pwhash_scryptxsalsa208sha256_STRSETTINGBYTES 57 +#define crypto_pwhash_scryptxsalsa208sha256_STRSALTBYTES 32 +#define crypto_pwhash_scryptxsalsa208sha256_STRSALTBYTES_ENCODED 43 +#define crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES 32 +#define crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES_ENCODED 43 + +#define BYTES2CHARS(bytes) ((((bytes) * 8) + 5) / 6) + /** * crypto_scrypt_compat(passwd, passwdlen, salt, saltlen, N, r, p, buf, buflen): * Compute scrypt(passwd[0 .. passwdlen - 1], salt[0 .. saltlen - 1], N, r, diff --git a/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/pwhash_scryptxsalsa208sha256.c b/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/pwhash_scryptxsalsa208sha256.c index 6ada4696..3621a36c 100644 --- a/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/pwhash_scryptxsalsa208sha256.c +++ b/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/pwhash_scryptxsalsa208sha256.c @@ -8,7 +8,6 @@ #include "crypto_scrypt.h" #include "randombytes.h" -#define BYTES2CHARS(bytes) ((((bytes) * 8) + 5) / 6) #define SETTING_SIZE(saltbytes) \ (sizeof "$7$" - 1U) + \ (1U /* N_log2 */) + (5U /* r */) + (5U /* p */) + BYTES2CHARS(saltbytes) diff --git a/src/libsodium/include/sodium/crypto_pwhash_scryptxsalsa208sha256.h b/src/libsodium/include/sodium/crypto_pwhash_scryptxsalsa208sha256.h index eba37679..098d2edc 100644 --- a/src/libsodium/include/sodium/crypto_pwhash_scryptxsalsa208sha256.h +++ b/src/libsodium/include/sodium/crypto_pwhash_scryptxsalsa208sha256.h @@ -8,12 +8,6 @@ #define crypto_pwhash_scryptxsalsa208sha256_SALTBYTES 32 #define crypto_pwhash_scryptxsalsa208sha256_STRBYTES 102 -#define crypto_pwhash_scryptxsalsa208sha256_STRPREFIXBYTES 14 -#define crypto_pwhash_scryptxsalsa208sha256_STRSETTINGBYTES 57 -#define crypto_pwhash_scryptxsalsa208sha256_STRSALTBYTES 32 -#define crypto_pwhash_scryptxsalsa208sha256_STRSALTBYTES_ENCODED 43 -#define crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES 32 -#define crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES_ENCODED 43 #ifdef __cplusplus # if __GNUC__