Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for asynchronous release - SHA3/HMAC devId #8119

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions wolfcrypt/src/hmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,21 @@ int wc_HmacSetKey_ex(Hmac* hmac, int type, const byte* key, word32 length,
return BAD_FUNC_ARG;
}

heap = hmac->heap;
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(6,0,0)
/* if set key has already been run then make sure and free existing */
/* This is for async and PIC32MZ situations, and just normally OK,
provided the user calls wc_HmacInit() first. That function is not
available in FIPS builds. In current FIPS builds, the hashes are
not allocating resources. */
if (hmac->macType != WC_HASH_TYPE_NONE) {
#ifdef WOLF_CRYPTO_CB
int devId = hmac->devId;
#endif
wc_HmacFree(hmac);
#ifdef WOLF_CRYPTO_CB
hmac->devId = devId;
#endif
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions wolfcrypt/src/sha3.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,10 +820,10 @@ static int wc_InitSha3(wc_Sha3* sha3, void* heap, int devId)
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA3)
ret = wolfAsync_DevCtxInit(&sha3->asyncDev,
WOLFSSL_ASYNC_MARKER_SHA3, sha3->heap, devId);
#elif defined(WOLF_CRYPTO_CB)
#endif
#if defined(WOLF_CRYPTO_CB)
sha3->devId = devId;
#endif /* WOLFSSL_ASYNC_CRYPT */

#endif
(void)devId;

return ret;
Expand Down
Loading