Skip to content

Commit af8061a

Browse files
committed
Merge branch 'master' into feature/integrate_openssl_comp_fixes
2 parents 4500977 + 750f3b1 commit af8061a

File tree

33 files changed

+408
-89
lines changed

33 files changed

+408
-89
lines changed

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/ssl_sess.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,38 @@ int wolfSSL_memsave_session_cache(void* mem, int sz)
483483
}
484484

485485

486+
#if !defined(SESSION_CACHE_DYNAMIC_MEM) && \
487+
(defined(HAVE_SESSION_TICKET) || \
488+
(defined(SESSION_CERTS) && defined(OPENSSL_EXTRA)))
489+
static void SessionSanityPointerSet(SessionRow* row)
490+
{
491+
int j;
492+
493+
/* Reset pointers to safe values after raw copy */
494+
for (j = 0; j < SESSIONS_PER_ROW; j++) {
495+
WOLFSSL_SESSION* s = &row->Sessions[j];
496+
#ifdef HAVE_SESSION_TICKET
497+
s->ticket = s->staticTicket;
498+
s->ticketLenAlloc = 0;
499+
if (s->ticketLen > SESSION_TICKET_LEN) {
500+
s->ticketLen = SESSION_TICKET_LEN;
501+
}
502+
#endif
503+
#if defined(WOLFSSL_TLS13) && defined(HAVE_SESSION_TICKET) && \
504+
defined(WOLFSSL_TICKET_NONCE_MALLOC) && \
505+
(!defined(HAVE_FIPS) || (defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3)))
506+
s->ticketNonce.data = s->ticketNonce.dataStatic;
507+
if (s->ticketNonce.len > MAX_TICKET_NONCE_STATIC_SZ) {
508+
s->ticketNonce.len = MAX_TICKET_NONCE_STATIC_SZ;
509+
}
510+
#endif
511+
#if defined(SESSION_CERTS) && defined(OPENSSL_EXTRA)
512+
s->peer = NULL;
513+
#endif
514+
}
515+
}
516+
#endif
517+
486518
/* Restore the persistent session cache from memory */
487519
int wolfSSL_memrestore_session_cache(const void* mem, int sz)
488520
{
@@ -522,6 +554,11 @@ int wolfSSL_memrestore_session_cache(const void* mem, int sz)
522554
#endif
523555

524556
XMEMCPY(&SessionCache[i], row++, SIZEOF_SESSION_ROW);
557+
#if !defined(SESSION_CACHE_DYNAMIC_MEM) && \
558+
(defined(HAVE_SESSION_TICKET) || \
559+
(defined(SESSION_CERTS) && defined(OPENSSL_EXTRA)))
560+
SessionSanityPointerSet(&SessionCache[i]);
561+
#endif
525562
#ifdef ENABLE_SESSION_CACHE_ROW_LOCK
526563
SESSION_ROW_UNLOCK(&SessionCache[i]);
527564
#endif
@@ -681,6 +718,11 @@ int wolfSSL_restore_session_cache(const char *fname)
681718
#endif
682719

683720
ret = (int)XFREAD(&SessionCache[i], SIZEOF_SESSION_ROW, 1, file);
721+
#if !defined(SESSION_CACHE_DYNAMIC_MEM) && \
722+
(defined(HAVE_SESSION_TICKET) || \
723+
(defined(SESSION_CERTS) && defined(OPENSSL_EXTRA)))
724+
SessionSanityPointerSet(&SessionCache[i]);
725+
#endif
684726
#ifdef ENABLE_SESSION_CACHE_ROW_LOCK
685727
SESSION_ROW_UNLOCK(&SessionCache[i]);
686728
#endif

0 commit comments

Comments
 (0)