Sync with Upstream master

pull/461/head
Jeffrey Walton 2017-08-15 08:52:01 -04:00
commit 4a31b367f2
2 changed files with 8 additions and 4 deletions

View File

@ -320,8 +320,7 @@ void RandomNumberGenerator::GenerateIntoBufferedTransformation(BufferedTransform
{
size_t len = UnsignedMin(buffer.size(), length);
GenerateBlock(buffer, len);
size_t rem = target.ChannelPut(channel, buffer, len);
CRYPTOPP_UNUSED(rem); CRYPTOPP_ASSERT(rem == 0);
(void)target.ChannelPut(channel, buffer, len);
length -= len;
}
}

View File

@ -65,9 +65,14 @@ static void Mash(const byte *in, size_t inLen, byte *out, size_t outLen, int ite
template <class BC, class H, class Info>
static void GenerateKeyIV(const byte *passphrase, size_t passphraseLength, const byte *salt, size_t saltLength, unsigned int iterations, byte *key, byte *IV)
{
// UBsan. User supplied params, may be NULL
SecByteBlock temp(passphraseLength+saltLength);
memcpy(temp, passphrase, passphraseLength);
memcpy(temp+passphraseLength, salt, saltLength);
if (passphrase != NULLPTR)
memcpy(temp, passphrase, passphraseLength);
if (salt != NULLPTR)
memcpy(temp+passphraseLength, salt, saltLength);
// OK. Derived params, cannot be NULL
SecByteBlock keyIV(Info::KEYLENGTH+Info::BLOCKSIZE);
Mash<H>(temp, passphraseLength + saltLength, keyIV, Info::KEYLENGTH+Info::BLOCKSIZE, iterations);
memcpy(key, keyIV, Info::KEYLENGTH);