From ea45da5fa87b369dd6ae6e061364447926c6aedc Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Sun, 20 Oct 2019 01:13:43 -0600 Subject: [PATCH] change add_all_* to be evp table init and fix valgrind report --- src/ssl.c | 4 +++- tests/api.c | 8 ++++++-- tests/suites.c | 4 ++++ wolfssl/openssl/evp.h | 4 ++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index 2b7599054..7cd12ae9f 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -6323,6 +6323,7 @@ int ProcessFile(WOLFSSL_CTX* ctx, const char* fname, int format, int type, WOLFSSL_MSG("Failed to detect certificate type"); if (dynamic) XFREE(myBuffer, heapHint, DYNAMIC_TYPE_FILE); + XFCLOSE(file); return WOLFSSL_BAD_CERTTYPE; } } @@ -16892,7 +16893,8 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md) { WOLFSSL_ENTER("wolfSSL_ERR_clear_error"); -#if defined(DEBUG_WOLFSSL) || defined(WOLFSSL_NGINX) +#if defined(DEBUG_WOLFSSL) || defined(WOLFSSL_NGINX) || \ + defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE) wc_ClearErrorNodes(); #endif } diff --git a/tests/api.c b/tests/api.c index 29614ab57..3a86d3f7e 100644 --- a/tests/api.c +++ b/tests/api.c @@ -19107,6 +19107,7 @@ static void test_wolfSSL_private_keys(void) SSL_free(ssl); SSL_CTX_free(ctx); #endif /* end of Ed25519 private key match tests */ + EVP_cleanup(); /* test existence of no-op macros in wolfssl/openssl/ssl.h */ CONF_modules_free(); @@ -28165,8 +28166,6 @@ static int test_various_pathlen_chains(void) WOLFSSL_CERT_MANAGER* cm; /* Test chain G (large chain with varying pathLens) */ - wolfSSL_Init(); - if ((cm = wolfSSL_CertManagerNew()) == NULL) { printf("cert manager new failed\n"); return -1; @@ -28648,6 +28647,7 @@ void ApiTest(void) AssertIntEQ(test_wc_DsaExportKeyRaw(), 0); AssertIntEQ(test_wc_SignatureGetSize_ecc(), 0); AssertIntEQ(test_wc_SignatureGetSize_rsa(), 0); + wolfCrypt_Cleanup(); #ifdef OPENSSL_EXTRA /*wolfSSL_EVP_get_cipherbynid test*/ @@ -28736,6 +28736,10 @@ void ApiTest(void) * a need to implement a new test case */ test_stubs_are_stubs(); +#if defined(HAVE_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS) \ + && (defined(NO_MAIN_DRIVER) || defined(HAVE_STACK_SIZE)) + wc_ecc_fp_free(); /* free per thread cache */ +#endif wolfSSL_Cleanup(); printf(" End API Tests\n"); diff --git a/tests/suites.c b/tests/suites.c index 252481cc1..c8eb2789d 100644 --- a/tests/suites.c +++ b/tests/suites.c @@ -998,6 +998,10 @@ exit: wolfSSL_CTX_free(cipherSuiteCtx); wolfSSL_Cleanup(); +#if defined(HAVE_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS) \ + && (defined(NO_MAIN_DRIVER) || defined(HAVE_STACK_SIZE)) + wc_ecc_fp_free(); /* free per thread cache */ +#endif #ifdef WOLFSSL_ASYNC_CRYPT wolfAsync_DevClose(&devId); #endif diff --git a/wolfssl/openssl/evp.h b/wolfssl/openssl/evp.h index faa68ffe7..07dbf300a 100644 --- a/wolfssl/openssl/evp.h +++ b/wolfssl/openssl/evp.h @@ -682,8 +682,8 @@ typedef WOLFSSL_EVP_CIPHER_CTX EVP_CIPHER_CTX; #define EVP_cleanup wolfSSL_EVP_cleanup #define EVP_read_pw_string wolfSSL_EVP_read_pw_string -#define OpenSSL_add_all_digests() wolfCrypt_Init() -#define OpenSSL_add_all_ciphers() wolfCrypt_Init() +#define OpenSSL_add_all_digests() wolfSSL_EVP_init() +#define OpenSSL_add_all_ciphers() wolfSSL_EVP_init() #define OpenSSL_add_all_algorithms wolfSSL_add_all_algorithms #define OpenSSL_add_all_algorithms_noconf wolfSSL_OpenSSL_add_all_algorithms_noconf #define wolfSSL_OPENSSL_add_all_algorithms_noconf wolfSSL_OpenSSL_add_all_algorithms_noconf