1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 18:15:18 -07:00

scrypt: reject r == 0 and p == 0

This commit is contained in:
Frank Denis 2019-05-21 14:11:03 +02:00
parent 76ac6ef605
commit 00c8ecd1c4
2 changed files with 8 additions and 0 deletions

View File

@ -305,6 +305,10 @@ escrypt_kdf_nosse(escrypt_local_t *local, const uint8_t *passwd,
uint32_t i; uint32_t i;
/* Sanity-check parameters. */ /* Sanity-check parameters. */
if (r == 0 || p == 0) {
errno = EINVAL;
return -1;
}
#if SIZE_MAX > UINT32_MAX #if SIZE_MAX > UINT32_MAX
if (buflen > (((uint64_t)(1) << 32) - 1) * 32) { if (buflen > (((uint64_t)(1) << 32) - 1) * 32) {
errno = EFBIG; errno = EFBIG;

View File

@ -317,6 +317,10 @@ escrypt_kdf_sse(escrypt_local_t *local, const uint8_t *passwd, size_t passwdlen,
uint32_t i; uint32_t i;
/* Sanity-check parameters. */ /* Sanity-check parameters. */
if (r == 0 || p == 0) {
errno = EINVAL;
return -1;
}
# if SIZE_MAX > UINT32_MAX # if SIZE_MAX > UINT32_MAX
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
if (buflen > (((uint64_t)(1) << 32) - 1) * 32) { if (buflen > (((uint64_t)(1) << 32) - 1) * 32) {