Fix divide by 0 finding (GH #855)

I'm not sure which tool is producing this finding. I am pretty sure it is a false positive, but clear it for the sake of dark and silent cockpits
This commit is contained in:
Jeffrey Walton 2019-06-28 14:22:03 -04:00
parent 26a59cd94b
commit 18d5e5528f

View File

@ -245,7 +245,11 @@ size_t PKCS5_PBKDF2_HMAC<T>::DeriveKey(byte *derived, size_t derivedLen, byte pu
// Business logic
if (!iterations) { iterations = 1; }
// DigestSize check due to https://github.com/weidai11/cryptopp/issues/855
HMAC<T> hmac(secret, secretLen);
if (hmac.DigestSize() == 0)
throw InvalidArgument("PKCS5_PBKDF2_HMAC: DigestSize cannot be 0");
SecByteBlock buffer(hmac.DigestSize());
ThreadUserTimer timer;