Fix for building ECC_CACHE_CURVE without WOLFSSL_CUSTOM_CURVES.

This commit is contained in:
David Garske
2020-08-20 16:16:18 -07:00
parent 3fbaccc8a1
commit fd2aece058

View File

@@ -1305,7 +1305,11 @@ static void wc_ecc_curve_free(ecc_curve_spec* curve)
if (curve) { if (curve) {
#ifdef ECC_CACHE_CURVE #ifdef ECC_CACHE_CURVE
/* only free custom curves (reset are globally cached) */ /* only free custom curves (reset are globally cached) */
if (curve->dp && curve->dp->id == ECC_CURVE_CUSTOM) { if (curve->dp
#ifdef WOLFSSL_CUSTOM_CURVES
&& curve->dp->id == ECC_CURVE_CUSTOM
#endif
) {
wc_ecc_curve_cache_free_spec(curve); wc_ecc_curve_cache_free_spec(curve);
XFREE(curve, NULL, DYNAMIC_TYPE_ECC); XFREE(curve, NULL, DYNAMIC_TYPE_ECC);
} }
@@ -1369,7 +1373,11 @@ static int wc_ecc_curve_load(const ecc_set_type* dp, ecc_curve_spec** pCurve,
#endif #endif
/* make sure cache has been allocated */ /* make sure cache has been allocated */
if (ecc_curve_spec_cache[x] == NULL || dp->id == ECC_CURVE_CUSTOM) { if (ecc_curve_spec_cache[x] == NULL
#ifdef WOLFSSL_CUSTOM_CURVES
|| dp->id == ECC_CURVE_CUSTOM
#endif
) {
curve = (ecc_curve_spec*)XMALLOC(sizeof(ecc_curve_spec), NULL, DYNAMIC_TYPE_ECC); curve = (ecc_curve_spec*)XMALLOC(sizeof(ecc_curve_spec), NULL, DYNAMIC_TYPE_ECC);
if (curve == NULL) { if (curve == NULL) {
#if defined(ECC_CACHE_CURVE) && !defined(SINGLE_THREADED) #if defined(ECC_CACHE_CURVE) && !defined(SINGLE_THREADED)
@@ -1380,7 +1388,10 @@ static int wc_ecc_curve_load(const ecc_set_type* dp, ecc_curve_spec** pCurve,
XMEMSET(curve, 0, sizeof(ecc_curve_spec)); XMEMSET(curve, 0, sizeof(ecc_curve_spec));
/* set curve pointer to cache */ /* set curve pointer to cache */
if (dp->id != ECC_CURVE_CUSTOM) { #ifdef WOLFSSL_CUSTOM_CURVES
if (dp->id != ECC_CURVE_CUSTOM)
#endif
{
ecc_curve_spec_cache[x] = curve; ecc_curve_spec_cache[x] = curve;
} }
} }