Skip to content

Commit 7e935ed

Browse files
committed
SecurityReview FND 40.2 + 36.1 + 6.4 + 10.1 + 15.1 + 26.7 + 11.3 + 43.2 + 20.1 + 6.2: integrity, PCT, zeroize, CMAC/SHAKE/AES-KW CASTs, DH PCT + configurable DRBG_SHA512_SEED_LEN, ML-DSA sign privateKeyReadEnable parity, FIPS CAST benchmark deliverable, RSA 1024 removed from FIPS RsaSizeCheck, linuxkm AES-GCM tag-min 96-bit FIPS gate
6.2 (Medium): The pre-existing linuxkm relaxation of WOLFSSL_MIN_AUTH_TAG_SZ to 4 bytes (32 bits) in wolfssl/wolfcrypt/settings.h is now gated by #ifndef HAVE_FIPS. FIPS-mode linuxkm builds revert to the standard 96-bit (12-byte) minimum mandated by NIST SP 800-38D sec 5.2.1.2 / sec 8.2 and FIPS 140-3 IG C.H. Non-FIPS linuxkm builds retain the 32-bit-tag relaxation for kernel crypto manager test vector compatibility.
1 parent d00a137 commit 7e935ed

13 files changed

Lines changed: 535 additions & 15 deletions

File tree

fips-hash.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ then
1313
fi
1414

1515
OUT=$(./wolfcrypt/test/testwolfcrypt | sed -n 's/hash = \(.*\)/\1/p')
16-
NEWHASH=$(echo "$OUT" | cut -c1-64)
16+
# FIPS v7.0.0+ uses HMAC-SHA-512 (128 hex chars); older FIPS versions
17+
# use HMAC-SHA-256 (64 hex chars). Take the whole captured hash; the
18+
# static_assert on sizeof(verifyCore) guards against wrong length at
19+
# compile time after this script runs.
20+
NEWHASH=$(echo "$OUT" | head -n1 | tr -d '[:space:]')
1721
if test -n "$NEWHASH"
1822
then
1923
cp wolfcrypt/src/fips_test.c wolfcrypt/src/fips_test.c.bak

tests/api/test_mldsa.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,20 @@ int test_wc_dilithium_sign_pubonly_fails(void)
752752
/* Import only the public key into a fresh key object. */
753753
ExpectIntEQ(wc_dilithium_import_public(pubBuf, pubLen, pubOnlyKey), 0);
754754

755-
/* Signing with a public-key-only object must fail. */
755+
/* Signing with a public-key-only object must fail.
756+
*
757+
* In FIPS v7.0.0 mode the ML-DSA sign wrappers enforce the
758+
* privateKeyReadEnable contract (FIPS 140-3 sec 7.10.2 CSP access
759+
* control); without unlocking, the wrapper short-circuits to
760+
* FIPS_PRIVATE_KEY_LOCKED_E before reaching the no-private-key
761+
* detection. Unlock briefly so this test exercises the underlying
762+
* BAD_FUNC_ARG path it is designed to verify. The
763+
* PRIVATE_KEY_UNLOCK / PRIVATE_KEY_LOCK macros expand to no-ops in
764+
* non-FIPS builds. */
765+
PRIVATE_KEY_UNLOCK();
756766
ExpectIntEQ(wc_dilithium_sign_ctx_msg(NULL, 0, msg, sizeof(msg), sig,
757767
&sigLen, pubOnlyKey, &rng), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
768+
PRIVATE_KEY_LOCK();
758769

759770
DoExpectIntEQ(wc_FreeRng(&rng), 0);
760771
wc_dilithium_free(pubOnlyKey);
@@ -1236,6 +1247,12 @@ int test_wc_dilithium_sign_vfy(void)
12361247

12371248
ExpectIntEQ(wc_InitRng(&rng), 0);
12381249

1250+
/* FIPS v7.0.0 ML-DSA sign wrappers enforce the privateKeyReadEnable
1251+
* contract (FIPS 140-3 sec 7.10.2 CSP access control); unlock for the
1252+
* duration of this test's signing operations and re-lock at the end.
1253+
* Macros expand to no-ops in non-FIPS builds. */
1254+
PRIVATE_KEY_UNLOCK();
1255+
12391256
#ifndef WOLFSSL_NO_ML_DSA_44
12401257
ExpectIntEQ(wc_dilithium_init(key), 0);
12411258
ExpectIntEQ(wc_dilithium_set_level(key, WC_ML_DSA_44), 0);
@@ -1300,6 +1317,8 @@ int test_wc_dilithium_sign_vfy(void)
13001317
wc_dilithium_free(key);
13011318
#endif
13021319

1320+
PRIVATE_KEY_LOCK();
1321+
13031322
wc_FreeRng(&rng);
13041323
XFREE(sig, NULL, DYNAMIC_TYPE_TMP_BUFFER);
13051324
XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);

0 commit comments

Comments
 (0)