Fix Free Callback Behavior for Dilithium's free callback path so that it respects the return code of the callback

This commit is contained in:
night1rider
2026-03-12 14:45:33 -06:00
parent e766b8f0af
commit 5ff2b55345
+9 -1
View File
@@ -10872,14 +10872,22 @@ int wc_dilithium_get_level(dilithium_key* key, byte* level)
*/
void wc_dilithium_free(dilithium_key* key)
{
#if defined(WOLF_CRYPTO_CB) && defined(WOLF_CRYPTO_CB_FREE)
int ret;
#endif
if (key != NULL) {
#if defined(WOLF_CRYPTO_CB) && defined(WOLF_CRYPTO_CB_FREE)
if (key->devId != INVALID_DEVID) {
wc_CryptoCb_Free(key->devId, WC_ALGO_TYPE_PK,
ret = wc_CryptoCb_Free(key->devId, WC_ALGO_TYPE_PK,
WC_PK_TYPE_PQC_SIG_KEYGEN,
WC_PQC_SIG_TYPE_DILITHIUM,
(void*)key);
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
return;
/* fall-through to software cleanup */
}
(void)ret;
#endif
#ifdef WOLFSSL_WC_DILITHIUM
#ifndef WC_DILITHIUM_FIXED_ARRAY