@@ -101049,15 +101049,15 @@ static int sp_256_ecc_mulmod_fast_8(sp_point_256* r, const sp_point_256* g, cons
101049101049 #endif
101050101050 }
101051101051#ifndef WC_NO_CACHE_RESISTANT
101052- #ifdef WOLFSSL_SP_SMALL_STACK
101052+ #ifdef WOLFSSL_SP_SMALL_STACK
101053101053 if (p != NULL)
101054+ #endif
101055+ {
101056+ ForceZero(p, sizeof(sp_point_256));
101057+ #ifdef WOLFSSL_SP_SMALL_STACK
101058+ XFREE(p, heap, DYNAMIC_TYPE_ECC);
101054101059 #endif
101055- {
101056- ForceZero(p, sizeof(sp_point_256));
101057- #ifdef WOLFSSL_SP_SMALL_STACK
101058- XFREE(p, heap, DYNAMIC_TYPE_ECC);
101059- #endif
101060- }
101060+ }
101061101061#endif /* !WC_NO_CACHE_RESISTANT */
101062101062#ifdef WOLFSSL_SP_SMALL_STACK
101063101063 if (t != NULL)
@@ -104024,10 +104024,8 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
104024104024
104025104025#ifdef WOLFSSL_SP_SMALL_STACK
104026104026 XFREE(k, heap, DYNAMIC_TYPE_ECC);
104027- if (point != NULL) {
104028- /* point is not sensitive, so no need to zeroize */
104029- XFREE(point, heap, DYNAMIC_TYPE_ECC);
104030- }
104027+ /* point is not sensitive, so no need to zeroize */
104028+ XFREE(point, heap, DYNAMIC_TYPE_ECC);
104031104029#endif
104032104030
104033104031 return err;
@@ -111877,15 +111875,15 @@ static int sp_384_ecc_mulmod_fast_12(sp_point_384* r, const sp_point_384* g, con
111877111875 #endif
111878111876 }
111879111877#ifndef WC_NO_CACHE_RESISTANT
111880- #ifdef WOLFSSL_SP_SMALL_STACK
111878+ #ifdef WOLFSSL_SP_SMALL_STACK
111881111879 if (p != NULL)
111880+ #endif
111881+ {
111882+ ForceZero(p, sizeof(sp_point_384));
111883+ #ifdef WOLFSSL_SP_SMALL_STACK
111884+ XFREE(p, heap, DYNAMIC_TYPE_ECC);
111882111885 #endif
111883- {
111884- ForceZero(p, sizeof(sp_point_384));
111885- #ifdef WOLFSSL_SP_SMALL_STACK
111886- XFREE(p, heap, DYNAMIC_TYPE_ECC);
111887- #endif
111888- }
111886+ }
111889111887#endif /* !WC_NO_CACHE_RESISTANT */
111890111888#ifdef WOLFSSL_SP_SMALL_STACK
111891111889 if (t != NULL)
@@ -114920,10 +114918,8 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
114920114918
114921114919#ifdef WOLFSSL_SP_SMALL_STACK
114922114920 XFREE(k, heap, DYNAMIC_TYPE_ECC);
114923- if (point != NULL) {
114924- /* point is not sensitive, so no need to zeroize */
114925- XFREE(point, heap, DYNAMIC_TYPE_ECC);
114926- }
114921+ /* point is not sensitive, so no need to zeroize */
114922+ XFREE(point, heap, DYNAMIC_TYPE_ECC);
114927114923#endif
114928114924
114929114925 return err;
@@ -125477,15 +125473,15 @@ static int sp_521_ecc_mulmod_fast_17(sp_point_521* r, const sp_point_521* g, con
125477125473 #endif
125478125474 }
125479125475#ifndef WC_NO_CACHE_RESISTANT
125480- #ifdef WOLFSSL_SP_SMALL_STACK
125476+ #ifdef WOLFSSL_SP_SMALL_STACK
125481125477 if (p != NULL)
125478+ #endif
125479+ {
125480+ ForceZero(p, sizeof(sp_point_521));
125481+ #ifdef WOLFSSL_SP_SMALL_STACK
125482+ XFREE(p, heap, DYNAMIC_TYPE_ECC);
125482125483 #endif
125483- {
125484- ForceZero(p, sizeof(sp_point_521));
125485- #ifdef WOLFSSL_SP_SMALL_STACK
125486- XFREE(p, heap, DYNAMIC_TYPE_ECC);
125487- #endif
125488- }
125484+ }
125489125485#endif /* !WC_NO_CACHE_RESISTANT */
125490125486#ifdef WOLFSSL_SP_SMALL_STACK
125491125487 if (t != NULL)
@@ -129150,10 +129146,8 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
129150129146
129151129147#ifdef WOLFSSL_SP_SMALL_STACK
129152129148 XFREE(k, heap, DYNAMIC_TYPE_ECC);
129153- if (point != NULL) {
129154- /* point is not sensitive, so no need to zeroize */
129155- XFREE(point, heap, DYNAMIC_TYPE_ECC);
129156- }
129149+ /* point is not sensitive, so no need to zeroize */
129150+ XFREE(point, heap, DYNAMIC_TYPE_ECC);
129157129151#endif
129158129152
129159129153 return err;
@@ -202402,16 +202396,16 @@ static void sp_1024_point_free_32(sp_point_1024* p, int clear, void* heap)
202402202396{
202403202397#if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
202404202398 defined(WOLFSSL_SP_SMALL_STACK)
202405- /* If valid pointer then clear point data if requested and free data. */
202399+ /* If valid pointer then clear point data if requested and free data. */
202406202400 if (p != NULL) {
202407- if (clear != 0 ) {
202401+ if (clear) {
202408202402 XMEMSET(p, 0, sizeof(*p));
202409202403 }
202410202404 XFREE(p, heap, DYNAMIC_TYPE_ECC);
202411202405 }
202412202406#else
202413- /* Clear point data if requested. */
202414- if ((p != NULL) && ( clear != 0) ) {
202407+ /* Clear point data if requested. */
202408+ if ((p != NULL) && clear) {
202415202409 XMEMSET(p, 0, sizeof(*p));
202416202410 }
202417202411#endif
0 commit comments