Skip to content

Commit

Permalink
Fix Scrypt crash when blockSize is 0 (GH #842)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
noloader committed May 20, 2019
1 parent 2c0455e commit e0b6043
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scrypt.cpp
Expand Up @@ -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())
{
Expand Down

0 comments on commit e0b6043

Please sign in to comment.