From 60d1e222b2aba33eae3043f9aa38a013270590f2 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Tue, 7 Apr 2026 13:18:53 -0500 Subject: [PATCH] globally fix all "BLAKE2" references (implicit BLAKE2B) to explicit "BLAKE2B": * implement legacy compatibility in settings.h and configure.ac (adds --enable-blake2b while retaining --enable-blake2); * fix incorrect Blake2 gates in wolfcrypt/src/hash.c wc_HashGetDigestSize() and wc_HashGetBlockSize(); * in wolfcrypt/test/test.c hash_test(), backfill missing Blake2 test coverage and separate blake2b from blake2s in typesHashBad[]; * in tests/api/test_hash.c, separate blake2b from blake2s in notCompiledHash[], sizeSupportedHash[], and sizeNotCompiledHash[]. --- IDE/MDK5-ARM/Conf/user_settings.h | 6 +-- IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h | 4 +- cmake/functions.cmake | 6 +-- configure.ac | 21 +++++--- examples/configs/user_settings_all.h | 1 - .../configs/user_settings_openssl_compat.h | 1 - examples/configs/user_settings_platformio.h | 1 - linuxkm/module_exports.c.template | 2 +- src/include.am | 2 +- src/tls.c | 10 ++-- tests/api/test_blake2.c | 12 ++--- tests/api/test_evp_digest.c | 4 +- tests/api/test_hash.c | 12 +++-- wolfcrypt/benchmark/benchmark.c | 8 +-- wolfcrypt/src/blake2b.c | 4 +- wolfcrypt/src/evp.c | 16 +++--- wolfcrypt/src/hash.c | 4 +- wolfcrypt/src/port/intel/quickassist.c | 2 +- wolfcrypt/test/test.c | 53 ++++++++++++++++--- wolfcrypt/test/test.h | 2 +- wolfssl/openssl/evp.h | 4 +- wolfssl/wolfcrypt/blake2.h | 4 +- wolfssl/wolfcrypt/hash.h | 4 +- wolfssl/wolfcrypt/settings.h | 9 +++- wrapper/Ada/user_settings.h | 1 - 25 files changed, 121 insertions(+), 72 deletions(-) diff --git a/IDE/MDK5-ARM/Conf/user_settings.h b/IDE/MDK5-ARM/Conf/user_settings.h index cffe0d548d5..bdc3ee8f8ab 100644 --- a/IDE/MDK5-ARM/Conf/user_settings.h +++ b/IDE/MDK5-ARM/Conf/user_settings.h @@ -208,9 +208,9 @@ #endif // // BLAKE2 -#define MDK_CONF_BLAKE2 0 -#if MDK_CONF_BLAKE2 == 1 -#define HAVE_BLAKE2 +#define MDK_CONF_BLAKE2B 0 +#if MDK_CONF_BLAKE2B == 1 +#define HAVE_BLAKE2B #endif // // HMAC diff --git a/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h b/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h index 89521e9791a..2ce13735ee8 100644 --- a/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h +++ b/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h @@ -330,9 +330,9 @@ extern "C" { #endif /* Blake2B */ -#undef HAVE_BLAKE2 +#undef HAVE_BLAKE2B #if 0 - #define HAVE_BLAKE2 + #define HAVE_BLAKE2B #endif /* Blake2S */ diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 50ad0d25304..009d5f95858 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -93,8 +93,8 @@ function(generate_build_flags) if(WOLFSSL_RIPEMD OR WOLFSSL_USER_SETTINGS) set(BUILD_RIPEMD "yes" PARENT_SCOPE) endif() - if(WOLFSSL_BLAKE2 OR WOLFSSL_USER_SETTINGS) - set(BUILD_BLAKE2 "yes" PARENT_SCOPE) + if(WOLFSSL_BLAKE2B OR WOLFSSL_USER_SETTINGS) + set(BUILD_BLAKE2B "yes" PARENT_SCOPE) endif() if(WOLFSSL_BLAKE2S OR WOLFSSL_USER_SETTINGS) set(BUILD_BLAKE2S "yes" PARENT_SCOPE) @@ -869,7 +869,7 @@ function(generate_lib_src_list LIB_SOURCES) list(APPEND LIB_SOURCES wolfcrypt/src/ripemd.c) endif() - if(BUILD_BLAKE2) + if(BUILD_BLAKE2B) list(APPEND LIB_SOURCES wolfcrypt/src/blake2b.c) endif() diff --git a/configure.ac b/configure.ac index c4948ba406b..708123bc3e7 100644 --- a/configure.ac +++ b/configure.ac @@ -1502,7 +1502,7 @@ then test "$enable_base64encode" = "" && enable_base64encode=yes test "$enable_base16" = "" && enable_base16=yes test "$enable_arc4" = "" && enable_arc4=yes - test "$enable_blake2" = "" && enable_blake2=yes + test "$enable_blake2b" = "" && enable_blake2b=yes test "$enable_blake2s" = "" && enable_blake2s=yes test "$enable_md2" = "" && enable_md2=yes test "$enable_md4" = "" && enable_md4=yes @@ -4442,15 +4442,21 @@ fi # BLAKE2 +AC_ARG_ENABLE([blake2b], + [AS_HELP_STRING([--enable-blake2b],[Enable wolfSSL BLAKE2b support (default: disabled)])], + [ ENABLED_BLAKE2B=$enableval ], + [ ENABLED_BLAKE2B=no ] + ) + +# Backward-compat synonym for blake2b: AC_ARG_ENABLE([blake2], [AS_HELP_STRING([--enable-blake2],[Enable wolfSSL BLAKE2b support (default: disabled)])], - [ ENABLED_BLAKE2=$enableval ], - [ ENABLED_BLAKE2=no ] + [ ENABLED_BLAKE2B=$enableval ] ) -if test "$ENABLED_BLAKE2" = "yes" +if test "$ENABLED_BLAKE2B" = "yes" then - AM_CFLAGS="$AM_CFLAGS -DHAVE_BLAKE2 -DHAVE_BLAKE2B" + AM_CFLAGS="$AM_CFLAGS -DHAVE_BLAKE2B" fi @@ -4463,7 +4469,6 @@ AC_ARG_ENABLE([blake2s], if test "$ENABLED_BLAKE2S" = "yes" then AM_CFLAGS="$AM_CFLAGS -DHAVE_BLAKE2S" - ENABLED_BLAKE2="yes" fi @@ -11492,7 +11497,7 @@ AM_CONDITIONAL([BUILD_DEVCRYPTO],[test "x$ENABLED_DEVCRYPTO" = "xyes"]) AM_CONDITIONAL([BUILD_CAMELLIA],[test "x$ENABLED_CAMELLIA" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"]) AM_CONDITIONAL([BUILD_MD2],[test "x$ENABLED_MD2" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"]) AM_CONDITIONAL([BUILD_RIPEMD],[test "x$ENABLED_RIPEMD" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"]) -AM_CONDITIONAL([BUILD_BLAKE2],[test "x$ENABLED_BLAKE2" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"]) +AM_CONDITIONAL([BUILD_BLAKE2B],[test "x$ENABLED_BLAKE2B" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"]) AM_CONDITIONAL([BUILD_BLAKE2S],[test "x$ENABLED_BLAKE2S" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"]) AM_CONDITIONAL([BUILD_SHA512],[test "x$ENABLED_SHA512" = "xyes" || test "x$ENABLED_SHA384" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"]) AM_CONDITIONAL([BUILD_DSA],[test "x$ENABLED_DSA" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"]) @@ -12013,7 +12018,7 @@ echo " * SHA3: $ENABLED_SHA3" echo " * SHAKE128: $ENABLED_SHAKE128" echo " * SHAKE256: $ENABLED_SHAKE256" echo " * SM3: $ENABLED_SM3" -echo " * BLAKE2: $ENABLED_BLAKE2" +echo " * BLAKE2B: $ENABLED_BLAKE2B" echo " * BLAKE2S: $ENABLED_BLAKE2S" echo " * SipHash: $ENABLED_SIPHASH" echo " * CMAC: $ENABLED_CMAC" diff --git a/examples/configs/user_settings_all.h b/examples/configs/user_settings_all.h index d23606a44da..9dd3f80e87f 100644 --- a/examples/configs/user_settings_all.h +++ b/examples/configs/user_settings_all.h @@ -228,7 +228,6 @@ extern "C" { #define HAVE_X963_KDF #define WOLFSSL_CMAC #define WOLFSSL_DES_ECB -#define HAVE_BLAKE2 #define HAVE_BLAKE2B #define HAVE_BLAKE2S #define WOLFSSL_SIPHASH diff --git a/examples/configs/user_settings_openssl_compat.h b/examples/configs/user_settings_openssl_compat.h index 49aca96e4d0..b2557bb2939 100644 --- a/examples/configs/user_settings_openssl_compat.h +++ b/examples/configs/user_settings_openssl_compat.h @@ -199,7 +199,6 @@ extern "C" { #define WOLFSSL_SHA3 #define WOLFSSL_SHAKE256 -#define HAVE_BLAKE2 #define HAVE_BLAKE2B #define HAVE_BLAKE2S diff --git a/examples/configs/user_settings_platformio.h b/examples/configs/user_settings_platformio.h index a39ef1fbf97..df422306e71 100644 --- a/examples/configs/user_settings_platformio.h +++ b/examples/configs/user_settings_platformio.h @@ -103,7 +103,6 @@ #define TEST_ESPIDF_ALL_WOLFSSL #ifdef TEST_ESPIDF_ALL_WOLFSSL #define WOLFSSL_MD2 - #define HAVE_BLAKE2 #define HAVE_BLAKE2B #define HAVE_BLAKE2S diff --git a/linuxkm/module_exports.c.template b/linuxkm/module_exports.c.template index c7515a17d9e..ad2f07cac95 100644 --- a/linuxkm/module_exports.c.template +++ b/linuxkm/module_exports.c.template @@ -106,7 +106,7 @@ #ifdef HAVE_ED448 #include #endif -#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S) +#if defined(HAVE_BLAKE2B) || defined(HAVE_BLAKE2S) #include #endif #ifdef WOLFSSL_SHA3 diff --git a/src/include.am b/src/include.am index cb91fe84cc5..7b012e8481c 100644 --- a/src/include.am +++ b/src/include.am @@ -1304,7 +1304,7 @@ if BUILD_RIPEMD src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/ripemd.c endif -if BUILD_BLAKE2 +if BUILD_BLAKE2B src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/blake2b.c endif if BUILD_BLAKE2S diff --git a/src/tls.c b/src/tls.c index 09e6c921740..ad3e3323f64 100644 --- a/src/tls.c +++ b/src/tls.c @@ -1188,7 +1188,7 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in, #endif #if defined(WOLFSSL_NO_HASH_RAW) || defined(HAVE_FIPS) || \ - defined(HAVE_SELFTEST) || defined(HAVE_BLAKE2) + defined(HAVE_SELFTEST) || defined(HAVE_BLAKE2B) /* Calculate the HMAC of the header + message data. * Constant time implementation using normal hashing operations. @@ -1249,14 +1249,14 @@ static int Hmac_UpdateFinal(Hmac* hmac, byte* digest, const byte* in, break; #endif /* WOLFSSL_SHA512 */ - #ifdef HAVE_BLAKE2 + #ifdef HAVE_BLAKE2B case WC_HASH_TYPE_BLAKE2B: blockSz = BLAKE2B_BLOCKBYTES; blockBits = 7; macSz = BLAKE2B_256; padSz = 0; break; - #endif /* HAVE_BLAKE2 */ + #endif /* HAVE_BLAKE2B */ #ifdef WOLFSSL_SM3 case WC_SM3: @@ -1450,7 +1450,7 @@ int TLS_hmac(WOLFSSL* ssl, byte* digest, const byte* in, word32 sz, int padSz, if (verify && padSz >= 0) { #if !defined(WOLFSSL_NO_HASH_RAW) && !defined(HAVE_FIPS) && \ !defined(HAVE_SELFTEST) - #ifdef HAVE_BLAKE2 + #ifdef HAVE_BLAKE2B if (wolfSSL_GetHmacType(ssl) == WC_HASH_TYPE_BLAKE2B) { ret = Hmac_UpdateFinal(&hmac, digest, in, totalSz, myInner, innerSz); @@ -1521,7 +1521,7 @@ int wolfSSL_GetHmacType_ex(CipherSpecs* specs) return WC_SHA; } #endif - #ifdef HAVE_BLAKE2 + #ifdef HAVE_BLAKE2B case blake2b_mac: { return BLAKE2B_ID; diff --git a/tests/api/test_blake2.c b/tests/api/test_blake2.c index 2067997fa23..4fb4446708b 100644 --- a/tests/api/test_blake2.c +++ b/tests/api/test_blake2.c @@ -40,7 +40,7 @@ int test_wc_InitBlake2b(void) { EXPECT_DECLS; -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B Blake2b blake; /* Test bad arg. */ @@ -66,7 +66,7 @@ int test_wc_InitBlake2b(void) int test_wc_InitBlake2b_WithKey(void) { EXPECT_DECLS; -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B Blake2b blake; word32 digestSz = BLAKE2B_KEYBYTES; byte key[BLAKE2B_KEYBYTES]; @@ -104,7 +104,7 @@ int test_wc_InitBlake2b_WithKey(void) int test_wc_Blake2bUpdate(void) { EXPECT_DECLS; -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B Blake2b blake; ExpectIntEQ(wc_InitBlake2b(&blake, WC_BLAKE2B_DIGEST_SIZE), 0); @@ -127,7 +127,7 @@ int test_wc_Blake2bUpdate(void) int test_wc_Blake2bFinal(void) { EXPECT_DECLS; -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B Blake2b blake; byte hash[WC_BLAKE2B_DIGEST_SIZE]; @@ -156,7 +156,7 @@ int test_wc_Blake2bFinal(void) int test_wc_Blake2b_KATs(void) { EXPECT_DECLS; -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B Blake2b blake; testVector blake2b_kat[BLAKE2B_KAT_CNT]; @@ -272,7 +272,7 @@ int test_wc_Blake2b_KATs(void) int test_wc_Blake2b_other(void) { EXPECT_DECLS; -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B Blake2b blake; byte hash[WC_BLAKE2B_DIGEST_SIZE + 1]; byte data[WC_BLAKE2B_DIGEST_SIZE * 8 + 1]; diff --git a/tests/api/test_evp_digest.c b/tests/api/test_evp_digest.c index c7949c30b7f..6aa6464ac01 100644 --- a/tests/api/test_evp_digest.c +++ b/tests/api/test_evp_digest.c @@ -165,11 +165,11 @@ int test_wolfSSL_EVP_sm3(void) int test_EVP_blake2(void) { EXPECT_DECLS; -#if defined(OPENSSL_EXTRA) && (defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S)) +#if defined(OPENSSL_EXTRA) && (defined(HAVE_BLAKE2B) || defined(HAVE_BLAKE2S)) const EVP_MD* md = NULL; (void)md; -#if defined(HAVE_BLAKE2) +#if defined(HAVE_BLAKE2B) ExpectNotNull(md = EVP_blake2b512()); ExpectIntEQ(XSTRNCMP(md, "BLAKE2b512", XSTRLEN("BLAKE2b512")), 0); #endif diff --git a/tests/api/test_hash.c b/tests/api/test_hash.c index e37400d6757..f6a968670ab 100644 --- a/tests/api/test_hash.c +++ b/tests/api/test_hash.c @@ -117,10 +117,10 @@ static const enum wc_HashType notCompiledHash[] = { #ifdef NO_MD4 WC_HASH_TYPE_MD4, #endif -#if !defined(HAVE_BLAKE2) && !defined(HAVE_BLAKE2S) +#ifndef HAVE_BLAKE2B WC_HASH_TYPE_BLAKE2B, #endif -#if !defined(HAVE_BLAKE2) && !defined(HAVE_BLAKE2B) +#ifndef HAVE_BLAKE2S WC_HASH_TYPE_BLAKE2S, #endif WC_HASH_TYPE_NONE /* Dummy value to ensure list is non-zero. */ @@ -145,8 +145,10 @@ static const enum wc_HashType sizeSupportedHash[] = { #ifndef NO_MD4 WC_HASH_TYPE_MD4, #endif -#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S) +#ifdef HAVE_BLAKE2B WC_HASH_TYPE_BLAKE2B, +#endif +#ifdef HAVE_BLAKE2S WC_HASH_TYPE_BLAKE2S, #endif WC_HASH_TYPE_NONE /* Dummy value to ensure list is non-zero. */ @@ -163,8 +165,10 @@ static const enum wc_HashType sizeNotCompiledHash[] = { #ifdef NO_MD4 WC_HASH_TYPE_MD4, #endif -#if !defined(HAVE_BLAKE2) && !defined(HAVE_BLAKE2S) +#ifndef HAVE_BLAKE2B WC_HASH_TYPE_BLAKE2B, +#endif +#ifndef HAVE_BLAKE2S WC_HASH_TYPE_BLAKE2S, #endif WC_HASH_TYPE_SHAKE128, diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 3b3c4159d9e..f61530b2c57 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -1168,7 +1168,7 @@ static const bench_alg bench_digest_opt[] = { #ifdef WOLFSSL_RIPEMD { "-ripemd", BENCH_RIPEMD }, #endif -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B { "-blake2b", BENCH_BLAKE2B }, #endif #ifdef HAVE_BLAKE2S @@ -2014,7 +2014,7 @@ static const char* bench_result_words3[][5] = { #include #endif -#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S) +#if defined(HAVE_BLAKE2B) || defined(HAVE_BLAKE2S) #include #endif @@ -4133,7 +4133,7 @@ static void* benchmarks_do(void* args) if (bench_all || (bench_digest_algs & BENCH_RIPEMD)) bench_ripemd(); #endif -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B if (bench_all || (bench_digest_algs & BENCH_BLAKE2B)) bench_blake2b(); #endif @@ -8851,7 +8851,7 @@ void bench_ripemd(void) #endif -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B void bench_blake2b(void) { Blake2b b2b; diff --git a/wolfcrypt/src/blake2b.c b/wolfcrypt/src/blake2b.c index 7e7b60bab93..6e9c37b3163 100644 --- a/wolfcrypt/src/blake2b.c +++ b/wolfcrypt/src/blake2b.c @@ -33,7 +33,7 @@ #include -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B #include #include @@ -603,4 +603,4 @@ int wc_Blake2bHmac(const byte* in, size_t in_len, /* end wolfCrypt API */ -#endif /* HAVE_BLAKE2 */ +#endif /* HAVE_BLAKE2B */ diff --git a/wolfcrypt/src/evp.c b/wolfcrypt/src/evp.c index e7a87d249b1..06cb121ab6c 100644 --- a/wolfcrypt/src/evp.c +++ b/wolfcrypt/src/evp.c @@ -98,7 +98,7 @@ static const struct s_ent { #ifdef WOLFSSL_SM3 {WC_HASH_TYPE_SM3, WC_NID_sm3, WC_SN_sm3}, #endif /* WOLFSSL_SHA512 */ -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B {WC_HASH_TYPE_BLAKE2B, WC_NID_blake2b512, WC_SN_blake2b512}, #endif #ifdef HAVE_BLAKE2S @@ -4780,11 +4780,11 @@ static unsigned int wolfssl_mac_len(unsigned char macType) break; #endif /* WOLFSSL_SHA512 */ - #ifdef HAVE_BLAKE2 + #ifdef HAVE_BLAKE2B case BLAKE2B_ID: hashLen = BLAKE2B_OUTBYTES; break; - #endif /* HAVE_BLAKE2 */ + #endif /* HAVE_BLAKE2B */ #ifdef WOLFSSL_SHA3 #ifndef WOLFSSL_NOSHA3_224 @@ -10339,7 +10339,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) #endif /* !NO_MD5 */ -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B /* return EVP_MD * @param none * @return "blake2b512" @@ -10927,7 +10927,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) } } else #endif - #ifdef HAVE_BLAKE2 + #ifdef HAVE_BLAKE2B if (XSTRCMP(md, WC_SN_blake2b512) == 0) { if (wc_InitBlake2b(&ctx->hash.digest.blake2b, WC_BLAKE2B_DIGEST_SIZE) != 0) { @@ -11084,7 +11084,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) ret = NOT_COMPILED_IN; #endif break; - #ifdef HAVE_BLAKE2 + #ifdef HAVE_BLAKE2B case WC_HASH_TYPE_BLAKE2B: if (wc_Blake2bUpdate(&ctx->hash.digest.blake2b, (const byte*)data, (word32)sz) == 0) { @@ -11103,7 +11103,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) case WC_HASH_TYPE_NONE: case WC_HASH_TYPE_MD2: case WC_HASH_TYPE_MD5_SHA: - #ifndef HAVE_BLAKE2 + #ifndef HAVE_BLAKE2B case WC_HASH_TYPE_BLAKE2B: #endif #ifndef HAVE_BLAKE2S @@ -11241,7 +11241,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) #endif break; case WC_HASH_TYPE_BLAKE2B: - #ifdef HAVE_BLAKE2 + #ifdef HAVE_BLAKE2B if (wc_Blake2bFinal(&ctx->hash.digest.blake2b, md, WC_BLAKE2B_DIGEST_SIZE) == 0) { if (s) *s = WC_BLAKE2B_DIGEST_SIZE; diff --git a/wolfcrypt/src/hash.c b/wolfcrypt/src/hash.c index d839cdb434f..b500d2145ef 100644 --- a/wolfcrypt/src/hash.c +++ b/wolfcrypt/src/hash.c @@ -483,7 +483,7 @@ int wc_HashGetDigestSize(enum wc_HashType hash_type) #endif break; case WC_HASH_TYPE_BLAKE2S: - #if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S) + #if defined(HAVE_BLAKE2S) dig_size = BLAKE2S_OUTBYTES; #else dig_size = HASH_TYPE_E; @@ -639,7 +639,7 @@ int wc_HashGetBlockSize(enum wc_HashType hash_type) #endif break; case WC_HASH_TYPE_BLAKE2S: - #if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S) + #if defined(HAVE_BLAKE2S) block_size = BLAKE2S_BLOCKBYTES; #else block_size = HASH_TYPE_E; diff --git a/wolfcrypt/src/port/intel/quickassist.c b/wolfcrypt/src/port/intel/quickassist.c index 74b0d5b23ff..2e2ae14646a 100644 --- a/wolfcrypt/src/port/intel/quickassist.c +++ b/wolfcrypt/src/port/intel/quickassist.c @@ -3431,7 +3431,7 @@ int IntelQaSymSha3(WC_ASYNC_DEV* dev, byte* out, const byte* in, word32 sz) } break; #endif - #ifdef HAVE_BLAKE2 + #ifdef HAVE_BLAKE2B case BLAKE2B_ID: #endif #ifdef WOLFSSL_SHA3 diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index ff297d7142f..5499ec89471 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -422,7 +422,7 @@ static const byte const_byte_array[] = "A+Gd\0\0\0"; #ifdef WOLFCRYPT_HAVE_SAKKE #include #endif -#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S) +#if defined(HAVE_BLAKE2B) || defined(HAVE_BLAKE2S) #include #endif #ifdef WOLFSSL_SHA3 @@ -795,7 +795,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t scrypt_test(void); #ifdef WOLFCRYPT_HAVE_SAKKE WOLFSSL_TEST_SUBROUTINE wc_test_ret_t sakke_test(void); #endif -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B WOLFSSL_TEST_SUBROUTINE wc_test_ret_t blake2b_test(void); WOLFSSL_TEST_SUBROUTINE wc_test_ret_t blake2b_hmac_test(void); #endif @@ -2237,7 +2237,7 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\ TEST_PASS("RIPEMD test passed!\n"); #endif -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B if ( (ret = blake2b_test()) != 0) TEST_FAIL("BLAKE2b test failed!\n", ret); else @@ -4706,7 +4706,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ripemd_test(void) #endif /* WOLFSSL_RIPEMD */ -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B #define BLAKE2B_TESTS 3 @@ -4864,7 +4864,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t blake2b_hmac_test(void) return 0; } -#endif /* HAVE_BLAKE2 */ +#endif /* HAVE_BLAKE2B */ #ifdef HAVE_BLAKE2S @@ -7659,8 +7659,11 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hash_test(void) #if defined(NO_MD5) || defined(NO_SHA) WC_HASH_TYPE_MD5_SHA, #endif -#if !defined(HAVE_BLAKE2) && !defined(HAVE_BLAKE2S) +#if !defined(HAVE_BLAKE2B) WC_HASH_TYPE_BLAKE2B, +#endif +#if !defined(HAVE_BLAKE2S) + WC_HASH_TYPE_BLAKE2S, #endif WC_HASH_TYPE_NONE }; @@ -7941,9 +7944,43 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hash_test(void) if (ret != WC_NO_ERR_TRACE(HASH_TYPE_E)) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); #endif + ret = wc_HashGetDigestSize(WC_HASH_TYPE_MD5_SHA); +#if !defined(NO_MD5) && !defined(NO_SHA) + if (ret == WC_NO_ERR_TRACE(HASH_TYPE_E) || + ret == WC_NO_ERR_TRACE(BAD_FUNC_ARG)) + { + ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); + } +#else + if (ret != WC_NO_ERR_TRACE(HASH_TYPE_E)) + ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); +#endif + + ret = wc_HashGetBlockSize(WC_HASH_TYPE_BLAKE2S); +#if defined(HAVE_BLAKE2S) + if (ret == WC_NO_ERR_TRACE(HASH_TYPE_E) || + ret == WC_NO_ERR_TRACE(BAD_FUNC_ARG)) + { + ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); + } +#else + if (ret != WC_NO_ERR_TRACE(HASH_TYPE_E)) + ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); +#endif + ret = wc_HashGetDigestSize(WC_HASH_TYPE_BLAKE2S); +#if defined(HAVE_BLAKE2S) + if (ret == WC_NO_ERR_TRACE(HASH_TYPE_E) || + ret == WC_NO_ERR_TRACE(BAD_FUNC_ARG)) + { + ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); + } +#else + if (ret != WC_NO_ERR_TRACE(HASH_TYPE_E)) + ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); +#endif ret = wc_HashGetBlockSize(WC_HASH_TYPE_BLAKE2B); -#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S) +#if defined(HAVE_BLAKE2B) if (ret == WC_NO_ERR_TRACE(HASH_TYPE_E) || ret == WC_NO_ERR_TRACE(BAD_FUNC_ARG)) { @@ -7954,7 +7991,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hash_test(void) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); #endif ret = wc_HashGetDigestSize(WC_HASH_TYPE_BLAKE2B); -#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S) +#if defined(HAVE_BLAKE2B) if (ret == WC_NO_ERR_TRACE(HASH_TYPE_E) || ret == WC_NO_ERR_TRACE(BAD_FUNC_ARG)) { diff --git a/wolfcrypt/test/test.h b/wolfcrypt/test/test.h index 1202c667f19..72b9ff586dc 100644 --- a/wolfcrypt/test/test.h +++ b/wolfcrypt/test/test.h @@ -328,7 +328,7 @@ extern WOLFSSL_TEST_SUBROUTINE wc_test_ret_t scrypt_test(void); #ifdef WOLFCRYPT_HAVE_SAKKE extern WOLFSSL_TEST_SUBROUTINE wc_test_ret_t sakke_test(void); #endif -#ifdef HAVE_BLAKE2 +#ifdef HAVE_BLAKE2B extern WOLFSSL_TEST_SUBROUTINE wc_test_ret_t blake2b_test(void); extern WOLFSSL_TEST_SUBROUTINE wc_test_ret_t blake2b_hmac_test(void); #endif diff --git a/wolfssl/openssl/evp.h b/wolfssl/openssl/evp.h index f4ee44cd00a..2117d0be7fc 100644 --- a/wolfssl/openssl/evp.h +++ b/wolfssl/openssl/evp.h @@ -61,7 +61,7 @@ #ifdef WOLFSSL_SM3 #include #endif -#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S) +#if defined(HAVE_BLAKE2B) || defined(HAVE_BLAKE2S) #include #endif #ifdef WOLFSSL_SM4 @@ -227,7 +227,7 @@ typedef union { #if defined(WOLFSSL_SHAKE128) || defined(WOLFSSL_SHAKE256) wc_Shake shake; #endif - #ifdef HAVE_BLAKE2 + #ifdef HAVE_BLAKE2B Blake2b blake2b; #endif #ifdef HAVE_BLAKE2S diff --git a/wolfssl/wolfcrypt/blake2.h b/wolfssl/wolfcrypt/blake2.h index e412e9b4fd1..2ed4f0dfd31 100644 --- a/wolfssl/wolfcrypt/blake2.h +++ b/wolfssl/wolfcrypt/blake2.h @@ -28,7 +28,7 @@ #include -#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S) +#if defined(HAVE_BLAKE2B) || defined(HAVE_BLAKE2S) #include @@ -121,6 +121,6 @@ WOLFSSL_API int wc_Blake2sHmac(const byte* in, size_t in_len, } #endif -#endif /* HAVE_BLAKE2 || HAVE_BLAKE2S */ +#endif /* HAVE_BLAKE2B || HAVE_BLAKE2S */ #endif /* WOLF_CRYPT_BLAKE2_H */ diff --git a/wolfssl/wolfcrypt/hash.h b/wolfssl/wolfcrypt/hash.h index e3c630cded3..781909b931d 100644 --- a/wolfssl/wolfcrypt/hash.h +++ b/wolfssl/wolfcrypt/hash.h @@ -40,7 +40,7 @@ #if defined(WOLFSSL_SHA384) || defined(WOLFSSL_SHA512) #include #endif -#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S) +#if defined(HAVE_BLAKE2B) || defined(HAVE_BLAKE2S) #include #endif #ifdef WOLFSSL_SHA3 @@ -131,7 +131,7 @@ typedef struct { #elif defined(WOLFSSL_SHA512) #define WC_MAX_DIGEST_SIZE WC_SHA512_DIGEST_SIZE #define WC_MAX_BLOCK_SIZE WC_SHA512_BLOCK_SIZE -#elif defined(HAVE_BLAKE2) +#elif defined(HAVE_BLAKE2B) #define WC_MAX_DIGEST_SIZE BLAKE2B_OUTBYTES #define WC_MAX_BLOCK_SIZE BLAKE2B_BLOCKBYTES #elif defined(WOLFSSL_SHA384) diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 9b6caf57f20..a6b9332e5c0 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -769,7 +769,6 @@ * the "enable all" feature: */ #if defined(TEST_ESPIDF_ALL_WOLFSSL) #define WOLFSSL_MD2 - #define HAVE_BLAKE2 #define HAVE_BLAKE2B #define HAVE_BLAKE2S @@ -5058,6 +5057,14 @@ extern void uITRON4_free(void *p) ; " requires ED448 (HAVE_ED448)" #endif +/* Accommodate legacy BLAKE gate. */ +#ifdef HAVE_BLAKE2 + #ifndef HAVE_BLAKE2B + #define HAVE_BLAKE2B + #endif + #undef HAVE_BLAKE2 +#endif + /* QUIC Rules */ #if !defined(WOLFCRYPT_ONLY) && defined(WOLFSSL_QUIC) && \ !defined(WOLFSSL_TLS13) diff --git a/wrapper/Ada/user_settings.h b/wrapper/Ada/user_settings.h index d871e772721..4cb4bb8c397 100644 --- a/wrapper/Ada/user_settings.h +++ b/wrapper/Ada/user_settings.h @@ -236,7 +236,6 @@ extern "C" { #define HAVE_X963_KDF #define WOLFSSL_CMAC #define WOLFSSL_DES_ECB -#define HAVE_BLAKE2 #define HAVE_BLAKE2B #define HAVE_BLAKE2S #define WOLFSSL_SIPHASH