Skip to content

Commit 2ad5afa

Browse files
committed
wolfcrypt/src/wc_slhdsa.c: fixes for uninited data reads in slhdsakey_wots_sign_chain_x4_*() and slhdsakey_wots_pk_from_sig_x4;
CMakeLists.txt, cmake/functions.cmake, cmake/options.h.in: fixes for -DWOLFSSL_SLHDSA.
1 parent 23f62bc commit 2ad5afa

4 files changed

Lines changed: 19 additions & 8 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,10 @@ add_option(WOLFSSL_XMSS
778778
"no" "yes;no")
779779

780780
# SLH-DSA
781+
add_option(WOLFSSL_SLHDSA
782+
"Enable the wolfSSL SLH-DSA implementation (default: disabled)"
783+
"no" "yes;no")
784+
781785
if (WOLFSSL_SLHDSA)
782786
message(STATUS "Automatically set related requirements for SLH-DSA")
783787
add_definitions("-DWOLFSSL_HAVE_SLHDSA")
@@ -790,10 +794,6 @@ if (WOLFSSL_SLHDSA)
790794
message(STATUS "Looking for WOLFSSL_SLHDSA - found")
791795
endif()
792796

793-
add_option(WOLFSSL_SLHDSA
794-
"Enable the wolfSSL SLH-DSA implementation (default: disabled)"
795-
"no" "yes;no")
796-
797797
# TODO: - Lean PSK
798798
# - Lean TLS
799799
# - Low resource

cmake/functions.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ function(generate_build_flags)
226226
if(WOLFSSL_XMSS OR WOLFSSL_USER_SETTINGS)
227227
set(BUILD_WC_XMSS "yes" PARENT_SCOPE)
228228
endif()
229+
if(WOLFSSL_SLHDSA OR WOLFSSL_USER_SETTINGS)
230+
set(BUILD_WC_SLHDSA "yes" PARENT_SCOPE)
231+
endif()
229232
if(WOLFSSL_ARIA OR WOLFSSL_USER_SETTINGS)
230233
message(STATUS "ARIA functions.cmake found WOLFSSL_ARIA")
231234
# we cannot actually build, as we only have pre-compiled bin
@@ -1078,6 +1081,10 @@ function(generate_lib_src_list LIB_SOURCES)
10781081
list(APPEND LIB_SOURCES wolfcrypt/src/wc_xmss_impl.c)
10791082
endif()
10801083

1084+
if(BUILD_WC_SLHDSA)
1085+
list(APPEND LIB_SOURCES wolfcrypt/src/wc_slhdsa.c)
1086+
endif()
1087+
10811088
if(BUILD_LIBZ)
10821089
list(APPEND LIB_SOURCES wolfcrypt/src/compress.c)
10831090
endif()

cmake/options.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,10 @@ extern "C" {
410410
#cmakedefine HAVE_SECRET_CALLBACK
411411
#undef WC_RSA_DIRECT
412412
#cmakedefine WC_RSA_DIRECT
413+
#undef WOLFSSL_HAVE_SLHDSA
414+
#cmakedefine WOLFSSL_HAVE_SLHDSA
415+
#undef WOLFSSL_WC_SLHDSA
416+
#cmakedefine WOLFSSL_WC_SLHDSA
413417

414418
#ifdef __cplusplus
415419
}

wolfcrypt/src/wc_slhdsa.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,7 +2547,7 @@ static int slhdsakey_wots_sign_chain_x4_16(SlhDsaKey* key, const byte* msg,
25472547
int i;
25482548
sword8 j;
25492549
byte ii;
2550-
byte idx[4];
2550+
byte idx[4] = {0};
25512551
byte n = key->params->n;
25522552
byte len = key->params->len;
25532553
WC_DECLARE_VAR(sk, byte, 4 * 16, key->heap);
@@ -2627,7 +2627,7 @@ static int slhdsakey_wots_sign_chain_x4_24(SlhDsaKey* key, const byte* msg,
26272627
int i;
26282628
sword8 j;
26292629
byte ii;
2630-
byte idx[4];
2630+
byte idx[4] = {0};
26312631
byte n = key->params->n;
26322632
byte len = key->params->len;
26332633
WC_DECLARE_VAR(sk, byte, 4 * 24, key->heap);
@@ -2707,7 +2707,7 @@ static int slhdsakey_wots_sign_chain_x4_32(SlhDsaKey* key, const byte* msg,
27072707
int i;
27082708
sword8 j;
27092709
byte ii;
2710-
byte idx[4];
2710+
byte idx[4] = {0};
27112711
byte n = key->params->n;
27122712
byte len = key->params->len;
27132713
WC_DECLARE_VAR(sk, byte, 4 * 32, key->heap);
@@ -3183,7 +3183,7 @@ static int slhdsakey_wots_pk_from_sig_x4(SlhDsaKey* key, const byte* sig,
31833183
const byte* msg, const byte* pk_seed, word32* adrs, byte* pk_sig)
31843184
{
31853185
int ret = 0;
3186-
byte idx[4];
3186+
byte idx[4] = {0};
31873187
int i;
31883188
byte ii;
31893189
sword8 j;

0 commit comments

Comments
 (0)