summaryrefslogtreecommitdiff
path: root/pwdbased.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2019-06-28 14:22:03 -0400
committerJeffrey Walton <noloader@gmail.com>2019-06-28 14:22:03 -0400
commit18d5e5528f480885d3373d200dffc8cd6beeca81 (patch)
tree0e289a9bd653301394db79bced22f531e3f41d26 /pwdbased.h
parent26a59cd94b854399b8c9516169532bb939e8728d (diff)
downloadcryptopp-git-18d5e5528f480885d3373d200dffc8cd6beeca81.tar.gz
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
Diffstat (limited to 'pwdbased.h')
-rw-r--r--pwdbased.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/pwdbased.h b/pwdbased.h
index a27550a7..e2a01464 100644
--- a/pwdbased.h
+++ b/pwdbased.h
@@ -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;