From 00c8ecd1c492cf5c6599ff5b8c28ed35d54cf2a1 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 21 May 2019 14:11:03 +0200 Subject: [PATCH] scrypt: reject r == 0 and p == 0 --- .../nosse/pwhash_scryptsalsa208sha256_nosse.c | 4 ++++ .../sse/pwhash_scryptsalsa208sha256_sse.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c index b1c1bd84..5bf0d704 100644 --- a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c +++ b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c @@ -305,6 +305,10 @@ escrypt_kdf_nosse(escrypt_local_t *local, const uint8_t *passwd, uint32_t i; /* Sanity-check parameters. */ + if (r == 0 || p == 0) { + errno = EINVAL; + return -1; + } #if SIZE_MAX > UINT32_MAX if (buflen > (((uint64_t)(1) << 32) - 1) * 32) { errno = EFBIG; diff --git a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c index 754a19fd..688f2d30 100644 --- a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +++ b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c @@ -317,6 +317,10 @@ escrypt_kdf_sse(escrypt_local_t *local, const uint8_t *passwd, size_t passwdlen, uint32_t i; /* Sanity-check parameters. */ + if (r == 0 || p == 0) { + errno = EINVAL; + return -1; + } # if SIZE_MAX > UINT32_MAX /* LCOV_EXCL_START */ if (buflen > (((uint64_t)(1) << 32) - 1) * 32) {