SP: Remove check of NULL before XFREE

Removed more checks of NULL before XFREE.
Formatting fixes as well.
This commit is contained in:
Sean Parkinson
2024-08-08 09:36:05 +10:00
parent 92952a5538
commit abc910c03c
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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)
/* If valid pointer then clear point data if requested and free data. */
if (p != NULL) {
if (clear != 0) {
if (clear) {
XMEMSET(p, 0, sizeof(*p));
}
XFREE(p, heap, DYNAMIC_TYPE_ECC);
}
#else
/* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) {
if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p));
}
#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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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)
/* If valid pointer then clear point data if requested and free data. */
if (p != NULL) {
if (clear != 0) {
if (clear) {
XMEMSET(p, 0, sizeof(*p));
}
XFREE(p, heap, DYNAMIC_TYPE_ECC);
}
#else
/* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) {
if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p));
}
#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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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)
/* If valid pointer then clear point data if requested and free data. */
if (p != NULL) {
if (clear != 0) {
if (clear) {
XMEMSET(p, 0, sizeof(*p));
}
XFREE(p, heap, DYNAMIC_TYPE_ECC);
}
#else
/* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) {
if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p));
}
#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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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)
/* If valid pointer then clear point data if requested and free data. */
if (p != NULL) {
if (clear != 0) {
if (clear) {
XMEMSET(p, 0, sizeof(*p));
}
XFREE(p, heap, DYNAMIC_TYPE_ECC);
}
#else
/* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) {
if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p));
}
#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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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)
/* If valid pointer then clear point data if requested and free data. */
if (p != NULL) {
if (clear != 0) {
if (clear) {
XMEMSET(p, 0, sizeof(*p));
}
XFREE(p, heap, DYNAMIC_TYPE_ECC);
}
#else
/* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) {
if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p));
}
#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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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)
/* If valid pointer then clear point data if requested and free data. */
if (p != NULL) {
if (clear != 0) {
if (clear) {
XMEMSET(p, 0, sizeof(*p));
}
XFREE(p, heap, DYNAMIC_TYPE_ECC);
}
#else
/* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) {
if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p));
}
#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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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
XFREE(k, heap, DYNAMIC_TYPE_ECC);
if (point != NULL) {
/* point is not sensitive, so no need to zeroize */
XFREE(point, heap, DYNAMIC_TYPE_ECC);
}
#endif
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)
/* If valid pointer then clear point data if requested and free data. */
if (p != NULL) {
if (clear != 0) {
if (clear) {
XMEMSET(p, 0, sizeof(*p));
}
XFREE(p, heap, DYNAMIC_TYPE_ECC);
}
#else
/* Clear point data if requested. */
if ((p != NULL) && (clear != 0)) {
if ((p != NULL) && clear) {
XMEMSET(p, 0, sizeof(*p));
}
#endif