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 17ecf421a9..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 @@ -781,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/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/src/internal.c b/src/internal.c index 7f9e9ca725..7d02dce0a8 100644 --- a/src/internal.c +++ b/src/internal.c @@ -13952,9 +13952,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) { @@ -41182,9 +41180,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/pk.c b/src/pk.c index 21dc32f258..84e92edd42 100644 --- a/src/pk.c +++ b/src/pk.c @@ -7799,9 +7799,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/ssl.c b/src/ssl.c index 28753936d5..0afee747c8 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; } } 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_p7p12.c b/src/ssl_p7p12.c index d91d0b0921..f76f5174ed 100644 --- a/src/ssl_p7p12.c +++ b/src/ssl_p7p12.c @@ -625,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 @@ -744,9 +742,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; @@ -1603,12 +1599,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; @@ -1736,9 +1728,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; @@ -1900,12 +1890,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; @@ -1939,12 +1925,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; @@ -1962,12 +1944,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) { @@ -1993,9 +1971,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; } @@ -2011,9 +1987,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; } diff --git a/src/tls.c b/src/tls.c index dda427ed5d..242afbcea9 100644 --- a/src/tls.c +++ b/src/tls.c @@ -5974,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; } diff --git a/src/x509.c b/src/x509.c index 534f18a0ab..8d9c1004af 100644 --- a/src/x509.c +++ b/src/x509.c @@ -6573,9 +6573,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); } @@ -8331,9 +8329,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); } diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index 6a3a341c17..6c63ad6680 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -13694,9 +13694,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 22a57e9981..16059e1c45 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); @@ -24321,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); diff --git a/wolfcrypt/src/cmac.c b/wolfcrypt/src/cmac.c index 5e0faecec5..a31d374865 100644 --- a/wolfcrypt/src/cmac.c +++ b/wolfcrypt/src/cmac.c @@ -414,9 +414,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 +493,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/ecc.c b/wolfcrypt/src/ecc.c index 7a1f869c1e..e336b39af6 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -9526,12 +9526,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); @@ -10797,12 +10793,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); diff --git a/wolfcrypt/src/evp.c b/wolfcrypt/src/evp.c index b53d6eca97..a5876e0675 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) { 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/pkcs12.c b/wolfcrypt/src/pkcs12.c index d6cf526221..632873bbb5 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,12 +189,8 @@ 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); } @@ -856,9 +850,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 +1091,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; } diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index d07f1f7889..923893c0d0 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; } diff --git a/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c b/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c index e40fdf7287..55bb0c7fce 100644 --- a/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c +++ b/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c @@ -1069,9 +1069,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_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_util.c b/wolfcrypt/src/port/Renesas/renesas_tsip_util.c index 6097eb0e16..294b728e9b 100644 --- a/wolfcrypt/src/port/Renesas/renesas_tsip_util.c +++ b/wolfcrypt/src/port/Renesas/renesas_tsip_util.c @@ -2428,10 +2428,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 +3545,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/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/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..3a231a77d8 100644 --- a/wolfcrypt/src/port/nxp/se050_port.c +++ b/wolfcrypt/src/port/nxp/se050_port.c @@ -1228,9 +1228,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 +1390,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 +1575,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 +1740,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/sp_arm32.c b/wolfcrypt/src/sp_arm32.c index ebfbb6f6fb..1e67bce317 100644 --- a/wolfcrypt/src/sp_arm32.c +++ b/wolfcrypt/src/sp_arm32.c @@ -153188,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; } @@ -155086,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; } @@ -155456,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); @@ -155883,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); @@ -156251,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); @@ -156446,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); diff --git a/wolfcrypt/src/sp_arm64.c b/wolfcrypt/src/sp_arm64.c index 6fd62e7131..a437258d1a 100644 --- a/wolfcrypt/src/sp_arm64.c +++ b/wolfcrypt/src/sp_arm64.c @@ -122101,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; } @@ -123743,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; } @@ -124113,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); @@ -124540,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); @@ -124908,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); @@ -125103,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); diff --git a/wolfcrypt/src/sp_armthumb.c b/wolfcrypt/src/sp_armthumb.c index 8a5ccbf1d0..de83f3da72 100644 --- a/wolfcrypt/src/sp_armthumb.c +++ b/wolfcrypt/src/sp_armthumb.c @@ -215179,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; } @@ -217077,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; } @@ -217447,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); @@ -217874,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); @@ -218242,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); @@ -218437,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); diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index bd70fd977b..8365c1336f 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -51227,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; } @@ -53125,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; } @@ -53495,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); @@ -53922,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); @@ -54290,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); @@ -54485,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); diff --git a/wolfcrypt/src/sp_c64.c b/wolfcrypt/src/sp_c64.c index 96163753ae..0d3ab51336 100644 --- a/wolfcrypt/src/sp_c64.c +++ b/wolfcrypt/src/sp_c64.c @@ -50056,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; } @@ -51698,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; } @@ -52068,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); @@ -52495,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); @@ -52863,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); @@ -53058,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); diff --git a/wolfcrypt/src/sp_cortexm.c b/wolfcrypt/src/sp_cortexm.c index 9be9c99931..7632528e15 100644 --- a/wolfcrypt/src/sp_cortexm.c +++ b/wolfcrypt/src/sp_cortexm.c @@ -78471,9 +78471,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; } @@ -80369,9 +80367,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; } @@ -80739,9 +80735,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); @@ -81166,9 +81160,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); @@ -81534,9 +81526,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); @@ -81729,9 +81719,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); diff --git a/wolfcrypt/src/sp_dsp32.c b/wolfcrypt/src/sp_dsp32.c index a814ee52d0..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; @@ -4630,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); @@ -4695,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); @@ -4753,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); @@ -4830,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; @@ -4905,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 1bd0762f67..636ebfb83e 100644 --- a/wolfcrypt/src/sp_x86_64.c +++ b/wolfcrypt/src/sp_x86_64.c @@ -100519,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; } @@ -102161,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; } @@ -102311,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; } @@ -102410,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; } @@ -102811,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); @@ -103238,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); @@ -103612,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); @@ -104012,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); @@ -104416,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); @@ -104611,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); @@ -104953,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); @@ -105148,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); diff --git a/wolfcrypt/src/wc_pkcs11.c b/wolfcrypt/src/wc_pkcs11.c index a7b00f8ade..363d90c8da 100644 --- a/wolfcrypt/src/wc_pkcs11.c +++ b/wolfcrypt/src/wc_pkcs11.c @@ -3008,9 +3008,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 +3153,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/test/test.c b/wolfcrypt/test/test.c index e97ebbdd6f..3e0242292f 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -31442,9 +31442,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; @@ -33041,9 +33039,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; } @@ -33762,13 +33758,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 @@ -54794,12 +54786,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);