[SECURITY] Fix a buffer overflow in SHA384

Caused by a difference in the size of the digest
byte array allocated on Haskell side and the
amount of bytes copied to it on the C side.

In cbits/cryptonite_sha512.c:cryptonite_sha384_finalize
SHA384_DIGEST_SIZE bytes is copied into the out buffer.
SHA384_DIGEST_SIZE is #defined as 64 in cbits/cryptonite_sha512.h
while the buffer given will have size 48, as defined in
Crypto/Hash/SHA384.hs.

Defining SHA384_DIGEST_SIZE as 48 fixes the issue.
This commit is contained in:
Mikael Bung 2016-02-20 15:29:31 +01:00 committed by Vincent Hanquez
parent 23a6ad1b35
commit 0ca7afcb87

View File

@ -35,7 +35,7 @@ struct sha512_ctx
#define sha384_ctx sha512_ctx
#define SHA384_DIGEST_SIZE 64
#define SHA384_DIGEST_SIZE 48
#define SHA384_CTX_SIZE sizeof(struct sha384_ctx)
#define SHA512_DIGEST_SIZE 64