Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/os-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ jobs:
'--enable-dtls --enable-dtlscid --enable-dtls13 --enable-secure-renegotiation
--enable-psk --enable-aesccm --enable-nullcipher
CPPFLAGS=-DWOLFSSL_STATIC_RSA',
'--enable-she=extended --enable-cryptocb --enable-cryptocbutils
CPPFLAGS=''-DWC_SHE_SW_DEFAULT'' ',
'--enable-she=standard --enable-cmac',
'--enable-she=extended --enable-cmac --enable-cryptocb --enable-cryptocbutils',
'--enable-she=standard --enable-cmac CPPFLAGS=''-DNO_WC_SHE_IMPORT_M123'' ',
'--enable-she=extended --enable-cmac --enable-cryptocb --enable-cryptocbutils
CPPFLAGS=''-DNO_WC_SHE_GETUID -DNO_WC_SHE_GETCOUNTER -DNO_WC_SHE_EXPORTKEY'' ',
'--enable-she=standard --enable-cmac --enable-cryptocb --enable-cryptocbutils
CPPFLAGS=''-DWC_SHE_SW_DEFAULT'' ',
'--enable-all CPPFLAGS=''-DNO_AES_192 -DNO_AES_256'' ',
'--enable-sniffer --enable-curve25519 --enable-curve448 --enable-enckeys
CPPFLAGS=-DWOLFSSL_DH_EXTRA',
Expand Down
1 change: 1 addition & 0 deletions .wolfssl_known_macro_extras
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ NO_TKERNEL_MEM_POOL
NO_TLSX_PSKKEM_PLAIN_ANNOUNCE
NO_VERIFY_OID
NO_WC_DHGENERATEPUBLIC
NO_WC_SHE_LOADKEY
NO_WC_SSIZE_TYPE
NO_WOLFSSL_ALLOC_ALIGN
NO_WOLFSSL_AUTOSAR_CRYIF
Expand Down
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,30 @@ if(WOLFSSL_CMAC)
endif()
endif()

# SHE (Secure Hardware Extension) key update message generation
# standard: core SHE support, extended: adds custom KDF/header overrides
add_option("WOLFSSL_SHE"
"Enable SHE key update support (standard|extended|no)"
"no" "standard;extended;no")

if(WOLFSSL_SHE STREQUAL "standard" OR WOLFSSL_SHE STREQUAL "extended")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH-1: CMakeLists.txt missing required SHE dependency definitions

  • File: CMakeLists.txt:1649-1656
  • Function: N/A (build system)
  • Category: bug
  • Confidence: High

Description: The CMakeLists.txt SHE section only adds -DWOLFSSL_SHE but does not add -DWOLFSSL_CMAC or -DWOLFSSL_AES_DIRECT, nor does it force-enable the CMAC option. By contrast, configure.ac correctly adds all three flags and sets ENABLED_CMAC=yes and ENABLED_AESCBC=yes. A CMake build with -DWOLFSSL_SHE=standard (without separately enabling CMAC) will hit the #error "SHE requires CMAC" directive in wc_she.c.

Code:

if(WOLFSSL_SHE STREQUAL "standard" OR WOLFSSL_SHE STREQUAL "extended")
    if (NOT WOLFSSL_AES)
        message(FATAL_ERROR "Cannot use SHE without AES.")
    else()
        list(APPEND WOLFSSL_DEFINITIONS
            "-DWOLFSSL_SHE")
    endif()
endif()

Recommendation: Mirror the configure.ac behavior: force-enable CMAC (and thus AES_DIRECT) when SHE is enabled. For example:

Suggested change
if(WOLFSSL_SHE STREQUAL "standard" OR WOLFSSL_SHE STREQUAL "extended")
if(WOLFSSL_SHE STREQUAL "standard" OR WOLFSSL_SHE STREQUAL "extended")
if (NOT WOLFSSL_AES)
message(FATAL_ERROR "Cannot use SHE without AES.")
else()
list(APPEND WOLFSSL_DEFINITIONS
"-DWOLFSSL_SHE")
# SHE requires CMAC and AES-DIRECT; force-enable them
override_cache(WOLFSSL_CMAC "yes")
endif()
endif()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added override_cache(WOLFSSL_CMAC "yes") and
override_cache(WOLFSSL_AESCBC "yes") to the CMakeLists.txt SHE block. CMAC's own block
already handles adding -DWOLFSSL_CMAC -DWOLFSSL_AES_DIRECT when it's enabled, so the
override is all that's needed to cascade the dependencies correctly.

