Merge pull request #9838 from SparkiDev/slhdsa_1

FIPS 205, SLH-DSA: implementation
This commit is contained in:
Daniel Pouzzner
2026-03-10 19:28:59 -05:00
committed by GitHub
25 changed files with 10588 additions and 18 deletions
+8 -8
View File
@@ -19,14 +19,14 @@ jobs:
config: [
# Add new configs here
'--enable-intelasm --enable-sp-asm --enable-mlkem=yes,kyber,ml-kem CPPFLAGS="-DWOLFSSL_ML_KEM_USE_OLD_IDS"',
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem --enable-lms --enable-xmss --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE"',
'--enable-smallstack --enable-smallstackcache --enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem --enable-lms --enable-xmss --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE"',
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem --enable-lms --enable-xmss --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE" CC=c++',
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem --enable-lms --enable-xmss --enable-dilithium --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE -DWOLFSSL_BLIND_PRIVATE_KEY"',
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem --enable-lms --enable-xmss --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE -DWOLFSSL_BLIND_PRIVATE_KEY"',
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem --enable-lms --enable-xmss --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE -DWOLFSSL_TLSX_PQC_MLKEM_STORE_OBJ"',
'--disable-intelasm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem,small --enable-lms=yes,small --enable-xmss=yes,small --enable-dilithium=yes,small --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE -DWOLFSSL_MLKEM_MAKEKEY_SMALL_MEM -DWOLFSSL_MLKEM_ENCAPSULATE_SMALL_MEM -DWOLFSSL_MLKEM_NO_LARGE_CODE -DWOLFSSL_DILITHIUM_SIGN_SMALL_MEM -DWOLFSSL_DILITHIUM_VERIFY_SMALL_MEM -DWOLFSSL_DILITHIUM_MAKE_KEY_SMALL_MEM -DWOLFSSL_DILITHIUM_NO_LARGE_CODE"',
'--disable-intelasm --enable-smallstack --enable-smallstackcache --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem,small --enable-lms=yes,small --enable-xmss=yes,small --enable-dilithium=yes,small --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE -DWOLFSSL_MLKEM_MAKEKEY_SMALL_MEM -DWOLFSSL_MLKEM_ENCAPSULATE_SMALL_MEM -DWOLFSSL_MLKEM_NO_LARGE_CODE -DWOLFSSL_DILITHIUM_SIGN_SMALL_MEM -DWOLFSSL_DILITHIUM_VERIFY_SMALL_MEM -DWOLFSSL_DILITHIUM_MAKE_KEY_SMALL_MEM -DWOLFSSL_DILITHIUM_NO_LARGE_CODE"',
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem --enable-lms --enable-xmss --enable-slhdsa --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE"',
'--enable-smallstack --enable-smallstackcache --enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem --enable-lms --enable-xmss --enable-slhdsa --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE"',
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem --enable-lms --enable-xmss --enable-slhdsa --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE" CC=c++',
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem --enable-lms --enable-xmss --enable-slhdsa --enable-dilithium --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE -DWOLFSSL_BLIND_PRIVATE_KEY"',
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem --enable-lms --enable-xmss --enable-slhdsa --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE -DWOLFSSL_BLIND_PRIVATE_KEY"',
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem --enable-lms --enable-xmss --enable-slhdsa --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE -DWOLFSSL_TLSX_PQC_MLKEM_STORE_OBJ"',
'--disable-intelasm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem,small --enable-lms=yes,small --enable-xmss=yes,small --enable-slhdsa=yes,small --enable-dilithium=yes,small --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE -DWOLFSSL_MLKEM_MAKEKEY_SMALL_MEM -DWOLFSSL_MLKEM_ENCAPSULATE_SMALL_MEM -DWOLFSSL_MLKEM_NO_LARGE_CODE -DWOLFSSL_DILITHIUM_SIGN_SMALL_MEM -DWOLFSSL_DILITHIUM_VERIFY_SMALL_MEM -DWOLFSSL_DILITHIUM_MAKE_KEY_SMALL_MEM -DWOLFSSL_DILITHIUM_NO_LARGE_CODE"',
'--disable-intelasm --enable-smallstack --enable-smallstackcache --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem,small --enable-lms=yes,small --enable-xmss=yes,small --enable-slhdsa=yes,small --enable-dilithium=yes,small --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE -DWOLFSSL_MLKEM_MAKEKEY_SMALL_MEM -DWOLFSSL_MLKEM_ENCAPSULATE_SMALL_MEM -DWOLFSSL_MLKEM_NO_LARGE_CODE -DWOLFSSL_DILITHIUM_SIGN_SMALL_MEM -DWOLFSSL_DILITHIUM_VERIFY_SMALL_MEM -DWOLFSSL_DILITHIUM_MAKE_KEY_SMALL_MEM -DWOLFSSL_DILITHIUM_NO_LARGE_CODE"',
]
name: make check
if: github.repository_owner == 'wolfssl'
+2
View File
@@ -880,6 +880,7 @@ WOLFSSL_RSA_DECRYPT_TO_0_LEN
WOLFSSL_RW_THREADED
WOLFSSL_SAKKE_SMALL
WOLFSSL_SAKKE_SMALL_MODEXP
WOLFSSL_SLHDSA_FULL_HASH
WOLFSSL_SE050_AUTO_ERASE
WOLFSSL_SE050_CRYPT
WOLFSSL_SE050_HASH
@@ -936,6 +937,7 @@ WOLFSSL_USE_FORCE_ZERO
WOLFSSL_USE_OPTIONS_H
WOLFSSL_VALIDATE_DH_KEYGEN
WOLFSSL_WC_LMS_SERIALIZE_STATE
WOLFSSL_WC_SLHDSA_RECURSIVE
WOLFSSL_WC_XMSS_NO_SHA256
WOLFSSL_WC_XMSS_NO_SHAKE256
WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME
+18
View File
@@ -777,6 +777,23 @@ add_option(WOLFSSL_XMSS
"Enable the wolfSSL XMSS implementation (default: disabled)"
"no" "yes;no")
# SLH-DSA
add_option(WOLFSSL_SLHDSA
"Enable the wolfSSL SLH-DSA implementation (default: disabled)"
"no" "yes;no")
if (WOLFSSL_SLHDSA)
message(STATUS "Automatically set related requirements for SLH-DSA")
add_definitions("-DWOLFSSL_HAVE_SLHDSA")
add_definitions("-DWOLFSSL_WC_SLHDSA")
add_definitions("-DWOLFSSL_SHAKE256")
set_wolfssl_definitions("WOLFSSL_HAVE_SLHDSA" RESULT)
set_wolfssl_definitions("WOLFSSL_WC_SLHDSA" RESULT)
set_wolfssl_definitions("WOLFSSL_SHAKE256" RESULT)
message(STATUS "Looking for WOLFSSL_SLHDSA - found")
endif()
# TODO: - Lean PSK
# - Lean TLS
# - Low resource
@@ -2816,6 +2833,7 @@ if(WOLFSSL_EXAMPLES)
tests/api/test_ed448.c
tests/api/test_mlkem.c
tests/api/test_mldsa.c
tests/api/test_slhdsa.c
tests/api/test_signature.c
tests/api/test_dtls.c
tests/api/test_ocsp.c
+7
View File
@@ -226,6 +226,9 @@ function(generate_build_flags)
if(WOLFSSL_XMSS OR WOLFSSL_USER_SETTINGS)
set(BUILD_WC_XMSS "yes" PARENT_SCOPE)
endif()
if(WOLFSSL_SLHDSA OR WOLFSSL_USER_SETTINGS)
set(BUILD_WC_SLHDSA "yes" PARENT_SCOPE)
endif()
if(WOLFSSL_ARIA OR WOLFSSL_USER_SETTINGS)
message(STATUS "ARIA functions.cmake found WOLFSSL_ARIA")
# we cannot actually build, as we only have pre-compiled bin
@@ -1078,6 +1081,10 @@ function(generate_lib_src_list LIB_SOURCES)
list(APPEND LIB_SOURCES wolfcrypt/src/wc_xmss_impl.c)
endif()
if(BUILD_WC_SLHDSA)
list(APPEND LIB_SOURCES wolfcrypt/src/wc_slhdsa.c)
endif()
if(BUILD_LIBZ)
list(APPEND LIB_SOURCES wolfcrypt/src/compress.c)
endif()
+4
View File
@@ -410,6 +410,10 @@ extern "C" {
#cmakedefine HAVE_SECRET_CALLBACK
#undef WC_RSA_DIRECT
#cmakedefine WC_RSA_DIRECT
#undef WOLFSSL_HAVE_SLHDSA
#cmakedefine WOLFSSL_HAVE_SLHDSA
#undef WOLFSSL_WC_SLHDSA
#cmakedefine WOLFSSL_WC_SLHDSA
#ifdef __cplusplus
}
+112 -3
View File
@@ -1,11 +1,11 @@
# configure.ac
#
# Copyright (C) 2006-2025 wolfSSL Inc.
# Copyright (C) 2006-2026 wolfSSL Inc.
#
# This file is part of wolfSSL. (formerly known as CyaSSL)
#
#
AC_COPYRIGHT([Copyright (C) 2006-2025 wolfSSL Inc.])
AC_COPYRIGHT([Copyright (C) 2006-2026 wolfSSL Inc.])
AC_PREREQ([2.69])
AC_INIT([wolfssl],[5.8.4],[https://github.com/wolfssl/wolfssl/issues],[wolfssl],[https://www.wolfssl.com])
AC_CONFIG_AUX_DIR([build-aux])
@@ -2144,6 +2144,113 @@ then
fi
fi
# SLH-DSA
ENABLED_SLHDSA=yes
AC_ARG_ENABLE([slhdsa],
[AS_HELP_STRING([--enable-slhdsa],[Enable SLH-DSA signatures (default: disabled)])],
[ ENABLED_SLHDSA=$enableval ],
[ ENABLED_SLHDSA=no ]
)
for v in `echo $ENABLED_SLHDSA | tr "," " "`
do
case $v in
yes)
SLHDSA_PARAM_128S=yes
SLHDSA_PARAM_128F=yes
SLHDSA_PARAM_192S=yes
SLHDSA_PARAM_192F=yes
SLHDSA_PARAM_256S=yes
SLHDSA_PARAM_256F=yes
;;
no)
;;
verify-only)
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_VERIFY_ONLY"
;;
small)
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_WC_SLHDSA_SMALL"
;;
small-mem)
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_WC_SLHDSA_SMALL_MEM"
;;
128s)
SLHDSA_PARAM_128S=yes
;;
128f)
SLHDSA_PARAM_128F=yes
;;
192s)
SLHDSA_PARAM_192S=yes
;;
192f)
SLHDSA_PARAM_192F=yes
;;
256s)
SLHDSA_PARAM_256S=yes
;;
256f)
SLHDSA_PARAM_256F=yes
;;
no-s)
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_NO_SMALL"
;;
no-f)
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_NO_FAST"
;;
*)
AC_MSG_ERROR([Invalid choice for SLH-DSA []: $ENABLED_SLHDSA.])
break;;
esac
done
if test "$ENABLED_SLHDSA" != "no"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_SLHDSA"
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_HAVE_SLHDSA"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_WC_SLHDSA"
if test "$SLHDSA_PARAM_128S" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_128S"
else
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_NO_128S"
fi
if test "$SLHDSA_PARAM_128F" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_128F"
else
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_NO_128F"
fi
if test "$SLHDSA_PARAM_192S" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_192S"
else
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_NO_192S"
fi
if test "$SLHDSA_PARAM_192F" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_192F"
else
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_NO_192F"
fi
if test "$SLHDSA_PARAM_256S" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_256S"
else
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_NO_256S"
fi
if test "$SLHDSA_PARAM_256F" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_256F"
else
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SLHDSA_PARAM_NO_256F"
fi
enable_shake256=yes
fi
# SINGLE THREADED
AC_ARG_ENABLE([singlethreaded],
[AS_HELP_STRING([--enable-singlethreaded],[Enable wolfSSL single threaded (default: disabled)])],
@@ -11232,6 +11339,7 @@ AM_CONDITIONAL([BUILD_CURVE448],[test "x$ENABLED_CURVE448" = "xyes" || test "x$E
AM_CONDITIONAL([BUILD_CURVE448_SMALL],[test "x$ENABLED_CURVE448_SMALL" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_WC_LMS],[test "x$ENABLED_WC_LMS" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_WC_XMSS],[test "x$ENABLED_WC_XMSS" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_WC_SLHDSA],[test "x$ENABLED_SLHDSA" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_WC_MLKEM],[test "x$ENABLED_WC_MLKEM" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_DILITHIUM],[test "x$ENABLED_DILITHIUM" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_ECCSI],[test "x$ENABLED_ECCSI" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
@@ -11485,7 +11593,7 @@ rm -f $OPTION_FILE
echo "/* wolfssl options.h" > $OPTION_FILE
echo " * generated from configure options" >> $OPTION_FILE
echo " *" >> $OPTION_FILE
echo " * Copyright (C) 2006-2025 wolfSSL Inc." >> $OPTION_FILE
echo " * Copyright (C) 2006-2026 wolfSSL Inc." >> $OPTION_FILE
echo " *" >> $OPTION_FILE
echo " * This file is part of wolfSSL. (formerly known as CyaSSL)" >> $OPTION_FILE
echo " *" >> $OPTION_FILE
@@ -11782,6 +11890,7 @@ echo " * XMSS wolfSSL impl: $ENABLED_WC_XMSS"
if test "$ENABLED_LIBXMSS" = "yes"; then
echo " * XMSS_ROOT: $XMSS_ROOT"
fi
echo " * SLH-DSA $ENABLED_SLHDSA"
echo " * MLKEM: $ENABLED_MLKEM"
echo " * MLKEM wolfSSL impl: $ENABLED_WC_MLKEM"
echo " * DILITHIUM: $ENABLED_DILITHIUM"
+3
View File
@@ -176,6 +176,9 @@
#ifdef HAVE_DILITHIUM
#include <wolfssl/wolfcrypt/dilithium.h>
#endif
#ifdef WOLFSSL_HAVE_SLHDSA
#include <wolfssl/wolfcrypt/wc_slhdsa.h>
#endif
#ifdef OPENSSL_EXTRA
#ifndef WOLFCRYPT_ONLY
+4
View File
@@ -1418,6 +1418,10 @@ src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_xmss.c
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_xmss_impl.c
endif
if BUILD_WC_SLHDSA
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_slhdsa.c
endif
if !BUILD_FIPS_V6_PLUS
if BUILD_CURVE25519
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/curve25519.c
+3
View File
@@ -207,6 +207,7 @@
#include <tests/api/test_ed448.h>
#include <tests/api/test_mlkem.h>
#include <tests/api/test_mldsa.h>
#include <tests/api/test_slhdsa.h>
#include <tests/api/test_signature.h>
#include <tests/api/test_dtls.h>
#include <tests/api/test_ocsp.h>
@@ -32969,6 +32970,8 @@ TEST_CASE testCases[] = {
TEST_MLKEM_DECLS,
/* Dilithium */
TEST_MLDSA_DECLS,
/* SLH-DSA */
TEST_SLHDSA_DECLS,
/* Signature API */
TEST_SIGNATURE_DECLS,
+2
View File
@@ -46,6 +46,7 @@ tests_unit_test_SOURCES += tests/api/test_curve448.c
tests_unit_test_SOURCES += tests/api/test_ed448.c
tests_unit_test_SOURCES += tests/api/test_mlkem.c
tests_unit_test_SOURCES += tests/api/test_mldsa.c
tests_unit_test_SOURCES += tests/api/test_slhdsa.c
tests_unit_test_SOURCES += tests/api/test_signature.c
# TLS Protocol
tests_unit_test_SOURCES += tests/api/test_dtls.c
@@ -148,6 +149,7 @@ EXTRA_DIST += tests/api/test_curve448.h
EXTRA_DIST += tests/api/test_ed448.h
EXTRA_DIST += tests/api/test_mlkem.h
EXTRA_DIST += tests/api/test_mldsa.h
EXTRA_DIST += tests/api/test_slhdsa.h
EXTRA_DIST += tests/api/test_signature.h
EXTRA_DIST += tests/api/test_dtls.h
EXTRA_DIST += tests/api/test_ocsp.h
File diff suppressed because it is too large Load Diff
+48
View File
@@ -0,0 +1,48 @@
/* test_slhdsa.h
*
* Copyright (C) 2006-2026 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifndef WOLFCRYPT_TEST_SLHDSA_H
#define WOLFCRYPT_TEST_SLHDSA_H
#include <tests/api/api_decl.h>
int test_wc_slhdsa(void);
int test_wc_slhdsa_sizes(void);
int test_wc_slhdsa_make_key(void);
int test_wc_slhdsa_sign(void);
int test_wc_slhdsa_verify(void);
int test_wc_slhdsa_sign_vfy(void);
int test_wc_slhdsa_sign_hash(void);
int test_wc_slhdsa_export_import(void);
int test_wc_slhdsa_check_key(void);
#define TEST_SLHDSA_DECLS \
TEST_DECL_GROUP("slhdsa", test_wc_slhdsa), \
TEST_DECL_GROUP("slhdsa", test_wc_slhdsa_sizes), \
TEST_DECL_GROUP("slhdsa", test_wc_slhdsa_make_key), \
TEST_DECL_GROUP("slhdsa", test_wc_slhdsa_sign), \
TEST_DECL_GROUP("slhdsa", test_wc_slhdsa_verify), \
TEST_DECL_GROUP("slhdsa", test_wc_slhdsa_sign_vfy), \
TEST_DECL_GROUP("slhdsa", test_wc_slhdsa_sign_hash), \
TEST_DECL_GROUP("slhdsa", test_wc_slhdsa_export_import), \
TEST_DECL_GROUP("slhdsa", test_wc_slhdsa_check_key)
#endif /* WOLFCRYPT_TEST_SLHDSA_H */
+163 -1
View File
@@ -192,6 +192,9 @@
#include <wolfssl/wolfcrypt/wc_xmss.h>
#endif
#endif
#if defined(WOLFSSL_HAVE_SLHDSA)
#include <wolfssl/wolfcrypt/wc_slhdsa.h>
#endif
#ifdef WOLFCRYPT_HAVE_ECCSI
#include <wolfssl/wolfcrypt/eccsi.h>
#endif
@@ -965,6 +968,18 @@ static WC_INLINE void bench_append_memory_info(char* buffer, size_t size,
#else
#define BENCH_XMSS_XMSSMT 0x00000000
#endif
#define BENCH_SLHDSA_SHAKE128S 0x00000020
#define BENCH_SLHDSA_SHAKE128F 0x00000040
#define BENCH_SLHDSA_SHAKE192S 0x00000080
#define BENCH_SLHDSA_SHAKE192F 0x00000100
#define BENCH_SLHDSA_SHAKE256S 0x00000200
#define BENCH_SLHDSA_SHAKE256F 0x00000400
#define BENCH_SLHDSA (BENCH_SLHDSA_SHAKE128S | \
BENCH_SLHDSA_SHAKE128F | \
BENCH_SLHDSA_SHAKE192S | \
BENCH_SLHDSA_SHAKE192F | \
BENCH_SLHDSA_SHAKE256S | \
BENCH_SLHDSA_SHAKE256F)
/* Other */
#define BENCH_RNG 0x00000001
@@ -987,7 +1002,8 @@ static WC_INLINE void bench_append_memory_info(char* buffer, size_t size,
#endif
#if (defined(WOLFSSL_HAVE_LMS) && !defined(WOLFSSL_LMS_VERIFY_ONLY)) || \
(defined(WOLFSSL_HAVE_XMSS) && !defined(WOLFSSL_XMSS_VERIFY_ONLY))
(defined(WOLFSSL_HAVE_XMSS) && !defined(WOLFSSL_XMSS_VERIFY_ONLY)) || \
defined(WOLFSSL_HAVE_SLHDSA)
#define BENCH_PQ_STATEFUL_HBS
#endif
@@ -1315,6 +1331,15 @@ static const bench_pq_hash_sig_alg bench_pq_hash_sig_opt[] = {
#ifdef WC_XMSS_SHAKE256
{ "-xmss_xmssmt_shake256", BENCH_XMSS_XMSSMT_SHAKE256},
#endif
#endif
#if defined(WOLFSSL_HAVE_SLHDSA)
{ "-slhdsa-shake128s", BENCH_SLHDSA_SHAKE128S},
{ "-slhdsa-shake128f", BENCH_SLHDSA_SHAKE128F},
{ "-slhdsa-shake192s", BENCH_SLHDSA_SHAKE192S},
{ "-slhdsa-shake192f", BENCH_SLHDSA_SHAKE192F},
{ "-slhdsa-shake256s", BENCH_SLHDSA_SHAKE256S},
{ "-slhdsa-shake256f", BENCH_SLHDSA_SHAKE256F},
{ "-slhdsa", BENCH_SLHDSA },
#endif
{ NULL, 0}
};
@@ -4335,6 +4360,42 @@ static void* benchmarks_do(void* args)
#endif
#endif /* if defined(WOLFSSL_HAVE_XMSS) && !defined(WOLFSSL_XMSS_VERIFY_ONLY) */
#if defined(WOLFSSL_HAVE_SLHDSA) && !defined(WOLFSSL_SLHDSA_VERIFY_ONLY)
if (bench_all) {
bench_pq_hash_sig_algs |= BENCH_SLHDSA;
}
#ifdef WOLFSSL_SLHDSA_PARAM_128S
if (bench_pq_hash_sig_algs & BENCH_SLHDSA_SHAKE128S) {
bench_slhdsa(SLHDSA_SHAKE128S);
}
#endif
#ifdef WOLFSSL_SLHDSA_PARAM_128F
if (bench_pq_hash_sig_algs & BENCH_SLHDSA_SHAKE128F) {
bench_slhdsa(SLHDSA_SHAKE128F);
}
#endif
#ifdef WOLFSSL_SLHDSA_PARAM_192S
if (bench_pq_hash_sig_algs & BENCH_SLHDSA_SHAKE192S) {
bench_slhdsa(SLHDSA_SHAKE192S);
}
#endif
#ifdef WOLFSSL_SLHDSA_PARAM_192F
if (bench_pq_hash_sig_algs & BENCH_SLHDSA_SHAKE192F) {
bench_slhdsa(SLHDSA_SHAKE192F);
}
#endif
#ifdef WOLFSSL_SLHDSA_PARAM_256S
if (bench_pq_hash_sig_algs & BENCH_SLHDSA_SHAKE256S) {
bench_slhdsa(SLHDSA_SHAKE256S);
}
#endif
#ifdef WOLFSSL_SLHDSA_PARAM_256F
if (bench_pq_hash_sig_algs & BENCH_SLHDSA_SHAKE256F) {
bench_slhdsa(SLHDSA_SHAKE256F);
}
#endif
#endif
#if defined(HAVE_ECC) && !defined(WC_NO_RNG)
if (bench_all || (bench_asym_algs & BENCH_ECC_MAKEKEY) ||
(bench_asym_algs & BENCH_ECC) ||
@@ -11960,6 +12021,107 @@ void bench_xmss(int hash)
}
#endif /* if defined(WOLFSSL_HAVE_XMSS) && !defined(WOLFSSL_XMSS_VERIFY_ONLY) */
#if defined(WOLFSSL_HAVE_SLHDSA) && !defined(WOLFSSL_SLHDSA_VERIFY_ONLY)
void bench_slhdsa(enum SlhDsaParam param)
{
int ret = 0, count = 0;
double start = 0;
SlhDsaKey key;
SlhDsaKey key_vfy;
byte sig[WC_SLHDSA_MAX_SIG_LEN];
word32 sigLen;
byte pk[2 * 32];
word32 outLen;
static const byte msg[] = {
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f,
0x72, 0x6c, 0x64, 0x21
};
byte ctx[1];
char name[30];
int len;
XMEMSET(&key, 0, sizeof(key));
XMEMSET(&key_vfy, 0, sizeof(key_vfy));
ret = wc_SlhDsaKey_Init(&key, param, NULL, INVALID_DEVID);
if (ret != 0) {
goto exit;
}
len = wc_SlhDsaKey_PublicSize(&key) / 2 * 8;
XMEMCPY(name, "SLH-DSA-S", 10);
if ((param & 1) == 1) {
name[8] = 'F';
}
bench_stats_start(&count, &start);
do {
ret = wc_SlhDsaKey_MakeKey(&key, &gRng);
if (ret != 0) {
goto exit;
}
count++;
RECORD_MULTI_VALUE_STATS();
} while (bench_stats_check(start)
#ifdef MULTI_VALUE_STATISTICS
|| runs < minimum_runs
#endif
);
bench_stats_asym_finish(name, len, "gen", 0, count, start, ret);
bench_stats_start(&count, &start);
do {
sigLen = (word32)sizeof(sig);
ret = wc_SlhDsaKey_Sign(&key, ctx, 0, msg, (word32)sizeof(msg),
sig, &sigLen, &gRng);
if (ret != 0) {
goto exit;
}
count++;
RECORD_MULTI_VALUE_STATS();
} while (bench_stats_check(start)
#ifdef MULTI_VALUE_STATISTICS
|| runs < minimum_runs
#endif
);
bench_stats_asym_finish(name, len, "sign", 0, count, start, ret);
outLen = (word32)sizeof(pk);
ret = wc_SlhDsaKey_ExportPublic(&key, pk, &outLen);
if (ret != 0) {
goto exit;
}
ret = wc_SlhDsaKey_Init(&key_vfy, param, NULL, INVALID_DEVID);
if (ret != 0) {
goto exit;
}
ret = wc_SlhDsaKey_ImportPublic(&key_vfy, pk, outLen);
if (ret != 0) {
goto exit;
}
bench_stats_start(&count, &start);
do {
ret = wc_SlhDsaKey_Verify(&key_vfy, ctx, 0, msg, (word32)sizeof(msg),
sig, sigLen);
if (ret != 0) {
goto exit;
}
count++;
RECORD_MULTI_VALUE_STATS();
} while (bench_stats_check(start)
#ifdef MULTI_VALUE_STATISTICS
|| runs < minimum_runs
#endif
);
bench_stats_asym_finish(name, len, "verify", 0, count, start, ret);
exit:
wc_SlhDsaKey_Free(&key_vfy);
wc_SlhDsaKey_Free(&key);
}
#endif
#if defined(HAVE_ECC) && !defined(WC_NO_RNG)
/* Maximum ECC name plus null terminator:
+3
View File
@@ -105,6 +105,9 @@ void bench_dh(int useDeviceID);
void bench_mlkem(int type);
void bench_lms(void);
void bench_xmss(int hash);
#ifdef WOLFSSL_HAVE_SLHDSA
void bench_slhdsa(enum SlhDsaParam param);
#endif
void bench_ecc_curve(int curveId);
void bench_eccMakeKey(int useDeviceID, int curveId);
void bench_ecc(int useDeviceID, int curveId);
+1 -1
View File
@@ -1,6 +1,6 @@
; /* aes_gcm_asm.asm */
; /*
; * Copyright (C) 2006-2026 wolfSSL Inc.
; * Copyright (C) 2006-2026 wolfSSL Inc.
; *
; * This file is part of wolfSSL.
; *
+1 -1
View File
@@ -1,6 +1,6 @@
; /* aes_xts_asm.asm */
; /*
; * Copyright (C) 2006-2026 wolfSSL Inc.
; * Copyright (C) 2006-2026 wolfSSL Inc.
; *
; * This file is part of wolfSSL.
; *
+1 -1
View File
@@ -1,6 +1,6 @@
; /* chacha_asm.asm */
; /*
; * Copyright (C) 2006-2026 wolfSSL Inc.
; * Copyright (C) 2006-2026 wolfSSL Inc.
; *
; * This file is part of wolfSSL.
; *
+1 -1
View File
@@ -1,6 +1,6 @@
; /* poly1305_asm.asm */
; /*
; * Copyright (C) 2006-2026 wolfSSL Inc.
; * Copyright (C) 2006-2026 wolfSSL Inc.
; *
; * This file is part of wolfSSL.
; *
+2 -2
View File
@@ -9928,7 +9928,7 @@ L_sha3_block_n_avx2_rounds:
#ifndef __APPLE__
.size sha3_block_n_avx2,.-sha3_block_n_avx2
#endif /* __APPLE__ */
#if defined(WOLFSSL_WC_MLKEM) || defined(WOLFSSL_WC_DILITHIUM)
#if defined(WOLFSSL_WC_MLKEM) || defined(WOLFSSL_WC_DILITHIUM) || defined(WOLFSSL_HAVE_SLHDSA)
#ifndef __APPLE__
.text
.globl sha3_blocksx4_avx2
@@ -20664,7 +20664,7 @@ _sha3_128_blocksx4_seed_avx2:
#ifndef __APPLE__
.size sha3_128_blocksx4_seed_avx2,.-sha3_128_blocksx4_seed_avx2
#endif /* __APPLE__ */
#endif /* defined(WOLFSSL_WC_MLKEM) || defined(WOLFSSL_WC_DILITHIUM) */
#endif /* defined(WOLFSSL_WC_MLKEM) || defined(WOLFSSL_WC_DILITHIUM) || defined(WOLFSSL_HAVE_SLHDSA) */
#ifdef WOLFSSL_WC_MLKEM
#ifndef __APPLE__
.data
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+3
View File
@@ -293,6 +293,9 @@ extern WOLFSSL_TEST_SUBROUTINE wc_test_ret_t scrypt_test(void);
extern WOLFSSL_TEST_SUBROUTINE wc_test_ret_t lms_test(void);
#endif
#endif
#if defined(WOLFSSL_HAVE_SLHDSA)
extern WOLFSSL_TEST_SUBROUTINE wc_test_ret_t slhdsa_test(void);
#endif
#ifdef WOLFCRYPT_HAVE_ECCSI
extern WOLFSSL_TEST_SUBROUTINE wc_test_ret_t eccsi_test(void);
#endif
+1
View File
@@ -88,6 +88,7 @@ nobase_include_HEADERS+= \
wolfssl/wolfcrypt/xmss.h \
wolfssl/wolfcrypt/wc_xmss.h \
wolfssl/wolfcrypt/ext_xmss.h \
wolfssl/wolfcrypt/wc_slhdsa.h \
wolfssl/wolfcrypt/oid_sum.h
noinst_HEADERS+= \
+1
View File
@@ -1362,6 +1362,7 @@ enum {
DYNAMIC_TYPE_OS_BUF = 104,
DYNAMIC_TYPE_ASCON = 105,
DYNAMIC_TYPE_SHA = 106,
DYNAMIC_TYPE_SLHDSA = 107,
DYNAMIC_TYPE_SNIFFER_SERVER = 1000,
DYNAMIC_TYPE_SNIFFER_SESSION = 1001,
DYNAMIC_TYPE_SNIFFER_PB = 1002,
+380
View File
@@ -0,0 +1,380 @@
/* wc_slhdsa.h
*
* Copyright (C) 2006-2026 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifndef WOLF_CRYPT_WC_SLHDSA_H
#define WOLF_CRYPT_WC_SLHDSA_H
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/wolfcrypt/sha3.h>
#ifdef WOLFSSL_HAVE_SLHDSA
/* When a bits/opt is defined then ensure 'NO' defines are off. */
#ifdef WOLFSSL_SLHDSA_PARAM_128S
#undef WOLFSSL_SLHDSA_PARAM_NO_128S
#undef WOLFSSL_SLHDSA_PARAM_NO_128
#undef WOLFSSL_SLHDSA_PARAM_NO_SMALL
#endif
#ifdef WOLFSSL_SLHDSA_PARAM_128F
#undef WOLFSSL_SLHDSA_PARAM_NO_128F
#undef WOLFSSL_SLHDSA_PARAM_NO_128
#undef WOLFSSL_SLHDSA_PARAM_NO_FAST
#endif
#ifdef WOLFSSL_SLHDSA_PARAM_192S
#undef WOLFSSL_SLHDSA_PARAM_NO_192S
#undef WOLFSSL_SLHDSA_PARAM_NO_192
#undef WOLFSSL_SLHDSA_PARAM_NO_SMALL
#endif
#ifdef WOLFSSL_SLHDSA_PARAM_192F
#undef WOLFSSL_SLHDSA_PARAM_NO_192F
#undef WOLFSSL_SLHDSA_PARAM_NO_192
#undef WOLFSSL_SLHDSA_PARAM_NO_FAST
#endif
#ifdef WOLFSSL_SLHDSA_PARAM_256S
#undef WOLFSSL_SLHDSA_PARAM_NO_256S
#undef WOLFSSL_SLHDSA_PARAM_NO_256
#undef WOLFSSL_SLHDSA_PARAM_NO_SMALL
#endif
#ifdef WOLFSSL_SLHDSA_PARAM_256F
#undef WOLFSSL_SLHDSA_PARAM_NO_256F
#undef WOLFSSL_SLHDSA_PARAM_NO_256
#undef WOLFSSL_SLHDSA_PARAM_NO_FAST
#endif
/* When 'NO' defines are on then define no parameter set. */
#if defined(WOLFSSL_SLHDSA_PARAM_NO_128S) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_128F)
#undef WOLFSSL_SLHDSA_NO_128
#define WOLFSSL_SLHDSA_NO_128
#endif
#if defined(WOLFSSL_SLHDSA_PARAM_NO_192S) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_192F)
#undef WOLFSSL_SLHDSA_NO_192
#define WOLFSSL_SLHDSA_NO_192
#endif
#if defined(WOLFSSL_SLHDSA_PARAM_NO_256S) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_256F)
#undef WOLFSSL_SLHDSA_NO_256
#define WOLFSSL_SLHDSA_NO_256
#endif
#if defined(WOLFSSL_SLHDSA_PARAM_NO_128S) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_192S) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_256S)
#undef WOLFSSL_SLHDSA_PARAM_NO_SMALL
#define WOLFSSL_SLHDSA_PARAM_NO_SMALL
#endif
#if defined(WOLFSSL_SLHDSA_PARAM_NO_128F) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_192F) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_256F)
#undef WOLFSSL_SLHDSA_PARAM_NO_FAST
#define WOLFSSL_SLHDSA_PARAM_NO_FAST
#endif
/* Turn on parameter set based on 'NO' defines. */
#if !defined(WOLFSSL_SLHDSA_PARAM_NO_128S) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_128) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_SMALL)
#undef WOLFSSL_SLHDSA_PARAM_128S
#define WOLFSSL_SLHDSA_PARAM_128S
#endif
#if !defined(WOLFSSL_SLHDSA_PARAM_NO_128F) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_128) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_FAST)
#undef WOLFSSL_SLHDSA_PARAM_128F
#define WOLFSSL_SLHDSA_PARAM_128F
#endif
#if !defined(WOLFSSL_SLHDSA_PARAM_NO_192S) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_192) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_SMALL)
#undef WOLFSSL_SLHDSA_PARAM_192S
#define WOLFSSL_SLHDSA_PARAM_192S
#endif
#if !defined(WOLFSSL_SLHDSA_PARAM_NO_192F) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_192) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_FAST)
#undef WOLFSSL_SLHDSA_PARAM_192F
#define WOLFSSL_SLHDSA_PARAM_192F
#endif
#if !defined(WOLFSSL_SLHDSA_PARAM_NO_256S) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_256) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_SMALL)
#undef WOLFSSL_SLHDSA_PARAM_256S
#define WOLFSSL_SLHDSA_PARAM_256S
#endif
#if !defined(WOLFSSL_SLHDSA_PARAM_NO_256F) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_256) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_FAST)
#undef WOLFSSL_SLHDSA_PARAM_256F
#define WOLFSSL_SLHDSA_PARAM_256F
#endif
#if defined(WOLFSSL_SLHDSA_PARAM_NO_128S) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_192S) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_256S)
#undef WOLFSSL_SLHDSA_PARAM_NO_SMALL
#define WOLFSSL_SLHDSA_PARAM_NO_SMALL
#endif
#if defined(WOLFSSL_SLHDSA_PARAM_NO_128F) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_192F) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_256F)
#undef WOLFSSL_SLHDSA_PARAM_NO_FAST
#define WOLFSSL_SLHDSA_PARAM_NO_FAST
#endif
#if defined(WOLFSSL_SLHDSA_PARAM_NO_128S) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_128F)
#undef WOLFSSL_SLHDSA_PARAM_NO_128
#define WOLFSSL_SLHDSA_PARAM_NO_128
#endif
#if defined(WOLFSSL_SLHDSA_PARAM_NO_192S) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_192F)
#undef WOLFSSL_SLHDSA_PARAM_NO_192
#define WOLFSSL_SLHDSA_PARAM_NO_192
#endif
#if defined(WOLFSSL_SLHDSA_PARAM_NO_256S) && \
defined(WOLFSSL_SLHDSA_PARAM_NO_256F)
#undef WOLFSSL_SLHDSA_PARAM_NO_256
#define WOLFSSL_SLHDSA_PARAM_NO_256
#endif
/* Seed length for SLH-DSA SHAKE-128s/f. */
#define WC_SLHDSA_SHAKE128_SEED_LEN 16
/* Seed length for SLH-DSA SHAKE-192s/f. */
#define WC_SLHDSA_SHAKE192_SEED_LEN 24
/* Seed length for SLH-DSA SHAKE-256s/f. */
#define WC_SLHDSA_SHAKE256_SEED_LEN 32
/* Private key length for SLH-DSA SHAKE-128s. */
#define WC_SLHDSA_SHAKE128S_PRIV_LEN (4 * 16)
/* Public key length for SLH-DSA SHAKE-128s. */
#define WC_SLHDSA_SHAKE128S_PUB_LEN (2 * 16)
/* Signature length for SLH-DSA SHAKE-128s. */
#define WC_SLHDSA_SHAKE128S_SIG_LEN 7856
/* Seed length for SLH-DSA SHAKE-128s. */
#define WC_SLHDSA_SHAKE128S_SEED_LEN WC_SLHDSA_SHAKE128_SEED_LEN
/* Private key length for SLH-DSA SHAKE-128f. */
#define WC_SLHDSA_SHAKE128F_PRIV_LEN (4 * 16)
/* Public key length for SLH-DSA SHAKE-128f. */
#define WC_SLHDSA_SHAKE128F_PUB_LEN (2 * 16)
/* Signature length for SLH-DSA SHAKE-128f. */
#define WC_SLHDSA_SHAKE128F_SIG_LEN 17088
/* Seed length for SLH-DSA SHAKE-128f. */
#define WC_SLHDSA_SHAKE128F_SEED_LEN WC_SLHDSA_SHAKE128_SEED_LEN
/* Private key length for SLH-DSA SHAKE-192s. */
#define WC_SLHDSA_SHAKE192S_PRIV_LEN (4 * 24)
/* Public key length for SLH-DSA SHAKE-192s. */
#define WC_SLHDSA_SHAKE192S_PUB_LEN (2 * 24)
/* Signature length for SLH-DSA SHAKE-192s. */
#define WC_SLHDSA_SHAKE192S_SIG_LEN 16224
/* Seed length for SLH-DSA SHAKE-192s. */
#define WC_SLHDSA_SHAKE192S_SEED_LEN WC_SLHDSA_SHAKE192_SEED_LEN
/* Private key length for SLH-DSA SHAKE-192f. */
#define WC_SLHDSA_SHAKE192F_PRIV_LEN (4 * 24)
/* Public key length for SLH-DSA SHAKE-192f. */
#define WC_SLHDSA_SHAKE192F_PUB_LEN (2 * 24)
/* Signature length for SLH-DSA SHAKE-192f. */
#define WC_SLHDSA_SHAKE192F_SIG_LEN 35664
/* Seed length for SLH-DSA SHAKE-192f. */
#define WC_SLHDSA_SHAKE192F_SEED_LEN WC_SLHDSA_SHAKE192_SEED_LEN
/* Private key length for SLH-DSA SHAKE-256s. */
#define WC_SLHDSA_SHAKE256S_PRIV_LEN (4 * 32)
/* Public key length for SLH-DSA SHAKE-256s. */
#define WC_SLHDSA_SHAKE256S_PUB_LEN (2 * 32)
/* Signature length for SLH-DSA SHAKE-256s. */
#define WC_SLHDSA_SHAKE256S_SIG_LEN 29792
/* Seed length for SLH-DSA SHAKE-256s. */
#define WC_SLHDSA_SHAKE256S_SEED_LEN WC_SLHDSA_SHAKE256_SEED_LEN
/* Private key length for SLH-DSA SHAKE-256f. */
#define WC_SLHDSA_SHAKE256F_PRIV_LEN (4 * 32)
/* Public key length for SLH-DSA SHAKE-256f. */
#define WC_SLHDSA_SHAKE256F_PUB_LEN (2 * 32)
/* Signature length for SLH-DSA SHAKE-256f. */
#define WC_SLHDSA_SHAKE256F_SIG_LEN 49856
/* Seed length for SLH-DSA SHAKE-256f. */
#define WC_SLHDSA_SHAKE256F_SEED_LEN WC_SLHDSA_SHAKE256_SEED_LEN
/* Determine maximum private and public key lengths based on maximum SHAKE-256
* output length. */
#ifndef WOLFSSL_SLHDSA_PARAM_NO_256
/* Maximum private key length. */
#define WC_SLHDSA_MAX_PRIV_LEN WC_SLHDSA_SHAKE256F_PRIV_LEN
/* Maximum public key length. */
#define WC_SLHDSA_MAX_PUB_LEN WC_SLHDSA_SHAKE256F_PUB_LEN
/* Maximum seed length. */
#define WC_SLHDSA_MAX_SEED WC_SLHDSA_SHAKE256_SEED_LEN
#elif !defined(WOLFSSL_SLHDSA_PARAM_NO_192)
/* Maximum private key length. */
#define WC_SLHDSA_MAX_PRIV_LEN WC_SLHDSA_SHAKE192F_PRIV_LEN
/* Maximum public key length. */
#define WC_SLHDSA_MAX_PUB_LEN WC_SLHDSA_SHAKE192F_PUB_LEN
/* Maximum seed length. */
#define WC_SLHDSA_MAX_SEED WC_SLHDSA_SHAKE192_SEED_LEN
#else
/* Maximum private key length. */
#define WC_SLHDSA_MAX_PRIV_LEN WC_SLHDSA_SHAKE128F_PRIV_LEN
/* Maximum public key length. */
#define WC_SLHDSA_MAX_PUB_LEN WC_SLHDSA_SHAKE128F_PUB_LEN
/* Maximum seed length. */
#define WC_SLHDSA_MAX_SEED WC_SLHDSA_SHAKE128_SEED_LEN
#endif
/* Determine maximum signature length depending on the parameters compiled in.
*/
#if !defined(WOLFSSL_SLHDSA_PARAM_NO_256) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_FAST)
/* Maximum signature length. */
#define WC_SLHDSA_MAX_SIG_LEN WC_SLHDSA_SHAKE256F_SIG_LEN
#elif !defined(WOLFSSL_SLHDSA_PARAM_NO_192) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_FAST)
/* Maximum signature length. */
#define WC_SLHDSA_MAX_SIG_LEN WC_SLHDSA_SHAKE192F_SIG_LEN
#elif !defined(WOLFSSL_SLHDSA_PARAM_NO_256) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_SMALL)
/* Maximum signature length. */
#define WC_SLHDSA_MAX_SIG_LEN WC_SLHDSA_SHAKE256S_SIG_LEN
#elif !defined(WOLFSSL_SLHDSA_PARAM_NO_128) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_FAST)
/* Maximum signature length. */
#define WC_SLHDSA_MAX_SIG_LEN WC_SLHDSA_SHAKE128F_SIG_LEN
#elif !defined(WOLFSSL_SLHDSA_PARAM_NO_192) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_SMALL)
/* Maximum signature length. */
#define WC_SLHDSA_MAX_SIG_LEN WC_SLHDSA_SHAKE192S_SIG_LEN
#elif !defined(WOLFSSL_SLHDSA_PARAM_NO_128) && \
!defined(WOLFSSL_SLHDSA_PARAM_NO_SMALL)
/* Maximum signature length. */
#define WC_SLHDSA_MAX_SIG_LEN WC_SLHDSA_SHAKE128S_SIG_LEN
#else
#error "No parameters defined"
#endif
/* Ids for supported SLH-DSA parameters. */
enum SlhDsaParam {
SLHDSA_SHAKE128S = 0, /* SLH-DSA SHAKE128s */
SLHDSA_SHAKE128F = 1, /* SLH-DSA SHAKE128f */
SLHDSA_SHAKE192S = 2, /* SLH-DSA SHAKE192s */
SLHDSA_SHAKE192F = 3, /* SLH-DSA SHAKE192f */
SLHDSA_SHAKE256S = 4, /* SLH-DSA SHAKE256s */
SLHDSA_SHAKE256F = 5, /* SLH-DSA SHAKE256f */
};
/* Pre-defined parameter values. */
typedef struct SlhDsaParameters {
enum SlhDsaParam param; /* Parameter set id. */
byte n; /* Size of digest output. */
byte h; /* Total tree height. */
byte d; /* Depth of subtree. */
byte h_m; /* Height of message tree - XMSS tree. */
byte a; /* Number of authenthication nodes. */
byte k; /* Number of FORS signatures. */
byte len; /* Length of WOTS+ encoded message with csum. */
byte dl1; /* Length first part of message digest. */
byte dl2; /* Length second part of message digest. */
byte dl3; /* Length third part of message digest. */
word32 sigLen; /* Signature length in bytes. */
} SlhDsaParameters;
#define WC_SLHDSA_FLAG_PRIVATE 0x0001
#define WC_SLHDSA_FLAG_PUBLIC 0x0002
#define WC_SLHDSA_FLAG_BOTH_KEYS (WC_SLHDSA_FLAG_PRIVATE | \
WC_SLHDSA_FLAG_PUBLIC)
/* SLH-DSA key data and state. */
typedef struct SlhDsaKey {
/* Parameters. */
const SlhDsaParameters* params;
/* Flags of the key. */
int flags;
/* Dynamic memory hint. */
void* heap;
#ifdef WOLF_CRYPTO_CB
/* Device Identifier. */
int devId;
#endif
/* sk_seed | sk_prf | pk_seed, pk_root */
byte sk[32 * 4];
/* First SHAKE-256 object. */
wc_Shake shake;
/* Second SHAKE-256 object. */
wc_Shake shake2;
} SlhDsaKey;
WOLFSSL_API int wc_SlhDsaKey_Init(SlhDsaKey* key, enum SlhDsaParam param,
void* heap, int devId);
WOLFSSL_API void wc_SlhDsaKey_Free(SlhDsaKey* key);
WOLFSSL_API int wc_SlhDsaKey_MakeKey(SlhDsaKey* key, WC_RNG* rng);
WOLFSSL_API int wc_SlhDsaKey_MakeKeyWithRandom(SlhDsaKey* key,
const byte* sk_seed, word32 sk_seed_len,
const byte* sk_prf, word32 sk_prf_len,
const byte* pk_seed, word32 pk_seed_len);
WOLFSSL_API int wc_SlhDsaKey_SignDeterministic(SlhDsaKey* key, const byte* ctx,
byte ctxSz, const byte* msg, word32 msgSz, byte* sig, word32* sigSz);
WOLFSSL_API int wc_SlhDsaKey_SignWithRandom(SlhDsaKey* key, const byte* ctx,
byte ctxSz, const byte* msg, word32 msgSz, byte* sig, word32* sigSz,
const byte* addRnd);
WOLFSSL_API int wc_SlhDsaKey_Sign(SlhDsaKey* key, const byte* ctx,
byte ctxSz, const byte* msg, word32 msgSz, byte* sig, word32* sigSz,
WC_RNG* rng);
WOLFSSL_API int wc_SlhDsaKey_Verify(SlhDsaKey* key, const byte* ctx,
byte ctxSz, const byte* msg, word32 msgSz, const byte* sig, word32 sigSz);
WOLFSSL_API int wc_SlhDsaKey_SignHashDeterministic(SlhDsaKey* key,
const byte* ctx, byte ctxSz, const byte* msg, word32 msgSz,
enum wc_HashType hashType, byte* sig, word32* sigSz);
WOLFSSL_API int wc_SlhDsaKey_SignHashWithRandom(SlhDsaKey* key,
const byte* ctx, byte ctxSz, const byte* msg, word32 msgSz,
enum wc_HashType hashType, byte* sig, word32* sigSz, byte* addRnd);
WOLFSSL_API int wc_SlhDsaKey_SignHash(SlhDsaKey* key, const byte* ctx,
byte ctxSz, const byte* msg, word32 msgSz, enum wc_HashType hashType,
byte* sig, word32* sigSz, WC_RNG* rng);
WOLFSSL_API int wc_SlhDsaKey_VerifyHash(SlhDsaKey* key, const byte* ctx,
byte ctxSz, const byte* msg, word32 msgSz, enum wc_HashType hashType,
const byte* sig, word32 sigSz);
WOLFSSL_API int wc_SlhDsaKey_ImportPrivate(SlhDsaKey* key, const byte* in,
word32 inLen);
WOLFSSL_API int wc_SlhDsaKey_ImportPublic(SlhDsaKey* key, const byte* in,
word32 inLen);
WOLFSSL_API int wc_SlhDsaKey_CheckKey(SlhDsaKey* key);
WOLFSSL_API int wc_SlhDsaKey_ExportPrivate(SlhDsaKey* key, byte* out,
word32* outLen);
WOLFSSL_API int wc_SlhDsaKey_ExportPublic(SlhDsaKey* key, byte* out,
word32* outLen);
WOLFSSL_API int wc_SlhDsaKey_PrivateSize(SlhDsaKey* key);
WOLFSSL_API int wc_SlhDsaKey_PublicSize(SlhDsaKey* key);
WOLFSSL_API int wc_SlhDsaKey_SigSize(SlhDsaKey* key);
WOLFSSL_API int wc_SlhDsaKey_PrivateSizeFromParam(enum SlhDsaParam param);
WOLFSSL_API int wc_SlhDsaKey_PublicSizeFromParam(enum SlhDsaParam param);
WOLFSSL_API int wc_SlhDsaKey_SigSizeFromParam(enum SlhDsaParam param);
#endif /* WOLFSSL_HAVE_SLHDSA */
#endif /* WOLF_CRYPT_WC_SLHDSA_H */