diff --git a/IDE/CRYPTOCELL/user_settings.h b/IDE/CRYPTOCELL/user_settings.h index 3f1866e90e..b6ffe4c781 100644 --- a/IDE/CRYPTOCELL/user_settings.h +++ b/IDE/CRYPTOCELL/user_settings.h @@ -401,6 +401,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/GCC-ARM/Header/user_settings.h b/IDE/GCC-ARM/Header/user_settings.h index e3a0922997..40986b08b4 100644 --- a/IDE/GCC-ARM/Header/user_settings.h +++ b/IDE/GCC-ARM/Header/user_settings.h @@ -419,6 +419,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/NETOS/user_settings.h b/IDE/NETOS/user_settings.h index 957cf82b01..efdbf01614 100644 --- a/IDE/NETOS/user_settings.h +++ b/IDE/NETOS/user_settings.h @@ -410,6 +410,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h b/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h index d3f3de9444..75d5f54d22 100644 --- a/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h +++ b/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h @@ -397,6 +397,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/Renesas/e2studio/RA6M4/test/src/test_main.c b/IDE/Renesas/e2studio/RA6M4/test/src/test_main.c index 172e484c4c..5b34a46752 100644 --- a/IDE/Renesas/e2studio/RA6M4/test/src/test_main.c +++ b/IDE/Renesas/e2studio/RA6M4/test/src/test_main.c @@ -151,17 +151,11 @@ void Clr_CallbackCtx(FSPSM_ST *g) (void) g; #if defined(WOLFSSL_RENESAS_SCEPROTECT_CRYPTONLY) - if (g->wrapped_key_rsapri2048 != NULL) - XFREE(g->wrapped_key_rsapri2048, - NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(g->wrapped_key_rsapri2048, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (g->wrapped_key_rsapub2048 != NULL) - XFREE(g->wrapped_key_rsapub2048, - NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(g->wrapped_key_rsapub2048, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (g->wrapped_key_rsapri1024 != NULL) - XFREE(g->wrapped_key_rsapri1024, - NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(g->wrapped_key_rsapri1024, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (g->wrapped_key_rsapub2048 != NULL) XFREE(g->wrapped_key_rsapub1024, diff --git a/IDE/Renesas/e2studio/RA6M4/test/src/wolfssl_sce_unit_test.c b/IDE/Renesas/e2studio/RA6M4/test/src/wolfssl_sce_unit_test.c index cf62b19dfa..591ca3ddce 100644 --- a/IDE/Renesas/e2studio/RA6M4/test/src/wolfssl_sce_unit_test.c +++ b/IDE/Renesas/e2studio/RA6M4/test/src/wolfssl_sce_unit_test.c @@ -691,18 +691,10 @@ static int sce_rsa_test(int prnt, int keySize) wc_FreeRsaKey(key); XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (in != NULL) { - XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (in2 != NULL) { - XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (out != NULL) { - XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (out2 != NULL) { - XFREE(out2, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(out2, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -778,15 +770,9 @@ static int sce_rsa_SignVerify_test(int prnt, int keySize) wc_FreeRsaKey(key); XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (in != NULL) { - XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (in2 != NULL) { - XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (out != NULL) { - XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; } diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_tsip_unit_test.c b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_tsip_unit_test.c index 048add2c62..1b84878d3c 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_tsip_unit_test.c +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_tsip_unit_test.c @@ -107,21 +107,13 @@ typedef struct tagInfo void Clr_CallbackCtx(TsipUserCtx *g) { - if (g->rsa1024pri_keyIdx != NULL) - XFREE(g->rsa1024pri_keyIdx, - NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(g->rsa1024pri_keyIdx, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (g->rsa1024pub_keyIdx != NULL) - XFREE(g->rsa1024pub_keyIdx, - NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(g->rsa1024pub_keyIdx, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (g->rsa2048pri_keyIdx != NULL) - XFREE(g->rsa2048pri_keyIdx, - NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(g->rsa2048pri_keyIdx, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (g->rsa2048pub_keyIdx != NULL) - XFREE(g->rsa2048pub_keyIdx, - NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(g->rsa2048pub_keyIdx, NULL, DYNAMIC_TYPE_TMP_BUFFER); XMEMSET(g, 0, sizeof(TsipUserCtx)); } @@ -789,15 +781,9 @@ static int tsip_rsa_SignVerify_test(int prnt, int keySize) wc_FreeRsaKey(key); XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (in != NULL) { - XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (in2 != NULL) { - XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (out != NULL) { - XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; } diff --git a/IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c b/IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c index 1176faa4c6..795d8286e1 100644 --- a/IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c +++ b/IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c @@ -718,18 +718,10 @@ static int rsip_rsa_test(int prnt, int keySize) wc_FreeRsaKey(key); XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (in != NULL) { - XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (in2 != NULL) { - XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (out != NULL) { - XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (out2 != NULL) { - XFREE(out2, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(out2, NULL, DYNAMIC_TYPE_TMP_BUFFER); (void) prnt; return ret; @@ -808,15 +800,9 @@ static int rsip_rsa_SignVerify_test(int prnt, int keySize) wc_FreeRsaKey(key); XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (in != NULL) { - XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (in2 != NULL) { - XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (out != NULL) { - XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; } diff --git a/IDE/STARCORE/user_settings.h b/IDE/STARCORE/user_settings.h index 8706865706..df74dbee70 100644 --- a/IDE/STARCORE/user_settings.h +++ b/IDE/STARCORE/user_settings.h @@ -417,6 +417,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/STM32Cube/wolfssl_example.c b/IDE/STM32Cube/wolfssl_example.c index ce67b0806d..d356af5e7b 100644 --- a/IDE/STM32Cube/wolfssl_example.c +++ b/IDE/STM32Cube/wolfssl_example.c @@ -1700,9 +1700,7 @@ static int tls13_uart_server(void) } #ifdef WOLFSSL_SMALL_STACK - if (tbuf != NULL) { - XFREE(tbuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(tbuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -1795,9 +1793,7 @@ static int tls13_uart_client(void) wolfSSL_CTX_free(ctx); } #ifdef WOLFSSL_SMALL_STACK - if (tbuf != NULL) { - XFREE(tbuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(tbuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; diff --git a/IDE/SimplicityStudio/user_settings.h b/IDE/SimplicityStudio/user_settings.h index a02cbd54d7..05ba8d517d 100644 --- a/IDE/SimplicityStudio/user_settings.h +++ b/IDE/SimplicityStudio/user_settings.h @@ -337,6 +337,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/WICED-STUDIO/user_settings.h b/IDE/WICED-STUDIO/user_settings.h index 927e7091f6..e4a6f2e8a5 100644 --- a/IDE/WICED-STUDIO/user_settings.h +++ b/IDE/WICED-STUDIO/user_settings.h @@ -411,6 +411,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/WINCE/user_settings.h b/IDE/WINCE/user_settings.h index 02157f2a54..eca61f0436 100644 --- a/IDE/WINCE/user_settings.h +++ b/IDE/WINCE/user_settings.h @@ -491,6 +491,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h b/IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h index 615c8beb6e..cbbdfe3a0e 100644 --- a/IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h +++ b/IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h @@ -407,6 +407,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h b/IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h index 494348d1b6..768ed06c2a 100644 --- a/IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h +++ b/IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h @@ -418,6 +418,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/XCODE-FIPSv2/user_settings.h b/IDE/XCODE-FIPSv2/user_settings.h index 030cd5807d..cf039344df 100644 --- a/IDE/XCODE-FIPSv2/user_settings.h +++ b/IDE/XCODE-FIPSv2/user_settings.h @@ -419,6 +419,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/XCODE-FIPSv5/user_settings.h b/IDE/XCODE-FIPSv5/user_settings.h index a66b0dce70..74fdb284e2 100644 --- a/IDE/XCODE-FIPSv5/user_settings.h +++ b/IDE/XCODE-FIPSv5/user_settings.h @@ -500,6 +500,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/examples/configs/user_settings_template.h b/examples/configs/user_settings_template.h index b7c0700b6e..680376ad2d 100644 --- a/examples/configs/user_settings_template.h +++ b/examples/configs/user_settings_template.h @@ -354,6 +354,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/examples/server/server.c b/examples/server/server.c index 6649569080..d7f4f07b57 100644 --- a/examples/server/server.c +++ b/examples/server/server.c @@ -3533,10 +3533,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args) size = wolfSSL_get_server_random(ssl, rnd, size); if (size == 0) { - if (rnd) { - XFREE(rnd, NULL, DYNAMIC_TYPE_TMP_BUFFER); - rnd = NULL; - } + XFREE(rnd, NULL, DYNAMIC_TYPE_TMP_BUFFER); + rnd = NULL; err_sys_ex(runWithErrors, "error getting server random buffer"); } diff --git a/linuxkm/lkcapi_glue.c b/linuxkm/lkcapi_glue.c index 7b2c135f54..29bd701c2d 100644 --- a/linuxkm/lkcapi_glue.c +++ b/linuxkm/lkcapi_glue.c @@ -2451,14 +2451,10 @@ static int aes_xts_128_test(void) test_xts_end: - if (enc2) - XFREE(enc2, NULL, DYNAMIC_TYPE_AES); - if (dec2) - XFREE(dec2, NULL, DYNAMIC_TYPE_AES); - if (src) - XFREE(src, NULL, DYNAMIC_TYPE_AES); - if (dst) - XFREE(dst, NULL, DYNAMIC_TYPE_AES); + XFREE(enc2, NULL, DYNAMIC_TYPE_AES); + XFREE(dec2, NULL, DYNAMIC_TYPE_AES); + XFREE(src, NULL, DYNAMIC_TYPE_AES); + XFREE(dst, NULL, DYNAMIC_TYPE_AES); if (req) skcipher_request_free(req); if (tfm) @@ -2466,19 +2462,14 @@ static int aes_xts_128_test(void) out: - if (large_input) - XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (aes_inited) wc_AesXtsFree(aes); - if (buf) - XFREE(buf, NULL, DYNAMIC_TYPE_AES); - if (cipher) - XFREE(cipher, NULL, DYNAMIC_TYPE_AES); - - if (aes) - XFREE(aes, NULL, DYNAMIC_TYPE_AES); + XFREE(buf, NULL, DYNAMIC_TYPE_AES); + XFREE(cipher, NULL, DYNAMIC_TYPE_AES); + XFREE(aes, NULL, DYNAMIC_TYPE_AES); #undef AES_XTS_128_TEST_BUF_SIZ @@ -2939,14 +2930,10 @@ static int aes_xts_256_test(void) test_xts_end: - if (enc2) - XFREE(enc2, NULL, DYNAMIC_TYPE_AES); - if (dec2) - XFREE(dec2, NULL, DYNAMIC_TYPE_AES); - if (src) - XFREE(src, NULL, DYNAMIC_TYPE_AES); - if (dst) - XFREE(dst, NULL, DYNAMIC_TYPE_AES); + XFREE(enc2, NULL, DYNAMIC_TYPE_AES); + XFREE(dec2, NULL, DYNAMIC_TYPE_AES); + XFREE(src, NULL, DYNAMIC_TYPE_AES); + XFREE(dst, NULL, DYNAMIC_TYPE_AES); if (req) skcipher_request_free(req); if (tfm) @@ -2954,19 +2941,15 @@ static int aes_xts_256_test(void) out: - if (large_input) - XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (aes_inited) wc_AesXtsFree(aes); - if (buf) - XFREE(buf, NULL, DYNAMIC_TYPE_AES); - if (cipher) - XFREE(cipher, NULL, DYNAMIC_TYPE_AES); + XFREE(buf, NULL, DYNAMIC_TYPE_AES); + XFREE(cipher, NULL, DYNAMIC_TYPE_AES); - if (aes) - XFREE(aes, NULL, DYNAMIC_TYPE_AES); + XFREE(aes, NULL, DYNAMIC_TYPE_AES); #undef AES_XTS_256_TEST_BUF_SIZ diff --git a/linuxkm/module_hooks.c b/linuxkm/module_hooks.c index 574e2ad6f8..f1bf46f8fb 100644 --- a/linuxkm/module_hooks.c +++ b/linuxkm/module_hooks.c @@ -803,16 +803,11 @@ static int updateFipsHash(void) if (tfm != NULL) crypto_free_shash(tfm); - if (desc != NULL) - XFREE(desc, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (hash != NULL) - XFREE(hash, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (base16_hash != NULL) - XFREE(base16_hash, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (binCoreKey != NULL) - XFREE(binCoreKey, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (binVerify != NULL) - XFREE(binVerify, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(desc, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(hash, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(base16_hash, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(binCoreKey, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(binVerify, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; } diff --git a/src/bio.c b/src/bio.c index 43492126df..494234c735 100644 --- a/src/bio.c +++ b/src/bio.c @@ -834,9 +834,7 @@ int wolfSSL_BIO_write(WOLFSSL_BIO* bio, const void* data, int len) (const char*)data, len, 0, ret); } - if (frmt != NULL) { - XFREE(frmt, front->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(frmt, front->heap, DYNAMIC_TYPE_TMP_BUFFER); #ifdef WOLFSSL_BASE64_ENCODE if (retB64 > 0 && ret > 0) @@ -2969,9 +2967,7 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) bio->pair->pair = NULL; } - if (bio->ip != NULL) { - XFREE(bio->ip, bio->heap, DYNAMIC_TYPE_OPENSSL); - } + XFREE(bio->ip, bio->heap, DYNAMIC_TYPE_OPENSSL); if (bio->shutdown) { if (bio->type == WOLFSSL_BIO_SSL && bio->ptr.ssl) diff --git a/src/conf.c b/src/conf.c index cc650ad5a2..8bf4b1ea95 100644 --- a/src/conf.c +++ b/src/conf.c @@ -146,9 +146,7 @@ WOLFSSL_TXT_DB *wolfSSL_TXT_DB_read(WOLFSSL_BIO *in, int num) wolfSSL_TXT_DB_free(ret); ret = NULL; } - if (buf) { - XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -793,8 +791,7 @@ static char* expandValue(WOLFSSL_CONF *conf, const char* section, return ret ? ret : str; expand_cleanup: - if (ret) - XFREE(ret, NULL, DYNAMIC_TYPE_OPENSSL); + XFREE(ret, NULL, DYNAMIC_TYPE_OPENSSL); return NULL; } @@ -961,8 +958,7 @@ int wolfSSL_NCONF_load(WOLFSSL_CONF *conf, const char *file, long *eline) cleanup: if (in) wolfSSL_BIO_free(in); - if (buf) - XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (eline) *eline = line; return ret; @@ -986,13 +982,11 @@ void wolfSSL_X509V3_conf_free(WOLFSSL_CONF_VALUE *val) if (val->name) { /* Not a section. Don't free section as it is a shared pointer. */ XFREE(val->name, NULL, DYNAMIC_TYPE_OPENSSL); - if (val->value) - XFREE(val->value, NULL, DYNAMIC_TYPE_OPENSSL); + XFREE(val->value, NULL, DYNAMIC_TYPE_OPENSSL); } else { /* Section so val->value is a stack */ - if (val->section) - XFREE(val->section, NULL, DYNAMIC_TYPE_OPENSSL); + XFREE(val->section, NULL, DYNAMIC_TYPE_OPENSSL); /* Only free the stack structures. The contained conf values * will be freed in wolfSSL_NCONF_free */ sk = (WOLF_STACK_OF(WOLFSSL_CONF_VALUE)*)val->value; diff --git a/src/crl.c b/src/crl.c index 10c83afb02..48c1476ec1 100644 --- a/src/crl.c +++ b/src/crl.c @@ -219,13 +219,10 @@ static void CRL_Entry_free(CRL_Entry* crle, void* heap) tmp = next; } #endif - if (crle->signature != NULL) - XFREE(crle->signature, heap, DYNAMIC_TYPE_CRL_ENTRY); - if (crle->toBeSigned != NULL) - XFREE(crle->toBeSigned, heap, DYNAMIC_TYPE_CRL_ENTRY); + XFREE(crle->signature, heap, DYNAMIC_TYPE_CRL_ENTRY); + XFREE(crle->toBeSigned, heap, DYNAMIC_TYPE_CRL_ENTRY); #ifdef WC_RSA_PSS - if (crle->sigParams != NULL) - XFREE(crle->sigParams, heap, DYNAMIC_TYPE_CRL_ENTRY); + XFREE(crle->sigParams, heap, DYNAMIC_TYPE_CRL_ENTRY); #endif #if defined(OPENSSL_EXTRA) if (crle->issuer != NULL) { diff --git a/src/dtls.c b/src/dtls.c index ae4cc7e2cb..9961ac21a4 100644 --- a/src/dtls.c +++ b/src/dtls.c @@ -1150,10 +1150,8 @@ void TLSX_ConnectionID_Free(byte* ext, void* heap) info = DtlsCidGetInfoFromExt(ext); if (info == NULL) return; - if (info->rx != NULL) - XFREE(info->rx, heap, DYNAMIC_TYPE_TLSX); - if (info->tx != NULL) - XFREE(info->tx, heap, DYNAMIC_TYPE_TLSX); + XFREE(info->rx, heap, DYNAMIC_TYPE_TLSX); + XFREE(info->tx, heap, DYNAMIC_TYPE_TLSX); XFREE(info, heap, DYNAMIC_TYPE_TLSX); DtlsCidUnsetInfoFromExt(ext); XFREE(ext, heap, DYNAMIC_TYPE_TLSX); @@ -1342,10 +1340,8 @@ int wolfSSL_dtls_cid_set(WOLFSSL* ssl, unsigned char* cid, unsigned int size) if (cidInfo == NULL) return WOLFSSL_FAILURE; - if (cidInfo->rx != NULL) { - XFREE(cidInfo->rx, ssl->heap, DYNAMIC_TYPE_TLSX); - cidInfo->rx = NULL; - } + XFREE(cidInfo->rx, ssl->heap, DYNAMIC_TYPE_TLSX); + cidInfo->rx = NULL; /* empty CID */ if (size == 0) diff --git a/src/dtls13.c b/src/dtls13.c index 0577715474..4d2365f38a 100644 --- a/src/dtls13.c +++ b/src/dtls13.c @@ -811,9 +811,7 @@ static void Dtls13MaybeSaveClientHello(WOLFSSL* ssl) while (r != NULL) { if (r->handshakeType == client_hello) { Dtls13RtxRecordUnlink(ssl, prev_next, r); - if (ssl->dtls13ClientHello != NULL) - XFREE(ssl->dtls13ClientHello, ssl->heap, - DYNAMIC_TYPE_DTLS_MSG); + XFREE(ssl->dtls13ClientHello, ssl->heap, DYNAMIC_TYPE_DTLS_MSG); ssl->dtls13ClientHello = r->data; ssl->dtls13ClientHelloSz = r->length; r->data = NULL; diff --git a/src/internal.c b/src/internal.c index 6395f0a23d..3cf89ad788 100644 --- a/src/internal.c +++ b/src/internal.c @@ -2576,8 +2576,7 @@ static void FreeEchConfigs(WOLFSSL_EchConfig* configs, void* heap) XFREE(working_config->cipherSuites, heap, DYNAMIC_TYPE_TMP_BUFFER); XFREE(working_config->publicName, heap, DYNAMIC_TYPE_TMP_BUFFER); - if (working_config->raw != NULL) - XFREE(working_config->raw, heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(working_config->raw, heap, DYNAMIC_TYPE_TMP_BUFFER); if (working_config->receiverPrivkey != NULL) { wc_HpkeFreeKey(NULL, working_config->kemId, @@ -2624,10 +2623,8 @@ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx) XFREE(ctx->method, heapAtCTXInit, DYNAMIC_TYPE_METHOD); ctx->method = NULL; - if (ctx->suites) { - XFREE(ctx->suites, ctx->heap, DYNAMIC_TYPE_SUITES); - ctx->suites = NULL; - } + XFREE(ctx->suites, ctx->heap, DYNAMIC_TYPE_SUITES); + ctx->suites = NULL; #ifndef NO_DH XFREE(ctx->serverDH_G.buffer, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY); @@ -2726,10 +2723,8 @@ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx) XFREE((void*)ctx->alpn_cli_protos, ctx->heap, DYNAMIC_TYPE_OPENSSL); ctx->alpn_cli_protos = NULL; } - if (ctx->param) { - XFREE(ctx->param, heapAtCTXInit, DYNAMIC_TYPE_OPENSSL); - ctx->param = NULL; - } + XFREE(ctx->param, heapAtCTXInit, DYNAMIC_TYPE_OPENSSL); + ctx->param = NULL; if (ctx->x509_store.param) { XFREE(ctx->x509_store.param, heapAtCTXInit, DYNAMIC_TYPE_OPENSSL); @@ -4575,23 +4570,15 @@ void FreeX509(WOLFSSL_X509* x509) x509->authKeyId = NULL; XFREE(x509->subjKeyId, x509->heap, DYNAMIC_TYPE_X509_EXT); x509->subjKeyId = NULL; - if (x509->authInfo != NULL) { - XFREE(x509->authInfo, x509->heap, DYNAMIC_TYPE_X509_EXT); - x509->authInfo = NULL; - } - if (x509->rawCRLInfo != NULL) { - XFREE(x509->rawCRLInfo, x509->heap, DYNAMIC_TYPE_X509_EXT); - x509->rawCRLInfo = NULL; - } - if (x509->CRLInfo != NULL) { - XFREE(x509->CRLInfo, x509->heap, DYNAMIC_TYPE_X509_EXT); - x509->CRLInfo = NULL; - } + XFREE(x509->authInfo, x509->heap, DYNAMIC_TYPE_X509_EXT); + x509->authInfo = NULL; + XFREE(x509->rawCRLInfo, x509->heap, DYNAMIC_TYPE_X509_EXT); + x509->rawCRLInfo = NULL; + XFREE(x509->CRLInfo, x509->heap, DYNAMIC_TYPE_X509_EXT); + x509->CRLInfo = NULL; #if defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA) || \ defined(WOLFSSL_QT) - if (x509->authInfoCaIssuer != NULL) { - XFREE(x509->authInfoCaIssuer, x509->heap, DYNAMIC_TYPE_X509_EXT); - } + XFREE(x509->authInfoCaIssuer, x509->heap, DYNAMIC_TYPE_X509_EXT); if (x509->ext_sk != NULL) { wolfSSL_sk_X509_EXTENSION_pop_free(x509->ext_sk, NULL); } @@ -4647,14 +4634,10 @@ void FreeX509(WOLFSSL_X509* x509) } #ifdef WOLFSSL_DUAL_ALG_CERTS - if (x509->sapkiDer) { - XFREE(x509->sapkiDer, x509->heap, DYNAMIC_TYPE_X509_EXT); - x509->sapkiDer = NULL; - } - if (x509->altSigAlgDer) { - XFREE(x509->altSigAlgDer, x509->heap, DYNAMIC_TYPE_X509_EXT); - x509->altSigAlgDer = NULL; - } + XFREE(x509->sapkiDer, x509->heap, DYNAMIC_TYPE_X509_EXT); + x509->sapkiDer = NULL; + XFREE(x509->altSigAlgDer, x509->heap, DYNAMIC_TYPE_X509_EXT); + x509->altSigAlgDer = NULL; if (x509->altSigValDer) { XFREE(x509->altSigValDer, x509->heap, DYNAMIC_TYPE_X509_EXT); x509->altSigValDer= NULL; @@ -8376,9 +8359,7 @@ void SSL_ResourceFree(WOLFSSL* ssl) } #endif #ifdef OPENSSL_EXTRA - if (ssl->param) { - XFREE(ssl->param, ssl->heap, DYNAMIC_TYPE_OPENSSL); - } + XFREE(ssl->param, ssl->heap, DYNAMIC_TYPE_OPENSSL); #endif #if defined(WOLFSSL_TLS13) && defined(WOLFSSL_POST_HANDSHAKE_AUTH) while (ssl->certReqCtx != NULL) { @@ -8921,8 +8902,7 @@ void DtlsMsgDelete(DtlsMsg* item, void* heap) DtlsMsgDestroyFragBucket(item->fragBucketList, heap); item->fragBucketList = next; } - if (item->raw != NULL) - XFREE(item->raw, heap, DYNAMIC_TYPE_DTLS_FRAG); + XFREE(item->raw, heap, DYNAMIC_TYPE_DTLS_FRAG); XFREE(item, heap, DYNAMIC_TYPE_DTLS_MSG); } } @@ -13263,12 +13243,9 @@ static int ProcessCSR(WOLFSSL* ssl, byte* input, word32* inOutIdx, DYNAMIC_TYPE_OCSP_REQUEST); if (status == NULL || single == NULL || response == NULL) { - if (status) - XFREE(status, ssl->heap, DYNAMIC_TYPE_OCSP_STATUS); - if (single) - XFREE(single, ssl->heap, DYNAMIC_TYPE_OCSP_ENTRY); - if (response) - XFREE(response, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST); + XFREE(status, ssl->heap, DYNAMIC_TYPE_OCSP_STATUS); + XFREE(single, ssl->heap, DYNAMIC_TYPE_OCSP_ENTRY); + XFREE(response, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST); return MEMORY_ERROR; } @@ -13557,8 +13534,7 @@ int SetupStoreCtxCallback(WOLFSSL_X509_STORE_CTX** store_pt, if (x509 != NULL) wolfSSL_X509_free(x509); #endif - if (domain != NULL) - XFREE(domain, heap, DYNAMIC_TYPE_STRING); + XFREE(domain, heap, DYNAMIC_TYPE_STRING); return MEMORY_E; } @@ -13837,15 +13813,11 @@ static void FreeProcPeerCertArgs(WOLFSSL* ssl, void* pArgs) (void)ssl; - if (args->certs) { - XFREE(args->certs, ssl->heap, DYNAMIC_TYPE_DER); - args->certs = NULL; - } + XFREE(args->certs, ssl->heap, DYNAMIC_TYPE_DER); + args->certs = NULL; #ifdef WOLFSSL_TLS13 - if (args->exts) { - XFREE(args->exts, ssl->heap, DYNAMIC_TYPE_CERT_EXT); - args->exts = NULL; - } + XFREE(args->exts, ssl->heap, DYNAMIC_TYPE_CERT_EXT); + args->exts = NULL; #endif if (args->dCert) { if (args->dCertInit) { @@ -13955,9 +13927,7 @@ int LoadCertByIssuer(WOLFSSL_X509_STORE* store, X509_NAME* issuer, int type) /* / .(r)N\0 */ /*|1| 8 |1|1|1|1| => 13 */ len = (int)XSTRLEN(entry->dir_name) + 13; - if (filename != NULL) { - XFREE(filename, NULL, DYNAMIC_TYPE_OPENSSL); - } + XFREE(filename, NULL, DYNAMIC_TYPE_OPENSSL); filename = (char*)XMALLOC(len, NULL, DYNAMIC_TYPE_OPENSSL); if (filename == NULL) { @@ -15038,8 +15008,7 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx, if (dCertAdd_inited) FreeDecodedCert(dCertAdd); #ifdef WOLFSSL_SMALL_STACK - if (dCertAdd) - XFREE(dCertAdd, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(dCertAdd, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER); #endif if (ret != 0) goto exit_ppc; @@ -16227,12 +16196,9 @@ static int DoCertificateStatus(WOLFSSL* ssl, byte* input, word32* inOutIdx, DYNAMIC_TYPE_OCSP_REQUEST); if (status == NULL || single == NULL || response == NULL) { - if (status) - XFREE(status, ssl->heap, DYNAMIC_TYPE_OCSP_STATUS); - if (single) - XFREE(single, ssl->heap, DYNAMIC_TYPE_OCSP_ENTRY); - if (response) - XFREE(response, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST); + XFREE(status, ssl->heap, DYNAMIC_TYPE_OCSP_STATUS); + XFREE(single, ssl->heap, DYNAMIC_TYPE_OCSP_ENTRY); + XFREE(response, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST); return MEMORY_ERROR; } @@ -30513,10 +30479,8 @@ static void FreeDskeArgs(WOLFSSL* ssl, void* pArgs) #if !defined(NO_DH) || defined(HAVE_ECC) || defined(HAVE_CURVE25519) || \ defined(HAVE_CURVE448) - if (args->verifySig) { - XFREE(args->verifySig, ssl->heap, DYNAMIC_TYPE_SIGNATURE); - args->verifySig = NULL; - } + XFREE(args->verifySig, ssl->heap, DYNAMIC_TYPE_SIGNATURE); + args->verifySig = NULL; #endif } @@ -31852,14 +31816,10 @@ static void FreeSckeArgs(WOLFSSL* ssl, void* pArgs) (void)ssl; - if (args->encSecret) { - XFREE(args->encSecret, ssl->heap, DYNAMIC_TYPE_SECRET); - args->encSecret = NULL; - } - if (args->input) { - XFREE(args->input, ssl->heap, DYNAMIC_TYPE_IN_BUFFER); - args->input = NULL; - } + XFREE(args->encSecret, ssl->heap, DYNAMIC_TYPE_SECRET); + args->encSecret = NULL; + XFREE(args->input, ssl->heap, DYNAMIC_TYPE_IN_BUFFER); + args->input = NULL; } /* handle generation client_key_exchange (16) */ @@ -33124,15 +33084,11 @@ static void FreeScvArgs(WOLFSSL* ssl, void* pArgs) (void)ssl; #ifndef NO_RSA - if (args->verifySig) { - XFREE(args->verifySig, ssl->heap, DYNAMIC_TYPE_SIGNATURE); - args->verifySig = NULL; - } + XFREE(args->verifySig, ssl->heap, DYNAMIC_TYPE_SIGNATURE); + args->verifySig = NULL; #endif - if (args->input) { - XFREE(args->input, ssl->heap, DYNAMIC_TYPE_IN_BUFFER); - args->input = NULL; - } + XFREE(args->input, ssl->heap, DYNAMIC_TYPE_IN_BUFFER); + args->input = NULL; } /* handle generation of certificate_verify (15) */ @@ -34251,16 +34207,12 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx, (void)ssl; #if defined(HAVE_ECC) || defined(HAVE_CURVE25519) || defined(HAVE_CURVE448) - if (args->exportBuf) { - XFREE(args->exportBuf, ssl->heap, DYNAMIC_TYPE_DER); - args->exportBuf = NULL; - } + XFREE(args->exportBuf, ssl->heap, DYNAMIC_TYPE_DER); + args->exportBuf = NULL; #endif #ifndef NO_RSA - if (args->verifySig) { - XFREE(args->verifySig, ssl->heap, DYNAMIC_TYPE_SIGNATURE); - args->verifySig = NULL; - } + XFREE(args->verifySig, ssl->heap, DYNAMIC_TYPE_SIGNATURE); + args->verifySig = NULL; #endif (void)args; } @@ -37157,8 +37109,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx, ssl->clSuites = NULL; #endif #ifdef WOLFSSL_SMALL_STACK - if (clSuites != NULL) - XFREE(clSuites, ssl->heap, DYNAMIC_TYPE_SUITES); + XFREE(clSuites, ssl->heap, DYNAMIC_TYPE_SUITES); #endif WOLFSSL_LEAVE("DoClientHello", ret); WOLFSSL_END(WC_FUNC_CLIENT_HELLO_DO); @@ -41185,9 +41136,7 @@ void wolfSSL_BY_DIR_entry_free(WOLFSSL_BY_DIR_entry* entry) wolfSSL_sk_BY_DIR_HASH_free(entry->hashes); } - if (entry->dir_name != NULL) { - XFREE(entry->dir_name, NULL, DYNAMIC_TYPE_OPENSSL); - } + XFREE(entry->dir_name, NULL, DYNAMIC_TYPE_OPENSSL); XFREE(entry, NULL, DYNAMIC_TYPE_OPENSSL); } diff --git a/src/keys.c b/src/keys.c index 38b1f88d1b..3123a610e0 100644 --- a/src/keys.c +++ b/src/keys.c @@ -3876,12 +3876,12 @@ int DeriveKeys(WOLFSSL* ssl) if (shaOutput == NULL || md5Input == NULL || shaInput == NULL || keyData == NULL || md5 == NULL || sha == NULL) { - if (shaOutput) XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (md5Input) XFREE(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (shaInput) XFREE(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (keyData) XFREE(keyData, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (md5) XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (sha) XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(keyData, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER); return MEMORY_E; } @@ -4013,11 +4013,11 @@ static int MakeSslMasterSecret(WOLFSSL* ssl) if (shaOutput == NULL || md5Input == NULL || shaInput == NULL || md5 == NULL || sha == NULL) { - if (shaOutput) XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (md5Input) XFREE(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (shaInput) XFREE(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (md5) XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (sha) XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER); return MEMORY_E; } diff --git a/src/ocsp.c b/src/ocsp.c index 70f6bf6f87..89a6f6ffb6 100644 --- a/src/ocsp.c +++ b/src/ocsp.c @@ -90,8 +90,7 @@ static void FreeOcspEntry(OcspEntry* entry, void* heap) for (status = entry->status; status; status = next) { next = status->next; - if (status->rawOcspResponse) - XFREE(status->rawOcspResponse, heap, DYNAMIC_TYPE_OCSP_STATUS); + XFREE(status->rawOcspResponse, heap, DYNAMIC_TYPE_OCSP_STATUS); #ifdef OPENSSL_EXTRA if (status->serialInt) { @@ -318,9 +317,9 @@ int CheckOcspResponse(WOLFSSL_OCSP *ocsp, byte *response, int responseSz, DYNAMIC_TYPE_OCSP_REQUEST); if (newStatus == NULL || newSingle == NULL || ocspResponse == NULL) { - if (newStatus) XFREE(newStatus, NULL, DYNAMIC_TYPE_OCSP_STATUS); - if (newSingle) XFREE(newSingle, NULL, DYNAMIC_TYPE_OCSP_ENTRY); - if (ocspResponse) XFREE(ocspResponse, NULL, DYNAMIC_TYPE_OCSP_REQUEST); + XFREE(newStatus, NULL, DYNAMIC_TYPE_OCSP_STATUS); + XFREE(newSingle, NULL, DYNAMIC_TYPE_OCSP_ENTRY); + XFREE(ocspResponse, NULL, DYNAMIC_TYPE_OCSP_REQUEST); WOLFSSL_LEAVE("CheckCertOCSP", MEMORY_ERROR); return MEMORY_E; @@ -375,10 +374,7 @@ int CheckOcspResponse(WOLFSSL_OCSP *ocsp, byte *response, int responseSz, } if (status != NULL) { - if (status->rawOcspResponse) { - XFREE(status->rawOcspResponse, ocsp->cm->heap, - DYNAMIC_TYPE_OCSP_STATUS); - } + XFREE(status->rawOcspResponse, ocsp->cm->heap, DYNAMIC_TYPE_OCSP_STATUS); /* Replace existing certificate entry with updated */ ocspResponse->single->status->next = status->next; @@ -493,8 +489,7 @@ int CheckOcspRequest(WOLFSSL_OCSP* ocsp, OcspRequest* ocspRequest, ret = wolfSSL_get_ocsp_response(ssl, &response); ret = CheckOcspResponse(ocsp, response, ret, responseBuffer, status, entry, NULL, heap); - if (response != NULL) - XFREE(response, NULL, DYNAMIC_TYPE_OPENSSL); + XFREE(response, NULL, DYNAMIC_TYPE_OPENSSL); break; case SSL_TLSEXT_ERR_NOACK: ret = OCSP_LOOKUP_FAIL; @@ -829,16 +824,15 @@ WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_cert_to_id( if (ret != 0) { if (derCert != NULL) FreeDer(&derCert); - if (certId != NULL) { + if (cm != NULL) { XFREE(certId, cm->heap, DYNAMIC_TYPE_OPENSSL); certId = NULL; - } - if (certStatus) XFREE(certStatus, cm->heap, DYNAMIC_TYPE_OPENSSL); + } } #ifdef WOLFSSL_SMALL_STACK - if (cert != NULL) + if (cm != NULL) XFREE(cert, cm->heap, DYNAMIC_TYPE_DCERT); #endif @@ -928,8 +922,7 @@ void wolfSSL_OCSP_RESPONSE_free(OcspResponse* response) XFREE(response->single, NULL, DYNAMIC_TYPE_OCSP_ENTRY); } - if (response->source != NULL) - XFREE(response->source, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(response->source, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(response, NULL, DYNAMIC_TYPE_OCSP_REQUEST); } @@ -1112,10 +1105,8 @@ WOLFSSL_OCSP_BASICRESP* wolfSSL_OCSP_response_get1_basic(OcspResponse* response) DYNAMIC_TYPE_OCSP_ENTRY); bs->source = (byte*)XMALLOC(bs->maxIdx, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (bs->single == NULL || bs->source == NULL) { - if (bs->single) { - XFREE(bs->single, NULL, DYNAMIC_TYPE_OCSP_ENTRY); - bs->single = NULL; - } + XFREE(bs->single, NULL, DYNAMIC_TYPE_OCSP_ENTRY); + bs->single = NULL; wolfSSL_OCSP_RESPONSE_free(bs); bs = NULL; } @@ -1170,8 +1161,7 @@ WOLFSSL_OCSP_ONEREQ* wolfSSL_OCSP_request_add0_id(OcspRequest *req, XMEMCPY(req->issuerHash, cid->issuerHash, KEYID_SIZE); XMEMCPY(req->issuerKeyHash, cid->issuerKeyHash, KEYID_SIZE); if (cid->status->serialSz > req->serialSz) { - if (req->serial != NULL) - XFREE(req->serial, req->heap, DYNAMIC_TYPE_OCSP); + XFREE(req->serial, req->heap, DYNAMIC_TYPE_OCSP); req->serial = (byte*)XMALLOC((size_t)cid->status->serialSz, req->heap, DYNAMIC_TYPE_OCSP_REQUEST); if (req->serial == NULL) diff --git a/src/pk.c b/src/pk.c index 2c06eca20e..8b8dd97737 100644 --- a/src/pk.c +++ b/src/pk.c @@ -4691,8 +4691,7 @@ int wolfSSL_RSA_GenAdd(WOLFSSL_RSA* rsa) mp_clear(t); #ifdef WOLFSSL_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, rsa->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmp, rsa->heap, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -5914,8 +5913,7 @@ int wolfSSL_PEM_write_mem_DSAPrivateKey(WOLFSSL_DSA* dsa, if (tmp == NULL) { WOLFSSL_MSG("malloc failed"); XFREE(derBuf, NULL, DYNAMIC_TYPE_DER); - if (cipherInfo != NULL) - XFREE(cipherInfo, NULL, DYNAMIC_TYPE_STRING); + XFREE(cipherInfo, NULL, DYNAMIC_TYPE_STRING); return 0; } @@ -5926,13 +5924,11 @@ int wolfSSL_PEM_write_mem_DSAPrivateKey(WOLFSSL_DSA* dsa, WOLFSSL_MSG("wc_DerToPemEx failed"); XFREE(derBuf, NULL, DYNAMIC_TYPE_DER); XFREE(tmp, NULL, DYNAMIC_TYPE_PEM); - if (cipherInfo != NULL) - XFREE(cipherInfo, NULL, DYNAMIC_TYPE_STRING); + XFREE(cipherInfo, NULL, DYNAMIC_TYPE_STRING); return 0; } XFREE(derBuf, NULL, DYNAMIC_TYPE_DER); - if (cipherInfo != NULL) - XFREE(cipherInfo, NULL, DYNAMIC_TYPE_STRING); + XFREE(cipherInfo, NULL, DYNAMIC_TYPE_STRING); *pem = (byte*)XMALLOC((size_t)((*pLen)+1), NULL, DYNAMIC_TYPE_KEY); if (*pem == NULL) { @@ -7802,9 +7798,7 @@ static int wolfssl_dhparams_to_der(WOLFSSL_DH* dh, unsigned char** out, *out = der; der = NULL; } - if (der != NULL) { - XFREE(der, heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(der, heap, DYNAMIC_TYPE_TMP_BUFFER); return ret; } diff --git a/src/sniffer.c b/src/sniffer.c index 8c5b4cf275..31d54a949f 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -851,14 +851,11 @@ static void FreeSnifferSession(SnifferSession* session) XFREE(session->hash, NULL, DYNAMIC_TYPE_HASHES); #endif #ifdef WOLFSSL_TLS13 - if (session->cliKeyShare) - XFREE(session->cliKeyShare, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(session->cliKeyShare, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif #ifdef HAVE_MAX_FRAGMENT - if (session->tlsFragBuf) { - XFREE(session->tlsFragBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - session->tlsFragBuf = NULL; - } + XFREE(session->tlsFragBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); + session->tlsFragBuf = NULL; #endif } XFREE(session, NULL, DYNAMIC_TYPE_SNIFFER_SESSION); @@ -4723,10 +4720,8 @@ static int DoHandShake(const byte* input, int* sslBytes, exit: #endif #ifdef HAVE_MAX_FRAGMENT - if (session->tlsFragBuf) { - XFREE(session->tlsFragBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - session->tlsFragBuf = NULL; - } + XFREE(session->tlsFragBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); + session->tlsFragBuf = NULL; #endif *sslBytes = startBytes - size; /* actual bytes of full process */ diff --git a/src/ssl.c b/src/ssl.c index 13450e8ce7..afd505027a 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -1034,9 +1034,7 @@ WOLFSSL_CTX* wolfSSL_CTX_new_ex(WOLFSSL_METHOD* method, void* heap) if (ret != WOLFSSL_SUCCESS) { WOLFSSL_MSG("wolfSSL_Init failed"); WOLFSSL_LEAVE("wolfSSL_CTX_new_ex", 0); - if (method != NULL) { - XFREE(method, heap, DYNAMIC_TYPE_METHOD); - } + XFREE(method, heap, DYNAMIC_TYPE_METHOD); return NULL; } } @@ -1132,10 +1130,8 @@ void wolfSSL_CTX_free(WOLFSSL_CTX* ctx) #if defined(OPENSSL_EXTRA) && defined(WOLFCRYPT_HAVE_SRP) \ && !defined(NO_SHA256) && !defined(WC_NO_RNG) if (ctx->srp != NULL) { - if (ctx->srp_password != NULL){ - XFREE(ctx->srp_password, ctx->heap, DYNAMIC_TYPE_SRP); - ctx->srp_password = NULL; - } + XFREE(ctx->srp_password, ctx->heap, DYNAMIC_TYPE_SRP); + ctx->srp_password = NULL; wc_SrpTerm(ctx->srp); XFREE(ctx->srp, ctx->heap, DYNAMIC_TYPE_SRP); ctx->srp = NULL; @@ -11553,16 +11549,12 @@ int wolfSSL_set_compression(WOLFSSL* ssl) wc_FreeRng(&rng); return WOLFSSL_FAILURE; } - if (ctx->srp_password != NULL){ - XFREE(ctx->srp_password,NULL, - DYNAMIC_TYPE_SRP); - ctx->srp_password = NULL; - } + XFREE(ctx->srp_password, NULL, DYNAMIC_TYPE_SRP); + ctx->srp_password = NULL; wc_FreeRng(&rng); } else { /* save password for wolfSSL_set_srp_username */ - if (ctx->srp_password != NULL) - XFREE(ctx->srp_password,ctx->heap, DYNAMIC_TYPE_SRP); + XFREE(ctx->srp_password, ctx->heap, DYNAMIC_TYPE_SRP); ctx->srp_password = (byte*)XMALLOC(XSTRLEN(password) + 1, ctx->heap, DYNAMIC_TYPE_SRP); @@ -21316,8 +21308,7 @@ void wolfSSL_WOLFSSL_STRING_free(WOLFSSL_STRING s) { WOLFSSL_ENTER("wolfSSL_WOLFSSL_STRING_free"); - if (s != NULL) - XFREE(s, NULL, DYNAMIC_TYPE_OPENSSL); + XFREE(s, NULL, DYNAMIC_TYPE_OPENSSL); } void wolfSSL_sk_WOLFSSL_STRING_free(WOLF_STACK_OF(WOLFSSL_STRING)* sk) @@ -23639,10 +23630,8 @@ int wolfSSL_BUF_MEM_resize(WOLFSSL_BUF_MEM* buf, size_t len) void wolfSSL_BUF_MEM_free(WOLFSSL_BUF_MEM* buf) { if (buf) { - if (buf->data) { - XFREE(buf->data, NULL, DYNAMIC_TYPE_OPENSSL); - buf->data = NULL; - } + XFREE(buf->data, NULL, DYNAMIC_TYPE_OPENSSL); + buf->data = NULL; buf->max = 0; buf->length = 0; XFREE(buf, NULL, DYNAMIC_TYPE_OPENSSL); @@ -24217,8 +24206,7 @@ int wolfSSL_RAND_bytes(unsigned char* buf, int num) if (initTmpRng) wc_FreeRng(tmpRNG); #ifdef WOLFSSL_SMALL_STACK - if (tmpRNG) - XFREE(tmpRNG, NULL, DYNAMIC_TYPE_RNG); + XFREE(tmpRNG, NULL, DYNAMIC_TYPE_RNG); #endif return ret; diff --git a/src/ssl_asn1.c b/src/ssl_asn1.c index 0cae277dc8..74e1381254 100644 --- a/src/ssl_asn1.c +++ b/src/ssl_asn1.c @@ -3002,9 +3002,7 @@ int wolfSSL_ASN1_STRING_print_ex(WOLFSSL_BIO *bio, WOLFSSL_ASN1_STRING *str, void wolfSSL_ASN1_GENERALIZEDTIME_free(WOLFSSL_ASN1_TIME* asn1Time) { WOLFSSL_ENTER("wolfSSL_ASN1_GENERALIZEDTIME_free"); - if (asn1Time != NULL) { - XFREE(asn1Time, NULL, DYNAMIC_TYPE_OPENSSL); - } + XFREE(asn1Time, NULL, DYNAMIC_TYPE_OPENSSL); } #ifndef NO_BIO diff --git a/src/ssl_certman.c b/src/ssl_certman.c index f9d87450ec..d520f24708 100644 --- a/src/ssl_certman.c +++ b/src/ssl_certman.c @@ -1382,9 +1382,7 @@ int CM_SaveCertCache(WOLFSSL_CERT_MANAGER* cm, const char* fname) ret = FWRITE_ERROR; } } - if (mem != NULL) { - XFREE(mem, cm->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(mem, cm->heap, DYNAMIC_TYPE_TMP_BUFFER); /* Unlock CA table. */ wc_UnLockMutex(&cm->caLock); diff --git a/src/ssl_p7p12.c b/src/ssl_p7p12.c index 11b6c40a9a..a60a356a8e 100644 --- a/src/ssl_p7p12.c +++ b/src/ssl_p7p12.c @@ -94,8 +94,7 @@ void wolfSSL_PKCS7_free(PKCS7* pkcs7) WOLFSSL_PKCS7* p7 = (WOLFSSL_PKCS7*)pkcs7; if (p7 != NULL) { - if (p7->data != NULL) - XFREE(p7->data, NULL, DYNAMIC_TYPE_PKCS7); + XFREE(p7->data, NULL, DYNAMIC_TYPE_PKCS7); wc_PKCS7_Free(&p7->pkcs7); if (p7->certs) wolfSSL_sk_pop_free(p7->certs, NULL); @@ -428,8 +427,7 @@ int wolfSSL_i2d_PKCS7_bio(WOLFSSL_BIO *bio, PKCS7 *p7) ret = WOLFSSL_SUCCESS; cleanup: - if (output) - XFREE(output, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(output, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -627,9 +625,7 @@ static int wolfSSL_BIO_to_MIME_crlf(WOLFSSL_BIO* in, WOLFSSL_BIO* out) } } - if (canonLine != NULL) { - XFREE(canonLine, NULL, DYNAMIC_TYPE_PKCS7); - } + XFREE(canonLine, NULL, DYNAMIC_TYPE_PKCS7); #ifdef WOLFSSL_SMALL_STACK XFREE(line, in->heap, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -718,9 +714,7 @@ int wolfSSL_PKCS7_final(PKCS7* pkcs7, WOLFSSL_BIO* in, int flags) } } - if (mem != NULL) { - XFREE(mem, in->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(mem, in->heap, DYNAMIC_TYPE_TMP_BUFFER); } else { #ifdef HAVE_SMIME @@ -746,9 +740,7 @@ int wolfSSL_PKCS7_final(PKCS7* pkcs7, WOLFSSL_BIO* in, int flags) } if (ret == 1) { - if (p7->data != NULL) { - XFREE(p7->data, NULL, DYNAMIC_TYPE_PKCS7); - } + XFREE(p7->data, NULL, DYNAMIC_TYPE_PKCS7); p7->data = (byte*)XMALLOC(memSz, NULL, DYNAMIC_TYPE_PKCS7); if (p7->data == NULL) { ret = 0; @@ -1040,19 +1032,11 @@ int wolfSSL_PEM_write_bio_PKCS7(WOLFSSL_BIO* bio, PKCS7* p7) error: #ifdef WOLFSSL_SMALL_STACK - if (outputHead) { - XFREE(outputHead, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); - } - if (outputFoot) { - XFREE(outputFoot, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(outputHead, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(outputFoot, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); #endif - if (output) { - XFREE(output, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); - } - if (pem) { - XFREE(pem, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(output, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(pem, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); return WOLFSSL_FAILURE; } @@ -1387,10 +1371,8 @@ PKCS7* wolfSSL_SMIME_read_PKCS7(WOLFSSL_BIO* in, XFREE(boundary, NULL, DYNAMIC_TYPE_PKCS7); XFREE(outHead, NULL, DYNAMIC_TYPE_PKCS7); XFREE(section, NULL, DYNAMIC_TYPE_PKCS7); - if (canonSection != NULL) - XFREE(canonSection, NULL, DYNAMIC_TYPE_PKCS7); - if (canonLine != NULL) - XFREE(canonLine, NULL, DYNAMIC_TYPE_PKCS7); + XFREE(canonSection, NULL, DYNAMIC_TYPE_PKCS7); + XFREE(canonLine, NULL, DYNAMIC_TYPE_PKCS7); if (bcont) { wolfSSL_BIO_free(*bcont); *bcont = NULL; /* reset 'bcount' pointer to NULL on failure */ @@ -1607,12 +1589,8 @@ int wolfSSL_SMIME_write_PKCS7(WOLFSSL_BIO* out, PKCS7* pkcs7, WOLFSSL_BIO* in, } } - if (p7out != NULL) { - XFREE(p7out, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (sigBase64 != NULL) { - XFREE(sigBase64, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(p7out, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(sigBase64, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (ret > 0) { return WOLFSSL_SUCCESS; @@ -1704,8 +1682,7 @@ WC_PKCS12* wolfSSL_d2i_PKCS12_bio(WOLFSSL_BIO* bio, WC_PKCS12** pkcs12) } /* cleanup */ - if (mem != NULL) - XFREE(mem, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(mem, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); if (ret < 0 && localPkcs12 != NULL) { wc_PKCS12_free(localPkcs12); localPkcs12 = NULL; @@ -1740,9 +1717,7 @@ int wolfSSL_i2d_PKCS12_bio(WOLFSSL_BIO *bio, WC_PKCS12 *pkcs12) } } - if (certDer != NULL) { - XFREE(certDer, NULL, DYNAMIC_TYPE_PKCS); - } + XFREE(certDer, NULL, DYNAMIC_TYPE_PKCS); } return ret; @@ -1904,12 +1879,8 @@ int wolfSSL_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw, *ca = (WOLF_STACK_OF(WOLFSSL_X509)*)XMALLOC( sizeof(WOLF_STACK_OF(WOLFSSL_X509)), heap, DYNAMIC_TYPE_X509); if (*ca == NULL) { - if (pk != NULL) { - XFREE(pk, heap, DYNAMIC_TYPE_PUBLIC_KEY); - } - if (certData != NULL) { - XFREE(certData, heap, DYNAMIC_TYPE_PKCS); - } + XFREE(pk, heap, DYNAMIC_TYPE_PUBLIC_KEY); + XFREE(certData, heap, DYNAMIC_TYPE_PKCS); /* Free up WC_DerCertList and move on */ while (current != NULL) { WC_DerCertList* next = current->next; @@ -1943,12 +1914,8 @@ int wolfSSL_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw, FreeDecodedCert(DeCert); wolfSSL_X509_free(x509); wolfSSL_sk_X509_pop_free(*ca, NULL); *ca = NULL; - if (pk != NULL) { - XFREE(pk, heap, DYNAMIC_TYPE_PUBLIC_KEY); - } - if (certData != NULL) { - XFREE(certData, heap, DYNAMIC_TYPE_PKCS); - } + XFREE(pk, heap, DYNAMIC_TYPE_PUBLIC_KEY); + XFREE(certData, heap, DYNAMIC_TYPE_PKCS); /* Free up WC_DerCertList */ while (current != NULL) { WC_DerCertList* next = current->next; @@ -1966,12 +1933,8 @@ int wolfSSL_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw, WOLFSSL_MSG("Failed to push x509 onto stack"); wolfSSL_X509_free(x509); wolfSSL_sk_X509_pop_free(*ca, NULL); *ca = NULL; - if (pk != NULL) { - XFREE(pk, heap, DYNAMIC_TYPE_PUBLIC_KEY); - } - if (certData != NULL) { - XFREE(certData, heap, DYNAMIC_TYPE_PKCS); - } + XFREE(pk, heap, DYNAMIC_TYPE_PUBLIC_KEY); + XFREE(certData, heap, DYNAMIC_TYPE_PKCS); /* Free up WC_DerCertList */ while (current != NULL) { @@ -1997,9 +1960,7 @@ int wolfSSL_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw, *cert = (WOLFSSL_X509*)XMALLOC(sizeof(WOLFSSL_X509), heap, DYNAMIC_TYPE_X509); if (*cert == NULL) { - if (pk != NULL) { - XFREE(pk, heap, DYNAMIC_TYPE_PUBLIC_KEY); - } + XFREE(pk, heap, DYNAMIC_TYPE_PUBLIC_KEY); if (ca != NULL) { wolfSSL_sk_X509_pop_free(*ca, NULL); *ca = NULL; } @@ -2015,9 +1976,7 @@ int wolfSSL_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw, if (CopyDecodedToX509(*cert, DeCert) != 0) { WOLFSSL_MSG("Failed to copy decoded cert"); FreeDecodedCert(DeCert); - if (pk != NULL) { - XFREE(pk, heap, DYNAMIC_TYPE_PUBLIC_KEY); - } + XFREE(pk, heap, DYNAMIC_TYPE_PUBLIC_KEY); if (ca != NULL) { wolfSSL_sk_X509_pop_free(*ca, NULL); *ca = NULL; } @@ -2064,8 +2023,7 @@ int wolfSSL_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw, } } #endif /* HAVE_ECC */ - if (pk != NULL) - XFREE(pk, heap, DYNAMIC_TYPE_PKCS); + XFREE(pk, heap, DYNAMIC_TYPE_PKCS); if (ret != 0) { /* if is in fail state and no PKEY then fail */ wolfSSL_X509_free(*cert); *cert = NULL; if (ca != NULL) { diff --git a/src/ssl_sess.c b/src/ssl_sess.c index 90b09b7363..62caa7a1cd 100644 --- a/src/ssl_sess.c +++ b/src/ssl_sess.c @@ -1309,8 +1309,7 @@ int wolfSSL_GetSessionFromCache(WOLFSSL* ssl, WOLFSSL_SESSION* output) output->ticketLenAlloc = 0; } #ifdef WOLFSSL_SMALL_STACK - if (tmpTicket != NULL) - XFREE(tmpTicket, output->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmpTicket, output->heap, DYNAMIC_TYPE_TMP_BUFFER); #endif return WOLFSSL_FAILURE; } @@ -1330,16 +1329,12 @@ int wolfSSL_GetSessionFromCache(WOLFSSL* ssl, WOLFSSL_SESSION* output) output->ticketLenAlloc = 0; } #ifdef WOLFSSL_TLS13 - if (preallocNonce != NULL) { - XFREE(preallocNonce, output->heap, DYNAMIC_TYPE_SESSION_TICK); - preallocNonce = NULL; - } + XFREE(preallocNonce, output->heap, DYNAMIC_TYPE_SESSION_TICK); + preallocNonce = NULL; #endif /* WOLFSSL_TLS13 */ #ifdef WOLFSSL_SMALL_STACK - if (tmpTicket != NULL) { - XFREE(tmpTicket, output->heap, DYNAMIC_TYPE_TMP_BUFFER); - tmpTicket = NULL; - } + XFREE(tmpTicket, output->heap, DYNAMIC_TYPE_TMP_BUFFER); + tmpTicket = NULL; #endif #endif } @@ -1417,8 +1412,7 @@ int wolfSSL_GetSessionFromCache(WOLFSSL* ssl, WOLFSSL_SESSION* output) } } #ifdef WOLFSSL_SMALL_STACK - if (tmpTicket != NULL) - XFREE(tmpTicket, output->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmpTicket, output->heap, DYNAMIC_TYPE_TMP_BUFFER); #endif #if defined(WOLFSSL_TLS13) && defined(WOLFSSL_TICKET_NONCE_MALLOC) && \ @@ -1455,8 +1449,7 @@ int wolfSSL_GetSessionFromCache(WOLFSSL* ssl, WOLFSSL_SESSION* output) preallocNonce = NULL; } } - if (preallocNonce != NULL) - XFREE(preallocNonce, output->heap, DYNAMIC_TYPE_SESSION_TICK); + XFREE(preallocNonce, output->heap, DYNAMIC_TYPE_SESSION_TICK); #endif /* WOLFSSL_TLS13 && WOLFSSL_TICKET_NONCE_MALLOC && FIPS_VERSION_GE(5,3)*/ #endif @@ -1839,8 +1832,7 @@ int AddSessionToCache(WOLFSSL_CTX* ctx, WOLFSSL_SESSION* addSession, preallocNonce = (byte*)XMALLOC(addSession->ticketNonce.len, addSession->heap, DYNAMIC_TYPE_SESSION_TICK); if (preallocNonce == NULL) { - if (ticBuff != NULL) - XFREE(ticBuff, addSession->heap, DYNAMIC_TYPE_SESSION_TICK); + XFREE(ticBuff, addSession->heap, DYNAMIC_TYPE_SESSION_TICK); return MEMORY_E; } preallocNonceLen = addSession->ticketNonce.len; @@ -3906,8 +3898,7 @@ static int wolfSSL_DupSessionEx(const WOLFSSL_SESSION* input, } } else { - if (ticBuff != NULL) - XFREE(ticBuff, output->heap, DYNAMIC_TYPE_SESSION_TICK); + XFREE(ticBuff, output->heap, DYNAMIC_TYPE_SESSION_TICK); output->ticket = output->staticTicket; output->ticketLenAlloc = 0; } diff --git a/src/tls.c b/src/tls.c index 472c6519f3..a2f3705cf0 100644 --- a/src/tls.c +++ b/src/tls.c @@ -2682,8 +2682,7 @@ static void TLSX_TCA_Free(TCA* tca, void* heap) (void)heap; if (tca) { - if (tca->id) - XFREE(tca->id, heap, DYNAMIC_TYPE_TLSX); + XFREE(tca->id, heap, DYNAMIC_TYPE_TLSX); XFREE(tca, heap, DYNAMIC_TYPE_TLSX); } } @@ -5975,9 +5974,7 @@ static TlsxSrtp* TLSX_UseSRTP_New(word16 ids, void* heap) static void TLSX_UseSRTP_Free(TlsxSrtp *srtp, void* heap) { - if (srtp != NULL) { - XFREE(srtp, heap, DYNAMIC_TYPE_TLSX); - } + XFREE(srtp, heap, DYNAMIC_TYPE_TLSX); (void)heap; } @@ -6594,8 +6591,7 @@ static void TLSX_Cookie_FreeAll(Cookie* cookie, void* heap) { (void)heap; - if (cookie != NULL) - XFREE(cookie, heap, DYNAMIC_TYPE_TLSX); + XFREE(cookie, heap, DYNAMIC_TYPE_TLSX); } /* Get the size of the encoded Cookie extension. @@ -6748,8 +6744,7 @@ int TLSX_Cookie_Use(const WOLFSSL* ssl, const byte* data, word16 len, byte* mac, if (mac != NULL) XMEMCPY(cookie->data + len, mac, macSz); - if (extension->data != NULL) - XFREE(extension->data, ssl->heap, DYNAMIC_TYPE_TLSX); + XFREE(extension->data, ssl->heap, DYNAMIC_TYPE_TLSX); extension->data = (void*)cookie; extension->resp = (byte)resp; @@ -7392,21 +7387,15 @@ static int TLSX_KeyShare_GenDhKey(WOLFSSL *ssl, KeyShareEntry* kse) * The DhKey will be setup again in TLSX_KeyShare_ProcessDh */ if (dhKey != NULL) wc_FreeDhKey(dhKey); - if (kse->key != NULL) { - XFREE(kse->key, ssl->heap, DYNAMIC_TYPE_DH); - kse->key = NULL; - } + XFREE(kse->key, ssl->heap, DYNAMIC_TYPE_DH); + kse->key = NULL; if (ret != 0) { /* Cleanup on error, otherwise data owned by key share entry */ - if (kse->privKey != NULL) { - XFREE(kse->privKey, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); - kse->privKey = NULL; - } - if (kse->pubKey != NULL) { - XFREE(kse->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); - kse->pubKey = NULL; - } + XFREE(kse->privKey, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); + kse->privKey = NULL; + XFREE(kse->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); + kse->pubKey = NULL; } #else (void)ssl; @@ -7488,16 +7477,12 @@ static int TLSX_KeyShare_GenX25519Key(WOLFSSL *ssl, KeyShareEntry* kse) if (ret != 0) { /* Data owned by key share entry otherwise. */ - if (kse->pubKey != NULL) { - XFREE(kse->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); - kse->pubKey = NULL; - } + XFREE(kse->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); + kse->pubKey = NULL; if (key != NULL) wc_curve25519_free(key); - if (kse->key != NULL) { - XFREE(kse->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); - kse->key = NULL; - } + XFREE(kse->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); + kse->key = NULL; } #else (void)ssl; @@ -7576,16 +7561,12 @@ static int TLSX_KeyShare_GenX448Key(WOLFSSL *ssl, KeyShareEntry* kse) if (ret != 0) { /* Data owned by key share entry otherwise. */ - if (kse->pubKey != NULL) { - XFREE(kse->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); - kse->pubKey = NULL; - } + XFREE(kse->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); + kse->pubKey = NULL; if (key != NULL) wc_curve448_free(key); - if (kse->key != NULL) { - XFREE(kse->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); - kse->key = NULL; - } + XFREE(kse->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); + kse->key = NULL; } #else (void)ssl; @@ -7739,16 +7720,12 @@ static int TLSX_KeyShare_GenEccKey(WOLFSSL *ssl, KeyShareEntry* kse) if (ret != 0) { /* Cleanup on error, otherwise data owned by key share entry */ - if (kse->pubKey != NULL) { - XFREE(kse->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); - kse->pubKey = NULL; - } + XFREE(kse->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); + kse->pubKey = NULL; if (eccKey != NULL) wc_ecc_free(eccKey); - if (kse->key != NULL) { - XFREE(kse->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); - kse->key = NULL; - } + XFREE(kse->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); + kse->key = NULL; } #else (void)ssl; @@ -7957,10 +7934,8 @@ static int TLSX_KeyShare_GenPqcKey(WOLFSSL *ssl, KeyShareEntry* kse) wc_KyberKey_Free(kem); TLSX_KeyShare_FreeAll(ecc_kse, ssl->heap); - if (pubKey != NULL) - XFREE(pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); - if (privKey != NULL) - XFREE(privKey, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); + XFREE(pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); + XFREE(privKey, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); return ret; } @@ -8024,10 +7999,8 @@ static void TLSX_KeyShare_FreeAll(KeyShareEntry* list, void* heap) if (current->key != NULL) { ForceZero((byte*)current->key, current->keyLen); } - if (current->pubKey != NULL) { - XFREE(current->pubKey, heap, DYNAMIC_TYPE_PUBLIC_KEY); - current->pubKey = NULL; - } + XFREE(current->pubKey, heap, DYNAMIC_TYPE_PUBLIC_KEY); + current->pubKey = NULL; if (current->privKey != NULL) { ForceZero(current->privKey, current->privKeyLen); XFREE(current->privKey, heap, DYNAMIC_TYPE_PRIVATE_KEY); @@ -8246,18 +8219,12 @@ static int TLSX_KeyShare_ProcessDh(WOLFSSL* ssl, KeyShareEntry* keyShareEntry) /* done with key share, release resources */ if (dhKey) wc_FreeDhKey(dhKey); - if (keyShareEntry->key) { - XFREE(keyShareEntry->key, ssl->heap, DYNAMIC_TYPE_DH); - keyShareEntry->key = NULL; - } - if (keyShareEntry->privKey != NULL) { - XFREE(keyShareEntry->privKey, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); - keyShareEntry->privKey = NULL; - } - if (keyShareEntry->pubKey != NULL) { - XFREE(keyShareEntry->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); - keyShareEntry->pubKey = NULL; - } + XFREE(keyShareEntry->key, ssl->heap, DYNAMIC_TYPE_DH); + keyShareEntry->key = NULL; + XFREE(keyShareEntry->privKey, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); + keyShareEntry->privKey = NULL; + XFREE(keyShareEntry->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); + keyShareEntry->pubKey = NULL; XFREE(keyShareEntry->ke, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); keyShareEntry->ke = NULL; #else @@ -8335,10 +8302,8 @@ static int TLSX_KeyShare_ProcessX25519(WOLFSSL* ssl, wc_curve25519_free(peerX25519Key); XFREE(peerX25519Key, ssl->heap, DYNAMIC_TYPE_TLSX); wc_curve25519_free((curve25519_key*)keyShareEntry->key); - if (keyShareEntry->key != NULL) { - XFREE(keyShareEntry->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); - keyShareEntry->key = NULL; - } + XFREE(keyShareEntry->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); + keyShareEntry->key = NULL; #else (void)ssl; (void)keyShareEntry; @@ -8415,10 +8380,8 @@ static int TLSX_KeyShare_ProcessX448(WOLFSSL* ssl, KeyShareEntry* keyShareEntry) wc_curve448_free(peerX448Key); XFREE(peerX448Key, ssl->heap, DYNAMIC_TYPE_TLSX); wc_curve448_free((curve448_key*)keyShareEntry->key); - if (keyShareEntry->key != NULL) { - XFREE(keyShareEntry->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); - keyShareEntry->key = NULL; - } + XFREE(keyShareEntry->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); + keyShareEntry->key = NULL; #else (void)ssl; (void)keyShareEntry; @@ -8735,9 +8698,7 @@ static int TLSX_KeyShare_ProcessPqc(WOLFSSL* ssl, KeyShareEntry* keyShareEntry) ssl->arrays->preMasterSz = (word32) sharedSecretLen; } - if (sharedSecret != NULL) { - XFREE(sharedSecret, ssl->heap, DYNAMIC_TYPE_SECRET); - } + XFREE(sharedSecret, ssl->heap, DYNAMIC_TYPE_SECRET); wc_ecc_free(&eccpubkey); wc_KyberKey_Free(kem); @@ -9224,9 +9185,7 @@ static int server_generate_pqc_ciphertext(WOLFSSL* ssl, } if (ret == 0) { - if (keyShareEntry->ke != NULL) { - XFREE(keyShareEntry->ke, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); - } + XFREE(keyShareEntry->ke, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); keyShareEntry->ke = sharedSecret; keyShareEntry->keLen = outlen + ssSz; @@ -9244,10 +9203,8 @@ static int server_generate_pqc_ciphertext(WOLFSSL* ssl, } TLSX_KeyShare_FreeAll(ecc_kse, ssl->heap); - if (sharedSecret != NULL) - XFREE(sharedSecret, ssl->heap, DYNAMIC_TYPE_SECRET); - if (ciphertext != NULL) - XFREE(ciphertext, ssl->heap, DYNAMIC_TYPE_TLSX); + XFREE(sharedSecret, ssl->heap, DYNAMIC_TYPE_SECRET); + XFREE(ciphertext, ssl->heap, DYNAMIC_TYPE_TLSX); wc_ecc_free(&eccpubkey); wc_KyberKey_Free(kem); return ret; @@ -9312,9 +9269,7 @@ int TLSX_KeyShare_Use(const WOLFSSL* ssl, word16 group, word16 len, byte* data, else #endif if (data != NULL) { - if (keyShareEntry->ke != NULL) { - XFREE(keyShareEntry->ke, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); - } + XFREE(keyShareEntry->ke, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); keyShareEntry->ke = data; keyShareEntry->keLen = len; } @@ -12106,8 +12061,7 @@ static int TLSX_ExtractEch(WOLFSSL_ECH* ech, WOLFSSL_EchConfig* echConfig, ech->hpke = NULL; } - if (info != NULL) - XFREE(info, heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(info, heap, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -12263,13 +12217,11 @@ static int TLSX_ECH_Parse(WOLFSSL* ssl, const byte* readBuf, word16 size, /* free the ech struct and the dynamic buffer it uses */ static void TLSX_ECH_Free(WOLFSSL_ECH* ech, void* heap) { - if (ech->innerClientHello != NULL) - XFREE(ech->innerClientHello, heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(ech->innerClientHello, heap, DYNAMIC_TYPE_TMP_BUFFER); if (ech->ephemeralKey != NULL) wc_HpkeFreeKey(ech->hpke, ech->hpke->kem, ech->ephemeralKey, ech->hpke->heap); - if (ech->hpke != NULL) - XFREE(ech->hpke, heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(ech->hpke, heap, DYNAMIC_TYPE_TMP_BUFFER); XFREE(ech, heap, DYNAMIC_TYPE_TMP_BUFFER); (void)heap; diff --git a/src/wolfio.c b/src/wolfio.c index 90c4ff271a..d6a285a913 100644 --- a/src/wolfio.c +++ b/src/wolfio.c @@ -2125,8 +2125,7 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz, /* in default callback ctx is heap hint */ void EmbedOcspRespFree(void* ctx, byte *resp) { - if (resp) - XFREE(resp, ctx, DYNAMIC_TYPE_OCSP); + XFREE(resp, ctx, DYNAMIC_TYPE_OCSP); (void)ctx; } diff --git a/src/x509.c b/src/x509.c index cbe3b92421..2e443a023a 100644 --- a/src/x509.c +++ b/src/x509.c @@ -6391,9 +6391,7 @@ static int X509PrintExtensions(WOLFSSL_BIO* bio, WOLFSSL_X509* x509, int indent) } } - if (buf != NULL) { - XFREE(buf, x509->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(buf, x509->heap, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -6573,9 +6571,7 @@ static int X509PrintSignature(WOLFSSL_BIO* bio, WOLFSSL_X509* x509, return WOLFSSL_FAILURE; } - if (sig != NULL) { - XFREE(sig, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(sig, NULL, DYNAMIC_TYPE_TMP_BUFFER); } @@ -7191,8 +7187,7 @@ int wolfSSL_X509_LOOKUP_load_file(WOLFSSL_X509_LOOKUP* lookup, while (ret == WOLFSSL_SUCCESS); end: - if (pem != NULL) - XFREE(pem, 0, DYNAMIC_TYPE_PEM); + XFREE(pem, 0, DYNAMIC_TYPE_PEM); XFCLOSE(fp); return WS_RETURN_CODE(ret, (int)WOLFSSL_FAILURE); #else @@ -7793,8 +7788,7 @@ static void *wolfSSL_d2i_X509_fp_ex(XFILE file, void **x509, int type) } #endif _exit: - if (fileBuffer != NULL) - XFREE(fileBuffer, NULL, DYNAMIC_TYPE_FILE); + XFREE(fileBuffer, NULL, DYNAMIC_TYPE_FILE); return newx509; } @@ -7969,9 +7963,7 @@ WOLFSSL_API WOLFSSL_X509_CRL *wolfSSL_d2i_X509_CRL_bio(WOLFSSL_BIO *bp, } } - if (der != NULL) { - XFREE(der, 0, DYNAMIC_TYPE_DER); - } + XFREE(der, 0, DYNAMIC_TYPE_DER); return crl; } @@ -8332,9 +8324,7 @@ static int X509CRLPrintSignature(WOLFSSL_BIO* bio, WOLFSSL_X509_CRL* crl, return WOLFSSL_FAILURE; } - if (sig != NULL) { - XFREE(sig, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(sig, NULL, DYNAMIC_TYPE_TMP_BUFFER); } @@ -8710,8 +8700,7 @@ WOLFSSL_X509_VERIFY_PARAM* wolfSSL_X509_VERIFY_PARAM_new(void) void wolfSSL_X509_VERIFY_PARAM_free(WOLFSSL_X509_VERIFY_PARAM *param) { - if (param != NULL) - XFREE(param, NULL, DYNAMIC_TYPE_OPENSSL); + XFREE(param, NULL, DYNAMIC_TYPE_OPENSSL); } @@ -9779,8 +9768,7 @@ WOLF_STACK_OF(WOLFSSL_X509)* wolfSSL_X509_chain_up_ref( XMEMCPY(out, der + idx, length); } - if (der != NULL) - XFREE(der, NULL, DYNAMIC_TYPE_OPENSSL); + XFREE(der, NULL, DYNAMIC_TYPE_OPENSSL); return length; } @@ -10782,8 +10770,7 @@ WOLF_STACK_OF(WOLFSSL_X509)* wolfSSL_X509_chain_up_ref( } out: - if (der) - XFREE(der, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(der, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -11412,9 +11399,7 @@ int wolfSSL_i2d_X509_NAME(WOLFSSL_X509_NAME* name, unsigned char** out) } err: - if(pem != NULL) { - XFREE(pem, 0, DYNAMIC_TYPE_PEM); - } + XFREE(pem, 0, DYNAMIC_TYPE_PEM); if(der != NULL) { FreeDer(&der); } @@ -11511,8 +11496,7 @@ int wolfSSL_i2d_X509_NAME(WOLFSSL_X509_NAME* name, unsigned char** out) return newx509; err_exit: - if (pem != NULL) - XFREE(pem, NULL, DYNAMIC_TYPE_PEM); + XFREE(pem, NULL, DYNAMIC_TYPE_PEM); if (der != NULL) FreeDer(&der); @@ -11777,8 +11761,7 @@ int wolfSSL_i2d_X509_NAME(WOLFSSL_X509_NAME* name, unsigned char** out) #endif return WOLFSSL_SUCCESS; err: - if (pem) - XFREE(pem, 0, DYNAMIC_TYPE_PEM); + XFREE(pem, 0, DYNAMIC_TYPE_PEM); #ifdef HAVE_CRL if (der) FreeDer(&der); @@ -12579,8 +12562,7 @@ int wolfSSL_PEM_write_bio_X509(WOLFSSL_BIO *bio, WOLFSSL_X509 *cert) return WOLFSSL_SUCCESS; error: - if (pem) - XFREE(pem, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(pem, NULL, DYNAMIC_TYPE_TMP_BUFFER); return WOLFSSL_FAILURE; } #endif /* WOLFSSL_CERT_GEN */ @@ -13525,8 +13507,7 @@ int wolfSSL_X509_check_ip_asc(WOLFSSL_X509 *x, const char *ipasc, } #ifdef WOLFSSL_SMALL_STACK - if (dCert != NULL) - XFREE(dCert, x->heap, DYNAMIC_TYPE_DCERT); + XFREE(dCert, x->heap, DYNAMIC_TYPE_DCERT); #endif return ret; diff --git a/src/x509_str.c b/src/x509_str.c index bfdaf413dc..705cb32dc0 100644 --- a/src/x509_str.c +++ b/src/x509_str.c @@ -76,10 +76,8 @@ void wolfSSL_X509_STORE_CTX_free(WOLFSSL_X509_STORE_CTX* ctx) #endif #ifdef OPENSSL_EXTRA - if (ctx->param != NULL) { - XFREE(ctx->param, ctx->heap, DYNAMIC_TYPE_OPENSSL); - ctx->param = NULL; - } + XFREE(ctx->param, ctx->heap, DYNAMIC_TYPE_OPENSSL); + ctx->param = NULL; #endif XFREE(ctx, ctx->heap, DYNAMIC_TYPE_X509_CTX); @@ -186,10 +184,8 @@ void wolfSSL_X509_STORE_CTX_cleanup(WOLFSSL_X509_STORE_CTX* ctx) { if (ctx != NULL) { - if (ctx->param != NULL) { - XFREE(ctx->param, ctx->heap, DYNAMIC_TYPE_OPENSSL); - ctx->param = NULL; - } + XFREE(ctx->param, ctx->heap, DYNAMIC_TYPE_OPENSSL); + ctx->param = NULL; wolfSSL_X509_STORE_CTX_init(ctx, NULL, NULL, NULL); } @@ -851,10 +847,8 @@ void wolfSSL_X509_STORE_free(WOLFSSL_X509_STORE* store) } #endif #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL) - if (store->param != NULL) { - XFREE(store->param, NULL, DYNAMIC_TYPE_OPENSSL); - store->param = NULL; - } + XFREE(store->param, NULL, DYNAMIC_TYPE_OPENSSL); + store->param = NULL; if (store->lookup.dirs != NULL) { #if defined(OPENSSL_ALL) && !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR) diff --git a/sslSniffer/sslSnifferTest/snifftest.c b/sslSniffer/sslSnifferTest/snifftest.c index d39020a08e..0cfb388597 100644 --- a/sslSniffer/sslSnifferTest/snifftest.c +++ b/sslSniffer/sslSnifferTest/snifftest.c @@ -677,10 +677,8 @@ static void ssl_Free_SnifferWorker(SnifferWorker* worker) { wm_SemFree(&worker->sem); - if (worker->head) { - XFREE(worker->head, NULL, DYNAMIC_TYPE_TMP_BUFFER); - worker->head = NULL; - } + XFREE(worker->head, NULL, DYNAMIC_TYPE_TMP_BUFFER); + worker->head = NULL; } static int SnifferWorkerPacketAdd(SnifferWorker* worker, int lastRet, diff --git a/tests/api.c b/tests/api.c index 1df7d0e6ca..04858591de 100644 --- a/tests/api.c +++ b/tests/api.c @@ -39767,8 +39767,7 @@ static int test_wc_PKCS7_VerifySignedData_RSA(void) pkcs7 = NULL; } - if (buf != NULL) - XFREE(buf, HEAP_HINT, DYNAMIC_TYPE_FILE); + XFREE(buf, HEAP_HINT, DYNAMIC_TYPE_FILE); } #endif /* BER and stream */ #endif @@ -68742,8 +68741,7 @@ static int test_wolfSSL_i2d_X509(void) ExpectIntGT(i2d_X509(cert, &tmp), 0); ExpectPtrGT(tmp, out); - if (out != NULL) - XFREE(out, NULL, DYNAMIC_TYPE_OPENSSL); + XFREE(out, NULL, DYNAMIC_TYPE_OPENSSL); X509_free(cert); #endif return EXPECT_RESULT(); diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 7f0e23d5f6..0bb5322370 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -10202,15 +10202,11 @@ static void bench_xmss_sign_verify(const char * params) bench_stats_asym_finish(params, (int)sigSz, "verify", 0, count, start, ret); /* Cleanup everything. */ - if (sig != NULL) { - XFREE(sig, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - sig = NULL; - } + XFREE(sig, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + sig = NULL; - if (sk != NULL) { - XFREE(sk, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - sk = NULL; - } + XFREE(sk, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + sk = NULL; if (freeRng) { wc_FreeRng(&rng); @@ -11070,10 +11066,8 @@ void bench_eccEncrypt(int curveId) wc_ecc_free(userB); XFREE(userB, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); } - if (msg) - XFREE(msg, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (out) - XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(msg, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #else wc_ecc_free(userB); wc_ecc_free(userA); @@ -12482,11 +12476,9 @@ void bench_sakke(void) exit: - if (iTable) - XFREE(iTable, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(iTable, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (table) - XFREE(table, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(table, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); WC_FREE_VAR(genKey, HEAP_HINT); } diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index 747c22c70e..93f91816b4 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -11307,10 +11307,8 @@ void wc_AesFree(Aes* aes) #endif #if defined(WOLFSSL_AESGCM_STREAM) && defined(WOLFSSL_SMALL_STACK) && \ !defined(WOLFSSL_AESNI) - if (aes->streamData != NULL) { - XFREE(aes->streamData, aes->heap, DYNAMIC_TYPE_AES); - aes->streamData = NULL; - } + XFREE(aes->streamData, aes->heap, DYNAMIC_TYPE_AES); + aes->streamData = NULL; #endif #if defined(WOLFSSL_SE050) && defined(WOLFSSL_SE050_CRYPT) @@ -12170,8 +12168,7 @@ int wc_AesKeyWrap(const byte* key, word32 keySz, const byte* in, word32 inSz, out: #ifdef WOLFSSL_SMALL_STACK - if (aes != NULL) - XFREE(aes, NULL, DYNAMIC_TYPE_AES); + XFREE(aes, NULL, DYNAMIC_TYPE_AES); #endif return ret; @@ -12289,8 +12286,7 @@ int wc_AesKeyUnWrap(const byte* key, word32 keySz, const byte* in, word32 inSz, out: #ifdef WOLFSSL_SMALL_STACK - if (aes) - XFREE(aes, NULL, DYNAMIC_TYPE_AES); + XFREE(aes, NULL, DYNAMIC_TYPE_AES); #endif return ret; @@ -13696,9 +13692,7 @@ static WARN_UNUSED_RESULT int S2V( } } #ifdef WOLFSSL_SMALL_STACK - if (cmac != NULL) { - XFREE(cmac, NULL, DYNAMIC_TYPE_CMAC); - } + XFREE(cmac, NULL, DYNAMIC_TYPE_CMAC); #elif defined(WOLFSSL_CHECK_MEM_ZERO) wc_MemZero_Check(cmac, sizeof(Cmac)); #endif diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 814d571b86..59235b940d 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -4025,9 +4025,7 @@ int wc_BerToDer(const byte* ber, word32 berSz, byte* der, word32* derSz) } end: #ifdef WOLFSSL_SMALL_STACK - if (indefItems != NULL) { - XFREE(indefItems, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(indefItems, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; } @@ -8616,9 +8614,7 @@ int wc_EncryptPKCS8Key(byte* key, word32 keySz, byte* out, word32* outSz, } #ifdef WOLFSSL_SMALL_STACK - if (saltTmp != NULL) { - XFREE(saltTmp, heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(saltTmp, heap, DYNAMIC_TYPE_TMP_BUFFER); #endif WOLFSSL_LEAVE("wc_EncryptPKCS8Key", ret); @@ -11554,8 +11550,7 @@ void FreeDecodedCert(DecodedCert* cert) wolfSSL_X509_NAME_free((WOLFSSL_X509_NAME*)cert->subjectName); #endif /* WOLFSSL_X509_NAME_AVAILABLE */ #if defined(WOLFSSL_RENESAS_TSIP_TLS) || defined(WOLFSSL_RENESAS_FSPSM_TLS) - if (cert->sce_tsip_encRsaKeyIdx != NULL) - XFREE(cert->sce_tsip_encRsaKeyIdx, cert->heap, DYNAMIC_TYPE_RSA); + XFREE(cert->sce_tsip_encRsaKeyIdx, cert->heap, DYNAMIC_TYPE_RSA); #endif FreeSignatureCtx(&cert->sigCtx); } @@ -16323,15 +16318,11 @@ void FreeSignatureCtx(SignatureCtx* sigCtx) if (sigCtx == NULL) return; - if (sigCtx->digest) { - XFREE(sigCtx->digest, sigCtx->heap, DYNAMIC_TYPE_DIGEST); - sigCtx->digest = NULL; - } + XFREE(sigCtx->digest, sigCtx->heap, DYNAMIC_TYPE_DIGEST); + sigCtx->digest = NULL; #if !(defined(NO_RSA) && defined(NO_DSA)) - if (sigCtx->sigCpy) { - XFREE(sigCtx->sigCpy, sigCtx->heap, DYNAMIC_TYPE_SIGNATURE); - sigCtx->sigCpy = NULL; - } + XFREE(sigCtx->sigCpy, sigCtx->heap, DYNAMIC_TYPE_SIGNATURE); + sigCtx->sigCpy = NULL; #endif #ifndef NO_ASN_CRYPT if (sigCtx->key.ptr) { @@ -17796,8 +17787,7 @@ int wc_ConfirmAltSignature( } #ifdef WOLFSSL_SMALL_STACK - if (sigCtx != NULL) - XFREE(sigCtx, heap, DYNAMIC_TYPE_SIGNATURE); + XFREE(sigCtx, heap, DYNAMIC_TYPE_SIGNATURE); #endif return ret; } @@ -23119,8 +23109,7 @@ static int CheckCertSignature_ex(const byte* cert, word32 certSz, void* heap, FreeSignatureCtx(sigCtx); #ifdef WOLFSSL_SMALL_STACK - if (sigCtx != NULL) - XFREE(sigCtx, heap, DYNAMIC_TYPE_SIGNATURE); + XFREE(sigCtx, heap, DYNAMIC_TYPE_SIGNATURE); #endif return ret; #else /* WOLFSSL_ASN_TEMPLATE */ @@ -24328,13 +24317,9 @@ void FreeTrustedPeer(TrustedPeerCert* tp, void* heap) return; } - if (tp->name) { - XFREE(tp->name, heap, DYNAMIC_TYPE_SUBJECT_CN); - } + XFREE(tp->name, heap, DYNAMIC_TYPE_SUBJECT_CN); - if (tp->sig) { - XFREE(tp->sig, heap, DYNAMIC_TYPE_SIGNATURE); - } + XFREE(tp->sig, heap, DYNAMIC_TYPE_SIGNATURE); #ifndef IGNORE_NAME_CONSTRAINTS if (tp->permittedNames) FreeNameSubtrees(tp->permittedNames, heap); @@ -27507,12 +27492,8 @@ static int SetExtKeyUsage(Cert* cert, byte* output, word32 outSz, byte input) } /* Dispose of allocated data. */ - if (extKuASN != NULL) { - XFREE(extKuASN, cert->heap, DYNAMIC_TYPE_TMP_BUFFER); - } - if (dataASN != NULL) { - XFREE(dataASN, cert->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(extKuASN, cert->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(dataASN, cert->heap, DYNAMIC_TYPE_TMP_BUFFER); return ret; #endif @@ -28611,10 +28592,8 @@ int SetNameEx(byte* output, word32 outputSz, CertName* name, void* heap) } } - if (namesASN != NULL) - XFREE(namesASN, heap, DYNAMIC_TYPE_TMP_BUFFER); - if (dataASN != NULL) - XFREE(dataASN, heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(namesASN, heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(dataASN, heap, DYNAMIC_TYPE_TMP_BUFFER); (void)heap; return ret; #endif @@ -37491,8 +37470,7 @@ void FreeOcspRequest(OcspRequest* req) WOLFSSL_ENTER("FreeOcspRequest"); if (req) { - if (req->serial) - XFREE(req->serial, req->heap, DYNAMIC_TYPE_OCSP_REQUEST); + XFREE(req->serial, req->heap, DYNAMIC_TYPE_OCSP_REQUEST); req->serial = NULL; #ifdef OPENSSL_EXTRA @@ -37505,8 +37483,7 @@ void FreeOcspRequest(OcspRequest* req) req->serialInt = NULL; #endif - if (req->url) - XFREE(req->url, req->heap, DYNAMIC_TYPE_OCSP_REQUEST); + XFREE(req->url, req->heap, DYNAMIC_TYPE_OCSP_REQUEST); req->url = NULL; #ifdef OPENSSL_EXTRA @@ -37727,8 +37704,7 @@ void FreeDecodedCRL(DecodedCRL* dcrl) tmp = next; } #ifdef OPENSSL_EXTRA - if (dcrl->issuer != NULL) - XFREE(dcrl->issuer, NULL, DYNAMIC_TYPE_OPENSSL); + XFREE(dcrl->issuer, NULL, DYNAMIC_TYPE_OPENSSL); #endif } @@ -39034,10 +39010,8 @@ int wc_MIME_parse_headers(char* in, int inLen, MimeHdr** headers) mimeType == MIME_PARAM)) && pos >= 1) { mimeStatus = MIME_BODYVAL; end = pos-1; - if (nameAttr != NULL) { - XFREE(nameAttr, NULL, DYNAMIC_TYPE_PKCS7); - nameAttr = NULL; - } + XFREE(nameAttr, NULL, DYNAMIC_TYPE_PKCS7); + nameAttr = NULL; ret = wc_MIME_header_strip(curLine, &nameAttr, start, end); if (ret) { goto error; @@ -39046,10 +39020,8 @@ int wc_MIME_parse_headers(char* in, int inLen, MimeHdr** headers) } else if (mimeStatus == MIME_BODYVAL && cur == ';' && pos >= 1) { end = pos-1; - if (bodyVal != NULL) { - XFREE(bodyVal, NULL, DYNAMIC_TYPE_PKCS7); - bodyVal = NULL; - } + XFREE(bodyVal, NULL, DYNAMIC_TYPE_PKCS7); + bodyVal = NULL; ret = wc_MIME_header_strip(curLine, &bodyVal, start, end); if (ret) { goto error; @@ -39142,12 +39114,9 @@ int wc_MIME_parse_headers(char* in, int inLen, MimeHdr** headers) if (ret != 0) wc_MIME_free_hdrs(curHdr); wc_MIME_free_hdrs(nextHdr); - if (nameAttr != NULL) - XFREE(nameAttr, NULL, DYNAMIC_TYPE_PKCS7); - if (bodyVal != NULL) - XFREE(bodyVal, NULL, DYNAMIC_TYPE_PKCS7); - if (nextParam != NULL) - XFREE(nextParam, NULL, DYNAMIC_TYPE_PKCS7); + XFREE(nameAttr, NULL, DYNAMIC_TYPE_PKCS7); + XFREE(bodyVal, NULL, DYNAMIC_TYPE_PKCS7); + XFREE(nextParam, NULL, DYNAMIC_TYPE_PKCS7); return ret; } diff --git a/wolfcrypt/src/cmac.c b/wolfcrypt/src/cmac.c index 5e0faecec5..8accb1a872 100644 --- a/wolfcrypt/src/cmac.c +++ b/wolfcrypt/src/cmac.c @@ -242,9 +242,7 @@ int wc_CmacFree(Cmac* cmac) /* TODO: msg is leaked if wc_CmacFinal() is not called * e.g. when multiple calls to wc_CmacUpdate() and one fails but * wc_CmacFinal() not called. */ - if (cmac->msg != NULL) { - XFREE(cmac->msg, cmac->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(cmac->msg, cmac->heap, DYNAMIC_TYPE_TMP_BUFFER); #endif wc_AesFree(&cmac->aes); ForceZero(cmac, sizeof(Cmac)); @@ -414,9 +412,7 @@ int wc_AesCmacGenerate(byte* out, word32* outSz, #ifdef WOLFSSL_SMALL_STACK - if (cmac) { - XFREE(cmac, NULL, DYNAMIC_TYPE_CMAC); - } + XFREE(cmac, NULL, DYNAMIC_TYPE_CMAC); #elif defined(WOLFSSL_CHECK_MEM_ZERO) wc_MemZero_Check(cmac, sizeof(Cmac)); #endif @@ -495,9 +491,7 @@ int wc_AesCmacVerify(const byte* check, word32 checkSz, INVALID_DEVID); #ifdef WOLFSSL_SMALL_STACK - if (cmac) { - XFREE(cmac, NULL, DYNAMIC_TYPE_CMAC); - } + XFREE(cmac, NULL, DYNAMIC_TYPE_CMAC); #elif defined(WOLFSSL_CHECK_MEM_ZERO) wc_MemZero_Check(cmac, sizeof(Cmac)); #endif diff --git a/wolfcrypt/src/compress.c b/wolfcrypt/src/compress.c index 6496ad436c..941596e7fa 100644 --- a/wolfcrypt/src/compress.c +++ b/wolfcrypt/src/compress.c @@ -310,10 +310,8 @@ int wc_DeCompressDynamic(byte** out, int maxSz, int memoryType, if (inflateEnd(&stream) != Z_OK) result = DECOMPRESS_E; - if (tmp != NULL) { - XFREE(tmp, heap, memoryType); - tmp = NULL; - } + XFREE(tmp, heap, memoryType); + tmp = NULL; return result; } diff --git a/wolfcrypt/src/dilithium.c b/wolfcrypt/src/dilithium.c index a40265fa07..bedba14ae0 100644 --- a/wolfcrypt/src/dilithium.c +++ b/wolfcrypt/src/dilithium.c @@ -7934,8 +7934,8 @@ int wc_dilithium_check_key(dilithium_key* key) } } - /* Dispose of allocated memory. */ - if (s1 != NULL) { + if (key != NULL) { + /* Dispose of allocated memory. */ XFREE(s1, key->heap, DYNAMIC_TYPE_DILITHIUM); } #else diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 1d5e8135c4..46d7da16c3 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -3653,17 +3653,12 @@ static void ecc_key_tmp_final(ecc_key* key, void* heap) FREE_MP_INT_SIZE(key->t1, heap, DYNAMIC_TYPE_ECC); #else #ifdef ALT_ECC_SIZE - if (key->z != NULL) - XFREE(key->z, heap, DYNAMIC_TYPE_ECC); - if (key->y != NULL) - XFREE(key->y, heap, DYNAMIC_TYPE_ECC); - if (key->x != NULL) - XFREE(key->x, heap, DYNAMIC_TYPE_ECC); + XFREE(key->z, heap, DYNAMIC_TYPE_ECC); + XFREE(key->y, heap, DYNAMIC_TYPE_ECC); + XFREE(key->x, heap, DYNAMIC_TYPE_ECC); #endif - if (key->t2 != NULL) - XFREE(key->t2, heap, DYNAMIC_TYPE_ECC); - if (key->t1 != NULL) - XFREE(key->t1, heap, DYNAMIC_TYPE_ECC); + XFREE(key->t2, heap, DYNAMIC_TYPE_ECC); + XFREE(key->t1, heap, DYNAMIC_TYPE_ECC); #endif } #endif /* WOLFSSL_SMALL_STACK_CACHE */ @@ -4981,8 +4976,7 @@ int wc_ecc_shared_secret_gen_sync(ecc_key* private_key, ecc_point* point, if (k == k_lcl) mp_clear(k); #ifdef WOLFSSL_SMALL_STACK - if (k_lcl != NULL) - XFREE(k_lcl, private_key->heap, DYNAMIC_TYPE_ECC_BUFFER); + XFREE(k_lcl, private_key->heap, DYNAMIC_TYPE_ECC_BUFFER); #endif #endif @@ -7619,14 +7613,10 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz, /* bail out if any error has been hit at this point */ if (ret != 0) { - if (x != NULL) - XFREE(x, heap, DYNAMIC_TYPE_PRIVATE_KEY); - if (K != NULL) - XFREE(K, heap, DYNAMIC_TYPE_ECC_BUFFER); - if (V != NULL) - XFREE(V, heap, DYNAMIC_TYPE_ECC_BUFFER); - if (h1 != NULL) - XFREE(h1, heap, DYNAMIC_TYPE_DIGEST); + XFREE(x, heap, DYNAMIC_TYPE_PRIVATE_KEY); + XFREE(K, heap, DYNAMIC_TYPE_ECC_BUFFER); + XFREE(V, heap, DYNAMIC_TYPE_ECC_BUFFER); + XFREE(h1, heap, DYNAMIC_TYPE_DIGEST); return ret; } #endif @@ -7779,16 +7769,11 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz, ForceZero(x, MAX_ECC_BYTES); #ifdef WOLFSSL_SMALL_STACK - if (z1 != NULL) - XFREE(z1, heap, DYNAMIC_TYPE_ECC_BUFFER); - if (x != NULL) - XFREE(x, heap, DYNAMIC_TYPE_PRIVATE_KEY); - if (K != NULL) - XFREE(K, heap, DYNAMIC_TYPE_ECC_BUFFER); - if (V != NULL) - XFREE(V, heap, DYNAMIC_TYPE_ECC_BUFFER); - if (h1 != NULL) - XFREE(h1, heap, DYNAMIC_TYPE_DIGEST); + XFREE(z1, heap, DYNAMIC_TYPE_ECC_BUFFER); + XFREE(x, heap, DYNAMIC_TYPE_PRIVATE_KEY); + XFREE(K, heap, DYNAMIC_TYPE_ECC_BUFFER); + XFREE(V, heap, DYNAMIC_TYPE_ECC_BUFFER); + XFREE(h1, heap, DYNAMIC_TYPE_DIGEST); #elif defined(WOLFSSL_CHECK_MEM_ZERO) wc_MemZero_Check(x, MAX_ECC_BYTES); #endif @@ -9540,12 +9525,8 @@ int wc_ecc_import_point_der_ex(const byte* in, word32 inLen, } #ifdef WOLFSSL_SMALL_STACK - if (t1 != NULL) { - XFREE(t1, NULL, DYNAMIC_TYPE_BIGINT); - } - if (t2 != NULL) { - XFREE(t2, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(t1, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(t2, NULL, DYNAMIC_TYPE_BIGINT); #endif wc_ecc_curve_free(curve); @@ -10811,12 +10792,8 @@ int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key, mp_clear(t1); } #ifdef WOLFSSL_SMALL_STACK - if (t1 != NULL) { - XFREE(t1, NULL, DYNAMIC_TYPE_BIGINT); - } - if (t2 != NULL) { - XFREE(t2, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(t1, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(t2, NULL, DYNAMIC_TYPE_BIGINT); #endif wc_ecc_curve_free(curve); @@ -14879,9 +14856,7 @@ int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg, #endif #ifdef WOLFSSL_SMALL_STACK #ifndef WOLFSSL_ECIES_OLD - if (peerKey != NULL) { - XFREE(peerKey, ctx->heap, DYNAMIC_TYPE_ECC_BUFFER); - } + XFREE(peerKey, ctx->heap, DYNAMIC_TYPE_ECC_BUFFER); #endif XFREE(sharedSecret, ctx->heap, DYNAMIC_TYPE_ECC_BUFFER); XFREE(keys, ctx->heap, DYNAMIC_TYPE_ECC_BUFFER); diff --git a/wolfcrypt/src/evp.c b/wolfcrypt/src/evp.c index b53d6eca97..8b78f620c6 100644 --- a/wolfcrypt/src/evp.c +++ b/wolfcrypt/src/evp.c @@ -2679,9 +2679,7 @@ int wolfSSL_EVP_PKEY_CTX_set1_hkdf_salt(WOLFSSL_EVP_PKEY_CTX* ctx, } if (ret == WOLFSSL_SUCCESS && salt != NULL && saltSz > 0) { - if (ctx->pkey->hkdfSalt != NULL) { - XFREE(ctx->pkey->hkdfSalt, NULL, DYNAMIC_TYPE_SALT); - } + XFREE(ctx->pkey->hkdfSalt, NULL, DYNAMIC_TYPE_SALT); ctx->pkey->hkdfSalt = (byte*)XMALLOC((size_t)saltSz, NULL, DYNAMIC_TYPE_SALT); if (ctx->pkey->hkdfSalt == NULL) { @@ -2716,9 +2714,7 @@ int wolfSSL_EVP_PKEY_CTX_set1_hkdf_key(WOLFSSL_EVP_PKEY_CTX* ctx, } if (ret == WOLFSSL_SUCCESS) { - if (ctx->pkey->hkdfKey != NULL) { - XFREE(ctx->pkey->hkdfKey, NULL, DYNAMIC_TYPE_KEY); - } + XFREE(ctx->pkey->hkdfKey, NULL, DYNAMIC_TYPE_KEY); ctx->pkey->hkdfKey = (byte*)XMALLOC((size_t)keySz, NULL, DYNAMIC_TYPE_KEY); if (ctx->pkey->hkdfKey == NULL) { @@ -6298,15 +6294,11 @@ void wolfSSL_EVP_init(void) ctx->keyLen = 0; #if defined(HAVE_AESGCM) || defined(HAVE_AESCCM) || defined(HAVE_ARIA) || \ defined(WOLFSSL_SM4_GCM) || defined(WOLFSSL_SM4_CCM) - if (ctx->authBuffer) { - XFREE(ctx->authBuffer, NULL, DYNAMIC_TYPE_OPENSSL); - ctx->authBuffer = NULL; - } + XFREE(ctx->authBuffer, NULL, DYNAMIC_TYPE_OPENSSL); + ctx->authBuffer = NULL; ctx->authBufferLen = 0; - if (ctx->authIn) { - XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL); - ctx->authIn = NULL; - } + XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL); + ctx->authIn = NULL; ctx->authInSz = 0; ctx->authIvGenEnable = 0; ctx->authIncIv = 0; @@ -6428,10 +6420,8 @@ void wolfSSL_EVP_init(void) { int ret = WOLFSSL_SUCCESS; - if (ctx->authIn) { - XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL); - ctx->authIn = NULL; - } + XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL); + ctx->authIn = NULL; ctx->authInSz = 0; ctx->block_size = AES_BLOCK_SIZE; @@ -6635,10 +6625,8 @@ void wolfSSL_EVP_init(void) { int ret = WOLFSSL_SUCCESS; - if (ctx->authIn) { - XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL); - ctx->authIn = NULL; - } + XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL); + ctx->authIn = NULL; ctx->authInSz = 0; ctx->block_size = AES_BLOCK_SIZE; @@ -6786,10 +6774,8 @@ void wolfSSL_EVP_init(void) return WOLFSSL_FAILURE; } - if (ctx->authIn) { - XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL); - ctx->authIn = NULL; - } + XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL); + ctx->authIn = NULL; ctx->authInSz = 0; ctx->block_size = AES_BLOCK_SIZE; @@ -7821,10 +7807,8 @@ void wolfSSL_EVP_init(void) ctx->ivSz = GCM_NONCE_MID_SZ; } ctx->authTagSz = SM4_BLOCK_SIZE; - if (ctx->authIn) { - XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL); - ctx->authIn = NULL; - } + XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL); + ctx->authIn = NULL; ctx->authInSz = 0; if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; @@ -7853,10 +7837,8 @@ void wolfSSL_EVP_init(void) ctx->ivSz = GCM_NONCE_MID_SZ; } ctx->authTagSz = SM4_BLOCK_SIZE; - if (ctx->authIn) { - XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL); - ctx->authIn = NULL; - } + XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL); + ctx->authIn = NULL; ctx->authInSz = 0; if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; @@ -11108,18 +11090,12 @@ void wolfSSL_EVP_PKEY_free(WOLFSSL_EVP_PKEY* key) #ifdef HAVE_HKDF case EVP_PKEY_HKDF: - if (key->hkdfSalt != NULL) { - XFREE(key->hkdfSalt, NULL, DYNAMIC_TYPE_SALT); - key->hkdfSalt = NULL; - } - if (key->hkdfKey != NULL) { - XFREE(key->hkdfKey, NULL, DYNAMIC_TYPE_KEY); - key->hkdfKey = NULL; - } - if (key->hkdfInfo != NULL) { - XFREE(key->hkdfInfo, NULL, DYNAMIC_TYPE_INFO); - key->hkdfInfo = NULL; - } + XFREE(key->hkdfSalt, NULL, DYNAMIC_TYPE_SALT); + key->hkdfSalt = NULL; + XFREE(key->hkdfKey, NULL, DYNAMIC_TYPE_KEY); + key->hkdfKey = NULL; + XFREE(key->hkdfInfo, NULL, DYNAMIC_TYPE_INFO); + key->hkdfInfo = NULL; key->hkdfSaltSz = 0; key->hkdfKeySz = 0; key->hkdfInfoSz = 0; @@ -11598,10 +11574,8 @@ static int PrintPubKeyEC(WOLFSSL_BIO* out, const byte* pkey, int pkeySz, res = wolfSSL_BIO_write(out, "\n", 1) > 0; } - if (pub != NULL) { - XFREE(pub, NULL, DYNAMIC_TYPE_ECC_BUFFER); - pub = NULL; - } + XFREE(pub, NULL, DYNAMIC_TYPE_ECC_BUFFER); + pub = NULL; wc_ecc_free(key); mp_free(a); diff --git a/wolfcrypt/src/ge_448.c b/wolfcrypt/src/ge_448.c index fbb600eaf2..415928f97f 100644 --- a/wolfcrypt/src/ge_448.c +++ b/wolfcrypt/src/ge_448.c @@ -10781,18 +10781,10 @@ int ge448_double_scalarmult_vartime(ge448_p2 *r, const byte *a, } #if defined(WOLFSSL_SMALL_STACK) && (!defined(WOLFSSL_NO_MALLOC) || defined(XMALLOC_USER)) - if (p2 != NULL) { - XFREE(p2, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (pi != NULL) { - XFREE(pi, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (bslide != NULL) { - XFREE(bslide, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } - if (aslide != NULL) { - XFREE(aslide, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(p2, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(pi, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(bslide, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(aslide, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; diff --git a/wolfcrypt/src/ge_operations.c b/wolfcrypt/src/ge_operations.c index 6a82d50dcd..bcf9d354b5 100644 --- a/wolfcrypt/src/ge_operations.c +++ b/wolfcrypt/src/ge_operations.c @@ -9470,18 +9470,12 @@ int ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a, #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC) out: - if (aslide != NULL) - XFREE(aslide, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (bslide != NULL) - XFREE(bslide, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (Ai != NULL) - XFREE(Ai, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (u != NULL) - XFREE(u, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (A2 != NULL) - XFREE(A2, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(aslide, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(bslide, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(Ai, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(u, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(A2, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; #else diff --git a/wolfcrypt/src/kdf.c b/wolfcrypt/src/kdf.c index fa0e096ca3..690774474b 100644 --- a/wolfcrypt/src/kdf.c +++ b/wolfcrypt/src/kdf.c @@ -157,9 +157,9 @@ int wc_PRF(byte* result, word32 resLen, const byte* secret, current = (byte*)XMALLOC(P_HASH_MAX_SIZE, heap, DYNAMIC_TYPE_DIGEST); hmac = (Hmac*)XMALLOC(sizeof(Hmac), heap, DYNAMIC_TYPE_HMAC); if (previous == NULL || current == NULL || hmac == NULL) { - if (previous) XFREE(previous, heap, DYNAMIC_TYPE_DIGEST); - if (current) XFREE(current, heap, DYNAMIC_TYPE_DIGEST); - if (hmac) XFREE(hmac, heap, DYNAMIC_TYPE_HMAC); + XFREE(previous, heap, DYNAMIC_TYPE_DIGEST); + XFREE(current, heap, DYNAMIC_TYPE_DIGEST); + XFREE(hmac, heap, DYNAMIC_TYPE_HMAC); return MEMORY_E; } #endif diff --git a/wolfcrypt/src/pkcs12.c b/wolfcrypt/src/pkcs12.c index d6cf526221..c24e1f1810 100644 --- a/wolfcrypt/src/pkcs12.c +++ b/wolfcrypt/src/pkcs12.c @@ -165,9 +165,7 @@ static void freeSafe(AuthenticatedSafe* safe, void* heap) safe->CI = ci->next; XFREE(ci, heap, DYNAMIC_TYPE_PKCS); } - if (safe->data != NULL) { - XFREE(safe->data, heap, DYNAMIC_TYPE_PKCS); - } + XFREE(safe->data, heap, DYNAMIC_TYPE_PKCS); XFREE(safe, heap, DYNAMIC_TYPE_PKCS); (void)heap; @@ -191,22 +189,14 @@ void wc_PKCS12_free(WC_PKCS12* pkcs12) /* free mac data */ if (pkcs12->signData != NULL) { - if (pkcs12->signData->digest != NULL) { - XFREE(pkcs12->signData->digest, heap, DYNAMIC_TYPE_DIGEST); - } - if (pkcs12->signData->salt != NULL) { - XFREE(pkcs12->signData->salt, heap, DYNAMIC_TYPE_SALT); - } + XFREE(pkcs12->signData->digest, heap, DYNAMIC_TYPE_DIGEST); + XFREE(pkcs12->signData->salt, heap, DYNAMIC_TYPE_SALT); XFREE(pkcs12->signData, heap, DYNAMIC_TYPE_PKCS); } #ifdef ASN_BER_TO_DER - if (pkcs12->der != NULL) { - XFREE(pkcs12->der, pkcs12->heap, DYNAMIC_TYPE_PKCS); - } - if (pkcs12->safeDer != NULL) { - XFREE(pkcs12->safeDer, pkcs12->heap, DYNAMIC_TYPE_PKCS); - } + XFREE(pkcs12->der, pkcs12->heap, DYNAMIC_TYPE_PKCS); + XFREE(pkcs12->safeDer, pkcs12->heap, DYNAMIC_TYPE_PKCS); #endif XFREE(pkcs12, heap, DYNAMIC_TYPE_PKCS); @@ -533,8 +523,7 @@ static int GetSignData(WC_PKCS12* pkcs12, const byte* mem, word32* idx, /* failure cleanup */ if (ret != 0) { if (mac) { - if (mac->digest) - XFREE(mac->digest, pkcs12->heap, DYNAMIC_TYPE_DIGEST); + XFREE(mac->digest, pkcs12->heap, DYNAMIC_TYPE_DIGEST); XFREE(mac, pkcs12->heap, DYNAMIC_TYPE_PKCS); } } @@ -856,9 +845,7 @@ int wc_d2i_PKCS12_fp(const char* file, WC_PKCS12** pkcs12) wc_PKCS12_free(*pkcs12); *pkcs12 = NULL; } - if (buf != NULL) { - XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); WOLFSSL_LEAVE("wc_d2i_PKCS12_fp", ret); @@ -1099,9 +1086,7 @@ void wc_FreeCertList(WC_DerCertList* list, void* heap) while (current != NULL) { next = current->next; - if (current->buffer != NULL) { - XFREE(current->buffer, heap, DYNAMIC_TYPE_PKCS); - } + XFREE(current->buffer, heap, DYNAMIC_TYPE_PKCS); XFREE(current, heap, DYNAMIC_TYPE_PKCS); current = next; } @@ -1707,10 +1692,8 @@ int wc_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw, } /* free temporary buffer */ - if (buf != NULL) { - XFREE(buf, pkcs12->heap, DYNAMIC_TYPE_PKCS); - buf = NULL; - } + XFREE(buf, pkcs12->heap, DYNAMIC_TYPE_PKCS); + buf = NULL; ci = ci->next; WOLFSSL_MSG("Done Parsing PKCS12 Content Info Container"); @@ -1744,10 +1727,8 @@ int wc_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw, XFREE(*pkey, pkcs12->heap, DYNAMIC_TYPE_PUBLIC_KEY); *pkey = NULL; } - if (buf) { - XFREE(buf, pkcs12->heap, DYNAMIC_TYPE_PKCS); - buf = NULL; - } + XFREE(buf, pkcs12->heap, DYNAMIC_TYPE_PKCS); + buf = NULL; wc_FreeCertList(certList, pkcs12->heap); } diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index d07f1f7889..9d2704b988 100644 --- a/wolfcrypt/src/pkcs7.c +++ b/wolfcrypt/src/pkcs7.c @@ -1265,12 +1265,8 @@ static void wc_PKCS7_FreeDecodedAttrib(PKCS7DecodedAttrib* attrib, void* heap) current = attrib; while (current != NULL) { PKCS7DecodedAttrib* next = current->next; - if (current->oid != NULL) { - XFREE(current->oid, heap, DYNAMIC_TYPE_PKCS7); - } - if (current->value != NULL) { - XFREE(current->value, heap, DYNAMIC_TYPE_PKCS7); - } + XFREE(current->oid, heap, DYNAMIC_TYPE_PKCS7); + XFREE(current->value, heap, DYNAMIC_TYPE_PKCS7); XFREE(current, heap, DYNAMIC_TYPE_PKCS7); current = next; } @@ -1282,10 +1278,8 @@ static void wc_PKCS7_FreeDecodedAttrib(PKCS7DecodedAttrib* attrib, void* heap) /* return 0 on success */ static int wc_PKCS7_SignerInfoNew(PKCS7* pkcs7) { - if (pkcs7->signerInfo != NULL) { - XFREE(pkcs7->signerInfo, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - pkcs7->signerInfo = NULL; - } + XFREE(pkcs7->signerInfo, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + pkcs7->signerInfo = NULL; pkcs7->signerInfo = (PKCS7SignerInfo*)XMALLOC(sizeof(PKCS7SignerInfo), pkcs7->heap, DYNAMIC_TYPE_PKCS7); @@ -1301,10 +1295,8 @@ static int wc_PKCS7_SignerInfoNew(PKCS7* pkcs7) static void wc_PKCS7_SignerInfoFree(PKCS7* pkcs7) { if (pkcs7->signerInfo != NULL) { - if (pkcs7->signerInfo->sid != NULL) { - XFREE(pkcs7->signerInfo->sid, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - pkcs7->signerInfo->sid = NULL; - } + XFREE(pkcs7->signerInfo->sid, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + pkcs7->signerInfo->sid = NULL; XFREE(pkcs7->signerInfo, pkcs7->heap, DYNAMIC_TYPE_PKCS7); pkcs7->signerInfo = NULL; } @@ -1320,10 +1312,8 @@ static int wc_PKCS7_SignerInfoSetSID(PKCS7* pkcs7, byte* in, int inSz) return BAD_FUNC_ARG; } - if (pkcs7->signerInfo->sid != NULL) { - XFREE(pkcs7->signerInfo->sid, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - pkcs7->signerInfo->sid = NULL; - } + XFREE(pkcs7->signerInfo->sid, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + pkcs7->signerInfo->sid = NULL; pkcs7->signerInfo->sid = (byte*)XMALLOC(inSz, pkcs7->heap, DYNAMIC_TYPE_PKCS7); if (pkcs7->signerInfo->sid == NULL) { @@ -1351,15 +1341,11 @@ void wc_PKCS7_Free(PKCS7* pkcs7) wc_PKCS7_FreeCertSet(pkcs7); #ifdef ASN_BER_TO_DER - if (pkcs7->der != NULL) { - XFREE(pkcs7->der, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - pkcs7->der = NULL; - } + XFREE(pkcs7->der, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + pkcs7->der = NULL; #endif - if (pkcs7->contentDynamic != NULL) { - XFREE(pkcs7->contentDynamic, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - pkcs7->contentDynamic = NULL; - } + XFREE(pkcs7->contentDynamic, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + pkcs7->contentDynamic = NULL; if (pkcs7->cek != NULL) { ForceZero(pkcs7->cek, pkcs7->cekSz); @@ -3378,14 +3364,11 @@ static int PKCS7_EncodeSigned(PKCS7* pkcs7, out: - if (flatSignedAttribs != NULL) - XFREE(flatSignedAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(flatSignedAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); #ifdef WOLFSSL_SMALL_STACK - if (esd) - XFREE(esd, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER); - if (signedDataOid) - XFREE(signedDataOid, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(esd, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(signedDataOid, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER); #endif return idx; @@ -5067,10 +5050,8 @@ static int wc_PKCS7_HandleOctetStrings(PKCS7* pkcs7, byte* in, word32 inSz, /* no content case, do nothing */ if (pkcs7->stream->noContent) { if (pkcs7->content && pkcs7->contentSz > 0) { - if (pkcs7->stream->content != NULL) { - XFREE(pkcs7->stream->content, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - pkcs7->stream->content = NULL; - } + XFREE(pkcs7->stream->content, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + pkcs7->stream->content = NULL; pkcs7->stream->content = (byte*)XMALLOC(pkcs7->contentSz, pkcs7->heap, DYNAMIC_TYPE_PKCS7); @@ -5085,10 +5066,8 @@ static int wc_PKCS7_HandleOctetStrings(PKCS7* pkcs7, byte* in, word32 inSz, } /* free pkcs7->contentDynamic buffer */ - if (pkcs7->contentDynamic != NULL) { - XFREE(pkcs7->contentDynamic, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - pkcs7->contentDynamic = NULL; - } + XFREE(pkcs7->contentDynamic, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + pkcs7->contentDynamic = NULL; while(1) { if ((ret = wc_PKCS7_AddDataToStream(pkcs7, in, inSz, @@ -5223,10 +5202,8 @@ static int wc_PKCS7_HandleOctetStrings(PKCS7* pkcs7, byte* in, word32 inSz, if (pkcs7->stream->content == NULL) { WOLFSSL_MSG("failed to grow content buffer."); - if (tempBuf != NULL) { - XFREE(tempBuf, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - tempBuf = NULL; - } + XFREE(tempBuf, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + tempBuf = NULL; ret = MEMORY_E; break; } @@ -5237,10 +5214,8 @@ static int wc_PKCS7_HandleOctetStrings(PKCS7* pkcs7, byte* in, word32 inSz, } XMEMCPY(pkcs7->stream->content + contBufSz, msg + *idx, pkcs7->stream->expected); - if (tempBuf != NULL) { - XFREE(tempBuf, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - tempBuf = NULL; - } + XFREE(tempBuf, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + tempBuf = NULL; } } @@ -5858,10 +5833,8 @@ static int PKCS7_VerifySignedData(PKCS7* pkcs7, const byte* hashBuf, #ifndef NO_PKCS7_STREAM /* free pkcs7->stream->content buffer */ - if (pkcs7->stream->content != NULL) { - XFREE(pkcs7->stream->content, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - pkcs7->stream->content = NULL; - } + XFREE(pkcs7->stream->content, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + pkcs7->stream->content = NULL; #endif /* !NO_PKCS7_STREAM */ FALL_THROUGH; @@ -9887,13 +9860,9 @@ int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outputSz) pkcs7->cekSz, tmpIv, blockSz, NULL, 0, NULL, 0, plain, encryptedOutSz, encryptedContent); if (ret != 0) { - if (encryptedContent != NULL) { - XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - } + XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - if (plain != NULL) { - XFREE(plain, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - } + XFREE(plain, pkcs7->heap, DYNAMIC_TYPE_PKCS7); wc_PKCS7_FreeEncodedRecipientSet(pkcs7); return ret; @@ -9939,13 +9908,9 @@ int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outputSz) idx += encryptedOutSz; } - if (plain != NULL) { - XFREE(plain, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - } + XFREE(plain, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - if (encryptedContent != NULL) { - XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - } + XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7); return idx; } @@ -12821,10 +12786,8 @@ int wc_PKCS7_EncodeAuthEnvelopedData(PKCS7* pkcs7, byte* output, DYNAMIC_TYPE_PKCS7); if (flatUnauthAttribs == NULL) { wc_PKCS7_FreeEncodedRecipientSet(pkcs7); - if (aadBuffer) - XFREE(aadBuffer, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER); - if (flatAuthAttribs) - XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(aadBuffer, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); return MEMORY_E; } @@ -12848,12 +12811,9 @@ int wc_PKCS7_EncodeAuthEnvelopedData(PKCS7* pkcs7, byte* output, plain = (byte*)XMALLOC(encryptedAllocSz, pkcs7->heap, DYNAMIC_TYPE_PKCS7); if (plain == NULL) { wc_PKCS7_FreeEncodedRecipientSet(pkcs7); - if (aadBuffer) - XFREE(aadBuffer, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER); - if (flatUnauthAttribs) - XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - if (flatAuthAttribs) - XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(aadBuffer, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); return MEMORY_E; } @@ -12867,12 +12827,9 @@ int wc_PKCS7_EncodeAuthEnvelopedData(PKCS7* pkcs7, byte* output, if (encryptedContent == NULL) { XFREE(plain, pkcs7->heap, DYNAMIC_TYPE_PKCS7); wc_PKCS7_FreeEncodedRecipientSet(pkcs7); - if (aadBuffer) - XFREE(aadBuffer, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER); - if (flatUnauthAttribs) - XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - if (flatAuthAttribs) - XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(aadBuffer, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); return MEMORY_E; } @@ -12884,17 +12841,13 @@ int wc_PKCS7_EncodeAuthEnvelopedData(PKCS7* pkcs7, byte* output, XFREE(plain, pkcs7->heap, DYNAMIC_TYPE_PKCS7); plain = NULL; - if (aadBuffer) { - XFREE(aadBuffer, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER); - aadBuffer = NULL; - } + XFREE(aadBuffer, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER); + aadBuffer = NULL; if (ret != 0) { wc_PKCS7_FreeEncodedRecipientSet(pkcs7); - if (flatUnauthAttribs) - XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - if (flatAuthAttribs) - XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7); return ret; } @@ -12904,10 +12857,8 @@ int wc_PKCS7_EncodeAuthEnvelopedData(PKCS7* pkcs7, byte* output, sizeof(contentType)); if (ret < 0) { wc_PKCS7_FreeEncodedRecipientSet(pkcs7); - if (flatUnauthAttribs) - XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - if (flatAuthAttribs) - XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7); return ret; } @@ -12933,10 +12884,8 @@ int wc_PKCS7_EncodeAuthEnvelopedData(PKCS7* pkcs7, byte* output, if (contentEncAlgoSz == 0) { wc_PKCS7_FreeEncodedRecipientSet(pkcs7); - if (flatUnauthAttribs) - XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - if (flatAuthAttribs) - XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7); return BAD_FUNC_ARG; } @@ -12973,10 +12922,8 @@ int wc_PKCS7_EncodeAuthEnvelopedData(PKCS7* pkcs7, byte* output, if (totalSz > (int)outputSz) { WOLFSSL_MSG("Pkcs7_encrypt output buffer too small"); wc_PKCS7_FreeEncodedRecipientSet(pkcs7); - if (flatUnauthAttribs) - XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - if (flatAuthAttribs) - XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7); return BUFFER_E; } @@ -13044,9 +12991,7 @@ int wc_PKCS7_EncodeAuthEnvelopedData(PKCS7* pkcs7, byte* output, idx += unauthAttribsSz; } - if (flatUnauthAttribs != NULL) { - XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - } + XFREE(flatUnauthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7); @@ -13903,10 +13848,8 @@ int wc_PKCS7_EncodeEncryptedData(PKCS7* pkcs7, byte* output, word32 outputSz) if (totalSz > (int)outputSz) { WOLFSSL_MSG("PKCS#7 output buffer too small"); - if (attribs != NULL) - XFREE(attribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - if (flatAttribs != NULL) - XFREE(flatAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(attribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(flatAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7); XFREE(plain, pkcs7->heap, DYNAMIC_TYPE_PKCS7); return BUFFER_E; @@ -13944,10 +13887,8 @@ int wc_PKCS7_EncodeEncryptedData(PKCS7* pkcs7, byte* output, word32 outputSz) idx += attribsSz; } - if (attribs != NULL) - XFREE(attribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); - if (flatAttribs != NULL) - XFREE(flatAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(attribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); + XFREE(flatAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7); XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7); XFREE(plain, pkcs7->heap, DYNAMIC_TYPE_PKCS7); diff --git a/wolfcrypt/src/port/Renesas/renesas_fspsm_sha.c b/wolfcrypt/src/port/Renesas/renesas_fspsm_sha.c index 9820f28d95..3ea643892d 100644 --- a/wolfcrypt/src/port/Renesas/renesas_fspsm_sha.c +++ b/wolfcrypt/src/port/Renesas/renesas_fspsm_sha.c @@ -100,10 +100,8 @@ static void FSPSM_HashFree(wolfssl_FSPSM_Hash* hash) return; #if defined(WOLFSSL_RENESAS_SCEPROTECT) - if (hash->msg != NULL) { - XFREE(hash->msg, hash->heap, DYNAMIC_TYPE_TMP_BUFFER); - hash->msg = NULL; - } + XFREE(hash->msg, hash->heap, DYNAMIC_TYPE_TMP_BUFFER); + hash->msg = NULL; #endif } diff --git a/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c b/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c index c955b571c6..50c34d266a 100644 --- a/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c +++ b/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c @@ -367,8 +367,7 @@ WOLFSSL_LOCAL int wc_fspsm_EccVerifyTLS(WOLFSSL* ssl, const uint8_t* sig, ret = fspsm_ServerKeyExVerify(2, ssl, sigforSCE, 64, ctx); - if (sigforSCE) - XFREE(sigforSCE, NULL, DYNAMIC_TYPE_TEMP); + XFREE(sigforSCE, NULL, DYNAMIC_TYPE_TEMP); if (ret == WOLFSSL_SUCCESS) { *result = 1; @@ -854,10 +853,8 @@ WOLFSSL_LOCAL int wc_fspsm_generateSessionKey(WOLFSSL *ssl, cbInfo->keyflgs_tls.bits.session_key_set = 1; } - if (key_client_aes) - XFREE(key_client_aes, aes->heap, DYNAMIC_TYPE_AES); - if (key_server_aes) - XFREE(key_server_aes, aes->heap, DYNAMIC_TYPE_AES); + XFREE(key_client_aes, aes->heap, DYNAMIC_TYPE_AES); + XFREE(key_server_aes, aes->heap, DYNAMIC_TYPE_AES); /* unlock hw */ wc_fspsm_hw_unlock(); @@ -1070,9 +1067,7 @@ WOLFSSL_LOCAL int wc_fspsm_tls_CertVerify( if (ret != FSP_SUCCESS) { WOLFSSL_MSG(" R_XXX_TlsCertificateVerification() failed"); } - if (sigforSCE) { - XFREE(sigforSCE, NULL, DYNAMIC_TYPE_TEMP); - } + XFREE(sigforSCE, NULL, DYNAMIC_TYPE_TEMP); wc_fspsm_hw_unlock(); } else { diff --git a/wolfcrypt/src/port/Renesas/renesas_rx64_hw_sha.c b/wolfcrypt/src/port/Renesas/renesas_rx64_hw_sha.c index 8cbd192c72..caee3c2a3e 100644 --- a/wolfcrypt/src/port/Renesas/renesas_rx64_hw_sha.c +++ b/wolfcrypt/src/port/Renesas/renesas_rx64_hw_sha.c @@ -159,10 +159,8 @@ static void RX64_HashFree(wolfssl_RX64_HW_Hash* hash) if (hash == NULL) return; - if (hash->msg != NULL) { - XFREE(hash->msg, hash->heap, DYNAMIC_TYPE_TMP_BUFFER); - hash->msg = NULL; - } + XFREE(hash->msg, hash->heap, DYNAMIC_TYPE_TMP_BUFFER); + hash->msg = NULL; } /** diff --git a/wolfcrypt/src/port/Renesas/renesas_tsip_rsa.c b/wolfcrypt/src/port/Renesas/renesas_tsip_rsa.c index 22664f836d..13db2dba12 100644 --- a/wolfcrypt/src/port/Renesas/renesas_tsip_rsa.c +++ b/wolfcrypt/src/port/Renesas/renesas_tsip_rsa.c @@ -88,13 +88,8 @@ WOLFSSL_LOCAL int wc_tsip_MakeRsaKey(int size, void* ctx) if (ret == TSIP_SUCCESS) { if (size == 1024) { - if (info->rsa1024pri_keyIdx != NULL) { - XFREE(info->rsa1024pri_keyIdx, NULL, - DYNAMIC_TYPE_RSA_BUFFER); - } - if (info->rsa1024pub_keyIdx != NULL) { - XFREE(info->rsa1024pub_keyIdx, NULL, DYNAMIC_TYPE_RSA_BUFFER); - } + XFREE(info->rsa1024pri_keyIdx, NULL, DYNAMIC_TYPE_RSA_BUFFER); + XFREE(info->rsa1024pub_keyIdx, NULL, DYNAMIC_TYPE_RSA_BUFFER); info->rsa1024pri_keyIdx = (tsip_rsa1024_private_key_index_t*)XMALLOC( sizeof(tsip_rsa1024_private_key_index_t), NULL, @@ -128,14 +123,8 @@ WOLFSSL_LOCAL int wc_tsip_MakeRsaKey(int size, void* ctx) info->keyflgs_crypt.bits.rsapub1024_key_set = 1; } else if (size == 2048) { - if (info->rsa2048pri_keyIdx != NULL) { - XFREE(info->rsa2048pri_keyIdx, NULL, - DYNAMIC_TYPE_RSA_BUFFER); - } - if (info->rsa2048pub_keyIdx != NULL) { - XFREE(info->rsa2048pub_keyIdx, NULL, - DYNAMIC_TYPE_RSA_BUFFER); - } + XFREE(info->rsa2048pri_keyIdx, NULL, DYNAMIC_TYPE_RSA_BUFFER); + XFREE(info->rsa2048pub_keyIdx, NULL, DYNAMIC_TYPE_RSA_BUFFER); info->rsa2048pri_keyIdx = (tsip_rsa2048_private_key_index_t*)XMALLOC( sizeof(tsip_rsa2048_private_key_index_t), NULL, diff --git a/wolfcrypt/src/port/Renesas/renesas_tsip_sha.c b/wolfcrypt/src/port/Renesas/renesas_tsip_sha.c index d4303839d6..a12c1ebcf8 100644 --- a/wolfcrypt/src/port/Renesas/renesas_tsip_sha.c +++ b/wolfcrypt/src/port/Renesas/renesas_tsip_sha.c @@ -287,10 +287,8 @@ static void TSIPHashFree(wolfssl_TSIP_Hash* hash) if (hash == NULL) return; - if (hash->msg != NULL) { - XFREE(hash->msg, hash->heap, DYNAMIC_TYPE_TMP_BUFFER); - hash->msg = NULL; - } + XFREE(hash->msg, hash->heap, DYNAMIC_TYPE_TMP_BUFFER); + hash->msg = NULL; } static int TSIPHashInit(wolfssl_TSIP_Hash* hash, void* heap, int devId, diff --git a/wolfcrypt/src/port/Renesas/renesas_tsip_util.c b/wolfcrypt/src/port/Renesas/renesas_tsip_util.c index 6097eb0e16..df49012d9e 100644 --- a/wolfcrypt/src/port/Renesas/renesas_tsip_util.c +++ b/wolfcrypt/src/port/Renesas/renesas_tsip_util.c @@ -417,14 +417,10 @@ WOLFSSL_LOCAL int tsip_Tls13GenEccKeyPair(WOLFSSL* ssl, KeyShareEntry* kse) } if ((ret != 0) && (ret != CRYPTOCB_UNAVAILABLE)) { - if (kse->key != NULL) { - XFREE(kse->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); - kse->key = NULL; - } - if (kse->pubKey != NULL) { - XFREE(kse->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); - kse->pubKey = NULL; - } + XFREE(kse->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY); + kse->key = NULL; + XFREE(kse->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY); + kse->pubKey = NULL; } WOLFSSL_LEAVE("tsip_Tls13GenEccKeyPair", ret); return ret; @@ -2428,10 +2424,7 @@ WOLFSSL_LOCAL int tsipImportPublicKey(TsipUserCtx* tuc, int keyType) #if defined(WOLFSSL_RENESAS_TSIP_TLS) tuc->ClientRsa2048PubKey_set = 0; #elif defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY) - if (tuc->rsa2048pub_keyIdx != NULL) { - XFREE(tuc->rsa2048pub_keyIdx, NULL, - DYNAMIC_TYPE_RSA_BUFFER); - } + XFREE(tuc->rsa2048pub_keyIdx, NULL, DYNAMIC_TYPE_RSA_BUFFER); tuc->keyflgs_crypt.bits.rsapub2048_key_set = 0; tuc->rsa2048pub_keyIdx = (tsip_rsa2048_public_key_index_t*)XMALLOC( @@ -3548,9 +3541,7 @@ int wc_tsip_tls_CertVerify( if (ret != TSIP_SUCCESS) { WOLFSSL_MSG(" R_TSIP_TlsCertificateVerification failed"); } - if (sigforSCE) { - XFREE(sigforSCE, NULL, DYNAMIC_TYPE_ECC); - } + XFREE(sigforSCE, NULL, DYNAMIC_TYPE_ECC); tsip_hw_unlock(); } else { diff --git a/wolfcrypt/src/port/af_alg/afalg_hash.c b/wolfcrypt/src/port/af_alg/afalg_hash.c index 33a7ad3efb..c14dfb0ee7 100644 --- a/wolfcrypt/src/port/af_alg/afalg_hash.c +++ b/wolfcrypt/src/port/af_alg/afalg_hash.c @@ -53,10 +53,8 @@ static void AfalgHashFree(wolfssl_AFALG_Hash* hash) } #if defined(WOLFSSL_AFALG_HASH_KEEP) - if (hash->msg != NULL) { - XFREE(hash->msg, hash->heap, DYNAMIC_TYPE_TMP_BUFFER); - hash->msg = NULL; - } + XFREE(hash->msg, hash->heap, DYNAMIC_TYPE_TMP_BUFFER); + hash->msg = NULL; #endif } diff --git a/wolfcrypt/src/port/arm/armv8-sha512.c b/wolfcrypt/src/port/arm/armv8-sha512.c index 7ac9eb9833..145f6b5ebb 100644 --- a/wolfcrypt/src/port/arm/armv8-sha512.c +++ b/wolfcrypt/src/port/arm/armv8-sha512.c @@ -670,10 +670,8 @@ void wc_Sha512Free(wc_Sha512* sha512) return; #ifdef WOLFSSL_SMALL_STACK_CACHE - if (sha512->W != NULL) { - XFREE(sha512->W, NULL, DYNAMIC_TYPE_TMP_BUFFER); - sha512->W = NULL; - } + XFREE(sha512->W, NULL, DYNAMIC_TYPE_TMP_BUFFER); + sha512->W = NULL; #endif } @@ -801,10 +799,8 @@ void wc_Sha384Free(wc_Sha384* sha384) return; #ifdef WOLFSSL_SMALL_STACK_CACHE - if (sha384->W != NULL) { - XFREE(sha384->W, NULL, DYNAMIC_TYPE_TMP_BUFFER); - sha384->W = NULL; - } + XFREE(sha384->W, NULL, DYNAMIC_TYPE_TMP_BUFFER); + sha384->W = NULL; #endif } diff --git a/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c b/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c index a9f574559e..b0bf50d72c 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c +++ b/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c @@ -160,9 +160,7 @@ static int wc_CAAM_CommonHash(caam_handle_t* hndl, caam_hash_ctx_t *ctx, } status = CAAM_HASH_Update(ctx, alignedIn, inSz); - if (tmpIn != NULL) { - XFREE(tmpIn, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(tmpIn, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (status != kStatus_Success) { return WC_HW_E; } @@ -339,9 +337,7 @@ static int DoAesCTR(unsigned int args[4], CAAM_BUFFER *buf, int sz) XMEMCPY((byte*)buf[3].TheAddress, alignedOut, buf[3].Length); XFREE(tmpOut, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (tmpIn != NULL) { - XFREE(tmpIn, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(tmpIn, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (status != kStatus_Success) { return -1; } @@ -491,9 +487,7 @@ int wc_CAAM_EccSign(const byte* in, int inlen, byte* out, word32* outlen, status = CAAM_ECC_Sign(CAAM, &hndl, k, kSz, alignedIn, inlen, r, rSz, s, sSz, ecdsel, enc); - if (tmpIn != NULL) { - XFREE(tmpIn, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(tmpIn, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (status != kStatus_Success) { ret = -1; @@ -604,9 +598,7 @@ static int wc_CAAM_EccVerify_ex(mp_int* r, mp_int *s, const byte* hash, status = CAAM_ECC_Verify(CAAM, &hndl, qxy, qxLen+qyLen, rbuf, keySz, sbuf, keySz, alignedIn, hashlen, ecdsel); - if (tmpIn != NULL) { - XFREE(tmpIn, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(tmpIn, NULL, DYNAMIC_TYPE_TMP_BUFFER); *res = 0; if (status == kStatus_Success) { *res = 1; diff --git a/wolfcrypt/src/port/caam/wolfcaam_seco.c b/wolfcrypt/src/port/caam/wolfcaam_seco.c index 995826c238..d7abc55da3 100644 --- a/wolfcrypt/src/port/caam/wolfcaam_seco.c +++ b/wolfcrypt/src/port/caam/wolfcaam_seco.c @@ -1215,9 +1215,7 @@ word32 wc_SECO_WrapKey(word32 keyId, byte* in, word32 inSz, byte* iv, } } - if (wrappedKey != NULL) { - XFREE(wrappedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(wrappedKey, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (wc_TranslateHSMError(0, err) != Success) { return 0; diff --git a/wolfcrypt/src/port/devcrypto/devcrypto_rsa.c b/wolfcrypt/src/port/devcrypto/devcrypto_rsa.c index 0fdfd015e0..0949c74a0b 100644 --- a/wolfcrypt/src/port/devcrypto/devcrypto_rsa.c +++ b/wolfcrypt/src/port/devcrypto/devcrypto_rsa.c @@ -244,20 +244,13 @@ static int _PrivateOperation(const byte* in, word32 inlen, byte* out, } } - if (d != NULL) - XFREE(d, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (q != NULL) - XFREE(q, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (dp != NULL) - XFREE(dp, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (dq != NULL) - XFREE(dq, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (u != NULL) - XFREE(u, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (n != NULL) - XFREE(n, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(d, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(p, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(q, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(dp, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(dq, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(u, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(n, NULL, DYNAMIC_TYPE_TMP_BUFFER); wc_DevCryptoFree(dev); return ret; @@ -311,10 +304,8 @@ static int _PublicOperation(const byte* in, word32 inlen, byte* out, } wc_DevCryptoFree(&key->ctx); - if (m != NULL) - XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (e != NULL) - XFREE(e, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(e, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -556,21 +547,13 @@ int wc_DevCrypto_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng) #endif } - if (p != NULL) - XFREE(p, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - if (q != NULL) - XFREE(q, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - if (dp != NULL) - XFREE(dp, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - if (dq != NULL) - XFREE(dq, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - if (c != NULL) - XFREE(c, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - if (n != NULL) - XFREE(n, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - if (d != NULL) { - XFREE(d, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(p, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(q, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(dp, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(dq, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(c, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(n, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(d, key->heap, DYNAMIC_TYPE_TMP_BUFFER); (void)rng; return ret; diff --git a/wolfcrypt/src/port/intel/quickassist_sync.c b/wolfcrypt/src/port/intel/quickassist_sync.c index c8b5c4191d..e92dde6323 100644 --- a/wolfcrypt/src/port/intel/quickassist_sync.c +++ b/wolfcrypt/src/port/intel/quickassist_sync.c @@ -359,21 +359,15 @@ void IntelQaHardwareStop(void) status); } - if (g_cyInstMap) { - XFREE(g_cyInstMap, NULL, DYNAMIC_TYPE_ASYNC); - g_cyInstMap = NULL; - } + XFREE(g_cyInstMap, NULL, DYNAMIC_TYPE_ASYNC); + g_cyInstMap = NULL; - if (g_cyInstanceInfo) { - XFREE(g_cyInstanceInfo, NULL, DYNAMIC_TYPE_ASYNC); - g_cyInstanceInfo = NULL; - } + XFREE(g_cyInstanceInfo, NULL, DYNAMIC_TYPE_ASYNC); + g_cyInstanceInfo = NULL; #ifdef QAT_USE_POLLING_CHECK - if (g_cyPolling) { - XFREE(g_cyPolling, NULL, DYNAMIC_TYPE_ASYNC); - g_cyPolling = NULL; - } + XFREE(g_cyPolling, NULL, DYNAMIC_TYPE_ASYNC); + g_cyPolling = NULL; if (g_PollLock) { for (i=0; iop.cipher.bufferList; if (opData) { - if (opData->pAdditionalAuthData) { - XFREE(opData->pAdditionalAuthData, dev->heap, - DYNAMIC_TYPE_ASYNC_NUMA); - opData->pAdditionalAuthData = NULL; - } - if (opData->pIv) { - XFREE(opData->pIv, dev->heap, DYNAMIC_TYPE_ASYNC_NUMA); - opData->pIv = NULL; - } + XFREE(opData->pAdditionalAuthData, dev->heap, DYNAMIC_TYPE_ASYNC_NUMA); + opData->pAdditionalAuthData = NULL; + XFREE(opData->pIv, dev->heap, DYNAMIC_TYPE_ASYNC_NUMA); + opData->pIv = NULL; XMEMSET(opData, 0, sizeof(CpaCySymOpData)); } if (pDstBuffer) { if (pDstBuffer->pBuffers) { - if (pDstBuffer->pBuffers->pData) { - XFREE(pDstBuffer->pBuffers->pData, dev->heap, - DYNAMIC_TYPE_ASYNC_NUMA); - pDstBuffer->pBuffers->pData = NULL; - } + XFREE(pDstBuffer->pBuffers->pData, dev->heap, DYNAMIC_TYPE_ASYNC_NUMA); + pDstBuffer->pBuffers->pData = NULL; XMEMSET(pDstBuffer->pBuffers, 0, sizeof(CpaFlatBuffer)); } - if (pDstBuffer->pPrivateMetaData) { - XFREE(pDstBuffer->pPrivateMetaData, dev->heap, - DYNAMIC_TYPE_ASYNC_NUMA); - pDstBuffer->pPrivateMetaData = NULL; - } + XFREE(pDstBuffer->pPrivateMetaData, dev->heap, DYNAMIC_TYPE_ASYNC_NUMA); + pDstBuffer->pPrivateMetaData = NULL; XMEMSET(pDstBuffer, 0, sizeof(CpaBufferList)); } diff --git a/wolfcrypt/src/port/kcapi/kcapi_dh.c b/wolfcrypt/src/port/kcapi/kcapi_dh.c index 65f592a385..9b69abc193 100644 --- a/wolfcrypt/src/port/kcapi/kcapi_dh.c +++ b/wolfcrypt/src/port/kcapi/kcapi_dh.c @@ -70,9 +70,7 @@ static int KcapiDh_SetParams(DhKey* key) } } - if (pkcs3 != NULL) { - XFREE(pkcs3, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(pkcs3, key->heap, DYNAMIC_TYPE_TMP_BUFFER); return ret; } diff --git a/wolfcrypt/src/port/kcapi/kcapi_hash.c b/wolfcrypt/src/port/kcapi/kcapi_hash.c index 1c88f356f3..c6fca932aa 100644 --- a/wolfcrypt/src/port/kcapi/kcapi_hash.c +++ b/wolfcrypt/src/port/kcapi/kcapi_hash.c @@ -51,10 +51,8 @@ void KcapiHashFree(wolfssl_KCAPI_Hash* hash) } #if defined(WOLFSSL_KCAPI_HASH_KEEP) - if (hash->msg != NULL) { - XFREE(hash->msg, hash->heap, DYNAMIC_TYPE_TMP_BUFFER); - hash->msg = NULL; - } + XFREE(hash->msg, hash->heap, DYNAMIC_TYPE_TMP_BUFFER); + hash->msg = NULL; #endif } } diff --git a/wolfcrypt/src/port/kcapi/kcapi_rsa.c b/wolfcrypt/src/port/kcapi/kcapi_rsa.c index 19436aec1e..a989141354 100644 --- a/wolfcrypt/src/port/kcapi/kcapi_rsa.c +++ b/wolfcrypt/src/port/kcapi/kcapi_rsa.c @@ -76,9 +76,7 @@ static int KcapiRsa_SetPrivKey(RsaKey* key) } } - if (priv != NULL) { - XFREE(priv, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(priv, key->heap, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -167,9 +165,7 @@ static int KcapiRsa_SetPubKey(RsaKey* key) } } - if (pub != NULL) { - XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER); return ret; } diff --git a/wolfcrypt/src/port/nxp/ksdk_port.c b/wolfcrypt/src/port/nxp/ksdk_port.c index a3bdbaa74f..f8460488da 100644 --- a/wolfcrypt/src/port/nxp/ksdk_port.c +++ b/wolfcrypt/src/port/nxp/ksdk_port.c @@ -186,18 +186,10 @@ int mp_mul(mp_int *A, mp_int *B, mp_int *C) } } - if (ptrA) { - XFREE(ptrA, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrB) { - XFREE(ptrB, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrN) { - XFREE(ptrN, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrC) { - XFREE(ptrC, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(ptrA, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrB, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrN, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrC, NULL, DYNAMIC_TYPE_BIGINT); } else { #ifdef WOLFSSL_SP_MATH @@ -280,15 +272,9 @@ int mp_mod(mp_int *a, mp_int *b, mp_int *c) res = MP_MEM; } - if (ptrA) { - XFREE(ptrA, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrB) { - XFREE(ptrB, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrC) { - XFREE(ptrC, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(ptrA, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrB, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrC, NULL, DYNAMIC_TYPE_BIGINT); } else { #if defined(FREESCALE_LTC_TFM_RSA_4096_ENABLE) @@ -372,15 +358,9 @@ int mp_invmod(mp_int *a, mp_int *b, mp_int *c) res = MP_MEM; } - if (ptrA) { - XFREE(ptrA, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrB) { - XFREE(ptrB, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrC) { - XFREE(ptrC, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(ptrA, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrB, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrC, NULL, DYNAMIC_TYPE_BIGINT); } else { #if defined(FREESCALE_LTC_TFM_RSA_4096_ENABLE) @@ -491,18 +471,10 @@ int mp_mulmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d) res = MP_MEM; } - if (ptrA) { - XFREE(ptrA, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrB) { - XFREE(ptrB, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrC) { - XFREE(ptrC, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrD) { - XFREE(ptrD, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(ptrA, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrB, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrC, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrD, NULL, DYNAMIC_TYPE_BIGINT); } else { #if defined(FREESCALE_LTC_TFM_RSA_4096_ENABLE) @@ -591,18 +563,10 @@ int ltc_mp_exptmod(mp_int *G, mp_int *X, mp_int *P, mp_int *Y, int useConstTime) res = MP_MEM; } - if (ptrY) { - XFREE(ptrY, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrP) { - XFREE(ptrP, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrX) { - XFREE(ptrX, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrG) { - XFREE(ptrG, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(ptrY, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrP, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrX, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrG, NULL, DYNAMIC_TYPE_BIGINT); } else { #if defined(FREESCALE_LTC_TFM_RSA_4096_ENABLE) @@ -687,12 +651,8 @@ int mp_prime_is_prime_ex(mp_int* a, int t, int* result, WC_RNG* rng) } } - if (ptrB) { - XFREE(ptrB, NULL, DYNAMIC_TYPE_BIGINT); - } - if (ptrA) { - XFREE(ptrA, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(ptrB, NULL, DYNAMIC_TYPE_BIGINT); + XFREE(ptrA, NULL, DYNAMIC_TYPE_BIGINT); } else { #if defined(FREESCALE_LTC_TFM_RSA_4096_ENABLE) diff --git a/wolfcrypt/src/port/nxp/se050_port.c b/wolfcrypt/src/port/nxp/se050_port.c index e54014bfb0..a514ecce7f 100644 --- a/wolfcrypt/src/port/nxp/se050_port.c +++ b/wolfcrypt/src/port/nxp/se050_port.c @@ -738,9 +738,7 @@ int se050_rsa_use_key_id(struct RsaKey* key, word32 keyId) status = kStatus_SSS_Fail; } } - if (derBuf != NULL) { - XFREE(derBuf, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(derBuf, key->heap, DYNAMIC_TYPE_TMP_BUFFER); if (status == kStatus_SSS_Success) { key->keyId = keyId; @@ -884,9 +882,7 @@ int se050_rsa_create_key(struct RsaKey* key, int size, long e) status = kStatus_SSS_Fail; } } - if (derBuf != NULL) { - XFREE(derBuf, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(derBuf, key->heap, DYNAMIC_TYPE_TMP_BUFFER); if (status == kStatus_SSS_Success) { key->keyId = keyId; @@ -1228,9 +1224,7 @@ int se050_rsa_sign(const byte* in, word32 inLen, byte* out, derSz, (keySz * 8), NULL, 0); } - if (derBuf != NULL) { - XFREE(derBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(derBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); } else { status = sss_key_object_get_handle(&newKey, keyId); @@ -1392,9 +1386,7 @@ int se050_rsa_verify(const byte* in, word32 inLen, byte* out, word32 outLen, derSz, (keySz * 8), NULL, 0); } - if (derBuf != NULL) { - XFREE(derBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(derBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); } else { status = sss_key_object_get_handle(&newKey, keyId); @@ -1579,9 +1571,7 @@ int se050_rsa_public_encrypt(const byte* in, word32 inLen, byte* out, status = sss_key_object_get_handle(&newKey, keyId); } - if (derBuf != NULL) { - XFREE(derBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(derBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); } if (status == kStatus_SSS_Success) { @@ -1746,9 +1736,7 @@ int se050_rsa_private_decrypt(const byte* in, word32 inLen, byte* out, status = sss_key_object_get_handle(&newKey, keyId); } - if (derBuf != NULL) { - XFREE(derBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(derBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); } if (status == kStatus_SSS_Success) { diff --git a/wolfcrypt/src/port/ti/ti-aes.c b/wolfcrypt/src/port/ti/ti-aes.c index 8021710487..8dcd10abce 100644 --- a/wolfcrypt/src/port/ti/ti-aes.c +++ b/wolfcrypt/src/port/ti/ti-aes.c @@ -545,9 +545,9 @@ static int AesAuthEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz, } exit: - if (in_save) XFREE(in_save, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (out_save) XFREE(out_save, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (authIn_save)XFREE(authIn_save, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(in_save, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(out_save, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(authIn_save, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -645,9 +645,9 @@ static int AesAuthDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz, } exit: - if (in_save) XFREE(in_save, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (out_save) XFREE(out_save, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (authIn_save)XFREE(authIn_save, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(in_save, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(out_save, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(authIn_save, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; } diff --git a/wolfcrypt/src/pwdbased.c b/wolfcrypt/src/pwdbased.c index 022d9f80c2..a8607adc7c 100644 --- a/wolfcrypt/src/pwdbased.c +++ b/wolfcrypt/src/pwdbased.c @@ -588,16 +588,11 @@ int wc_PKCS12_PBKDF_ex(byte* output, const byte* passwd, int passLen, #ifdef WOLFSSL_SMALL_STACK out: - if (Ai != NULL) - XFREE(Ai, heap, DYNAMIC_TYPE_TMP_BUFFER); - if (B != NULL) - XFREE(B, heap, DYNAMIC_TYPE_TMP_BUFFER); - if (B1 != NULL) - XFREE(B1, heap, DYNAMIC_TYPE_TMP_BUFFER); - if (i1 != NULL) - XFREE(i1, heap, DYNAMIC_TYPE_TMP_BUFFER); - if (res != NULL) - XFREE(res, heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(Ai, heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(B, heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(B1, heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(i1, heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(res, heap, DYNAMIC_TYPE_TMP_BUFFER); #endif if (dynamic) @@ -859,12 +854,9 @@ int wc_scrypt(byte* output, const byte* passwd, int passLen, ret = wc_PBKDF2(output, passwd, passLen, blocks, (int)blocksSz, 1, dkLen, WC_SHA256); end: - if (blocks != NULL) - XFREE(blocks, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (v != NULL) - XFREE(v, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (y != NULL) - XFREE(y, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(blocks, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(v, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(y, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; } diff --git a/wolfcrypt/src/rsa.c b/wolfcrypt/src/rsa.c index 71745bcbfd..4c7d3a0e89 100644 --- a/wolfcrypt/src/rsa.c +++ b/wolfcrypt/src/rsa.c @@ -373,9 +373,7 @@ int wc_InitRsaHw(RsaKey* key) } /* check for existing mod buffer to avoid memory leak */ - if (key->mod != NULL) { - XFREE(key->mod, key->heap, DYNAMIC_TYPE_KEY); - } + XFREE(key->mod, key->heap, DYNAMIC_TYPE_KEY); key->pubExp = e; key->mod = m; @@ -2144,9 +2142,7 @@ static int wc_RsaFunctionSync(const byte* in, word32 inLen, byte* out, #endif } - if (d != NULL) { - XFREE(d, key->heap, DYNAMIC_TYPE_PRIVATE_KEY); - } + XFREE(d, key->heap, DYNAMIC_TYPE_PRIVATE_KEY); } #endif break; @@ -5085,16 +5081,13 @@ int wc_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng) #if !defined(WOLFSSL_CRYPTOCELL) && !defined(WOLFSSL_SE050) #ifdef WOLFSSL_SMALL_STACK - if (p) + if (key != NULL) { XFREE(p, key->heap, DYNAMIC_TYPE_RSA); - if (q) XFREE(q, key->heap, DYNAMIC_TYPE_RSA); - if (tmp1) XFREE(tmp1, key->heap, DYNAMIC_TYPE_RSA); - if (tmp2) XFREE(tmp2, key->heap, DYNAMIC_TYPE_RSA); - if (tmp3) XFREE(tmp3, key->heap, DYNAMIC_TYPE_RSA); + } #elif defined(WOLFSSL_CHECK_MEM_ZERO) mp_memzero_check(p); mp_memzero_check(q); diff --git a/wolfcrypt/src/sha.c b/wolfcrypt/src/sha.c index bed2c4c0b6..44db748225 100644 --- a/wolfcrypt/src/sha.c +++ b/wolfcrypt/src/sha.c @@ -1058,10 +1058,8 @@ void wc_ShaFree(wc_Sha* sha) defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY)) && \ !defined(NO_WOLFSSL_RENESAS_TSIP_CRYPT_HASH) || \ defined(WOLFSSL_RENESAS_RX64_HASH) - if (sha->msg != NULL) { - XFREE(sha->msg, sha->heap, DYNAMIC_TYPE_TMP_BUFFER); - sha->msg = NULL; - } + XFREE(sha->msg, sha->heap, DYNAMIC_TYPE_TMP_BUFFER); + sha->msg = NULL; #endif #ifdef WOLFSSL_IMXRT_DCP DCPShaFree(sha); diff --git a/wolfcrypt/src/sp_arm32.c b/wolfcrypt/src/sp_arm32.c index 73f4103d4f..1e67bce317 100644 --- a/wolfcrypt/src/sp_arm32.c +++ b/wolfcrypt/src/sp_arm32.c @@ -12027,8 +12027,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -12196,8 +12195,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -16788,8 +16786,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -16940,8 +16937,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -17104,8 +17100,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -18122,8 +18117,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -37404,8 +37398,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -37573,8 +37566,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -44035,8 +44027,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -44187,8 +44178,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -44351,8 +44341,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -45617,8 +45606,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -59454,8 +59442,7 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -59606,8 +59593,7 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -59770,8 +59756,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -61284,8 +61269,7 @@ static int sp_4096_mod_exp_2_128(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -73875,8 +73859,7 @@ static int sp_256_gen_stripe_table_8(const sp_point_256* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74040,10 +74023,8 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74299,8 +74280,7 @@ static int sp_256_gen_stripe_table_8(const sp_point_256* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74464,10 +74444,8 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74685,10 +74663,8 @@ int sp_ecc_mulmod_256(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74765,10 +74741,8 @@ int sp_ecc_mulmod_add_256(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -76235,10 +76209,8 @@ int sp_ecc_mulmod_base_256(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -76313,10 +76285,8 @@ int sp_ecc_mulmod_base_add_256(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -76493,8 +76463,7 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -76656,10 +76625,8 @@ int sp_ecc_secret_gen_256(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -78976,10 +78943,8 @@ int sp_ecc_verify_256(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -79186,8 +79151,7 @@ static int sp_256_ecc_is_point_8(const sp_point_256* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -79226,8 +79190,7 @@ int sp_ecc_is_point_256(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -79335,10 +79298,8 @@ int sp_ecc_check_key_256(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -79417,10 +79378,8 @@ int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -79485,10 +79444,8 @@ int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -79549,10 +79506,8 @@ int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -79618,8 +79573,7 @@ static int sp_256_mont_sqrt_8(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -79684,8 +79638,7 @@ int sp_ecc_uncompress_256(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -88876,8 +88829,7 @@ static int sp_384_mod_mul_norm_12(sp_digit* r, const sp_digit* a, const sp_digit } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -91628,8 +91580,7 @@ static int sp_384_gen_stripe_table_12(const sp_point_384* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -91809,10 +91760,8 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -92068,8 +92017,7 @@ static int sp_384_gen_stripe_table_12(const sp_point_384* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -92249,10 +92197,8 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -92470,10 +92416,8 @@ int sp_ecc_mulmod_384(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -92550,10 +92494,8 @@ int sp_ecc_mulmod_add_384(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -94020,10 +93962,8 @@ int sp_ecc_mulmod_base_384(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -94098,10 +94038,8 @@ int sp_ecc_mulmod_base_add_384(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -94284,8 +94222,7 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -94447,10 +94384,8 @@ int sp_ecc_secret_gen_384(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -97060,10 +96995,8 @@ int sp_ecc_verify_384(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -97270,8 +97203,7 @@ static int sp_384_ecc_is_point_12(const sp_point_384* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -97310,8 +97242,7 @@ int sp_ecc_is_point_384(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -97419,10 +97350,8 @@ int sp_ecc_check_key_384(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -97501,10 +97430,8 @@ int sp_ecc_proj_add_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -97569,10 +97496,8 @@ int sp_ecc_proj_dbl_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -97633,10 +97558,8 @@ int sp_ecc_map_384(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -97732,8 +97655,7 @@ static int sp_384_mont_sqrt_12(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -97798,8 +97720,7 @@ int sp_ecc_uncompress_384(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -118811,8 +118732,7 @@ static int sp_521_gen_stripe_table_17(const sp_point_521* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -119012,10 +118932,8 @@ static int sp_521_ecc_mulmod_stripe_17(sp_point_521* r, const sp_point_521* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -119271,8 +119189,7 @@ static int sp_521_gen_stripe_table_17(const sp_point_521* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -119472,10 +119389,8 @@ static int sp_521_ecc_mulmod_stripe_17(sp_point_521* r, const sp_point_521* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -119693,10 +119608,8 @@ int sp_ecc_mulmod_521(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -119773,10 +119686,8 @@ int sp_ecc_mulmod_add_521(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -121787,10 +121698,8 @@ int sp_ecc_mulmod_base_521(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -121865,10 +121774,8 @@ int sp_ecc_mulmod_base_add_521(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -122061,8 +121968,7 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -122226,10 +122132,8 @@ int sp_ecc_secret_gen_521(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -126015,10 +125919,8 @@ int sp_ecc_verify_521(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -126228,8 +126130,7 @@ static int sp_521_ecc_is_point_17(const sp_point_521* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -126268,8 +126169,7 @@ int sp_ecc_is_point_521(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -126377,10 +126277,8 @@ int sp_ecc_check_key_521(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -126459,10 +126357,8 @@ int sp_ecc_proj_add_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -126527,10 +126423,8 @@ int sp_ecc_proj_dbl_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -126591,10 +126485,8 @@ int sp_ecc_map_521(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -126644,8 +126536,7 @@ static int sp_521_mont_sqrt_17(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -126710,8 +126601,7 @@ int sp_ecc_uncompress_521(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -148604,8 +148494,7 @@ static int sp_1024_gen_stripe_table_32(const sp_point_1024* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -148704,10 +148593,8 @@ static int sp_1024_ecc_mulmod_stripe_32(sp_point_1024* r, const sp_point_1024* g } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -148963,8 +148850,7 @@ static int sp_1024_gen_stripe_table_32(const sp_point_1024* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -149063,10 +148949,8 @@ static int sp_1024_ecc_mulmod_stripe_32(sp_point_1024* r, const sp_point_1024* g } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -149284,10 +149168,8 @@ int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -152922,10 +152804,8 @@ int sp_ecc_mulmod_base_1024(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -153000,10 +152880,8 @@ int sp_ecc_mulmod_base_add_1024(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -153068,10 +152946,8 @@ int sp_ecc_gen_table_1024(const ecc_point* gm, byte* table, word32* len, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -153164,10 +153040,8 @@ int sp_ecc_mulmod_table_1024(const mp_int* km, const ecc_point* gm, byte* table, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -153314,9 +153188,7 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -155212,9 +155084,7 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -155582,9 +155452,7 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_32(c, 1, NULL); sp_1024_point_free_32(q, 1, NULL); @@ -156009,9 +155877,7 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_32(c, 1, NULL); sp_1024_point_free_32(q, 1, NULL); @@ -156377,9 +156243,7 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_32(neg, 1, NULL); sp_1024_point_free_32(c, 1, NULL); @@ -156572,9 +156436,7 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_32(c, 1, NULL); sp_1024_point_free_32(q, 1, NULL); @@ -156675,8 +156537,7 @@ static int sp_1024_ecc_is_point_32(const sp_point_1024* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -156715,8 +156576,7 @@ int sp_ecc_is_point_1024(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -156824,10 +156684,8 @@ int sp_ecc_check_key_1024(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; diff --git a/wolfcrypt/src/sp_arm64.c b/wolfcrypt/src/sp_arm64.c index c51a730e04..a437258d1a 100644 --- a/wolfcrypt/src/sp_arm64.c +++ b/wolfcrypt/src/sp_arm64.c @@ -4169,8 +4169,7 @@ static int sp_2048_mod_exp_16(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -4338,8 +4337,7 @@ static int sp_2048_mod_exp_16(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5795,8 +5793,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5997,8 +5994,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -6161,8 +6157,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -6842,8 +6837,7 @@ static int sp_2048_mod_exp_2_32(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -13360,8 +13354,7 @@ static int sp_3072_mod_exp_24(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -13529,8 +13522,7 @@ static int sp_3072_mod_exp_24(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -15352,8 +15344,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -15504,8 +15495,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -15668,8 +15658,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -16445,8 +16434,7 @@ static int sp_3072_mod_exp_2_48(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -20463,8 +20451,7 @@ static int sp_4096_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -20615,8 +20602,7 @@ static int sp_4096_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -20779,8 +20765,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -21652,8 +21637,7 @@ static int sp_4096_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -24486,10 +24470,8 @@ static int sp_256_ecc_mulmod_win_add_sub_4(sp_point_256* r, const sp_point_256* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -24731,8 +24713,7 @@ static int sp_256_gen_stripe_table_4(const sp_point_256* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -24902,10 +24883,8 @@ static int sp_256_ecc_mulmod_stripe_4(sp_point_256* r, const sp_point_256* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -25164,8 +25143,7 @@ static int sp_256_gen_stripe_table_4(const sp_point_256* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -25335,10 +25313,8 @@ static int sp_256_ecc_mulmod_stripe_4(sp_point_256* r, const sp_point_256* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -25557,10 +25533,8 @@ int sp_ecc_mulmod_256(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -25637,10 +25611,8 @@ int sp_ecc_mulmod_add_256(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -39494,8 +39466,7 @@ static int sp_256_ecc_mulmod_add_only_4(sp_point_256* r, const sp_point_256* g, #endif } #ifdef WOLFSSL_SP_SMALL_STACK - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -39562,10 +39533,8 @@ int sp_ecc_mulmod_base_256(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -39640,10 +39609,8 @@ int sp_ecc_mulmod_base_add_256(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -39890,8 +39857,7 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -40059,10 +40025,8 @@ int sp_ecc_secret_gen_256(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -41930,10 +41894,8 @@ int sp_ecc_verify_256(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -42184,8 +42146,7 @@ static int sp_256_ecc_is_point_4(const sp_point_256* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -42224,8 +42185,7 @@ int sp_ecc_is_point_256(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42333,10 +42293,8 @@ int sp_ecc_check_key_256(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -42415,10 +42373,8 @@ int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42483,10 +42439,8 @@ int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42547,10 +42501,8 @@ int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42616,8 +42568,7 @@ static int sp_256_mont_sqrt_4(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42682,8 +42633,7 @@ int sp_ecc_uncompress_256(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -43465,8 +43415,7 @@ static int sp_384_mod_mul_norm_6(sp_digit* r, const sp_digit* a, const sp_digit* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -45483,10 +45432,8 @@ static int sp_384_ecc_mulmod_win_add_sub_6(sp_point_384* r, const sp_point_384* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -45688,8 +45635,7 @@ static int sp_384_gen_stripe_table_6(const sp_point_384* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -45859,10 +45805,8 @@ static int sp_384_ecc_mulmod_stripe_6(sp_point_384* r, const sp_point_384* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -46121,8 +46065,7 @@ static int sp_384_gen_stripe_table_6(const sp_point_384* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -46292,10 +46235,8 @@ static int sp_384_ecc_mulmod_stripe_6(sp_point_384* r, const sp_point_384* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -46514,10 +46455,8 @@ int sp_ecc_mulmod_384(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -46594,10 +46533,8 @@ int sp_ecc_mulmod_add_384(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -66265,8 +66202,7 @@ static int sp_384_ecc_mulmod_add_only_6(sp_point_384* r, const sp_point_384* g, #endif } #ifdef WOLFSSL_SP_SMALL_STACK - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -66333,10 +66269,8 @@ int sp_ecc_mulmod_base_384(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -66411,10 +66345,8 @@ int sp_ecc_mulmod_base_add_384(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -66665,8 +66597,7 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -66834,10 +66765,8 @@ int sp_ecc_secret_gen_384(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -68062,10 +67991,8 @@ int sp_ecc_verify_384(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -68272,8 +68199,7 @@ static int sp_384_ecc_is_point_6(const sp_point_384* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -68312,8 +68238,7 @@ int sp_ecc_is_point_384(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -68421,10 +68346,8 @@ int sp_ecc_check_key_384(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -68503,10 +68426,8 @@ int sp_ecc_proj_add_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -68571,10 +68492,8 @@ int sp_ecc_proj_dbl_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -68635,10 +68554,8 @@ int sp_ecc_map_384(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -68734,8 +68651,7 @@ static int sp_384_mont_sqrt_6(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -68800,8 +68716,7 @@ int sp_ecc_uncompress_384(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -73897,10 +73812,8 @@ static int sp_521_ecc_mulmod_win_add_sub_9(sp_point_521* r, const sp_point_521* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74102,8 +74015,7 @@ static int sp_521_gen_stripe_table_9(const sp_point_521* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74291,10 +74203,8 @@ static int sp_521_ecc_mulmod_stripe_9(sp_point_521* r, const sp_point_521* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74553,8 +74463,7 @@ static int sp_521_gen_stripe_table_9(const sp_point_521* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74742,10 +74651,8 @@ static int sp_521_ecc_mulmod_stripe_9(sp_point_521* r, const sp_point_521* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74964,10 +74871,8 @@ int sp_ecc_mulmod_521(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -75044,10 +74949,8 @@ int sp_ecc_mulmod_add_521(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -111429,8 +111332,7 @@ static int sp_521_ecc_mulmod_add_only_9(sp_point_521* r, const sp_point_521* g, #endif } #ifdef WOLFSSL_SP_SMALL_STACK - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -111497,10 +111399,8 @@ int sp_ecc_mulmod_base_521(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -111575,10 +111475,8 @@ int sp_ecc_mulmod_base_add_521(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -111838,8 +111736,7 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -112009,10 +111906,8 @@ int sp_ecc_secret_gen_521(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -113011,10 +112906,8 @@ int sp_ecc_verify_521(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -113224,8 +113117,7 @@ static int sp_521_ecc_is_point_9(const sp_point_521* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -113264,8 +113156,7 @@ int sp_ecc_is_point_521(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -113373,10 +113264,8 @@ int sp_ecc_check_key_521(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -113455,10 +113344,8 @@ int sp_ecc_proj_add_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -113523,10 +113410,8 @@ int sp_ecc_proj_dbl_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -113587,10 +113472,8 @@ int sp_ecc_map_521(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -113640,8 +113523,7 @@ static int sp_521_mont_sqrt_9(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -113706,8 +113588,7 @@ int sp_ecc_uncompress_521(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -117918,10 +117799,8 @@ static int sp_1024_ecc_mulmod_win_add_sub_16(sp_point_1024* r, const sp_point_10 } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -118122,8 +118001,7 @@ static int sp_1024_gen_stripe_table_16(const sp_point_1024* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -118222,10 +118100,8 @@ static int sp_1024_ecc_mulmod_stripe_16(sp_point_1024* r, const sp_point_1024* g } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -118442,10 +118318,8 @@ int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -121843,10 +121717,8 @@ int sp_ecc_mulmod_base_1024(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -121921,10 +121793,8 @@ int sp_ecc_mulmod_base_add_1024(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -121989,10 +121859,8 @@ int sp_ecc_gen_table_1024(const ecc_point* gm, byte* table, word32* len, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -122085,10 +121953,8 @@ int sp_ecc_mulmod_table_1024(const mp_int* km, const ecc_point* gm, byte* table, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -122235,9 +122101,7 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -123877,9 +123741,7 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -124247,9 +124109,7 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_16(c, 1, NULL); sp_1024_point_free_16(q, 1, NULL); @@ -124674,9 +124534,7 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_16(c, 1, NULL); sp_1024_point_free_16(q, 1, NULL); @@ -125042,9 +124900,7 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_16(neg, 1, NULL); sp_1024_point_free_16(c, 1, NULL); @@ -125237,9 +125093,7 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_16(c, 1, NULL); sp_1024_point_free_16(q, 1, NULL); @@ -125415,8 +125269,7 @@ static int sp_1024_ecc_is_point_16(const sp_point_1024* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -125455,8 +125308,7 @@ int sp_ecc_is_point_1024(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -125564,10 +125416,8 @@ int sp_ecc_check_key_1024(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; diff --git a/wolfcrypt/src/sp_armthumb.c b/wolfcrypt/src/sp_armthumb.c index f10b944e13..de83f3da72 100644 --- a/wolfcrypt/src/sp_armthumb.c +++ b/wolfcrypt/src/sp_armthumb.c @@ -24139,8 +24139,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -24308,8 +24307,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -27720,8 +27718,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -27872,8 +27869,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -28036,8 +28032,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -30137,8 +30132,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -75601,8 +75595,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -75770,8 +75763,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -80013,8 +80005,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -80165,8 +80156,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -80329,8 +80319,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -83228,8 +83217,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -92562,8 +92550,7 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -92714,8 +92701,7 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -92878,8 +92864,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -96570,8 +96555,7 @@ static int sp_4096_mod_exp_2_128(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -101377,8 +101361,7 @@ static int sp_256_gen_stripe_table_8(const sp_point_256* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -101542,10 +101525,8 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -101801,8 +101782,7 @@ static int sp_256_gen_stripe_table_8(const sp_point_256* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -101966,10 +101946,8 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -102187,10 +102165,8 @@ int sp_ecc_mulmod_256(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -102267,10 +102243,8 @@ int sp_ecc_mulmod_add_256(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -103737,10 +103711,8 @@ int sp_ecc_mulmod_base_256(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -103815,10 +103787,8 @@ int sp_ecc_mulmod_base_add_256(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -104053,8 +104023,7 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -104216,10 +104185,8 @@ int sp_ecc_secret_gen_256(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -107521,10 +107488,8 @@ int sp_ecc_verify_256(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -107731,8 +107696,7 @@ static int sp_256_ecc_is_point_8(const sp_point_256* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -107771,8 +107735,7 @@ int sp_ecc_is_point_256(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -107880,10 +107843,8 @@ int sp_ecc_check_key_256(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -107962,10 +107923,8 @@ int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -108030,10 +107989,8 @@ int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -108094,10 +108051,8 @@ int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -108163,8 +108118,7 @@ static int sp_256_mont_sqrt_8(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -108229,8 +108183,7 @@ int sp_ecc_uncompress_256(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -109286,8 +109239,7 @@ static int sp_384_mod_mul_norm_12(sp_digit* r, const sp_digit* a, const sp_digit } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -112237,8 +112189,7 @@ static int sp_384_gen_stripe_table_12(const sp_point_384* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -112418,10 +112369,8 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -112677,8 +112626,7 @@ static int sp_384_gen_stripe_table_12(const sp_point_384* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -112858,10 +112806,8 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -113079,10 +113025,8 @@ int sp_ecc_mulmod_384(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -113159,10 +113103,8 @@ int sp_ecc_mulmod_add_384(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -114629,10 +114571,8 @@ int sp_ecc_mulmod_base_384(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -114707,10 +114647,8 @@ int sp_ecc_mulmod_base_add_384(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -114981,8 +114919,7 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -115144,10 +115081,8 @@ int sp_ecc_secret_gen_384(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -118725,10 +118660,8 @@ int sp_ecc_verify_384(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -118935,8 +118868,7 @@ static int sp_384_ecc_is_point_12(const sp_point_384* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -118975,8 +118907,7 @@ int sp_ecc_is_point_384(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -119084,10 +119015,8 @@ int sp_ecc_check_key_384(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -119166,10 +119095,8 @@ int sp_ecc_proj_add_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -119234,10 +119161,8 @@ int sp_ecc_proj_dbl_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -119298,10 +119223,8 @@ int sp_ecc_map_384(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -119397,8 +119320,7 @@ static int sp_384_mont_sqrt_12(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -119463,8 +119385,7 @@ int sp_ecc_uncompress_384(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -125868,8 +125789,7 @@ static int sp_521_gen_stripe_table_17(const sp_point_521* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -126069,10 +125989,8 @@ static int sp_521_ecc_mulmod_stripe_17(sp_point_521* r, const sp_point_521* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -126328,8 +126246,7 @@ static int sp_521_gen_stripe_table_17(const sp_point_521* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -126529,10 +126446,8 @@ static int sp_521_ecc_mulmod_stripe_17(sp_point_521* r, const sp_point_521* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -126750,10 +126665,8 @@ int sp_ecc_mulmod_521(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -126830,10 +126743,8 @@ int sp_ecc_mulmod_add_521(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -128844,10 +128755,8 @@ int sp_ecc_mulmod_base_521(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -128922,10 +128831,8 @@ int sp_ecc_mulmod_base_add_521(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -129242,8 +129149,7 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -129407,10 +129313,8 @@ int sp_ecc_secret_gen_521(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -135672,10 +135576,8 @@ int sp_ecc_verify_521(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -135885,8 +135787,7 @@ static int sp_521_ecc_is_point_17(const sp_point_521* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -135925,8 +135826,7 @@ int sp_ecc_is_point_521(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -136034,10 +135934,8 @@ int sp_ecc_check_key_521(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -136116,10 +136014,8 @@ int sp_ecc_proj_add_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -136184,10 +136080,8 @@ int sp_ecc_proj_dbl_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -136248,10 +136142,8 @@ int sp_ecc_map_521(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -136301,8 +136193,7 @@ static int sp_521_mont_sqrt_17(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -136367,8 +136258,7 @@ int sp_ecc_uncompress_521(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -210595,8 +210485,7 @@ static int sp_1024_gen_stripe_table_32(const sp_point_1024* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -210695,10 +210584,8 @@ static int sp_1024_ecc_mulmod_stripe_32(sp_point_1024* r, const sp_point_1024* g } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -210954,8 +210841,7 @@ static int sp_1024_gen_stripe_table_32(const sp_point_1024* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -211054,10 +210940,8 @@ static int sp_1024_ecc_mulmod_stripe_32(sp_point_1024* r, const sp_point_1024* g } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -211275,10 +211159,8 @@ int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -214913,10 +214795,8 @@ int sp_ecc_mulmod_base_1024(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -214991,10 +214871,8 @@ int sp_ecc_mulmod_base_add_1024(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -215059,10 +214937,8 @@ int sp_ecc_gen_table_1024(const ecc_point* gm, byte* table, word32* len, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -215155,10 +215031,8 @@ int sp_ecc_mulmod_table_1024(const mp_int* km, const ecc_point* gm, byte* table, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -215305,9 +215179,7 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -217203,9 +217075,7 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -217573,9 +217443,7 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_32(c, 1, NULL); sp_1024_point_free_32(q, 1, NULL); @@ -218000,9 +217868,7 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_32(c, 1, NULL); sp_1024_point_free_32(q, 1, NULL); @@ -218368,9 +218234,7 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_32(neg, 1, NULL); sp_1024_point_free_32(c, 1, NULL); @@ -218563,9 +218427,7 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_32(c, 1, NULL); sp_1024_point_free_32(q, 1, NULL); @@ -218666,8 +218528,7 @@ static int sp_1024_ecc_is_point_32(const sp_point_1024* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -218706,8 +218567,7 @@ int sp_ecc_is_point_1024(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -218815,10 +218675,8 @@ int sp_ecc_check_key_1024(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index b89c7419cb..8365c1336f 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -2105,8 +2105,7 @@ static int sp_2048_div_36(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -2224,8 +2223,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -2314,8 +2312,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -2460,8 +2457,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -3167,8 +3163,7 @@ static int sp_2048_div_72(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -3289,8 +3284,7 @@ static int sp_2048_mod_exp_72(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -3379,8 +3373,7 @@ static int sp_2048_mod_exp_72(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -3508,8 +3501,7 @@ static int sp_2048_mod_exp_72(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -3630,8 +3622,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -3742,8 +3733,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (d != NULL) - XFREE(d, NULL, DYNAMIC_TYPE_RSA); + XFREE(d, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -4615,8 +4605,7 @@ static int sp_2048_mod_exp_2_72(sp_digit* r, const sp_digit* e, int bits, const } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5790,8 +5779,7 @@ static int sp_3072_div_53(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5909,8 +5897,7 @@ static int sp_3072_mod_exp_53(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5999,8 +5986,7 @@ static int sp_3072_mod_exp_53(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -6145,8 +6131,7 @@ static int sp_3072_mod_exp_53(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -6629,8 +6614,7 @@ static int sp_3072_div_106(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -6749,8 +6733,7 @@ static int sp_3072_mod_exp_106(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -6839,8 +6822,7 @@ static int sp_3072_mod_exp_106(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -6968,8 +6950,7 @@ static int sp_3072_mod_exp_106(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -7088,8 +7069,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -7200,8 +7180,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (d != NULL) - XFREE(d, NULL, DYNAMIC_TYPE_RSA); + XFREE(d, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -7923,8 +7902,7 @@ static int sp_3072_mod_exp_2_106(sp_digit* r, const sp_digit* e, int bits, const } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -9824,8 +9802,7 @@ static int sp_3072_div_56(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -9943,8 +9920,7 @@ static int sp_3072_mod_exp_56(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -10033,8 +10009,7 @@ static int sp_3072_mod_exp_56(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -10179,8 +10154,7 @@ static int sp_3072_mod_exp_56(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -10743,8 +10717,7 @@ static int sp_3072_div_112(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -10865,8 +10838,7 @@ static int sp_3072_mod_exp_112(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -10955,8 +10927,7 @@ static int sp_3072_mod_exp_112(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -11084,8 +11055,7 @@ static int sp_3072_mod_exp_112(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -11206,8 +11176,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -11318,8 +11287,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (d != NULL) - XFREE(d, NULL, DYNAMIC_TYPE_RSA); + XFREE(d, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -12262,8 +12230,7 @@ static int sp_3072_mod_exp_2_112(sp_digit* r, const sp_digit* e, int bits, const } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -13447,8 +13414,7 @@ static int sp_4096_div_71(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -13566,8 +13532,7 @@ static int sp_4096_mod_exp_71(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -13656,8 +13621,7 @@ static int sp_4096_mod_exp_71(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -13802,8 +13766,7 @@ static int sp_4096_mod_exp_71(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -14287,8 +14250,7 @@ static int sp_4096_div_142(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -14407,8 +14369,7 @@ static int sp_4096_mod_exp_142(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -14497,8 +14458,7 @@ static int sp_4096_mod_exp_142(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -14626,8 +14586,7 @@ static int sp_4096_mod_exp_142(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -14746,8 +14705,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -14858,8 +14816,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (d != NULL) - XFREE(d, NULL, DYNAMIC_TYPE_RSA); + XFREE(d, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -15581,8 +15538,7 @@ static int sp_4096_mod_exp_2_142(sp_digit* r, const sp_digit* e, int bits, const } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -17362,8 +17318,7 @@ static int sp_4096_div_81(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -17481,8 +17436,7 @@ static int sp_4096_mod_exp_81(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -17571,8 +17525,7 @@ static int sp_4096_mod_exp_81(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -17717,8 +17670,7 @@ static int sp_4096_mod_exp_81(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -18268,8 +18220,7 @@ static int sp_4096_div_162(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -18390,8 +18341,7 @@ static int sp_4096_mod_exp_162(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -18480,8 +18430,7 @@ static int sp_4096_mod_exp_162(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -18609,8 +18558,7 @@ static int sp_4096_mod_exp_162(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -18731,8 +18679,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -18843,8 +18790,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (d != NULL) - XFREE(d, NULL, DYNAMIC_TYPE_RSA); + XFREE(d, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -19887,8 +19833,7 @@ static int sp_4096_mod_exp_2_162(sp_digit* r, const sp_digit* e, int bits, const } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -21907,8 +21852,7 @@ static int sp_256_mod_mul_norm_9(sp_digit* r, const sp_digit* a, const sp_digit* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -22717,10 +22661,8 @@ static int sp_256_ecc_mulmod_win_add_sub_9(sp_point_256* r, const sp_point_256* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -22915,8 +22857,7 @@ static int sp_256_gen_stripe_table_9(const sp_point_256* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -23084,10 +23025,8 @@ static int sp_256_ecc_mulmod_stripe_9(sp_point_256* r, const sp_point_256* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -23305,10 +23244,8 @@ int sp_ecc_mulmod_256(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -23385,10 +23322,8 @@ int sp_ecc_mulmod_add_256(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -24774,10 +24709,8 @@ int sp_ecc_mulmod_base_256(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -24852,10 +24785,8 @@ int sp_ecc_mulmod_base_add_256(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -25013,8 +24944,7 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -25201,10 +25131,8 @@ int sp_ecc_secret_gen_256(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -25449,8 +25377,7 @@ static int sp_256_div_9(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -26175,8 +26102,7 @@ static int sp_256_mod_inv_9(sp_digit* r, const sp_digit* a, const sp_digit* m) XMEMCPY(r, d, sizeof(sp_digit) * 9); } #ifdef WOLFSSL_SP_SMALL_STACK - if (u != NULL) - XFREE(u, NULL, DYNAMIC_TYPE_ECC); + XFREE(u, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -26384,10 +26310,8 @@ int sp_ecc_verify_256(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -26594,8 +26518,7 @@ static int sp_256_ecc_is_point_9(const sp_point_256* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -26634,8 +26557,7 @@ int sp_ecc_is_point_256(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -26743,10 +26665,8 @@ int sp_ecc_check_key_256(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -26825,10 +26745,8 @@ int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -26893,10 +26811,8 @@ int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -26957,10 +26873,8 @@ int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -27026,8 +26940,7 @@ static int sp_256_mont_sqrt_9(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -27092,8 +27005,7 @@ int sp_ecc_uncompress_256(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -29393,8 +29305,7 @@ static int sp_384_mod_mul_norm_15(sp_digit* r, const sp_digit* a, const sp_digit } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -30251,10 +30162,8 @@ static int sp_384_ecc_mulmod_win_add_sub_15(sp_point_384* r, const sp_point_384* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -30449,8 +30358,7 @@ static int sp_384_gen_stripe_table_15(const sp_point_384* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -30642,10 +30550,8 @@ static int sp_384_ecc_mulmod_stripe_15(sp_point_384* r, const sp_point_384* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -30863,10 +30769,8 @@ int sp_ecc_mulmod_384(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -30943,10 +30847,8 @@ int sp_ecc_mulmod_add_384(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -32844,10 +32746,8 @@ int sp_ecc_mulmod_base_384(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -32922,10 +32822,8 @@ int sp_ecc_mulmod_base_add_384(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -33083,8 +32981,7 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -33271,10 +33168,8 @@ int sp_ecc_secret_gen_384(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -33561,8 +33456,7 @@ static int sp_384_div_15(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -34254,8 +34148,7 @@ static int sp_384_mod_inv_15(sp_digit* r, const sp_digit* a, const sp_digit* m) XMEMCPY(r, d, sizeof(sp_digit) * 15); } #ifdef WOLFSSL_SP_SMALL_STACK - if (u != NULL) - XFREE(u, NULL, DYNAMIC_TYPE_ECC); + XFREE(u, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -34469,10 +34362,8 @@ int sp_ecc_verify_384(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -34679,8 +34570,7 @@ static int sp_384_ecc_is_point_15(const sp_point_384* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -34719,8 +34609,7 @@ int sp_ecc_is_point_384(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -34828,10 +34717,8 @@ int sp_ecc_check_key_384(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -34910,10 +34797,8 @@ int sp_ecc_proj_add_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -34978,10 +34863,8 @@ int sp_ecc_proj_dbl_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -35042,10 +34925,8 @@ int sp_ecc_map_384(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -35141,8 +35022,7 @@ static int sp_384_mont_sqrt_15(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -35207,8 +35087,7 @@ int sp_ecc_uncompress_384(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -37834,10 +37713,8 @@ static int sp_521_ecc_mulmod_win_add_sub_21(sp_point_521* r, const sp_point_521* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -38032,8 +37909,7 @@ static int sp_521_gen_stripe_table_21(const sp_point_521* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -38249,10 +38125,8 @@ static int sp_521_ecc_mulmod_stripe_21(sp_point_521* r, const sp_point_521* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -38470,10 +38344,8 @@ int sp_ecc_mulmod_521(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -38550,10 +38422,8 @@ int sp_ecc_mulmod_add_521(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -40961,10 +40831,8 @@ int sp_ecc_mulmod_base_521(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -41039,10 +40907,8 @@ int sp_ecc_mulmod_base_add_521(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -41201,8 +41067,7 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -41389,10 +41254,8 @@ int sp_ecc_secret_gen_521(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -41699,8 +41562,7 @@ static int sp_521_div_21(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -42417,8 +42279,7 @@ static int sp_521_mod_inv_21(sp_digit* r, const sp_digit* a, const sp_digit* m) XMEMCPY(r, d, sizeof(sp_digit) * 21); } #ifdef WOLFSSL_SP_SMALL_STACK - if (u != NULL) - XFREE(u, NULL, DYNAMIC_TYPE_ECC); + XFREE(u, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42643,10 +42504,8 @@ int sp_ecc_verify_521(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -42857,8 +42716,7 @@ static int sp_521_ecc_is_point_21(const sp_point_521* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -42897,8 +42755,7 @@ int sp_ecc_is_point_521(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -43006,10 +42863,8 @@ int sp_ecc_check_key_521(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -43088,10 +42943,8 @@ int sp_ecc_proj_add_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -43156,10 +43009,8 @@ int sp_ecc_proj_dbl_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -43220,10 +43071,8 @@ int sp_ecc_map_521(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -43273,8 +43122,7 @@ static int sp_521_mont_sqrt_21(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -43339,8 +43187,7 @@ int sp_ecc_uncompress_521(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -44382,8 +44229,7 @@ static int sp_1024_div_42(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -46540,10 +46386,8 @@ static int sp_1024_ecc_mulmod_win_add_sub_42(sp_point_1024* r, const sp_point_10 } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -46738,8 +46582,7 @@ static int sp_1024_gen_stripe_table_42(const sp_point_1024* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -46838,10 +46681,8 @@ static int sp_1024_ecc_mulmod_stripe_42(sp_point_1024* r, const sp_point_1024* g } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -47059,10 +46900,8 @@ int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -51004,10 +50843,8 @@ int sp_ecc_mulmod_base_1024(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -51082,10 +50919,8 @@ int sp_ecc_mulmod_base_add_1024(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -51150,10 +50985,8 @@ int sp_ecc_gen_table_1024(const ecc_point* gm, byte* table, word32* len, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -51246,10 +51079,8 @@ int sp_ecc_mulmod_table_1024(const mp_int* km, const ecc_point* gm, byte* table, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -51396,9 +51227,7 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -53294,9 +53123,7 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -53664,9 +53491,7 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_42(c, 1, NULL); sp_1024_point_free_42(q, 1, NULL); @@ -54091,9 +53916,7 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_42(c, 1, NULL); sp_1024_point_free_42(q, 1, NULL); @@ -54459,9 +54282,7 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_42(neg, 1, NULL); sp_1024_point_free_42(c, 1, NULL); @@ -54654,9 +54475,7 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_42(c, 1, NULL); sp_1024_point_free_42(q, 1, NULL); @@ -54754,8 +54573,7 @@ static int sp_1024_ecc_is_point_42(const sp_point_1024* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -54794,8 +54612,7 @@ int sp_ecc_is_point_1024(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -54903,10 +54720,8 @@ int sp_ecc_check_key_1024(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; diff --git a/wolfcrypt/src/sp_c64.c b/wolfcrypt/src/sp_c64.c index c1fadc5b09..0d3ab51336 100644 --- a/wolfcrypt/src/sp_c64.c +++ b/wolfcrypt/src/sp_c64.c @@ -1017,8 +1017,7 @@ static int sp_2048_div_17(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -1136,8 +1135,7 @@ static int sp_2048_mod_exp_17(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -1226,8 +1224,7 @@ static int sp_2048_mod_exp_17(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -1372,8 +1369,7 @@ static int sp_2048_mod_exp_17(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -1842,8 +1838,7 @@ static int sp_2048_div_34(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -1962,8 +1957,7 @@ static int sp_2048_mod_exp_34(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -2052,8 +2046,7 @@ static int sp_2048_mod_exp_34(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -2181,8 +2174,7 @@ static int sp_2048_mod_exp_34(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -2301,8 +2293,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -2413,8 +2404,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (d != NULL) - XFREE(d, NULL, DYNAMIC_TYPE_RSA); + XFREE(d, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -3137,8 +3127,7 @@ static int sp_2048_mod_exp_2_34(sp_digit* r, const sp_digit* e, int bits, const } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -4552,8 +4541,7 @@ static int sp_2048_div_18(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -4671,8 +4659,7 @@ static int sp_2048_mod_exp_18(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -4761,8 +4748,7 @@ static int sp_2048_mod_exp_18(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -4907,8 +4893,7 @@ static int sp_2048_mod_exp_18(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5438,8 +5423,7 @@ static int sp_2048_div_36(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5560,8 +5544,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5650,8 +5633,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5779,8 +5761,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5901,8 +5882,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -6013,8 +5993,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (d != NULL) - XFREE(d, NULL, DYNAMIC_TYPE_RSA); + XFREE(d, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -6806,8 +6785,7 @@ static int sp_2048_mod_exp_2_36(sp_digit* r, const sp_digit* e, int bits, const } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -7894,8 +7872,7 @@ static int sp_3072_div_26(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -8013,8 +7990,7 @@ static int sp_3072_mod_exp_26(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -8103,8 +8079,7 @@ static int sp_3072_mod_exp_26(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -8249,8 +8224,7 @@ static int sp_3072_mod_exp_26(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -8725,8 +8699,7 @@ static int sp_3072_div_52(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -8845,8 +8818,7 @@ static int sp_3072_mod_exp_52(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -8935,8 +8907,7 @@ static int sp_3072_mod_exp_52(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -9064,8 +9035,7 @@ static int sp_3072_mod_exp_52(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -9184,8 +9154,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -9296,8 +9265,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (d != NULL) - XFREE(d, NULL, DYNAMIC_TYPE_RSA); + XFREE(d, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -10020,8 +9988,7 @@ static int sp_3072_mod_exp_2_52(sp_digit* r, const sp_digit* e, int bits, const } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -11573,8 +11540,7 @@ static int sp_3072_div_27(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -11692,8 +11658,7 @@ static int sp_3072_mod_exp_27(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -11782,8 +11747,7 @@ static int sp_3072_mod_exp_27(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -11928,8 +11892,7 @@ static int sp_3072_mod_exp_27(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -12470,8 +12433,7 @@ static int sp_3072_div_54(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -12592,8 +12554,7 @@ static int sp_3072_mod_exp_54(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -12682,8 +12643,7 @@ static int sp_3072_mod_exp_54(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -12811,8 +12771,7 @@ static int sp_3072_mod_exp_54(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -12933,8 +12892,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -13045,8 +13003,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (d != NULL) - XFREE(d, NULL, DYNAMIC_TYPE_RSA); + XFREE(d, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -13874,8 +13831,7 @@ static int sp_3072_mod_exp_2_54(sp_digit* r, const sp_digit* e, int bits, const } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -14968,8 +14924,7 @@ static int sp_4096_div_35(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -15087,8 +15042,7 @@ static int sp_4096_mod_exp_35(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -15177,8 +15131,7 @@ static int sp_4096_mod_exp_35(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -15323,8 +15276,7 @@ static int sp_4096_mod_exp_35(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -15794,8 +15746,7 @@ static int sp_4096_div_70(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -15914,8 +15865,7 @@ static int sp_4096_mod_exp_70(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -16004,8 +15954,7 @@ static int sp_4096_mod_exp_70(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -16133,8 +16082,7 @@ static int sp_4096_mod_exp_70(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -16253,8 +16201,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -16365,8 +16312,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (d != NULL) - XFREE(d, NULL, DYNAMIC_TYPE_RSA); + XFREE(d, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -17089,8 +17035,7 @@ static int sp_4096_mod_exp_2_70(sp_digit* r, const sp_digit* e, int bits, const } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -18697,8 +18642,7 @@ static int sp_4096_div_39(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -18816,8 +18760,7 @@ static int sp_4096_mod_exp_39(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -18906,8 +18849,7 @@ static int sp_4096_mod_exp_39(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -19052,8 +18994,7 @@ static int sp_4096_mod_exp_39(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -19595,8 +19536,7 @@ static int sp_4096_div_78(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -19717,8 +19657,7 @@ static int sp_4096_mod_exp_78(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -19807,8 +19746,7 @@ static int sp_4096_mod_exp_78(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -19936,8 +19874,7 @@ static int sp_4096_mod_exp_78(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -20058,8 +19995,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -20170,8 +20106,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (d != NULL) - XFREE(d, NULL, DYNAMIC_TYPE_RSA); + XFREE(d, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -21047,8 +20982,7 @@ static int sp_4096_mod_exp_2_78(sp_digit* r, const sp_digit* e, int bits, const } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -22862,8 +22796,7 @@ static int sp_256_mod_mul_norm_5(sp_digit* r, const sp_digit* a, const sp_digit* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -23640,10 +23573,8 @@ static int sp_256_ecc_mulmod_win_add_sub_5(sp_point_256* r, const sp_point_256* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -23838,8 +23769,7 @@ static int sp_256_gen_stripe_table_5(const sp_point_256* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -23991,10 +23921,8 @@ static int sp_256_ecc_mulmod_stripe_5(sp_point_256* r, const sp_point_256* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -24212,10 +24140,8 @@ int sp_ecc_mulmod_256(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -24292,10 +24218,8 @@ int sp_ecc_mulmod_add_256(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -25681,10 +25605,8 @@ int sp_ecc_mulmod_base_256(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -25759,10 +25681,8 @@ int sp_ecc_mulmod_base_add_256(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -25920,8 +25840,7 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -26108,10 +26027,8 @@ int sp_ecc_secret_gen_256(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -26342,8 +26259,7 @@ static int sp_256_div_5(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -27073,8 +26989,7 @@ static int sp_256_mod_inv_5(sp_digit* r, const sp_digit* a, const sp_digit* m) XMEMCPY(r, d, sizeof(sp_digit) * 5); } #ifdef WOLFSSL_SP_SMALL_STACK - if (u != NULL) - XFREE(u, NULL, DYNAMIC_TYPE_ECC); + XFREE(u, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -27278,10 +27193,8 @@ int sp_ecc_verify_256(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -27488,8 +27401,7 @@ static int sp_256_ecc_is_point_5(const sp_point_256* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -27528,8 +27440,7 @@ int sp_ecc_is_point_256(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -27637,10 +27548,8 @@ int sp_ecc_check_key_256(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -27719,10 +27628,8 @@ int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -27787,10 +27694,8 @@ int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -27851,10 +27756,8 @@ int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -27920,8 +27823,7 @@ static int sp_256_mont_sqrt_5(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -27986,8 +27888,7 @@ int sp_ecc_uncompress_256(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -29823,8 +29724,7 @@ static int sp_384_mod_mul_norm_7(sp_digit* r, const sp_digit* a, const sp_digit* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -30617,10 +30517,8 @@ static int sp_384_ecc_mulmod_win_add_sub_7(sp_point_384* r, const sp_point_384* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -30815,8 +30713,7 @@ static int sp_384_gen_stripe_table_7(const sp_point_384* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -30976,10 +30873,8 @@ static int sp_384_ecc_mulmod_stripe_7(sp_point_384* r, const sp_point_384* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -31197,10 +31092,8 @@ int sp_ecc_mulmod_384(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -31277,10 +31170,8 @@ int sp_ecc_mulmod_add_384(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -33176,10 +33067,8 @@ int sp_ecc_mulmod_base_384(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -33254,10 +33143,8 @@ int sp_ecc_mulmod_base_add_384(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -33415,8 +33302,7 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -33603,10 +33489,8 @@ int sp_ecc_secret_gen_384(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -33845,8 +33729,7 @@ static int sp_384_div_7(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -34543,8 +34426,7 @@ static int sp_384_mod_inv_7(sp_digit* r, const sp_digit* a, const sp_digit* m) XMEMCPY(r, d, sizeof(sp_digit) * 7); } #ifdef WOLFSSL_SP_SMALL_STACK - if (u != NULL) - XFREE(u, NULL, DYNAMIC_TYPE_ECC); + XFREE(u, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -34750,10 +34632,8 @@ int sp_ecc_verify_384(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -34960,8 +34840,7 @@ static int sp_384_ecc_is_point_7(const sp_point_384* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -35000,8 +34879,7 @@ int sp_ecc_is_point_384(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -35109,10 +34987,8 @@ int sp_ecc_check_key_384(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -35191,10 +35067,8 @@ int sp_ecc_proj_add_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -35259,10 +35133,8 @@ int sp_ecc_proj_dbl_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -35323,10 +35195,8 @@ int sp_ecc_map_384(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -35422,8 +35292,7 @@ static int sp_384_mont_sqrt_7(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -35488,8 +35357,7 @@ int sp_ecc_uncompress_384(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -38054,10 +37922,8 @@ static int sp_521_ecc_mulmod_win_add_sub_9(sp_point_521* r, const sp_point_521* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -38252,8 +38118,7 @@ static int sp_521_gen_stripe_table_9(const sp_point_521* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -38421,10 +38286,8 @@ static int sp_521_ecc_mulmod_stripe_9(sp_point_521* r, const sp_point_521* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -38642,10 +38505,8 @@ int sp_ecc_mulmod_521(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -38722,10 +38583,8 @@ int sp_ecc_mulmod_add_521(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -40621,10 +40480,8 @@ int sp_ecc_mulmod_base_521(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -40699,10 +40556,8 @@ int sp_ecc_mulmod_base_add_521(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -40861,8 +40716,7 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -41049,10 +40903,8 @@ int sp_ecc_secret_gen_521(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -41297,8 +41149,7 @@ static int sp_521_div_9(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -42020,8 +41871,7 @@ static int sp_521_mod_inv_9(sp_digit* r, const sp_digit* a, const sp_digit* m) XMEMCPY(r, d, sizeof(sp_digit) * 9); } #ifdef WOLFSSL_SP_SMALL_STACK - if (u != NULL) - XFREE(u, NULL, DYNAMIC_TYPE_ECC); + XFREE(u, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42234,10 +42084,8 @@ int sp_ecc_verify_521(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -42448,8 +42296,7 @@ static int sp_521_ecc_is_point_9(const sp_point_521* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -42488,8 +42335,7 @@ int sp_ecc_is_point_521(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42597,10 +42443,8 @@ int sp_ecc_check_key_521(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -42679,10 +42523,8 @@ int sp_ecc_proj_add_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42747,10 +42589,8 @@ int sp_ecc_proj_dbl_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42811,10 +42651,8 @@ int sp_ecc_map_521(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42864,8 +42702,7 @@ static int sp_521_mont_sqrt_9(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42930,8 +42767,7 @@ int sp_ecc_uncompress_521(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -43847,8 +43683,7 @@ static int sp_1024_div_18(const sp_digit* a, const sp_digit* d, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -45894,10 +45729,8 @@ static int sp_1024_ecc_mulmod_win_add_sub_18(sp_point_1024* r, const sp_point_10 } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -46092,8 +45925,7 @@ static int sp_1024_gen_stripe_table_18(const sp_point_1024* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -46192,10 +46024,8 @@ static int sp_1024_ecc_mulmod_stripe_18(sp_point_1024* r, const sp_point_1024* g } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -46413,10 +46243,8 @@ int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -49844,10 +49672,8 @@ int sp_ecc_mulmod_base_1024(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -49922,10 +49748,8 @@ int sp_ecc_mulmod_base_add_1024(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -49990,10 +49814,8 @@ int sp_ecc_gen_table_1024(const ecc_point* gm, byte* table, word32* len, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -50086,10 +49908,8 @@ int sp_ecc_mulmod_table_1024(const mp_int* km, const ecc_point* gm, byte* table, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -50236,9 +50056,7 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -51878,9 +51696,7 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -52248,9 +52064,7 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_18(c, 1, NULL); sp_1024_point_free_18(q, 1, NULL); @@ -52675,9 +52489,7 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_18(c, 1, NULL); sp_1024_point_free_18(q, 1, NULL); @@ -53043,9 +52855,7 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_18(neg, 1, NULL); sp_1024_point_free_18(c, 1, NULL); @@ -53238,9 +53048,7 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_18(c, 1, NULL); sp_1024_point_free_18(q, 1, NULL); @@ -53338,8 +53146,7 @@ static int sp_1024_ecc_is_point_18(const sp_point_1024* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -53378,8 +53185,7 @@ int sp_ecc_is_point_1024(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -53487,10 +53293,8 @@ int sp_ecc_check_key_1024(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; diff --git a/wolfcrypt/src/sp_cortexm.c b/wolfcrypt/src/sp_cortexm.c index be5def3ea1..d841b990de 100644 --- a/wolfcrypt/src/sp_cortexm.c +++ b/wolfcrypt/src/sp_cortexm.c @@ -5350,8 +5350,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5519,8 +5518,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -8469,8 +8467,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -8621,8 +8618,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -8785,8 +8781,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -9831,8 +9826,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -17031,8 +17025,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -17200,8 +17193,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -21086,8 +21078,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -21238,8 +21229,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -21402,8 +21392,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -22696,8 +22685,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -29473,8 +29461,7 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -29625,8 +29612,7 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -29789,8 +29775,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -31331,8 +31316,7 @@ static int sp_4096_mod_exp_2_128(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -36960,8 +36944,7 @@ static int sp_256_gen_stripe_table_8(const sp_point_256* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -37125,10 +37108,8 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -37384,8 +37365,7 @@ static int sp_256_gen_stripe_table_8(const sp_point_256* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -37549,10 +37529,8 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -37770,10 +37748,8 @@ int sp_ecc_mulmod_256(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -37850,10 +37826,8 @@ int sp_ecc_mulmod_add_256(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -39320,10 +39294,8 @@ int sp_ecc_mulmod_base_256(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -39398,10 +39370,8 @@ int sp_ecc_mulmod_base_add_256(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -39584,8 +39554,7 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -39747,10 +39716,8 @@ int sp_ecc_secret_gen_256(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -41542,10 +41509,8 @@ int sp_ecc_verify_256(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -41752,8 +41717,7 @@ static int sp_256_ecc_is_point_8(const sp_point_256* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -41792,8 +41756,7 @@ int sp_ecc_is_point_256(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -41901,10 +41864,8 @@ int sp_ecc_check_key_256(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -41983,10 +41944,8 @@ int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42051,10 +42010,8 @@ int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42115,10 +42072,8 @@ int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42184,8 +42139,7 @@ static int sp_256_mont_sqrt_8(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -42250,8 +42204,7 @@ int sp_ecc_uncompress_256(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -44519,8 +44472,7 @@ static int sp_384_mod_mul_norm_12(sp_digit* r, const sp_digit* a, const sp_digit } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -47013,8 +46965,7 @@ static int sp_384_gen_stripe_table_12(const sp_point_384* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -47194,10 +47145,8 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -47453,8 +47402,7 @@ static int sp_384_gen_stripe_table_12(const sp_point_384* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -47634,10 +47582,8 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -47855,10 +47801,8 @@ int sp_ecc_mulmod_384(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -47935,10 +47879,8 @@ int sp_ecc_mulmod_add_384(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -49405,10 +49347,8 @@ int sp_ecc_mulmod_base_384(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -49483,10 +49423,8 @@ int sp_ecc_mulmod_base_add_384(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -49675,8 +49613,7 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -49838,10 +49775,8 @@ int sp_ecc_secret_gen_384(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -51633,10 +51568,8 @@ int sp_ecc_verify_384(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -51843,8 +51776,7 @@ static int sp_384_ecc_is_point_12(const sp_point_384* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -51883,8 +51815,7 @@ int sp_ecc_is_point_384(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -51992,10 +51923,8 @@ int sp_ecc_check_key_384(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -52074,10 +52003,8 @@ int sp_ecc_proj_add_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -52142,10 +52069,8 @@ int sp_ecc_proj_dbl_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -52206,10 +52131,8 @@ int sp_ecc_map_384(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -52305,8 +52228,7 @@ static int sp_384_mont_sqrt_12(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -52371,8 +52293,7 @@ int sp_ecc_uncompress_384(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -59209,8 +59130,7 @@ static int sp_521_gen_stripe_table_17(const sp_point_521* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -59410,10 +59330,8 @@ static int sp_521_ecc_mulmod_stripe_17(sp_point_521* r, const sp_point_521* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -59669,8 +59587,7 @@ static int sp_521_gen_stripe_table_17(const sp_point_521* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -59870,10 +59787,8 @@ static int sp_521_ecc_mulmod_stripe_17(sp_point_521* r, const sp_point_521* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -60091,10 +60006,8 @@ int sp_ecc_mulmod_521(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -60171,10 +60084,8 @@ int sp_ecc_mulmod_add_521(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -62185,10 +62096,8 @@ int sp_ecc_mulmod_base_521(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -62263,10 +62172,8 @@ int sp_ecc_mulmod_base_add_521(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -62465,8 +62372,7 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -62630,10 +62536,8 @@ int sp_ecc_secret_gen_521(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -65231,10 +65135,8 @@ int sp_ecc_verify_521(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -65444,8 +65346,7 @@ static int sp_521_ecc_is_point_17(const sp_point_521* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -65484,8 +65385,7 @@ int sp_ecc_is_point_521(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -65593,10 +65493,8 @@ int sp_ecc_check_key_521(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -65675,10 +65573,8 @@ int sp_ecc_proj_add_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -65743,10 +65639,8 @@ int sp_ecc_proj_dbl_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -65807,10 +65701,8 @@ int sp_ecc_map_521(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -65860,8 +65752,7 @@ static int sp_521_mont_sqrt_17(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -65926,8 +65817,7 @@ int sp_ecc_uncompress_521(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -73923,8 +73813,7 @@ static int sp_1024_gen_stripe_table_32(const sp_point_1024* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74023,10 +73912,8 @@ static int sp_1024_ecc_mulmod_stripe_32(sp_point_1024* r, const sp_point_1024* g } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74282,8 +74169,7 @@ static int sp_1024_gen_stripe_table_32(const sp_point_1024* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74382,10 +74268,8 @@ static int sp_1024_ecc_mulmod_stripe_32(sp_point_1024* r, const sp_point_1024* g } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -74603,10 +74487,8 @@ int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -78241,10 +78123,8 @@ int sp_ecc_mulmod_base_1024(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -78319,10 +78199,8 @@ int sp_ecc_mulmod_base_add_1024(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -78387,10 +78265,8 @@ int sp_ecc_gen_table_1024(const ecc_point* gm, byte* table, word32* len, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -78483,10 +78359,8 @@ int sp_ecc_mulmod_table_1024(const mp_int* km, const ecc_point* gm, byte* table, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -78633,9 +78507,7 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -80531,9 +80403,7 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -80901,9 +80771,7 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_32(c, 1, NULL); sp_1024_point_free_32(q, 1, NULL); @@ -81328,9 +81196,7 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res) #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_32(c, 1, NULL); sp_1024_point_free_32(q, 1, NULL); @@ -81696,9 +81562,7 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_32(neg, 1, NULL); sp_1024_point_free_32(c, 1, NULL); @@ -81891,9 +81755,7 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_32(c, 1, NULL); sp_1024_point_free_32(q, 1, NULL); @@ -81994,8 +81856,7 @@ static int sp_1024_ecc_is_point_32(const sp_point_1024* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -82034,8 +81895,7 @@ int sp_ecc_is_point_1024(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -82143,10 +82003,8 @@ int sp_ecc_check_key_1024(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; diff --git a/wolfcrypt/src/sp_dsp32.c b/wolfcrypt/src/sp_dsp32.c index 8522fdaeab..f14e1ab37f 100644 --- a/wolfcrypt/src/sp_dsp32.c +++ b/wolfcrypt/src/sp_dsp32.c @@ -296,9 +296,7 @@ static int sp_256_mod_mul_norm_10(sp_digit* r, const sp_digit* a, const sp_digit } #if defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_ECC); - } + XFREE(td, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -2592,9 +2590,7 @@ static int sp_256_ecc_mulmod_stripe_10(sp_point* r, const sp_point* g, } #if defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK) - if (t != NULL) { - XFREE(t, heap, DYNAMIC_TYPE_ECC); - } + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif sp_ecc_point_free(p, 0, heap); sp_ecc_point_free(rt, 0, heap); @@ -4233,9 +4229,7 @@ static int sp_256_div_10(const sp_digit* a, const sp_digit* d, sp_digit* m, } #if defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -4530,8 +4524,7 @@ int wolfSSL_DSP_ECC_Verify_256(remote_handle64 h, int32 *u1, int hashLen, int32* } #if defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK) - if (d != NULL) - XFREE(d, heap, DYNAMIC_TYPE_ECC); + XFREE(d, heap, DYNAMIC_TYPE_ECC); #endif sp_ecc_point_free(p1, 0, heap); sp_ecc_point_free(p2, 0, heap); @@ -4631,9 +4624,7 @@ int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #if defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK) - if (tmp != NULL) { - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - } + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); #endif sp_ecc_point_free(q, 0, NULL); sp_ecc_point_free(p, 0, NULL); @@ -4696,9 +4687,7 @@ int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #if defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK) - if (tmp != NULL) { - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - } + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); #endif sp_ecc_point_free(p, 0, NULL); @@ -4754,9 +4743,7 @@ int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ) } #if defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK) - if (tmp != NULL) { - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - } + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); #endif sp_ecc_point_free(p, 0, NULL); @@ -4831,9 +4818,7 @@ static int sp_256_mont_sqrt_10(sp_digit* y) } #if defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK) - if (d != NULL) { - XFREE(d, NULL, DYNAMIC_TYPE_ECC); - } + XFREE(d, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -4906,9 +4891,7 @@ int sp_ecc_uncompress_256(mp_int* xm, int odd, mp_int* ym) } #if defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK) - if (d != NULL) { - XFREE(d, NULL, DYNAMIC_TYPE_ECC); - } + XFREE(d, NULL, DYNAMIC_TYPE_ECC); #endif return err; diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index b1d18d5549..a25ddab4ab 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -8964,9 +8964,7 @@ static int _sp_mul_nxn(const sp_int* a, const sp_int* b, sp_int* r) } #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC) - if (t != NULL) { - XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); #endif return err; } @@ -9042,9 +9040,7 @@ static int _sp_mul(const sp_int* a, const sp_int* b, sp_int* r) } #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC) - if (t != NULL) { - XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); #endif return err; } @@ -9126,9 +9122,7 @@ static int _sp_mul(const sp_int* a, const sp_int* b, sp_int* r) } #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC) - if (t != NULL) { - XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); #endif return err; } @@ -9252,9 +9246,7 @@ static int _sp_mul_4(const sp_int* a, const sp_int* b, sp_int* r) } #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC) - if (w != NULL) { - XFREE(w, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(w, NULL, DYNAMIC_TYPE_BIGINT); #endif return err; } @@ -10251,9 +10243,7 @@ static int _sp_mul_16(const sp_int* a, const sp_int* b, sp_int* r) } #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC) - if (t != NULL) { - XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); #endif return err; } @@ -11059,9 +11049,7 @@ static int _sp_mul_24(const sp_int* a, const sp_int* b, sp_int* r) } #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC) - if (t != NULL) { - XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); #endif return err; } @@ -14707,9 +14695,7 @@ static int _sp_sqr(const sp_int* a, sp_int* r) } #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC) - if (t != NULL) { - XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); #endif return err; } @@ -14814,9 +14800,7 @@ static int _sp_sqr(const sp_int* a, sp_int* r) } #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC) - if (t != NULL) { - XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); #endif return err; } @@ -14928,9 +14912,7 @@ static int _sp_sqr_4(const sp_int* a, sp_int* r) } #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC) - if (w != NULL) { - XFREE(w, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(w, NULL, DYNAMIC_TYPE_BIGINT); #endif return err; } @@ -15755,9 +15737,7 @@ static int _sp_sqr_16(const sp_int* a, sp_int* r) } #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC) - if (t != NULL) { - XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); #endif return err; } @@ -16330,9 +16310,7 @@ static int _sp_sqr_24(const sp_int* a, sp_int* r) } #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC) - if (t != NULL) { - XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); - } + XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); #endif return err; } diff --git a/wolfcrypt/src/sp_x86_64.c b/wolfcrypt/src/sp_x86_64.c index ea1b9635c0..636ebfb83e 100644 --- a/wolfcrypt/src/sp_x86_64.c +++ b/wolfcrypt/src/sp_x86_64.c @@ -811,8 +811,7 @@ static int sp_2048_mod_exp_16(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -1052,8 +1051,7 @@ static int sp_2048_mod_exp_avx2_16(sp_digit* r, const sp_digit* a, const sp_digi } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -1623,8 +1621,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -1899,8 +1896,7 @@ static int sp_2048_mod_exp_avx2_32(sp_digit* r, const sp_digit* a, const sp_digi } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -2105,8 +2101,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -2531,14 +2526,12 @@ int sp_ModExp_2048(const mp_int* base, const mp_int* exp, const mp_int* mod, } #ifdef WOLFSSL_SP_SMALL_STACK - if (b != NULL) - XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (e != NULL) { XMEMSET(e, 0, 32); XFREE(e, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (m != NULL) - XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); #else XMEMSET(e, 0, sizeof(e)); #endif @@ -2687,8 +2680,7 @@ static int sp_2048_mod_exp_2_avx2_32(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -2826,8 +2818,7 @@ static int sp_2048_mod_exp_2_32(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -2932,14 +2923,12 @@ int sp_DhExp_2048(const mp_int* base, const byte* exp, word32 expLen, } #ifdef WOLFSSL_SP_SMALL_STACK - if (b != NULL) - XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (e != NULL) { XMEMSET(e, 0, 32); XFREE(e, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (m != NULL) - XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); #else XMEMSET(e, 0, sizeof(e)); #endif @@ -3023,14 +3012,12 @@ int sp_ModExp_1024(const mp_int* base, const mp_int* exp, const mp_int* mod, } #ifdef WOLFSSL_SP_SMALL_STACK - if (b != NULL) - XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (e != NULL) { XMEMSET(e, 0, 16); XFREE(e, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (m != NULL) - XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); #else XMEMSET(e, 0, sizeof(e)); #endif @@ -3813,8 +3800,7 @@ static int sp_3072_mod_exp_24(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -4054,8 +4040,7 @@ static int sp_3072_mod_exp_avx2_24(sp_digit* r, const sp_digit* a, const sp_digi } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -4573,8 +4558,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -4797,8 +4781,7 @@ static int sp_3072_mod_exp_avx2_48(sp_digit* r, const sp_digit* a, const sp_digi } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5003,8 +4986,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -5429,14 +5411,12 @@ int sp_ModExp_3072(const mp_int* base, const mp_int* exp, const mp_int* mod, } #ifdef WOLFSSL_SP_SMALL_STACK - if (b != NULL) - XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (e != NULL) { XMEMSET(e, 0, 48); XFREE(e, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (m != NULL) - XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); #else XMEMSET(e, 0, sizeof(e)); #endif @@ -5585,8 +5565,7 @@ static int sp_3072_mod_exp_2_avx2_48(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5724,8 +5703,7 @@ static int sp_3072_mod_exp_2_48(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -5830,14 +5808,12 @@ int sp_DhExp_3072(const mp_int* base, const byte* exp, word32 expLen, } #ifdef WOLFSSL_SP_SMALL_STACK - if (b != NULL) - XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (e != NULL) { XMEMSET(e, 0, 48); XFREE(e, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (m != NULL) - XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); #else XMEMSET(e, 0, sizeof(e)); #endif @@ -5921,14 +5897,12 @@ int sp_ModExp_1536(const mp_int* base, const mp_int* exp, const mp_int* mod, } #ifdef WOLFSSL_SP_SMALL_STACK - if (b != NULL) - XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (e != NULL) { XMEMSET(e, 0, 24); XFREE(e, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (m != NULL) - XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); #else XMEMSET(e, 0, sizeof(e)); #endif @@ -6697,8 +6671,7 @@ static int sp_4096_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -6921,8 +6894,7 @@ static int sp_4096_mod_exp_avx2_64(sp_digit* r, const sp_digit* a, const sp_digi } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -7127,8 +7099,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, } #ifdef WOLFSSL_SP_SMALL_STACK - if (a != NULL) - XFREE(a, NULL, DYNAMIC_TYPE_RSA); + XFREE(a, NULL, DYNAMIC_TYPE_RSA); #endif return err; @@ -7553,14 +7524,12 @@ int sp_ModExp_4096(const mp_int* base, const mp_int* exp, const mp_int* mod, } #ifdef WOLFSSL_SP_SMALL_STACK - if (b != NULL) - XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (e != NULL) { XMEMSET(e, 0, 64); XFREE(e, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (m != NULL) - XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); #else XMEMSET(e, 0, sizeof(e)); #endif @@ -7709,8 +7678,7 @@ static int sp_4096_mod_exp_2_avx2_64(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -7848,8 +7816,7 @@ static int sp_4096_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits, } #ifdef WOLFSSL_SP_SMALL_STACK - if (td != NULL) - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; @@ -7954,14 +7921,12 @@ int sp_DhExp_4096(const mp_int* base, const byte* exp, word32 expLen, } #ifdef WOLFSSL_SP_SMALL_STACK - if (b != NULL) - XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(b, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (e != NULL) { XMEMSET(e, 0, 64); XFREE(e, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - if (m != NULL) - XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(m, NULL, DYNAMIC_TYPE_TMP_BUFFER); #else XMEMSET(e, 0, sizeof(e)); #endif @@ -9575,10 +9540,8 @@ static int sp_256_ecc_mulmod_win_add_sub_4(sp_point_256* r, const sp_point_256* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -10610,10 +10573,8 @@ static int sp_256_ecc_mulmod_win_add_sub_avx2_4(sp_point_256* r, const sp_point_ } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -10812,8 +10773,7 @@ static int sp_256_gen_stripe_table_4(const sp_point_256* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -10942,10 +10902,8 @@ static int sp_256_ecc_mulmod_stripe_4(sp_point_256* r, const sp_point_256* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -11304,8 +11262,7 @@ static int sp_256_gen_stripe_table_avx2_4(const sp_point_256* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -11420,10 +11377,8 @@ static int sp_256_ecc_mulmod_stripe_avx2_4(sp_point_256* r, const sp_point_256* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -11555,10 +11510,8 @@ int sp_ecc_mulmod_256(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -11653,10 +11606,8 @@ int sp_ecc_mulmod_add_256(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -24183,8 +24134,7 @@ static int sp_256_ecc_mulmod_add_only_4(sp_point_256* r, const sp_point_256* g, #endif } #ifdef WOLFSSL_SP_SMALL_STACK - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -24317,8 +24267,7 @@ static int sp_256_ecc_mulmod_add_only_avx2_4(sp_point_256* r, const sp_point_256 #endif } #ifdef WOLFSSL_SP_SMALL_STACK - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -24394,10 +24343,8 @@ int sp_ecc_mulmod_base_256(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -24490,10 +24437,8 @@ int sp_ecc_mulmod_base_add_256(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -24663,8 +24608,7 @@ int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -24850,10 +24794,8 @@ int sp_ecc_secret_gen_256(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -26237,10 +26179,8 @@ int sp_ecc_verify_256(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -26447,8 +26387,7 @@ static int sp_256_ecc_is_point_4(const sp_point_256* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -26487,8 +26426,7 @@ int sp_ecc_is_point_256(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -26609,10 +26547,8 @@ int sp_ecc_check_key_256(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -26699,10 +26635,8 @@ int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -26775,10 +26709,8 @@ int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -26847,10 +26779,8 @@ int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -26953,8 +26883,7 @@ static int sp_256_mont_sqrt_4(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -27029,8 +26958,7 @@ int sp_ecc_uncompress_256(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -27272,8 +27200,7 @@ static int sp_384_mod_mul_norm_6(sp_digit* r, const sp_digit* a, const sp_digit* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -28713,10 +28640,8 @@ static int sp_384_ecc_mulmod_win_add_sub_6(sp_point_384* r, const sp_point_384* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -29801,10 +29726,8 @@ static int sp_384_ecc_mulmod_win_add_sub_avx2_6(sp_point_384* r, const sp_point_ } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -30006,8 +29929,7 @@ static int sp_384_gen_stripe_table_6(const sp_point_384* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -30136,10 +30058,8 @@ static int sp_384_ecc_mulmod_stripe_6(sp_point_384* r, const sp_point_384* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -30501,8 +30421,7 @@ static int sp_384_gen_stripe_table_avx2_6(const sp_point_384* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -30617,10 +30536,8 @@ static int sp_384_ecc_mulmod_stripe_avx2_6(sp_point_384* r, const sp_point_384* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -30752,10 +30669,8 @@ int sp_ecc_mulmod_384(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -30850,10 +30765,8 @@ int sp_ecc_mulmod_add_384(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -49194,8 +49107,7 @@ static int sp_384_ecc_mulmod_add_only_6(sp_point_384* r, const sp_point_384* g, #endif } #ifdef WOLFSSL_SP_SMALL_STACK - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -49328,8 +49240,7 @@ static int sp_384_ecc_mulmod_add_only_avx2_6(sp_point_384* r, const sp_point_384 #endif } #ifdef WOLFSSL_SP_SMALL_STACK - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -49405,10 +49316,8 @@ int sp_ecc_mulmod_base_384(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -49501,10 +49410,8 @@ int sp_ecc_mulmod_base_add_384(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -49674,8 +49581,7 @@ int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -49861,10 +49767,8 @@ int sp_ecc_secret_gen_384(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -51190,10 +51094,8 @@ int sp_ecc_verify_384(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -51400,8 +51302,7 @@ static int sp_384_ecc_is_point_6(const sp_point_384* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -51440,8 +51341,7 @@ int sp_ecc_is_point_384(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -51562,10 +51462,8 @@ int sp_ecc_check_key_384(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -51652,10 +51550,8 @@ int sp_ecc_proj_add_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -51728,10 +51624,8 @@ int sp_ecc_proj_dbl_point_384(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -51800,10 +51694,8 @@ int sp_ecc_map_384(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -51961,8 +51853,7 @@ static int sp_384_mont_sqrt_6(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, NULL, DYNAMIC_TYPE_ECC); + XFREE(t1, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -52037,8 +51928,7 @@ int sp_ecc_uncompress_384(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -53620,10 +53510,8 @@ static int sp_521_ecc_mulmod_win_add_sub_9(sp_point_521* r, const sp_point_521* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -54685,10 +54573,8 @@ static int sp_521_ecc_mulmod_win_add_sub_avx2_9(sp_point_521* r, const sp_point_ } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -54890,8 +54776,7 @@ static int sp_521_gen_stripe_table_9(const sp_point_521* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -55020,10 +54905,8 @@ static int sp_521_ecc_mulmod_stripe_9(sp_point_521* r, const sp_point_521* g, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -55385,8 +55268,7 @@ static int sp_521_gen_stripe_table_avx2_9(const sp_point_521* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -55501,10 +55383,8 @@ static int sp_521_ecc_mulmod_stripe_avx2_9(sp_point_521* r, const sp_point_521* } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -55636,10 +55516,8 @@ int sp_ecc_mulmod_521(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -55734,10 +55612,8 @@ int sp_ecc_mulmod_add_521(const mp_int* km, const ecc_point* gm, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -90264,8 +90140,7 @@ static int sp_521_ecc_mulmod_add_only_9(sp_point_521* r, const sp_point_521* g, #endif } #ifdef WOLFSSL_SP_SMALL_STACK - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -90398,8 +90273,7 @@ static int sp_521_ecc_mulmod_add_only_avx2_9(sp_point_521* r, const sp_point_521 #endif } #ifdef WOLFSSL_SP_SMALL_STACK - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -90475,10 +90349,8 @@ int sp_ecc_mulmod_base_521(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -90571,10 +90443,8 @@ int sp_ecc_mulmod_base_add_521(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -90745,8 +90615,7 @@ int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); if (point != NULL) { /* point is not sensitive, so no need to zeroize */ XFREE(point, heap, DYNAMIC_TYPE_ECC); @@ -90932,10 +90801,8 @@ int sp_ecc_secret_gen_521(const mp_int* priv, const ecc_point* pub, byte* out, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -92331,10 +92198,8 @@ int sp_ecc_verify_521(const byte* hash, word32 hashLen, const mp_int* pX, } #ifdef WOLFSSL_SP_SMALL_STACK - if (u1 != NULL) - XFREE(u1, heap, DYNAMIC_TYPE_ECC); - if (p1 != NULL) - XFREE(p1, heap, DYNAMIC_TYPE_ECC); + XFREE(u1, heap, DYNAMIC_TYPE_ECC); + XFREE(p1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -92544,8 +92409,7 @@ static int sp_521_ecc_is_point_9(const sp_point_521* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -92584,8 +92448,7 @@ int sp_ecc_is_point_521(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -92706,10 +92569,8 @@ int sp_ecc_check_key_521(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -92796,10 +92657,8 @@ int sp_ecc_proj_add_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -92872,10 +92731,8 @@ int sp_ecc_proj_dbl_point_521(mp_int* pX, mp_int* pY, mp_int* pZ, } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -92944,10 +92801,8 @@ int sp_ecc_map_521(mp_int* pX, mp_int* pY, mp_int* pZ) } #ifdef WOLFSSL_SP_SMALL_STACK - if (tmp != NULL) - XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); - if (p != NULL) - XFREE(p, NULL, DYNAMIC_TYPE_ECC); + XFREE(tmp, NULL, DYNAMIC_TYPE_ECC); + XFREE(p, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -93014,8 +92869,7 @@ static int sp_521_mont_sqrt_9(sp_digit* y) } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, NULL, DYNAMIC_TYPE_ECC); + XFREE(t, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -93090,8 +92944,7 @@ int sp_ecc_uncompress_521(mp_int* xm, int odd, mp_int* ym) } #ifdef WOLFSSL_SP_SMALL_STACK - if (x != NULL) - XFREE(x, NULL, DYNAMIC_TYPE_ECC); + XFREE(x, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -94881,10 +94734,8 @@ static int sp_1024_ecc_mulmod_win_add_sub_16(sp_point_1024* r, const sp_point_10 } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -95922,10 +95773,8 @@ static int sp_1024_ecc_mulmod_win_add_sub_avx2_16(sp_point_1024* r, const sp_poi } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (tmp != NULL) - XFREE(tmp, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(tmp, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -96127,8 +95976,7 @@ static int sp_1024_gen_stripe_table_16(const sp_point_1024* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -96227,10 +96075,8 @@ static int sp_1024_ecc_mulmod_stripe_16(sp_point_1024* r, const sp_point_1024* g } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -96591,8 +96437,7 @@ static int sp_1024_gen_stripe_table_avx2_16(const sp_point_1024* a, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -96691,10 +96536,8 @@ static int sp_1024_ecc_mulmod_stripe_avx2_16(sp_point_1024* r, const sp_point_10 } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (rt != NULL) - XFREE(rt, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(rt, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -96825,10 +96668,8 @@ int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm, ecc_point* r, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -100258,10 +100099,8 @@ int sp_ecc_mulmod_base_1024(const mp_int* km, ecc_point* r, int map, void* heap) } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -100354,10 +100193,8 @@ int sp_ecc_mulmod_base_add_1024(const mp_int* km, const ecc_point* am, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -100431,10 +100268,8 @@ int sp_ecc_gen_table_1024(const ecc_point* gm, byte* table, word32* len, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t != NULL) - XFREE(t, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(t, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -100536,10 +100371,8 @@ int sp_ecc_mulmod_table_1024(const mp_int* km, const ecc_point* gm, byte* table, } #ifdef WOLFSSL_SP_SMALL_STACK - if (k != NULL) - XFREE(k, heap, DYNAMIC_TYPE_ECC); - if (point != NULL) - XFREE(point, heap, DYNAMIC_TYPE_ECC); + XFREE(k, heap, DYNAMIC_TYPE_ECC); + XFREE(point, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -100686,9 +100519,7 @@ static int sp_ModExp_Fp_star_x64_1024(const mp_int* base, mp_int* exp, mp_int* r #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -102328,9 +102159,7 @@ static int sp_ModExp_Fp_star_x64_1024(const mp_int* base, mp_int* exp, mp_int* r #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -102478,9 +102307,7 @@ static int sp_ModExp_Fp_star_avx2_1024(const mp_int* base, mp_int* exp, mp_int* #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -102577,9 +102404,7 @@ static int sp_ModExp_Fp_star_avx2_1024(const mp_int* base, mp_int* exp, mp_int* #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return err; } @@ -102978,9 +102803,7 @@ static int sp_Pairing_x64_1024(const ecc_point* pm, const ecc_point* qm, mp_int* #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_16(c, 1, NULL); sp_1024_point_free_16(q, 1, NULL); @@ -103405,9 +103228,7 @@ static int sp_Pairing_x64_1024(const ecc_point* pm, const ecc_point* qm, mp_int* #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_16(c, 1, NULL); sp_1024_point_free_16(q, 1, NULL); @@ -103779,9 +103600,7 @@ static int sp_Pairing_avx2_1024(const ecc_point* pm, const ecc_point* qm, mp_int #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_16(c, 1, NULL); sp_1024_point_free_16(q, 1, NULL); @@ -104179,9 +103998,7 @@ static int sp_Pairing_avx2_1024(const ecc_point* pm, const ecc_point* qm, mp_int #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_16(c, 1, NULL); sp_1024_point_free_16(q, 1, NULL); @@ -104583,9 +104400,7 @@ static int sp_Pairing_gen_precomp_x64_1024(const ecc_point* pm, byte* table, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_16(neg, 1, NULL); sp_1024_point_free_16(c, 1, NULL); @@ -104778,9 +104593,7 @@ static int sp_Pairing_precomp_x64_1024(const ecc_point* pm, const ecc_point* qm, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_16(c, 1, NULL); sp_1024_point_free_16(q, 1, NULL); @@ -105120,9 +104933,7 @@ static int sp_Pairing_gen_precomp_avx2_1024(const ecc_point* pm, byte* table, #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_16(neg, 1, NULL); sp_1024_point_free_16(c, 1, NULL); @@ -105315,9 +105126,7 @@ static int sp_Pairing_precomp_avx2_1024(const ecc_point* pm, const ecc_point* qm #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \ defined(WOLFSSL_SP_SMALL_STACK) - if (td != NULL) { - XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif sp_1024_point_free_16(c, 1, NULL); sp_1024_point_free_16(q, 1, NULL); @@ -105485,8 +105294,7 @@ static int sp_1024_ecc_is_point_16(const sp_point_1024* point, } #ifdef WOLFSSL_SP_SMALL_STACK - if (t1 != NULL) - XFREE(t1, heap, DYNAMIC_TYPE_ECC); + XFREE(t1, heap, DYNAMIC_TYPE_ECC); #endif return err; @@ -105525,8 +105333,7 @@ int sp_ecc_is_point_1024(const mp_int* pX, const mp_int* pY) } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return err; @@ -105647,10 +105454,8 @@ int sp_ecc_check_key_1024(const mp_int* pX, const mp_int* pY, } #ifdef WOLFSSL_SP_SMALL_STACK - if (pub != NULL) - XFREE(pub, heap, DYNAMIC_TYPE_ECC); - if (priv != NULL) - XFREE(priv, heap, DYNAMIC_TYPE_ECC); + XFREE(pub, heap, DYNAMIC_TYPE_ECC); + XFREE(priv, heap, DYNAMIC_TYPE_ECC); #endif return err; diff --git a/wolfcrypt/src/srp.c b/wolfcrypt/src/srp.c index 5216fecf3f..717a93822e 100644 --- a/wolfcrypt/src/srp.c +++ b/wolfcrypt/src/srp.c @@ -903,10 +903,8 @@ int wc_SrpComputeKey(Srp* srp, byte* clientPubKey, word32 clientPubKeySz, } #ifdef WOLFSSL_SMALL_STACK - if (hash) - XFREE(hash, srp->heap, DYNAMIC_TYPE_SRP); - if (digest) - XFREE(digest, srp->heap, DYNAMIC_TYPE_SRP); + XFREE(hash, srp->heap, DYNAMIC_TYPE_SRP); + XFREE(digest, srp->heap, DYNAMIC_TYPE_SRP); if (u) { if (r != WC_NO_ERR_TRACE(MP_INIT_E)) mp_clear(u); diff --git a/wolfcrypt/src/wc_kyber.c b/wolfcrypt/src/wc_kyber.c index a99cd6c1e9..ffa37d84c1 100644 --- a/wolfcrypt/src/wc_kyber.c +++ b/wolfcrypt/src/wc_kyber.c @@ -286,9 +286,7 @@ int wc_KyberKey_MakeKeyWithRandom(KyberKey* key, const unsigned char* rand, } /* Free dynamic memory allocated in function. */ - if (a != NULL) { - XFREE(a, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(a, key->heap, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -892,9 +890,7 @@ int wc_KyberKey_Decapsulate(KyberKey* key, unsigned char* ss, #ifndef USE_INTEL_SPEEDUP /* Dispose of dynamic memory allocated in function. */ - if (cmp != NULL) { - XFREE(cmp, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(cmp, key->heap, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; diff --git a/wolfcrypt/src/wc_pkcs11.c b/wolfcrypt/src/wc_pkcs11.c index a7b00f8ade..78d78dc1a9 100644 --- a/wolfcrypt/src/wc_pkcs11.c +++ b/wolfcrypt/src/wc_pkcs11.c @@ -559,9 +559,7 @@ static int Pkcs11Slot_FindByTokenName(Pkcs11Dev* dev, } out: - if (slot != NULL) { - XFREE(slot, dev->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(slot, dev->heap, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -629,9 +627,7 @@ static int Pkcs11Token_Init(Pkcs11Token* token, Pkcs11Dev* dev, int slotId, token->userPinLogin = 0; } - if (slot != NULL) { - XFREE(slot, dev->heap, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(slot, dev->heap, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -1154,8 +1150,7 @@ static int Pkcs11CreateEccPublicKey(CK_OBJECT_HANDLE* publicKey, } } - if (ecPoint != NULL) - XFREE(ecPoint, public_key->heap, DYNAMIC_TYPE_ECC); + XFREE(ecPoint, public_key->heap, DYNAMIC_TYPE_ECC); return ret; } @@ -1732,10 +1727,8 @@ static int Pkcs11GetRsaPublicKey(RsaKey* key, Pkcs11Session* session, if (ret == 0) ret = wc_RsaPublicKeyDecodeRaw(mod, modSz, exp, expSz, key); - if (exp != NULL) - XFREE(exp, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - if (mod != NULL) - XFREE(mod, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(exp, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(mod, key->heap, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -2238,8 +2231,7 @@ static int Pkcs11FindEccKey(CK_OBJECT_HANDLE* key, CK_OBJECT_CLASS keyClass, } } - if (ecPoint != NULL) - XFREE(ecPoint, eccKey->heap, DYNAMIC_TYPE_ECC); + XFREE(ecPoint, eccKey->heap, DYNAMIC_TYPE_ECC); return ret; } @@ -2322,8 +2314,7 @@ static int Pkcs11GetEccPublicKey(ecc_key* key, Pkcs11Session* session, key->type = ECC_PUBLICKEY; } - if (point != NULL) - XFREE(point, key->heap, DYNAMIC_TYPE_ECC); + XFREE(point, key->heap, DYNAMIC_TYPE_ECC); return ret; } @@ -3008,9 +2999,7 @@ static int wc_Pkcs11CheckPrivKey_Rsa(RsaKey* priv, wc_FreeRsaKey(pub); } #ifdef WOLFSSL_SMALL_STACK - if (pub != NULL) { - XFREE(pub, NULL, DYNAMIC_TYPE_RSA); - } + XFREE(pub, NULL, DYNAMIC_TYPE_RSA); #endif return ret; @@ -3155,9 +3144,7 @@ static int wc_Pkcs11CheckPrivKey_Ecc(ecc_key* priv, wc_ecc_free(pub); } #ifdef WOLFSSL_SMALL_STACK - if (pub != NULL) { - XFREE(pub, NULL, DYNAMIC_TYPE_ECC); - } + XFREE(pub, NULL, DYNAMIC_TYPE_ECC); #endif return ret; diff --git a/wolfcrypt/src/wolfmath.c b/wolfcrypt/src/wolfmath.c index eb5f5419cf..b7853dd8fd 100644 --- a/wolfcrypt/src/wolfmath.c +++ b/wolfcrypt/src/wolfmath.c @@ -358,9 +358,7 @@ void wc_bigint_zero(WC_BIGINT* a) void wc_bigint_free(WC_BIGINT* a) { if (a) { - if (a->buf) { - XFREE(a->buf, a->heap, DYNAMIC_TYPE_WOLF_BIGINT); - } + XFREE(a->buf, a->heap, DYNAMIC_TYPE_WOLF_BIGINT); a->buf = NULL; a->len = 0; } diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 59d415883e..b0a56c224b 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -5336,8 +5336,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t shake128_test(void) wc_Shake128_Free(&sha); #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (large_input != NULL) - XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -5675,8 +5674,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t shake256_test(void) wc_Shake256_Free(&sha); #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (large_input != NULL) - XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -8871,8 +8869,7 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key, } EVP_TEST_END: - if (cipher) - XFREE(cipher, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(cipher, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); (void)cipherSz; if (ctx_inited) { @@ -9257,11 +9254,9 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key, wc_AesFree(dec); #endif #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (enc) - XFREE(enc, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(enc, HEAP_HINT, DYNAMIC_TYPE_AES); #ifdef HAVE_AES_DECRYPT - if (dec) - XFREE(dec, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(dec, HEAP_HINT, DYNAMIC_TYPE_AES); #endif #endif @@ -9590,11 +9585,9 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key, #endif #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (enc) - XFREE(enc, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(enc, HEAP_HINT, DYNAMIC_TYPE_AES); #ifdef HAVE_AES_DECRYPT - if (dec) - XFREE(dec, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(dec, HEAP_HINT, DYNAMIC_TYPE_AES); #endif #endif @@ -9855,11 +9848,9 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key, #endif #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (enc) - XFREE(enc, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(enc, HEAP_HINT, DYNAMIC_TYPE_AES); #ifdef HAVE_AES_DECRYPT - if (dec) - XFREE(dec, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(dec, HEAP_HINT, DYNAMIC_TYPE_AES); #endif #endif @@ -10070,11 +10061,9 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key, #endif #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (enc) - XFREE(enc, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(enc, HEAP_HINT, DYNAMIC_TYPE_AES); #ifdef HAVE_AES_DECRYPT - if (dec) - XFREE(dec, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(dec, HEAP_HINT, DYNAMIC_TYPE_AES); #endif #endif @@ -10910,16 +10899,14 @@ static wc_test_ret_t aes_xts_128_test(void) #if !defined(BENCH_EMBEDDED) && !defined(HAVE_CAVIUM) && \ !defined(WOLFSSL_AFALG) && defined(WOLFSSL_SMALL_STACK) && \ !defined(WOLFSSL_NO_MALLOC) - if (large_input) - XFREE(large_input, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(large_input, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif if (aes_inited) wc_AesXtsFree(aes); #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (aes) - XFREE(aes, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(aes, HEAP_HINT, DYNAMIC_TYPE_AES); #endif return ret; @@ -11612,16 +11599,14 @@ static wc_test_ret_t aes_xts_192_test(void) #if !defined(BENCH_EMBEDDED) && !defined(HAVE_CAVIUM) && \ !defined(WOLFSSL_AFALG) && defined(WOLFSSL_SMALL_STACK) && \ !defined(WOLFSSL_NO_MALLOC) - if (large_input) - XFREE(large_input, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(large_input, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif if (aes_inited) wc_AesXtsFree(aes); #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (aes) - XFREE(aes, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(aes, HEAP_HINT, DYNAMIC_TYPE_AES); #endif return ret; @@ -12069,16 +12054,14 @@ static wc_test_ret_t aes_xts_256_test(void) #if !defined(BENCH_EMBEDDED) && !defined(HAVE_CAVIUM) && \ !defined(WOLFSSL_AFALG) && defined(WOLFSSL_SMALL_STACK) && \ !defined(WOLFSSL_NO_MALLOC) - if (large_input) - XFREE(large_input, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(large_input, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif if (aes_inited) wc_AesXtsFree(aes); #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (aes) - XFREE(aes, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(aes, HEAP_HINT, DYNAMIC_TYPE_AES); #endif return ret; @@ -12382,8 +12365,7 @@ static wc_test_ret_t aes_xts_sector_test(void) wc_AesXtsFree(aes); #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (aes) - XFREE(aes, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(aes, HEAP_HINT, DYNAMIC_TYPE_AES); #endif return ret; @@ -12492,8 +12474,7 @@ static wc_test_ret_t aes_xts_args_test(void) wc_AesXtsFree(aes); #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (aes) - XFREE(aes, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(aes, HEAP_HINT, DYNAMIC_TYPE_AES); #endif return ret; @@ -13663,8 +13644,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_test(void) if ((bigCipher == NULL) || (bigPlain == NULL)) { - if (bigCipher != NULL) - XFREE(bigCipher, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(bigCipher, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); ERROR_OUT(WC_TEST_RET_ENC_NC, out); } #else @@ -15450,20 +15430,15 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aesgcm_test(void) #if !defined(BENCH_EMBEDDED) && !defined(HAVE_CAVIUM) && \ !defined(WOLFSSL_NO_MALLOC) - if (large_input) - XFREE(large_input, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (large_output) - XFREE(large_output, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (large_outdec) - XFREE(large_outdec, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(large_input, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(large_output, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(large_outdec, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (enc) - XFREE(enc, HEAP_HINT, DYNAMIC_TYPE_AES); - if (dec) - XFREE(dec, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(enc, HEAP_HINT, DYNAMIC_TYPE_AES); + XFREE(dec, HEAP_HINT, DYNAMIC_TYPE_AES); #endif return ret; @@ -17284,12 +17259,9 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t XChaCha_test(void) { out: #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (chacha) - XFREE(chacha, HEAP_HINT, DYNAMIC_TYPE_CIPHER); - if (buf1) - XFREE(buf1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (buf2) - XFREE(buf2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(chacha, HEAP_HINT, DYNAMIC_TYPE_CIPHER); + XFREE(buf1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(buf2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -17380,10 +17352,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t XChaCha20Poly1305_test(void) { out: #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (buf1 != NULL) - XFREE(buf1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (buf2 != NULL) - XFREE(buf2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(buf1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(buf2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -17918,8 +17888,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void) b = c; } #endif - if (b) - XFREE(b, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(b, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); if (b == NULL #ifndef WOLFSSL_NO_REALLOC || c == NULL @@ -18324,8 +18293,7 @@ static wc_test_ret_t cert_asn1_test(void) ret = 0; done: - if (badCert != NULL) - XFREE(badCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(badCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -20583,8 +20551,7 @@ static wc_test_ret_t rsa_certgen_test(RsaKey* key, RsaKey* keypub, WC_RNG* rng, XFREE(caKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); } #ifdef WOLFSSL_TEST_CERT - if (decode != NULL) - XFREE(decode, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(decode, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif #else wc_FreeRsaKey(caKey); @@ -20820,8 +20787,7 @@ static wc_test_ret_t rsa_ecc_certgen_test(WC_RNG* rng, byte* tmp) XFREE(caEccKeyPub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); } #ifdef WOLFSSL_TEST_CERT - if (decode != NULL) - XFREE(decode, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(decode, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif #else wc_FreeRsaKey(caKey); @@ -20940,10 +20906,8 @@ static wc_test_ret_t rsa_keygen_test(WC_RNG* rng) #endif #ifndef WOLFSSL_NO_MALLOC - if (der != NULL) { - XFREE(der, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - der = NULL; - } + XFREE(der, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + der = NULL; #endif return ret; @@ -21925,8 +21889,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t rsa_test(void) } #endif #ifdef WOLFSSL_TEST_CERT - if (cert != NULL) - XFREE(cert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(cert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif XFREE(der, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); @@ -22301,8 +22264,7 @@ static wc_test_ret_t dh_generate_test(WC_RNG *rng) wc_FreeDhKey(smallKey); #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (smallKey != NULL) - XFREE(smallKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(smallKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -22541,18 +22503,12 @@ static wc_test_ret_t dh_ffdhe_test(WC_RNG *rng, int name) #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) && \ !defined(WC_NO_RNG) - if (priv) - XFREE(priv, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (pub) - XFREE(pub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (priv2) - XFREE(priv2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (pub2) - XFREE(pub2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (agree) - XFREE(agree, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (agree2) - XFREE(agree2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(priv, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(pub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(priv2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(pub2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(agree, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(agree2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); if (key) { wc_FreeDhKey(key); XFREE(key, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); @@ -22975,20 +22931,13 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t dh_test(void) wc_FreeDhKey(key2); XFREE(key2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); } - if (tmp) - XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (priv) - XFREE(priv, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (pub) - XFREE(pub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (priv2) - XFREE(priv2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (pub2) - XFREE(pub2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (agree) - XFREE(agree, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (agree2) - XFREE(agree2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(priv, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(pub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(priv2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(pub2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(agree, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(agree2, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #else if (keyInit) wc_FreeDhKey(key); @@ -23165,13 +23114,11 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t dsa_test(void) out: #ifdef WOLFSSL_KEY_GEN - if (der) - XFREE(der, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(der, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (tmp) - XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); if (key) { if (key_inited) wc_FreeDsaKey(key); @@ -23362,14 +23309,10 @@ static wc_test_ret_t srp_test_digest(SrpType dgstType) #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) out: - if (cli) - XFREE(cli, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (srv) - XFREE(srv, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (clientProof) - XFREE(clientProof, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (serverProof) - XFREE(serverProof, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(cli, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(srv, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(clientProof, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(serverProof, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif return r; @@ -26085,12 +26028,9 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t openssl_pkey1_test(void) } #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (tmp != NULL) - XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (cipher != NULL) - XFREE(cipher, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (plain != NULL) - XFREE(plain, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(cipher, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(plain, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif #endif @@ -28009,8 +27949,7 @@ static wc_test_ret_t hpke_test_single(Hpke* hpke) wc_HpkeFreeKey(hpke, hpke->kem, receiverKey, hpke->heap); #ifdef WOLFSSL_SMALL_STACK - if (pubKey != NULL) - XFREE(pubKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(pubKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif if (rngRet == 0) @@ -29428,16 +29367,11 @@ static wc_test_ret_t ecc384_test_deterministic_k(WC_RNG* rng) mp_free(expS); } #ifdef WOLFSSL_SMALL_STACK - if (key != NULL) - XFREE(key, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (r != NULL) - XFREE(r, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (s != NULL) - XFREE(s, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (expR != NULL) - XFREE(expR, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (expS != NULL) - XFREE(expS, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(key, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(r, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(s, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(expR, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(expS, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -29584,16 +29518,11 @@ static wc_test_ret_t ecc521_test_deterministic_k(WC_RNG* rng) mp_free(expS); } #ifdef WOLFSSL_SMALL_STACK - if (key != NULL) - XFREE(key, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (r != NULL) - XFREE(r, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (s != NULL) - XFREE(s, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (expR != NULL) - XFREE(expR, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (expS != NULL) - XFREE(expS, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(key, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(r, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(s, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(expR, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(expS, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -30092,13 +30021,10 @@ static wc_test_ret_t ecc_test_make_pub(WC_RNG* rng) XFREE(key, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); } #if defined(HAVE_ECC_DHE) && defined(HAVE_ECC_KEY_EXPORT) - if (pub != NULL) - XFREE(pub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(pub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif - if (exportBuf != NULL) - XFREE(exportBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (tmp != NULL) - XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(exportBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #else wc_ecc_free(key); #endif @@ -30177,8 +30103,7 @@ static wc_test_ret_t ecc_test_key_decode(WC_RNG* rng, int keySize) wc_ecc_free(eccKey); XFREE(eccKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); } - if (tmpBuf != NULL) - XFREE(tmpBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmpBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #else wc_ecc_free(eccKey); #endif @@ -30282,8 +30207,7 @@ static wc_test_ret_t ecc_test_key_gen(WC_RNG* rng, int keySize) done: #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (der != NULL) - XFREE(der, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(der, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); if (userA != NULL) { wc_ecc_free(userA); XFREE(userA, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); @@ -31516,9 +31440,7 @@ static wc_test_ret_t ecc_def_curve_test(WC_RNG *rng) wc_ecc_free(key); #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (key != NULL) { - XFREE(key, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(key, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -32639,11 +32561,9 @@ static wc_test_ret_t ecc_test_cert_gen(WC_RNG* rng) #endif #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (myCert != NULL) - XFREE(myCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(myCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #ifdef WOLFSSL_TEST_CERT - if (decode != NULL) - XFREE(decode, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(decode, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif if (caEccKey != NULL) { wc_ecc_free(caEccKey); @@ -33117,9 +33037,7 @@ static wc_test_ret_t ecc_test_nonblock_ecdsa(int curveId, word32 curveSz, sigSz, curveSz, curveId); } - if (sig != NULL) { - XFREE(sig, HEAP_HINT, DYNAMIC_TYPE_SIGNATURE); - } + XFREE(sig, HEAP_HINT, DYNAMIC_TYPE_SIGNATURE); return ret; } @@ -33838,13 +33756,9 @@ static wc_test_ret_t ecc_encrypt_kat(WC_RNG *rng) wc_ecc_free(userA); #endif #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (userB != NULL) { - XFREE(userB, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(userB, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #ifdef WOLFSSL_ECIES_OLD - if (userA != NULL) { - XFREE(userA, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(userA, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif #endif @@ -35120,8 +35034,7 @@ static wc_test_ret_t ed25519_test_cert(void) #endif /* HAVE_ED25519_VERIFY */ done: - if (tmp != NULL) - XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #ifdef HAVE_ED25519_VERIFY wc_ed25519_free(pubKey); #endif /* HAVE_ED25519_VERIFY */ @@ -35194,8 +35107,7 @@ static wc_test_ret_t ed25519_test_make_cert(void) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done); done: - if (tmp != NULL) - XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); wc_ed25519_free(privKey); wc_FreeRng(&rng); return ret; @@ -36636,8 +36548,7 @@ static wc_test_ret_t ed448_test_cert(void) #endif /* HAVE_ED448_VERIFY */ done: - if (tmp != NULL) - XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #ifdef HAVE_ED448_VERIFY wc_ed448_free(pubKey); #endif /* HAVE_ED448_VERIFY */ @@ -36710,8 +36621,7 @@ static wc_test_ret_t ed448_test_make_cert(void) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done); done: - if (tmp != NULL) - XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(tmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); wc_ed448_free(privKey); wc_FreeRng(&rng); return ret; @@ -42622,20 +42532,14 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t xmss_test(void) } /* Cleanup everything. */ - if (sig != NULL) { - XFREE(sig, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - sig = NULL; - } + XFREE(sig, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + sig = NULL; - if (sk != NULL) { - XFREE(sk, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - sk = NULL; - } + XFREE(sk, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + sk = NULL; - if (old_sk != NULL) { - XFREE(old_sk, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - old_sk = NULL; - } + XFREE(old_sk, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + old_sk = NULL; wc_XmssKey_Free(&signingKey); wc_FreeRng(&rng); @@ -45280,10 +45184,8 @@ static wc_test_ret_t sakke_kat_derive_test(SakkeKey* key, ecc_point* rsk) if (ret != 0) return WC_TEST_RET_ENC_EC(ret); /* Dispose of tables */ - if (iTable != NULL) - XFREE(iTable, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (table != NULL) - XFREE(table, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(iTable, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(table, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); /* Make sure the key public key is exportable - convert to Montgomery form * in Validation. @@ -45778,8 +45680,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t sakke_test(void) } if (rng_inited) wc_FreeRng(&rng); - if (key != NULL) - XFREE(key, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(key, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); if (pub != NULL) { wc_FreeSakkeKey(pub); XFREE(pub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); @@ -46050,8 +45951,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t cmac_test(void) out: #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (cmac) - XFREE(cmac, HEAP_HINT, DYNAMIC_TYPE_CMAC); + XFREE(cmac, HEAP_HINT, DYNAMIC_TYPE_CMAC); #endif return ret; @@ -46706,8 +46606,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t compress_test(void) ret = 0; /* success */ exit: - if (c) XFREE(c, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (d) XFREE(d, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(c, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(d, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -47750,12 +47650,9 @@ static wc_test_ret_t pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz, (void)rsaPrivKeySz; out: - if (testVectors) - XFREE(testVectors, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (enveloped) - XFREE(enveloped, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (decoded) - XFREE(decoded, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(testVectors, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(enveloped, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(decoded, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -48458,12 +48355,9 @@ static wc_test_ret_t pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCer #endif out: - if (testVectors) - XFREE(testVectors, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (enveloped) - XFREE(enveloped, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (decoded) - XFREE(decoded, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(testVectors, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(enveloped, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(decoded, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -48926,12 +48820,10 @@ static wc_test_ret_t verifyBundle(byte* derBuf, word32 derSz, int keyHint) out: - if (decoded) - XFREE(decoded, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(decoded, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); if (pkcs7) wc_PKCS7_Free(pkcs7); - if (sid) - XFREE(sid, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(sid, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -48988,8 +48880,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t pkcs7callback_test(byte* cert, word32 cert ret = 0; out: - if (derBuf) - XFREE(derBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(derBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -49258,10 +49149,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t pkcs7encrypted_test(void) } out: - if (encrypted) - XFREE(encrypted, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (decoded) - XFREE(decoded, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(encrypted, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(decoded, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); return ret; } @@ -49384,10 +49273,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t pkcs7compressed_test(void) out: #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) - if (compressed) - XFREE(compressed, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (decoded) - XFREE(decoded, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(compressed, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(decoded, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -49910,10 +49797,8 @@ static wc_test_ret_t pkcs7signed_run_vectors( if (pkcs7 != NULL) wc_PKCS7_Free(pkcs7); - if (out != NULL) - XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - if (testVectors != NULL) - XFREE(testVectors, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(testVectors, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); wc_FreeRng(&rng); if (ret > 0) @@ -50444,15 +50329,12 @@ static wc_test_ret_t pkcs7signed_run_SingleShotVectors( if (pkcs7 != NULL) wc_PKCS7_Free(pkcs7); - if (out != NULL) - XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #if defined(HAVE_LIBZ) && !defined(NO_PKCS7_COMPRESSED_DATA) && \ !defined(NO_PKCS7_ENCRYPTED_DATA) - if (encryptedTmp != NULL) - XFREE(encryptedTmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(encryptedTmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif - if (testVectors != NULL) - XFREE(testVectors, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(testVectors, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); wc_FreeRng(&rng); if (ret > 0) @@ -54896,12 +54778,8 @@ static wc_test_ret_t ecc_onlycb_test(myCryptoDevCtx *ctx) wc_ecc_free(key); XFREE(key, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); } - if (pub != NULL) { - XFREE(pub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - } - if (out != NULL) { - XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - } + XFREE(pub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #ifdef OPENSSL_EXTRA if (check) { FREE(check, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); diff --git a/wolfssl/wolfcrypt/types.h b/wolfssl/wolfcrypt/types.h index 5292168116..a540699e64 100644 --- a/wolfssl/wolfcrypt/types.h +++ b/wolfssl/wolfcrypt/types.h @@ -437,7 +437,13 @@ typedef struct w64wrapper { /* idea to add global alloc override by Moises Guimaraes */ /* default to libc stuff */ /* XREALLOC is used once in normal math lib, not in fast math lib */ - /* XFREE on some embedded systems doesn't like free(0) so test */ + /* XFREE on some embedded systems doesn't like free(0) so test for NULL + * explicitly. + * + * For example: + * #define XFREE(p, h, t) \ + * {void* xp = (p); if (xp != NULL) free(xp, h, t);} + */ #if defined(HAVE_IO_POOL) WOLFSSL_API void* XMALLOC(size_t n, void* heap, int type); WOLFSSL_API void* XREALLOC(void *p, size_t n, void* heap, int type);