if (NOT WOLFSSL_AES)
message(FATAL_ERROR "Cannot use SHE without AES.")
else()
list(APPEND WOLFSSL_DEFINITIONS
"-DWOLFSSL_SHE"
"-DWOLFSSL_CMAC"
"-DWOLFSSL_AES_DIRECT")
override_cache(WOLFSSL_CMAC "yes")
override_cache(WOLFSSL_AESCBC "yes")
endif()
endif()

if(WOLFSSL_SHE STREQUAL "extended")
list(APPEND WOLFSSL_DEFINITIONS
"-DWOLFSSL_SHE_EXTENDED")
endif()

# TODO: - RC2
# - FIPS, again (there's more logic for FIPS in configure.ac)
# - Selftest
Expand Down Expand Up @@ -2816,6 +2840,7 @@ if(WOLFSSL_EXAMPLES)
tests/api/test_hash.c
tests/api/test_hmac.c
tests/api/test_cmac.c
tests/api/test_she.c
tests/api/test_des3.c
tests/api/test_chacha.c
tests/api/test_poly1305.c
Expand Down
7 changes: 7 additions & 0 deletions cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ function(generate_build_flags)
if(WOLFSSL_HPKE OR WOLFSSL_USER_SETTINGS)
set(BUILD_HPKE "yes" PARENT_SCOPE)
endif()
if(WOLFSSL_SHE AND NOT WOLFSSL_SHE STREQUAL "no")
set(BUILD_SHE "yes" PARENT_SCOPE)
endif()

set(BUILD_FLAGS_GENERATED "yes" PARENT_SCOPE)
endfunction()
Expand Down Expand Up @@ -1150,6 +1153,10 @@ function(generate_lib_src_list LIB_SOURCES)
list(APPEND LIB_SOURCES wolfcrypt/src/cryptocb.c)
endif()

if(BUILD_SHE)
list(APPEND LIB_SOURCES wolfcrypt/src/wc_she.c)
endif()

