Expose low-level scryptsalsa208sha256()

This commit is contained in:
Frank Denis
2014-05-18 23:48:02 -07:00
parent 27d1f4d9cb
commit a992ac5252
4 changed files with 16 additions and 23 deletions
@@ -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;
@@ -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;
@@ -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
@@ -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