Skip to content

Commit 70f39fe

Browse files
committed
Fixing up tests and preparing for SLH-DSA integration
1 parent 6b8c222 commit 70f39fe

3 files changed

Lines changed: 47 additions & 14 deletions

File tree

configure.ac

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6230,6 +6230,16 @@ AS_CASE([$FIPS_VERSION],
62306230
# LMS: enable SHA-256/192 and SHAKE256 parameter sets for FIPS v7
62316231
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_LMS_SHA256_192 -DWOLFSSL_LMS_SHAKE256"
62326232
6233+
AS_IF([test "$ENABLED_SLHDSA" != "yes" &&
6234+
(test "$FIPS_VERSION" != "dev" || test "$enable_slhdsa" != "no")],
6235+
[ENABLED_SLHDSA="yes"
6236+
SLHDSA_PARAM_128S="yes"
6237+
SLHDSA_PARAM_128F="yes"
6238+
SLHDSA_PARAM_192S="yes"
6239+
SLHDSA_PARAM_192F="yes"
6240+
SLHDSA_PARAM_256S="yes"
6241+
SLHDSA_PARAM_256F="yes"])
6242+
62336243
# SHA-256 DRBG -- cannot be disabled at build time in FIPS mode
62346244
AS_IF([test "$enable_sha256_drbg" = "no"],
62356245
[AC_MSG_WARN([Can not disable SHA256-DRBG at build time in FIPS mode, disable at run-time with wc_Sha256Drbg_Disable() or wc_Sha256Drbg_Disable_fips()])])
@@ -7352,11 +7362,16 @@ if test "x$ENABLED_HASHDRBG" != "xyes" && test "x$ENABLED_FIPS" = "xyes" && test
73527362
then
73537363
if test "$enable_hashdrbg" = "no"
73547364
then
7355-
AC_MSG_WARN([SHA256-DRBG and SHA512-DRBG required in FIPS build, may be disabled at run-time with wc_Sha256Drbg_Disable_fips() or wc_Sha512Drbg_Disable_fips()])
7365+
AC_MSG_WARN([SHA256-DRBG required in FIPS build])
73567366
fi
73577367
ENABLED_HASHDRBG=yes
73587368
ENABLED_SHA256_DRBG=yes
7359-
ENABLED_SHA512_DRBG=yes
7369+
fi
7370+
7371+
# SHA-512 DRBG and runtime DRBG disable/enable APIs are v7+ only
7372+
if test "x$ENABLED_FIPS" = "xyes" && test $HAVE_FIPS_VERSION -lt 7
7373+
then
7374+
ENABLED_SHA512_DRBG=no
73607375
fi
73617376
73627377
# Set Hash DRBG compiler flags

src/include.am

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,10 @@ src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_xmss.c
11401140
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_xmss_impl.c
11411141
endif
11421142

1143+
if BUILD_WC_SLHDSA
1144+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_slhdsa.c
1145+
endif
1146+
11431147
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/fips.c \
11441148
wolfcrypt/src/fips_test.c
11451149

@@ -1809,9 +1813,11 @@ src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_xmss_impl.c
18091813
endif
18101814
endif !BUILD_FIPS_V7_PLUS
18111815

1816+
if !BUILD_FIPS_V7_PLUS
18121817
if BUILD_WC_SLHDSA
18131818
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_slhdsa.c
18141819
endif
1820+
endif !BUILD_FIPS_V7_PLUS
18151821

18161822
if !BUILD_FIPS_V6_PLUS
18171823
if BUILD_CURVE25519

tests/api/test_hash.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ static const enum wc_HashType supportedHash[] = {
6868
WC_HASH_TYPE_SHA3_256,
6969
WC_HASH_TYPE_SHA3_384,
7070
WC_HASH_TYPE_SHA3_512,
71+
#if defined(WOLFSSL_SHAKE128)
72+
WC_HASH_TYPE_SHAKE128,
73+
#endif
74+
#if defined(WOLFSSL_SHAKE256)
75+
WC_HASH_TYPE_SHAKE256,
76+
#endif
7177
#endif
7278
#ifdef WOLFSSL_SM3
7379
WC_HASH_TYPE_SM3,
@@ -101,19 +107,19 @@ static const enum wc_HashType notCompiledHash[] = {
101107
WC_HASH_TYPE_SHA3_256,
102108
WC_HASH_TYPE_SHA3_384,
103109
WC_HASH_TYPE_SHA3_512,
110+
#endif
111+
#if !defined(WOLFSSL_SHA3) || !defined(WOLFSSL_SHAKE128)
112+
WC_HASH_TYPE_SHAKE128,
113+
#endif
114+
#if !defined(WOLFSSL_SHA3) || !defined(WOLFSSL_SHAKE256)
115+
WC_HASH_TYPE_SHAKE256,
104116
#endif
105117
WC_HASH_TYPE_NONE /* Dummy value to ensure list is non-zero. */
106118
};
107119
static const int notCompiledHashLen = (sizeof(notCompiledHash) /
108120
sizeof(enum wc_HashType)) - 1;
109121

110122
static const enum wc_HashType notSupportedHash[] = {
111-
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_SHAKE128)
112-
WC_HASH_TYPE_SHAKE128,
113-
#endif
114-
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_SHAKE256)
115-
WC_HASH_TYPE_SHAKE256,
116-
#endif
117123
WC_HASH_TYPE_MD5_SHA,
118124
WC_HASH_TYPE_MD2,
119125
WC_HASH_TYPE_MD4,
@@ -137,6 +143,12 @@ static const enum wc_HashType sizeSupportedHash[] = {
137143
#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S)
138144
WC_HASH_TYPE_BLAKE2B,
139145
WC_HASH_TYPE_BLAKE2S,
146+
#endif
147+
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_SHAKE128)
148+
WC_HASH_TYPE_SHAKE128,
149+
#endif
150+
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_SHAKE256)
151+
WC_HASH_TYPE_SHAKE256,
140152
#endif
141153
WC_HASH_TYPE_NONE /* Dummy value to ensure list is non-zero. */
142154
};
@@ -155,18 +167,18 @@ static const enum wc_HashType sizeNotCompiledHash[] = {
155167
#if !defined(HAVE_BLAKE2) && !defined(HAVE_BLAKE2S)
156168
WC_HASH_TYPE_BLAKE2B,
157169
WC_HASH_TYPE_BLAKE2S,
170+
#endif
171+
#if !defined(WOLFSSL_SHA3) || !defined(WOLFSSL_SHAKE128)
172+
WC_HASH_TYPE_SHAKE128,
173+
#endif
174+
#if !defined(WOLFSSL_SHA3) || !defined(WOLFSSL_SHAKE256)
175+
WC_HASH_TYPE_SHAKE256,
158176
#endif
159177
WC_HASH_TYPE_NONE /* Dummy value to ensure list is non-zero. */
160178
};
161179
static const int sizeNotCompiledHashLen = (sizeof(sizeNotCompiledHash) /
162180
sizeof(enum wc_HashType)) - 1;
163181
static const enum wc_HashType sizeNotSupportedHash[] = {
164-
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_SHAKE128)
165-
WC_HASH_TYPE_SHAKE128,
166-
#endif
167-
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_SHAKE256)
168-
WC_HASH_TYPE_SHAKE256,
169-
#endif
170182
WC_HASH_TYPE_NONE
171183
};
172184
static const int sizeNotSupportedHashLen = (sizeof(sizeNotSupportedHash) /

0 commit comments

Comments
 (0)