Fix Scrypt crash when blockSize is 0 (GH #842)

This may change in the future. I prefer to recover, and use default block size when block size is 0. But this stops the immediate problem of a crash.
This commit is contained in:
Jeffrey Walton 2019-05-19 21:24:32 -04:00
parent 2c0455edf8
commit e0b60439bf
No known key found for this signature in database
GPG Key ID: B36AB348921B1838

View File

@ -190,6 +190,15 @@ void Scrypt::ValidateParameters(size_t derivedLen, word64 cost, word64 blockSize
CRYPTOPP_ASSERT(blockSize != 0);
CRYPTOPP_ASSERT(parallelization != 0);
if (cost == 0)
throw InvalidArgument("Scrypt: cost cannot be 0");
if (blockSize == 0)
throw InvalidArgument("Scrypt: block size cannot be 0");
if (parallelization == 0)
throw InvalidArgument("Scrypt: parallelization cannot be 0");
// Optimizer should remove this on 32-bit platforms
if (std::numeric_limits<size_t>::max() > std::numeric_limits<word32>::max())
{