diff --git a/src/ssl.c b/src/ssl.c index a6dd2c75a..fcea7ee85 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -36407,6 +36407,7 @@ int wolfSSL_DH_LoadDer(WOLFSSL_DH* dh, const unsigned char* derBuf, int derSz) WOLFSSL_MSG("wc_DhKeyDecode failed"); return WOLFSSL_FATAL_ERROR; } + dh->inSet = 1; if (SetDhExternal(dh) != WOLFSSL_SUCCESS) { WOLFSSL_MSG("SetDhExternal failed"); diff --git a/tests/api.c b/tests/api.c index e306a21e8..d9c84548b 100644 --- a/tests/api.c +++ b/tests/api.c @@ -1271,6 +1271,7 @@ static void test_wolfSSL_CertManagerNameConstraint(void) XFREE(der, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); wolfSSL_X509_free(x509); + wc_FreeRsaKey(&key); wc_FreeRng(&rng); #endif } @@ -28357,27 +28358,30 @@ static int test_wolfSSL_GetLoggingCb (void) #ifdef DEBUG_WOLFSSL printf(testingFmt, "wolfSSL_GetLoggingCb()"); - /*Testing without wolfSSL_SetLoggingCb()*/ + /* Testing without wolfSSL_SetLoggingCb() */ if (ret == 0) { - if(wolfSSL_GetLoggingCb() == NULL){ /*Should be true*/ + if (wolfSSL_GetLoggingCb() == NULL) { /* Should be true */ ret = 0; } - if(wolfSSL_GetLoggingCb() != NULL){ /*Should not be true*/ + if (wolfSSL_GetLoggingCb() != NULL) { /* Should not be true */ ret = -1; } } - /*Testing with wolfSSL_SetLoggingCb()*/ + /* Testing with wolfSSL_SetLoggingCb() */ if (ret == 0) { ret = wolfSSL_SetLoggingCb(Logging_cb); if (ret == 0){ - if(wolfSSL_GetLoggingCb() == NULL){ /*Should not be true*/ + if (wolfSSL_GetLoggingCb() == NULL) { /* Should not be true */ ret = -1; } if (ret == 0) { - if(wolfSSL_GetLoggingCb() == Logging_cb){ /*Should be true*/ + if (wolfSSL_GetLoggingCb() == Logging_cb) { /* Should be true */ ret = 0; } } + + /* reset logging callback */ + wolfSSL_SetLoggingCb(NULL); } } printf(resultFmt, ret == 0 ? passed : failed); @@ -31560,16 +31564,11 @@ static void test_wolfSSL_EC_KEY_dup(void) /* NULL private key */ AssertNotNull(ecKey = wolfSSL_EC_KEY_new()); AssertIntEQ(wolfSSL_EC_KEY_generate_key(ecKey), 1); -#if defined(WOLFSSL_PUBLIC_MP) - mp_int* mp = (mp_int*)ecKey->priv_key->internal; - mp_forcezero(mp); - mp_free(mp); - ecKey->priv_key->internal = NULL; /* Set internal key to NULL */ - AssertNull(dupKey = wolfSSL_EC_KEY_dup(ecKey)); -#endif + wolfSSL_BN_free(ecKey->priv_key); ecKey->priv_key = NULL; /* Set priv_key to NULL */ AssertNull(dupKey = wolfSSL_EC_KEY_dup(ecKey)); + wolfSSL_EC_KEY_free(ecKey); wolfSSL_EC_KEY_free(dupKey); diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index c57e28b33..865a5a807 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -6919,7 +6919,7 @@ int wc_GmacVerify(const byte* key, word32 keySz, const byte* authTag, word32 authTagSz) { int ret; -#ifndef NO_AES_DECRYPT +#ifdef HAVE_AES_DECRYPT Aes aes; if (key == NULL || iv == NULL || (authIn == NULL && authInSz != 0) || diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index b92d339c4..9bde59606 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -1346,9 +1346,12 @@ static int wc_ecc_curve_cache_load_item(ecc_curve_spec* curve, const char* src, static int wc_ecc_curve_load(const ecc_set_type* dp, ecc_curve_spec** pCurve, byte load_mask) { - int ret = 0, x; + int ret = 0; ecc_curve_spec* curve; byte load_items = 0; /* mask of items to load */ +#ifdef ECC_CACHE_CURVE + int x; +#endif if (dp == NULL || pCurve == NULL) return BAD_FUNC_ARG; diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index db325b619..952712fa0 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -151,7 +151,20 @@ int sp_init_multi(sp_int* a, sp_int* b, sp_int* c, sp_int* d, sp_int* e, } #endif -/* Clear the data from the big number and set to zero. +/* Free the memory from the big number. + * + * a SP integer. + */ +void sp_free(sp_int* a) +{ + if (a != NULL) { + #ifdef HAVE_WOLF_BIGINT + wc_bigint_free(&a->raw); + #endif + } +} + +/* Clear and Free the data from the big number and set to zero. * * a SP integer. */ @@ -163,6 +176,8 @@ void sp_clear(sp_int* a) for (i=0; iused; i++) a->dp[i] = 0; a->used = 0; + + sp_free(a); } } diff --git a/wolfssl/internal.h b/wolfssl/internal.h index a9eade0de..925720fd2 100644 --- a/wolfssl/internal.h +++ b/wolfssl/internal.h @@ -911,7 +911,7 @@ #define BUILD_DES3 #endif -#if defined(NO_AES) || defined(NO_AES_DECRYPT) +#if defined(NO_AES) || !defined(HAVE_AES_DECRYPT) #define AES_BLOCK_SIZE 16 #undef BUILD_AES #else diff --git a/wolfssl/wolfcrypt/sp_int.h b/wolfssl/wolfcrypt/sp_int.h index f01c1d04b..f616b2471 100644 --- a/wolfssl/wolfcrypt/sp_int.h +++ b/wolfssl/wolfcrypt/sp_int.h @@ -189,6 +189,7 @@ typedef sp_int_digit mp_digit; MP_API int sp_init(sp_int* a); MP_API int sp_init_multi(sp_int* a, sp_int* b, sp_int* c, sp_int* d, sp_int* e, sp_int* f); +MP_API void sp_free(sp_int* a); MP_API void sp_clear(sp_int* a); MP_API int sp_unsigned_bin_size(sp_int* a); MP_API int sp_read_unsigned_bin(sp_int* a, const byte* in, word32 inSz); @@ -250,7 +251,7 @@ MP_API int sp_mul_d(sp_int* a, sp_int_digit n, sp_int* r); #define CheckFastMathSettings() 1 -#define mp_free(a) +#define mp_free(a) sp_free #define mp_isodd sp_isodd #define mp_iseven sp_iseven