Skip to content

Commit 9d65982

Browse files
committed
Fix Free Callback Behavior for ECC's free callback path so that it respects the return code of the callback
1 parent 352daa0 commit 9d65982

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

wolfcrypt/src/ecc.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7886,15 +7886,23 @@ void wc_ecc_free_curve(const ecc_set_type* curve, void* heap)
78867886
WOLFSSL_ABI
78877887
int wc_ecc_free(ecc_key* key)
78887888
{
7889+
#if defined(WOLF_CRYPTO_CB) && defined(WOLF_CRYPTO_CB_FREE)
7890+
int ret;
7891+
#endif
7892+
78897893
if (key == NULL) {
78907894
return 0;
78917895
}
78927896

78937897
#if defined(WOLF_CRYPTO_CB) && defined(WOLF_CRYPTO_CB_FREE)
78947898
if (key->devId != INVALID_DEVID) {
7895-
wc_CryptoCb_Free(key->devId, WC_ALGO_TYPE_PK,
7899+
ret = wc_CryptoCb_Free(key->devId, WC_ALGO_TYPE_PK,
78967900
WC_PK_TYPE_EC_KEYGEN, 0, key);
7901+
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
7902+
return ret;
7903+
/* fall-through to software cleanup */
78977904
}
7905+
(void)ret;
78987906
#endif
78997907

79007908
#if defined(WOLFSSL_ECDSA_SET_K) || defined(WOLFSSL_ECDSA_SET_K_ONE_LOOP) || \

0 commit comments

Comments
 (0)