@@ -1495,7 +1495,11 @@ static int xil_mpi_import(mp_int *mpi,
14951495
14961496#ifdef ECC_CACHE_CURVE
14971497 /* cache (mp_int) of the curve parameters */
1498+ #ifdef WOLFSSL_NO_MALLOC
1499+ static ecc_curve_spec ecc_curve_spec_cache[ECC_SET_COUNT];
1500+ #else
14981501 static ecc_curve_spec* ecc_curve_spec_cache[ECC_SET_COUNT];
1502+ #endif
14991503 #ifndef SINGLE_THREADED
15001504 static wolfSSL_Mutex ecc_curve_cache_mutex WOLFSSL_MUTEX_INITIALIZER_CLAUSE(ecc_curve_cache_mutex);
15011505 #endif
@@ -1675,6 +1679,9 @@ static int wc_ecc_curve_load(const ecc_set_type* dp, ecc_curve_spec** pCurve,
16751679 }
16761680#endif
16771681
1682+ #ifdef WOLFSSL_NO_MALLOC
1683+ curve = &ecc_curve_spec_cache[x];
1684+ #else
16781685 /* make sure cache has been allocated */
16791686 if (ecc_curve_spec_cache[x] == NULL
16801687 #ifdef WOLFSSL_CUSTOM_CURVES
@@ -1701,6 +1708,8 @@ static int wc_ecc_curve_load(const ecc_set_type* dp, ecc_curve_spec** pCurve,
17011708 else {
17021709 curve = ecc_curve_spec_cache[x];
17031710 }
1711+ #endif /* WOLFSSL_NO_MALLOC */
1712+
17041713 /* return new or cached curve */
17051714 *pCurve = curve;
17061715#else
@@ -1780,11 +1789,16 @@ void wc_ecc_curve_cache_free(void)
17801789
17811790 /* free all ECC curve caches */
17821791 for (x = 0; x < (int)ECC_SET_COUNT; x++) {
1792+ #ifdef WOLFSSL_NO_MALLOC
1793+ wc_ecc_curve_cache_free_spec(&ecc_curve_spec_cache[x]);
1794+ XMEMSET(&ecc_curve_spec_cache[x], 0, sizeof(ecc_curve_spec_cache[x]));
1795+ #else
17831796 if (ecc_curve_spec_cache[x]) {
17841797 wc_ecc_curve_cache_free_spec(ecc_curve_spec_cache[x]);
17851798 XFREE(ecc_curve_spec_cache[x], NULL, DYNAMIC_TYPE_ECC);
17861799 ecc_curve_spec_cache[x] = NULL;
17871800 }
1801+ #endif /* WOLFSSL_NO_MALLOC */
17881802 }
17891803
17901804#if defined(ECC_CACHE_CURVE) && !defined(SINGLE_THREADED) && \
0 commit comments