From f938617d45d1ef62a3315591174a7dc6862aa8b7 Mon Sep 17 00:00:00 2001 From: vnugent Date: Wed, 23 Oct 2024 21:59:03 -0400 Subject: fix: Add Valgrind to testing suite, openssl fixes --- Taskfile.yaml | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'Taskfile.yaml') diff --git a/Taskfile.yaml b/Taskfile.yaml index b19a135..7430244 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -37,7 +37,19 @@ tasks: cmds: - task: build-debug - cmd: cd {{ .CMAKE_BUILD_DIR }} && ctest -C Debug --verbose - + + dev: + watch: true + sources: + - include/* + - src/* + - src/*/* + - tests/* + - CMakelists.txt + - vendor/* + cmds: + - task: test-dev + test-mbedtls: desc: "Builds and runs tests for noscrypt using the mbedtls crypto library for the current platform" cmds: @@ -55,6 +67,7 @@ tasks: - task: compile vars: { BUILD_CONFIG: 'Debug' } - cmd: cd {{ .CMAKE_BUILD_DIR }} && ctest -C Debug --verbose --output-on-failure + - task: memcheck build-internal: internal: true @@ -84,7 +97,23 @@ tasks: - cmd: echo "Installing noscrypt globally" silent: true - cmd: cmake --install {{ .CMAKE_BUILD_DIR }} {{ .CLI_ARGS }} - + + memcheck: + desc: 'Runs Valgrind memcheck in debug mode against the nctest executable (Linux only)' + platforms: + - linux + preconditions: + - which valgrind + cmds: + - cmd: echo "Running valgrind memory check on test executable" + silent: true + - cmd: + valgrind + --tool=memcheck + --leak-check=full + --show-leak-kinds=all + --track-origins=yes + {{ .CMAKE_BUILD_DIR }}/{{ .TEST_EXE_NAME }} #CI ONLY!! -- cgit From 3c17d3d5f3e34a9302212856b019ddb7842a8a66 Mon Sep 17 00:00:00 2001 From: vnugent Date: Fri, 25 Oct 2024 02:21:25 -0400 Subject: make ossl updates work --- Taskfile.yaml | 1 + src/providers/openssl-helpers.c | 21 +++++++++++---------- src/providers/openssl.c | 2 ++ 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'Taskfile.yaml') diff --git a/Taskfile.yaml b/Taskfile.yaml index 7430244..ea12599 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -98,6 +98,7 @@ tasks: silent: true - cmd: cmake --install {{ .CMAKE_BUILD_DIR }} {{ .CLI_ARGS }} + #Test executable and library must be built for tests to run memcheck: desc: 'Runs Valgrind memcheck in debug mode against the nctest executable (Linux only)' platforms: diff --git a/src/providers/openssl-helpers.c b/src/providers/openssl-helpers.c index 6037a2f..42e98c3 100644 --- a/src/providers/openssl-helpers.c +++ b/src/providers/openssl-helpers.c @@ -37,7 +37,7 @@ typedef enum { struct ossl_evp_state { void* _context; - void* _cipher; + void* _providerHandle; OSSL_PARAM params[2]; @@ -82,6 +82,7 @@ _IMPLSTB cstatus_t _osslEvpUpdate(const struct ossl_evp_state* state, cspan_t da int result; DEBUG_ASSERT(state != NULL); + DEBUG_ASSERT(state->_context != NULL); result = 0; @@ -174,11 +175,11 @@ _IMPLSTB void _osslEvpFree(struct ossl_evp_state* state) { case EvpStateTypeDigest: if (state->_context) EVP_MD_CTX_free(state->_context); - if (state->_cipher) EVP_MD_free(state->_cipher); + if (state->_providerHandle) EVP_MD_free(state->_providerHandle); break; case EvpStateTypeMac: if (state->_context) EVP_MAC_CTX_free(state->_context); - if (state->_cipher) EVP_MAC_free(state->_cipher); + if (state->_providerHandle) EVP_MAC_free(state->_providerHandle); break; } } @@ -197,16 +198,16 @@ _IMPLSTB cstatus_t _osslEvpInit( switch (type) { case EvpStateTypeDigest: - state->_cipher = EVP_MD_fetch(NULL, providerName, NULL); + state->_providerHandle = EVP_MD_fetch(NULL, providerName, NULL); state->_context = EVP_MD_CTX_new(); break; case EvpStateTypeMac: - state->_cipher = EVP_MAC_fetch(NULL, providerName, NULL); + state->_providerHandle = EVP_MAC_fetch(NULL, providerName, NULL); - if (state->_cipher) + if (state->_providerHandle) { - state->_context = EVP_MAC_CTX_new((EVP_MAC*)(state->_cipher)); + state->_context = EVP_MAC_CTX_new((EVP_MAC*)(state->_providerHandle)); } break; @@ -218,7 +219,7 @@ _IMPLSTB cstatus_t _osslEvpInit( * Ensure allocations succeded, otherwise free the context * and return a failure status. */ - if (state->_cipher == NULL || state->_context == NULL) + if (state->_providerHandle == NULL || state->_context == NULL) { return CSTATUS_FAIL; } @@ -230,8 +231,8 @@ _IMPLSTB cstatus_t _osslEvpInit( { if ( !EVP_DigestInit_ex( - state->_context, - state->_cipher, + (EVP_MD_CTX*)state->_context, + (EVP_MD*)state->_providerHandle, NULL ) ) diff --git a/src/providers/openssl.c b/src/providers/openssl.c index 7167fac..4b41f1a 100644 --- a/src/providers/openssl.c +++ b/src/providers/openssl.c @@ -93,6 +93,8 @@ goto Cleanup; } + result = CSTATUS_OK; + Cleanup: _osslEvpFree(&evpState); -- cgit