Skip to content

Commit 60d1e22

Browse files
committed
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[].
1 parent 7aac9e5 commit 60d1e22

25 files changed

Lines changed: 121 additions & 72 deletions

File tree

IDE/MDK5-ARM/Conf/user_settings.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@
208208
#endif
209209
// </e>
210210
// <e>BLAKE2
211-
#define MDK_CONF_BLAKE2 0
212-
#if MDK_CONF_BLAKE2 == 1
213-
#define HAVE_BLAKE2
211+
#define MDK_CONF_BLAKE2B 0
212+
#if MDK_CONF_BLAKE2B == 1
213+
#define HAVE_BLAKE2B
214214
#endif
215215
// </e>
216216
// <e>HMAC

IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@ extern "C" {
330330
#endif
331331

332332
/* Blake2B */
333-
#undef HAVE_BLAKE2
333+
#undef HAVE_BLAKE2B
334334
#if 0
335-
#define HAVE_BLAKE2
335+
#define HAVE_BLAKE2B
336336
#endif
337337

338338
/* Blake2S */

cmake/functions.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ function(generate_build_flags)
9393
if(WOLFSSL_RIPEMD OR WOLFSSL_USER_SETTINGS)
9494
set(BUILD_RIPEMD "yes" PARENT_SCOPE)
9595
endif()
96-
if(WOLFSSL_BLAKE2 OR WOLFSSL_USER_SETTINGS)
97-
set(BUILD_BLAKE2 "yes" PARENT_SCOPE)
96+
if(WOLFSSL_BLAKE2B OR WOLFSSL_USER_SETTINGS)
97+
set(BUILD_BLAKE2B "yes" PARENT_SCOPE)
9898
endif()
9999
if(WOLFSSL_BLAKE2S OR WOLFSSL_USER_SETTINGS)
100100
set(BUILD_BLAKE2S "yes" PARENT_SCOPE)
@@ -869,7 +869,7 @@ function(generate_lib_src_list LIB_SOURCES)
869869
list(APPEND LIB_SOURCES wolfcrypt/src/ripemd.c)
870870
endif()
871871

872-
if(BUILD_BLAKE2)
872+
if(BUILD_BLAKE2B)
873873
list(APPEND LIB_SOURCES wolfcrypt/src/blake2b.c)
874874
endif()
875875

configure.ac

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ then
15021502
test "$enable_base64encode" = "" && enable_base64encode=yes
15031503
test "$enable_base16" = "" && enable_base16=yes
15041504
test "$enable_arc4" = "" && enable_arc4=yes
1505-
test "$enable_blake2" = "" && enable_blake2=yes
1505+
test "$enable_blake2b" = "" && enable_blake2b=yes
15061506
test "$enable_blake2s" = "" && enable_blake2s=yes
15071507
test "$enable_md2" = "" && enable_md2=yes
15081508
test "$enable_md4" = "" && enable_md4=yes
@@ -4442,15 +4442,21 @@ fi
44424442

44434443

44444444
# BLAKE2
4445+
AC_ARG_ENABLE([blake2b],
4446+
[AS_HELP_STRING([--enable-blake2b],[Enable wolfSSL BLAKE2b support (default: disabled)])],
4447+
[ ENABLED_BLAKE2B=$enableval ],
4448+
[ ENABLED_BLAKE2B=no ]
4449+
)
4450+
4451+
# Backward-compat synonym for blake2b:
44454452
AC_ARG_ENABLE([blake2],
44464453
[AS_HELP_STRING([--enable-blake2],[Enable wolfSSL BLAKE2b support (default: disabled)])],
4447-
[ ENABLED_BLAKE2=$enableval ],
4448-
[ ENABLED_BLAKE2=no ]
4454+
[ ENABLED_BLAKE2B=$enableval ]
44494455
)
44504456

4451-
if test "$ENABLED_BLAKE2" = "yes"
4457+
if test "$ENABLED_BLAKE2B" = "yes"
44524458
then
4453-
AM_CFLAGS="$AM_CFLAGS -DHAVE_BLAKE2 -DHAVE_BLAKE2B"
4459+
AM_CFLAGS="$AM_CFLAGS -DHAVE_BLAKE2B"
44544460
fi
44554461

44564462

@@ -4463,7 +4469,6 @@ AC_ARG_ENABLE([blake2s],
44634469
if test "$ENABLED_BLAKE2S" = "yes"
44644470
then
44654471
AM_CFLAGS="$AM_CFLAGS -DHAVE_BLAKE2S"
4466-
ENABLED_BLAKE2="yes"
44674472
fi
44684473

44694474

@@ -11492,7 +11497,7 @@ AM_CONDITIONAL([BUILD_DEVCRYPTO],[test "x$ENABLED_DEVCRYPTO" = "xyes"])
1149211497
AM_CONDITIONAL([BUILD_CAMELLIA],[test "x$ENABLED_CAMELLIA" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
1149311498
AM_CONDITIONAL([BUILD_MD2],[test "x$ENABLED_MD2" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
1149411499
AM_CONDITIONAL([BUILD_RIPEMD],[test "x$ENABLED_RIPEMD" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
11495-
AM_CONDITIONAL([BUILD_BLAKE2],[test "x$ENABLED_BLAKE2" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
11500+
AM_CONDITIONAL([BUILD_BLAKE2B],[test "x$ENABLED_BLAKE2B" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
1149611501
AM_CONDITIONAL([BUILD_BLAKE2S],[test "x$ENABLED_BLAKE2S" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
1149711502
AM_CONDITIONAL([BUILD_SHA512],[test "x$ENABLED_SHA512" = "xyes" || test "x$ENABLED_SHA384" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
1149811503
AM_CONDITIONAL([BUILD_DSA],[test "x$ENABLED_DSA" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
@@ -12013,7 +12018,7 @@ echo " * SHA3: $ENABLED_SHA3"
1201312018
echo " * SHAKE128: $ENABLED_SHAKE128"
1201412019
echo " * SHAKE256: $ENABLED_SHAKE256"
1201512020
echo " * SM3: $ENABLED_SM3"
12016-
echo " * BLAKE2: $ENABLED_BLAKE2"
12021+
echo " * BLAKE2B: $ENABLED_BLAKE2B"
1201712022
echo " * BLAKE2S: $ENABLED_BLAKE2S"
1201812023
echo " * SipHash: $ENABLED_SIPHASH"
1201912024
echo " * CMAC: $ENABLED_CMAC"

examples/configs/user_settings_all.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ extern "C" {
228228
#define HAVE_X963_KDF
229229
#define WOLFSSL_CMAC
230230
#define WOLFSSL_DES_ECB
231-
#define HAVE_BLAKE2
232231
#define HAVE_BLAKE2B
233232
#define HAVE_BLAKE2S
234233
#define WOLFSSL_SIPHASH

examples/configs/user_settings_openssl_compat.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ extern "C" {
199199
#define WOLFSSL_SHA3
200200
#define WOLFSSL_SHAKE256
201201

202-
#define HAVE_BLAKE2
203202
#define HAVE_BLAKE2B
204203
#define HAVE_BLAKE2S
205204

examples/configs/user_settings_platformio.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
#define TEST_ESPIDF_ALL_WOLFSSL
104104
#ifdef TEST_ESPIDF_ALL_WOLFSSL
105105
#define WOLFSSL_MD2
106-
#define HAVE_BLAKE2
107106
#define HAVE_BLAKE2B
108107
#define HAVE_BLAKE2S
109108

linuxkm/module_exports.c.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
#ifdef HAVE_ED448
107107
#include <wolfssl/wolfcrypt/ed448.h>
108108
#endif
109-
#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S)
109+
#if defined(HAVE_BLAKE2B) || defined(HAVE_BLAKE2S)
110110
#include <wolfssl/wolfcrypt/blake2.h>
111111
#endif
112112
#ifdef WOLFSSL_SHA3

src/include.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ if BUILD_RIPEMD
13041304
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/ripemd.c
13051305
endif
13061306

1307-
if BUILD_BLAKE2
1307+
if BUILD_BLAKE2B
13081308
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/blake2b.c
13091309
endif
13101310
if BUILD_BLAKE2S

src/tls.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in,
11881188
#endif
11891189

11901190
#if defined(WOLFSSL_NO_HASH_RAW) || defined(HAVE_FIPS) || \
1191-
defined(HAVE_SELFTEST) || defined(HAVE_BLAKE2)
1191+
defined(HAVE_SELFTEST) || defined(HAVE_BLAKE2B)
11921192

11931193
/* Calculate the HMAC of the header + message data.
11941194
* Constant time implementation using normal hashing operations.
@@ -1249,14 +1249,14 @@ static int Hmac_UpdateFinal(Hmac* hmac, byte* digest, const byte* in,
12491249
break;
12501250
#endif /* WOLFSSL_SHA512 */
12511251

1252-
#ifdef HAVE_BLAKE2
1252+
#ifdef HAVE_BLAKE2B
12531253
case WC_HASH_TYPE_BLAKE2B:
12541254
blockSz = BLAKE2B_BLOCKBYTES;
12551255
blockBits = 7;
12561256
macSz = BLAKE2B_256;
12571257
padSz = 0;
12581258
break;
1259-
#endif /* HAVE_BLAKE2 */
1259+
#endif /* HAVE_BLAKE2B */
12601260

12611261
#ifdef WOLFSSL_SM3
12621262
case WC_SM3:
@@ -1450,7 +1450,7 @@ int TLS_hmac(WOLFSSL* ssl, byte* digest, const byte* in, word32 sz, int padSz,
14501450
if (verify && padSz >= 0) {
14511451
#if !defined(WOLFSSL_NO_HASH_RAW) && !defined(HAVE_FIPS) && \
14521452
!defined(HAVE_SELFTEST)
1453-
#ifdef HAVE_BLAKE2
1453+
#ifdef HAVE_BLAKE2B
14541454
if (wolfSSL_GetHmacType(ssl) == WC_HASH_TYPE_BLAKE2B) {
14551455
ret = Hmac_UpdateFinal(&hmac, digest, in,
14561456
totalSz, myInner, innerSz);
@@ -1521,7 +1521,7 @@ int wolfSSL_GetHmacType_ex(CipherSpecs* specs)
15211521
return WC_SHA;
15221522
}
15231523
#endif
1524-
#ifdef HAVE_BLAKE2
1524+
#ifdef HAVE_BLAKE2B
15251525
case blake2b_mac:
15261526
{
15271527
return BLAKE2B_ID;

0 commit comments

Comments
 (0)