From e0d30c1d8f407bfef05a9cc36398bb0894a96c39 Mon Sep 17 00:00:00 2001 From: vnugent Date: Sun, 3 Nov 2024 12:44:22 -0500 Subject: Once over and fix all valgrind warnings --- src/providers/openssl-helpers.c | 5 +++-- src/providers/openssl.c | 6 ++---- tests/test.c | 7 +++++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/providers/openssl-helpers.c b/src/providers/openssl-helpers.c index bc3a272..5369457 100644 --- a/src/providers/openssl-helpers.c +++ b/src/providers/openssl-helpers.c @@ -2,7 +2,7 @@ * Copyright (c) 2024 Vaughn Nugent * * Package: noscrypt -* File: providers/openssl.c +* File: providers/openssl-helpers.c * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -113,8 +113,9 @@ _IMPLSTB cstatus_t _osslEvpUpdate(const struct ossl_evp_state* state, cspan_t da ncSpanGetSizeC(data) ); break; - + /* Cipher is not supported by this api */ default: + DEBUG_ASSERT2(0, "Called update on an invalid state type"); break; } diff --git a/src/providers/openssl.c b/src/providers/openssl.c index 73a7902..925386d 100644 --- a/src/providers/openssl.c +++ b/src/providers/openssl.c @@ -167,7 +167,6 @@ _osslEvpFree(&evpState); return result; - } #endif /* !_IMPL_CRYPTO_SHA256_HMAC */ @@ -186,7 +185,6 @@ const struct _hkdf_state* state; DEBUG_ASSERT(ctx != NULL); - _overflow_check(data.size); state = (const struct _hkdf_state*)ctx; @@ -231,8 +229,7 @@ handler.update = _ossl_hkdf_update; handler.finish = _ossl_hkdf_finish; - - _overflow_check(prk.size); + _overflow_check(info.size); _overflow_check(okm.size); @@ -336,6 +333,7 @@ /* * Possible static asser that int size must be 32bit or smaller + * so it can be cast safely to uint32 */ if (bytesWritten < 0 || bytesWritten > INT32_MAX) { diff --git a/tests/test.c b/tests/test.c index e8ce756..a1f5abe 100644 --- a/tests/test.c +++ b/tests/test.c @@ -289,10 +289,13 @@ static int TestPublicApiArgumentValidation() NCPublicKey pubKey; uint8_t hmacKeyOut[NC_HMAC_KEY_SIZE]; uint8_t nonce[NC_NIP44_IV_SIZE]; - + NCEncryptionArgs cryptoData; - PRINTL("TEST: Public API argument validation tests") + PRINTL("TEST: Public API argument validation tests"); + + /* Zero fill the structure to inialize */ + ZERO_FILL(&cryptoData, sizeof(cryptoData)); { TEST(NCEncryptionGetIvSize(NC_ENC_VERSION_NIP44), sizeof(nonce)); -- cgit