From 551ff3f1b6f8a8d6264cf43ea3e0a62ea498f15a Mon Sep 17 00:00:00 2001 From: David Garske Date: Wed, 23 Jul 2025 15:59:08 -0700 Subject: [PATCH] Fixes for building with MD5 and SHA1 to support Hash `WC_HASH_TYPE_MD5_SHA`. ZD 20269. --- tests/api/test_hash.c | 4 ++-- wolfssl/wolfcrypt/hash.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/api/test_hash.c b/tests/api/test_hash.c index 717c0849d..ac0b635ff 100644 --- a/tests/api/test_hash.c +++ b/tests/api/test_hash.c @@ -214,9 +214,9 @@ int test_wc_HashInit(void) for (i = 0; i < notSupportedHashLen; i++) { /* check for null ptr */ - ExpectIntEQ(wc_HashInit(NULL, supportedHash[i]), + ExpectIntEQ(wc_HashInit(NULL, notSupportedHash[i]), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); - ExpectIntEQ(wc_HashInit_ex(NULL, supportedHash[i], HEAP_HINT, + ExpectIntEQ(wc_HashInit_ex(NULL, notSupportedHash[i], HEAP_HINT, INVALID_DEVID), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); ExpectIntEQ(wc_HashInit(&hash, notSupportedHash[i]), diff --git a/wolfssl/wolfcrypt/hash.h b/wolfssl/wolfcrypt/hash.h index 9ac6cff2a..99bcea00a 100644 --- a/wolfssl/wolfcrypt/hash.h +++ b/wolfssl/wolfcrypt/hash.h @@ -137,6 +137,9 @@ typedef struct { #elif defined(WOLFSSL_SHA384) #define WC_MAX_DIGEST_SIZE WC_SHA384_DIGEST_SIZE #define WC_MAX_BLOCK_SIZE WC_SHA384_BLOCK_SIZE +#elif !defined(NO_SHA) && !defined(NO_MD5) + #define WC_MAX_DIGEST_SIZE (WC_SHA_DIGEST_SIZE + WC_MD5_DIGEST_SIZE) + #define WC_MAX_BLOCK_SIZE WC_SHA_BLOCK_SIZE #elif !defined(NO_SHA256) #define WC_MAX_DIGEST_SIZE WC_SHA256_DIGEST_SIZE #define WC_MAX_BLOCK_SIZE WC_SHA256_BLOCK_SIZE