Skip to content

Commit 1e9cb7e

Browse files
committed
Fix for TLS PRF HMAC with STM32
1 parent 299f39c commit 1e9cb7e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

wolfcrypt/src/hmac.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,11 +1042,14 @@ int wc_HmacFinal(Hmac* hmac, byte* hash)
10421042
ret = wc_Stm32_Hmac_Final(&hmac->stmCtx, hmac->stmAlgo,
10431043
(const byte*)hmac->ipad, hmac->stmKeyLen, hash,
10441044
hmac->stmDigestSize);
1045+
/* Re-run Phase 1 so HMAC is ready for next Update/Final cycle
1046+
* (needed for PRF/HKDF loops that reuse the same key) */
1047+
if (ret == 0) {
1048+
ret = wc_Stm32_Hmac_SetKey(&hmac->stmCtx, hmac->macType,
1049+
(const byte*)hmac->ipad, hmac->stmKeyLen);
1050+
}
10451051
wolfSSL_CryptHwMutexUnLock();
10461052
}
1047-
if (ret == 0) {
1048-
hmac->innerHashKeyed = 0;
1049-
}
10501053
return ret;
10511054
}
10521055
#endif /* STM32_HASH && STM32_HMAC */

0 commit comments

Comments
 (0)