Merge pull request #7847 from SparkiDev/sp_xfree_2

SP: Remove check of NULL before XFREE
This commit is contained in:
Daniel Pouzzner
2024-08-09 14:47:05 -05:00
committed by GitHub
7 changed files with 144 additions and 186 deletions

View File

@@ -76464,10 +76464,8 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -94223,10 +94221,8 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -121969,10 +121965,8 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -144553,14 +144547,14 @@ static void sp_1024_point_free_32(sp_point_1024* p, int clear, void* heap)
defined(WOLFSSL_SP_SMALL_STACK) defined(WOLFSSL_SP_SMALL_STACK)
/* If valid pointer then clear point data if requested and free data. */ /* If valid pointer then clear point data if requested and free data. */
if (p != NULL) { if (p != NULL) {
if (clear != 0) { if (clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
XFREE(p, heap, DYNAMIC_TYPE_ECC); XFREE(p, heap, DYNAMIC_TYPE_ECC);
} }
#else #else
/* Clear point data if requested. */ /* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) { if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
#endif #endif

View File

@@ -39858,10 +39858,8 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -66598,10 +66596,8 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -111737,10 +111733,8 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -115525,14 +115519,14 @@ static void sp_1024_point_free_16(sp_point_1024* p, int clear, void* heap)
defined(WOLFSSL_SP_SMALL_STACK) defined(WOLFSSL_SP_SMALL_STACK)
/* If valid pointer then clear point data if requested and free data. */ /* If valid pointer then clear point data if requested and free data. */
if (p != NULL) { if (p != NULL) {
if (clear != 0) { if (clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
XFREE(p, heap, DYNAMIC_TYPE_ECC); XFREE(p, heap, DYNAMIC_TYPE_ECC);
} }
#else #else
/* Clear point data if requested. */ /* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) { if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
#endif #endif

View File

@@ -104024,10 +104024,8 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -114920,10 +114918,8 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -129150,10 +129146,8 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -202404,14 +202398,14 @@ static void sp_1024_point_free_32(sp_point_1024* p, int clear, void* heap)
defined(WOLFSSL_SP_SMALL_STACK) defined(WOLFSSL_SP_SMALL_STACK)
/* If valid pointer then clear point data if requested and free data. */ /* If valid pointer then clear point data if requested and free data. */
if (p != NULL) { if (p != NULL) {
if (clear != 0) { if (clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
XFREE(p, heap, DYNAMIC_TYPE_ECC); XFREE(p, heap, DYNAMIC_TYPE_ECC);
} }
#else #else
/* Clear point data if requested. */ /* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) { if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
#endif #endif

View File

@@ -24945,10 +24945,8 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -32982,10 +32980,8 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -41068,10 +41064,8 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -44310,14 +44304,14 @@ static void sp_1024_point_free_42(sp_point_1024* p, int clear, void* heap)
defined(WOLFSSL_SP_SMALL_STACK) defined(WOLFSSL_SP_SMALL_STACK)
/* If valid pointer then clear point data if requested and free data. */ /* If valid pointer then clear point data if requested and free data. */
if (p != NULL) { if (p != NULL) {
if (clear != 0) { if (clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
XFREE(p, heap, DYNAMIC_TYPE_ECC); XFREE(p, heap, DYNAMIC_TYPE_ECC);
} }
#else #else
/* Clear point data if requested. */ /* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) { if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
#endif #endif

View File

@@ -25841,10 +25841,8 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -33303,10 +33301,8 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -40717,10 +40713,8 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -43764,14 +43758,14 @@ static void sp_1024_point_free_18(sp_point_1024* p, int clear, void* heap)
defined(WOLFSSL_SP_SMALL_STACK) defined(WOLFSSL_SP_SMALL_STACK)
/* If valid pointer then clear point data if requested and free data. */ /* If valid pointer then clear point data if requested and free data. */
if (p != NULL) { if (p != NULL) {
if (clear != 0) { if (clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
XFREE(p, heap, DYNAMIC_TYPE_ECC); XFREE(p, heap, DYNAMIC_TYPE_ECC);
} }
#else #else
/* Clear point data if requested. */ /* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) { if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
#endif #endif

View File

@@ -39555,10 +39555,8 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -49614,10 +49612,8 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -62373,10 +62369,8 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -70773,14 +70767,14 @@ static void sp_1024_point_free_32(sp_point_1024* p, int clear, void* heap)
defined(WOLFSSL_SP_SMALL_STACK) defined(WOLFSSL_SP_SMALL_STACK)
/* If valid pointer then clear point data if requested and free data. */ /* If valid pointer then clear point data if requested and free data. */
if (p != NULL) { if (p != NULL) {
if (clear != 0) { if (clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
XFREE(p, heap, DYNAMIC_TYPE_ECC); XFREE(p, heap, DYNAMIC_TYPE_ECC);
} }
#else #else
/* Clear point data if requested. */ /* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) { if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
#endif #endif

View File

@@ -24609,10 +24609,8 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -49582,10 +49580,8 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -90616,10 +90612,8 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
XFREE(k, heap, DYNAMIC_TYPE_ECC); XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */ /* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC); XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif #endif
return err; return err;
@@ -93354,14 +93348,14 @@ static void sp_1024_point_free_16(sp_point_1024* p, int clear, void* heap)
defined(WOLFSSL_SP_SMALL_STACK) defined(WOLFSSL_SP_SMALL_STACK)
/* If valid pointer then clear point data if requested and free data. */ /* If valid pointer then clear point data if requested and free data. */
if (p != NULL) { if (p != NULL) {
if (clear != 0) { if (clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
XFREE(p, heap, DYNAMIC_TYPE_ECC); XFREE(p, heap, DYNAMIC_TYPE_ECC);
} }
#else #else
/* Clear point data if requested. */ /* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) { if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p)); XMEMSET(p, 0, sizeof(*p));
} }
#endif #endif