Skip to content

Commit 773d25f

Browse files
committed
Update we_hmac_pkey_update to handle 0 length input.
In this case, we should return success immediately. This mirrors OpenSSL behavior.
1 parent 29adb73 commit 773d25f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/we_mac.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,13 @@ static int we_hmac_pkey_update(EVP_MD_CTX *ctx, const void *data, size_t dataSz)
10151015
WOLFENGINE_MSG_VERBOSE(WE_LOG_MAC, "ARGS [ctx = %p, data = %p, "
10161016
"dataSz = %zu]", ctx, data, dataSz);
10171017

1018+
/* If this function is called with an input buffer length of 0, we need to
1019+
* return success immediately. This is how OpenSSL handles this scenario. */
1020+
if (dataSz == 0) {
1021+
WOLFENGINE_MSG(WE_LOG_MAC, "dataSz == 0, returning success.");
1022+
return 1;
1023+
}
1024+
10181025
/* Validate parameters. */
10191026
if ((ctx == NULL) || (data == NULL)) {
10201027
WOLFENGINE_ERROR_FUNC_NULL(WE_LOG_MAC,

0 commit comments

Comments
 (0)