From 2c2907c2a5d9c0649e023c0d422118a041f7e74b Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Tue, 17 Sep 2019 11:23:43 +1000 Subject: [PATCH] Enc-Then-MAC: when message size is less than digest size return error --- src/internal.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/internal.c b/src/internal.c index a39f91a64..cbf8e8c0f 100644 --- a/src/internal.c +++ b/src/internal.c @@ -13581,6 +13581,10 @@ static WC_INLINE int VerifyMacEnc(WOLFSSL* ssl, const byte* input, word32 msgSz, WOLFSSL_MSG("Verify MAC of Encrypted Data"); + if (msgSz < digestSz) { + return VERIFY_MAC_ERROR; + } + ret = ssl->hmac(ssl, verify, input, msgSz - digestSz, -1, content, 1); ret |= ConstantCompare(verify, input + msgSz - digestSz, digestSz); if (ret != 0) {