diff --git a/wolfcrypt/src/hmac.c b/wolfcrypt/src/hmac.c index bcebc1ce2..a212dc141 100644 --- a/wolfcrypt/src/hmac.c +++ b/wolfcrypt/src/hmac.c @@ -1215,11 +1215,18 @@ int wolfSSL_GetHmacMaxSize(void) word32 outIdx = 0; word32 hashSz = wc_HmacSizeByType(type); byte n = 0x1; + word32 N = 0; /* rf5869: N = ceil(L/HashLen)*/ + + N = (outSz/hashSz) + ((outSz % hashSz) != 0); + + if (out == NULL || N > 255) + return BAD_FUNC_ARG; ret = wc_HmacInit(&myHmac, NULL, INVALID_DEVID); if (ret != 0) return ret; + while (outIdx < outSz) { int tmpSz = (n == 1) ? 0 : hashSz; word32 left = outSz - outIdx;