if(BUILD_PKCS11)
list(APPEND LIB_SOURCES wolfcrypt/src/wc_pkcs11.c)
endif()
Expand Down
26 changes: 26 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5944,6 +5944,31 @@ fi
AS_IF([test "x$ENABLED_CMAC" = "xyes"],
[AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CMAC -DWOLFSSL_AES_DIRECT"])

# SHE (Secure Hardware Extension) key update message generation
# --enable-she=standard: standard SHE support
# --enable-she=extended: standard + extended overrides (custom KDF/headers)
AC_ARG_ENABLE([she],
[AS_HELP_STRING([--enable-she@<:@=standard|extended@:>@],
[Enable SHE key update support (default: disabled)])],
[ ENABLED_SHE=$enableval ],
[ ENABLED_SHE=no ]
)

if test "x$ENABLED_SHE" = "xstandard" || test "x$ENABLED_SHE" = "xextended"
then
if test "$ENABLED_AESCBC" = "no"
then
AC_MSG_ERROR([SHE requires AES-CBC. Cannot use --disable-aescbc with --enable-she.])
fi
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SHE -DWOLFSSL_CMAC -DWOLFSSL_AES_DIRECT"
ENABLED_CMAC=yes
ENABLED_AESCBC=yes
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM-5: configure.ac SHE section sets ENABLED_AESCBC=yes too late to take effect

  • File: configure.ac:5963
  • Function: N/A (build system)
  • Category: bug
  • Confidence: Medium

Description: The SHE configure block sets ENABLED_AESCBC=yes (line 5963), but the AES-CBC disable check already ran at line 3287. If a user passes --disable-aescbc --enable-she=standard, the -DNO_AES_CBC flag is already added to AM_CFLAGS before the SHE block runs. Setting ENABLED_AESCBC=yes at that point doesn't remove the already-appended flag. The #error in wc_she.c will catch this at compile time, but it would be better to fail at configure time with a clear error message.

Code:

# Line 3287 (runs first):
if test "$ENABLED_AESCBC" = "no"
then
    AM_CFLAGS="$AM_CFLAGS -DNO_AES_CBC"  # Already added!
fi

# Line 5959 (runs later):
if test "x$ENABLED_SHE" = "xstandard" || ...
then
    ENABLED_AESCBC=yes  # Too late, -DNO_AES_CBC already in AM_CFLAGS
fi

Recommendation: Either add a check for NO_AES_CBC after the SHE block or, more robustly, move the ENABLED_AESCBC check to after all feature blocks that might override it (similar to how some flags are consolidated at the end of configure.ac). Alternatively, add an explicit check:

if test "x$ENABLED_SHE" != "xno" && test "$ENABLED_AESCBC" = "no"
then
    AC_MSG_ERROR([SHE requires AES-CBC. Remove --disable-aescbc or disable SHE.])
fi

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an explicit AC_MSG_ERROR check at the top of the SHE enable
block in configure.ac: if ENABLED_AESCBC is "no" when SHE is being enabled, configure
now fails with "SHE requires AES-CBC. Cannot use --disable-aescbc with --enable-she.".

fi

if test "x$ENABLED_SHE" = "xextended"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SHE_EXTENDED"
fi

# AES-XTS
AC_ARG_ENABLE([aesxts],
Expand Down Expand Up @@ -11543,6 +11568,7 @@ AM_CONDITIONAL([BUILD_FIPS_V6],[test $HAVE_FIPS_VERSION = 6])
AM_CONDITIONAL([BUILD_FIPS_V6_PLUS],[test $HAVE_FIPS_VERSION -ge 6])
AM_CONDITIONAL([BUILD_SIPHASH],[test "x$ENABLED_SIPHASH" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_CMAC],[test "x$ENABLED_CMAC" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_SHE],[test "x$ENABLED_SHE" = "xstandard" || test "x$ENABLED_SHE" = "xextended" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_SELFTEST],[test "x$ENABLED_SELFTEST" = "xyes"])
AM_CONDITIONAL([BUILD_SHA224],[test "x$ENABLED_SHA224" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_SHA3],[test "x$ENABLED_SHA3" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
Expand Down
16 changes: 16 additions & 0 deletions src/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ if BUILD_CMAC
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/cmac.c
endif

if BUILD_SHE
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_she.c
endif

src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/fips.c \
wolfcrypt/src/fips_test.c

Expand Down Expand Up @@ -424,6 +428,10 @@ if BUILD_CMAC
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/cmac.c
endif

if BUILD_SHE
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_she.c
endif

src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/fips.c \
wolfcrypt/src/fips_test.c

Expand Down Expand Up @@ -673,6 +681,10 @@ if BUILD_CMAC
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/cmac.c
endif

if BUILD_SHE
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_she.c
endif

if BUILD_CURVE448
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/curve448.c
endif
Expand Down Expand Up @@ -1005,6 +1017,10 @@ if !BUILD_FIPS_V2_PLUS
if BUILD_CMAC
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/cmac.c
endif

if BUILD_SHE
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_she.c
endif
endif !BUILD_FIPS_V2_PLUS

if !BUILD_FIPS_V2
Expand Down
9 changes: 9 additions & 0 deletions tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
#include <tests/api/test_hash.h>
#include <tests/api/test_hmac.h>
#include <tests/api/test_cmac.h>
#include <tests/api/test_she.h>
#include <tests/api/test_des3.h>
#include <tests/api/test_chacha.h>
#include <tests/api/test_poly1305.h>
Expand Down Expand Up @@ -35174,6 +35175,14 @@ TEST_CASE testCases[] = {
TEST_HMAC_DECLS,
/* CMAC */
TEST_CMAC_DECLS,
/* SHE */
TEST_SHE_DECLS,
#ifdef WOLFSSL_SHE_EXTENDED
TEST_SHE_EXT_DECLS,
#endif
#if defined(WOLF_CRYPTO_CB) && defined(WOLFSSL_SHE)
TEST_SHE_CB_DECLS,
#endif

/* Cipher */
/* Triple-DES */
Expand Down
3 changes: 3 additions & 0 deletions tests/api/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ tests_unit_test_SOURCES += tests/api/test_hash.c
# MAC
tests_unit_test_SOURCES += tests/api/test_hmac.c
tests_unit_test_SOURCES += tests/api/test_cmac.c
# SHE
tests_unit_test_SOURCES += tests/api/test_she.c
# Cipher
tests_unit_test_SOURCES += tests/api/test_des3.c
tests_unit_test_SOURCES += tests/api/test_chacha.c
Expand Down Expand Up @@ -124,6 +126,7 @@ EXTRA_DIST += tests/api/test_digest.h
EXTRA_DIST += tests/api/test_hash.h
EXTRA_DIST += tests/api/test_hmac.h
EXTRA_DIST += tests/api/test_cmac.h
EXTRA_DIST += tests/api/test_she.h
EXTRA_DIST += tests/api/test_des3.h
EXTRA_DIST += tests/api/test_chacha.h
EXTRA_DIST += tests/api/test_poly1305.h
Expand Down
Loading
Loading