From a992ac52526017df42390693fd07d0c6c6645126 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 18 May 2014 23:47:20 -0700 Subject: [PATCH] Expose low-level scryptsalsa208sha256() --- .../scryptsalsa208sha256/crypto_scrypt-common.c | 8 ++++---- .../scryptsalsa208sha256/crypto_scrypt.h | 14 -------------- .../pwhash_scryptsalsa208sha256.c | 11 ++++++----- .../sodium/crypto_pwhash_scryptsalsa208sha256.h | 6 ++++++ 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c index 89e88b40..837ce3fc 100644 --- a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +++ b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c @@ -222,10 +222,10 @@ escrypt_gensalt_r(uint32_t N_log2, uint32_t r, uint32_t p, } int -crypto_scrypt_compat(const uint8_t * passwd, size_t passwdlen, - const uint8_t * salt, size_t saltlen, - uint64_t N, uint32_t r, uint32_t p, - uint8_t * buf, size_t buflen) +crypto_pwhash_scryptsalsa208sha256_ll(const uint8_t * passwd, size_t passwdlen, + const uint8_t * salt, size_t saltlen, + uint64_t N, uint32_t r, uint32_t p, + uint8_t * buf, size_t buflen) { escrypt_kdf_t escrypt_kdf; escrypt_local_t local; diff --git a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h index 5710b16a..fbbf38b5 100644 --- a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +++ b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h @@ -41,20 +41,6 @@ #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, - * p, buflen) and write the result into buf. The parameters r, p, and buflen - * must satisfy r * p < 2^30 and buflen <= (2^32 - 1) * 32. The parameter N - * must be a power of 2 greater than 1. - * - * Return 0 on success; or -1 on error. - */ -extern int crypto_scrypt_compat(const uint8_t * __passwd, size_t __passwdlen, - const uint8_t * __salt, size_t __saltlen, - uint64_t __N, uint32_t __r, uint32_t __p, - uint8_t * __buf, size_t __buflen); - typedef struct { void * base, * aligned; size_t size; diff --git a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c index 3aa81ffc..c9c41032 100644 --- a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +++ b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c @@ -83,11 +83,12 @@ crypto_pwhash_scryptsalsa208sha256(unsigned char * const out, errno = EINVAL; return -1; } - return crypto_scrypt_compat((const uint8_t *) passwd, (size_t) passwdlen, - (const uint8_t *) salt, - crypto_pwhash_scryptsalsa208sha256_SALTBYTES, - (uint64_t) (1) << N_log2, r, p, - out, (size_t) outlen); + return crypto_pwhash_scryptsalsa208sha256_ll((const uint8_t *) passwd, + (size_t) passwdlen, + (const uint8_t *) salt, + crypto_pwhash_scryptsalsa208sha256_SALTBYTES, + (uint64_t) (1) << N_log2, r, p, + out, (size_t) outlen); } int diff --git a/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h b/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h index df992928..a067cf82 100644 --- a/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +++ b/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h @@ -41,6 +41,12 @@ int crypto_pwhash_scryptsalsa208sha256_str_verify(const char str[crypto_pwhash_s const char * const passwd, unsigned long long passwdlen); +SODIUM_EXPORT +int crypto_pwhash_scryptsalsa208sha256_ll(const uint8_t * passwd, size_t passwdlen, + const uint8_t * salt, size_t saltlen, + uint64_t N, uint32_t r, uint32_t p, + uint8_t * buf, size_t buflen); + #ifdef __cplusplus } #endif