Skip to content

Commit 5ff2b55

Browse files
committed
Fix Free Callback Behavior for Dilithium's free callback path so that it respects the return code of the callback
1 parent e766b8f commit 5ff2b55

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

wolfcrypt/src/dilithium.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10872,14 +10872,22 @@ int wc_dilithium_get_level(dilithium_key* key, byte* level)
1087210872
*/
1087310873
void wc_dilithium_free(dilithium_key* key)
1087410874
{
10875+
#if defined(WOLF_CRYPTO_CB) && defined(WOLF_CRYPTO_CB_FREE)
10876+
int ret;
10877+
#endif
10878+
1087510879
if (key != NULL) {
1087610880
#if defined(WOLF_CRYPTO_CB) && defined(WOLF_CRYPTO_CB_FREE)
1087710881
if (key->devId != INVALID_DEVID) {
10878-
wc_CryptoCb_Free(key->devId, WC_ALGO_TYPE_PK,
10882+
ret = wc_CryptoCb_Free(key->devId, WC_ALGO_TYPE_PK,
1087910883
WC_PK_TYPE_PQC_SIG_KEYGEN,
1088010884
WC_PQC_SIG_TYPE_DILITHIUM,
1088110885
(void*)key);
10886+
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
10887+
return;
10888+
/* fall-through to software cleanup */
1088210889
}
10890+
(void)ret;
1088310891
#endif
1088410892
#ifdef WOLFSSL_WC_DILITHIUM
1088510893
#ifndef WC_DILITHIUM_FIXED_ARRAY

0 commit comments

Comments
 (0)