From d1e26b4f5d5e780de704a3714eb10dd90bf6622e Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Mon, 8 Jul 2024 15:02:43 +1000 Subject: [PATCH] Dilithium: fixes Fix inclusion of functions dilithium_vec_check_low() in build: --enable-dilithium=verify-only,44,65,87 CFLAGS=-DWOLFSSL_DILITHIUM_VERIFY_SMALL_MEM Fix memory leaks in unit.test: --enable-dilithium CFLAGS=-DWC_DILITHIUM_CACHE_MATRIX_A 'CC=clang -fsanitize=address' --- tests/api.c | 2 ++ wolfcrypt/src/dilithium.c | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/api.c b/tests/api.c index 2e23ea1fb1..bad4eabc05 100644 --- a/tests/api.c +++ b/tests/api.c @@ -34565,6 +34565,7 @@ static int test_wc_dilithium_make_key_from_seed(void) ExpectIntEQ(XMEMCMP(key->k, sk_87, sizeof(sk_87)), 0); #endif + wc_dilithium_free(key); XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return EXPECT_RESULT(); @@ -36710,6 +36711,7 @@ static int test_wc_dilithium_verify_kats(void) ExpectIntEQ(res, 1); #endif + wc_dilithium_free(key); XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return EXPECT_RESULT(); diff --git a/wolfcrypt/src/dilithium.c b/wolfcrypt/src/dilithium.c index f3a6f01000..007a9b35ee 100644 --- a/wolfcrypt/src/dilithium.c +++ b/wolfcrypt/src/dilithium.c @@ -2825,8 +2825,7 @@ static int dilithium_check_low(const sword32* a, sword32 hi) return ret; } -#if (!defined(WOLFSSL_DILITHIUM_NO_VERIFY) && \ - !defined(WOLFSSL_DILITHIUM_VERIFY_SMALL_MEM)) || \ +#if !defined(WOLFSSL_DILITHIUM_NO_VERIFY) || \ (!defined(WOLFSSL_DILITHIUM_NO_SIGN) && \ !defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM)) /* Check that the values of the vector are in range.