Skip to content

Commit 30baf0a

Browse files
Merge pull request #9435 from dgarske/hmac_zerolen
Improve wc_HmacUpdate to return early if input length == 0
2 parents 50c5028 + 4e1b719 commit 30baf0a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

wolfcrypt/src/hmac.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,9 @@ int wc_HmacUpdate(Hmac* hmac, const byte* msg, word32 length)
814814
if (hmac == NULL || (msg == NULL && length > 0)) {
815815
return BAD_FUNC_ARG;
816816
}
817+
if (length == 0) {
818+
return 0; /* nothing to do, return success */
819+
}
817820

818821
#ifdef WOLF_CRYPTO_CB
819822
if (hmac->devId != INVALID_DEVID) {

0 commit comments

Comments
 (0)