Skip to content

Commit 73dc5a6

Browse files
committed
SecurityReview FND 40.2: upgrade in-core integrity HMAC to SHA-512
FIPS 140-3 v7.0.0 security review finding 40.2: the in-core integrity test must use HMAC-SHA-512 with a 512-bit key for NSA 2.0 compliance (customers requiring no SHA-256 usage anywhere in the validated module). - wolfssl/wolfcrypt/fips_test.h: add v7+ branch that selects SHA-512 / 64-byte digest / 512-bit key / 64-byte verify-size. Older versions (v5.3, v6.x) keep HMAC-SHA-256. - fips-hash.sh: drop the hardcoded cut -c1-64 so the script works for SHA-512 (128 hex chars) as well as SHA-256. Length is guarded at compile time by the static_assert on sizeof(verifyCore). Companion change in kh-fork-fips updates fips_test.c verifyCore placeholder, coreKey (fresh 512-bit random), and the static_assert to use FIPS_IN_CORE_DIGEST_SIZE. Paperwork (PQ-FS-dev-area/Final_Submission_Paperwork/): - PL-R36 compliance summary already reflects HMAC-SHA-512 (no change). - PL-R34 Security Policy section 5.1 updated via tracked changes to say HMAC-SHA2-512 with a 512-bit key. Verified: make + fips-hash.sh + make; make check all pass.
1 parent be15865 commit 73dc5a6

2 files changed

Lines changed: 22 additions & 3 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

wolfssl/wolfcrypt/fips_test.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,23 @@
3131
extern "C" {
3232
#endif
3333

34-
/* Added for FIPS v5.3 or later */
35-
#if defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3)
34+
/* Added for FIPS v5.3 or later.
35+
*
36+
* v7.0.0 and later upgrade the in-core integrity HMAC to SHA-512 (with a
37+
* 512-bit key) for NSA 2.0 compliance. Customers that must avoid SHA-256
38+
* anywhere in the validated module can therefore use the v7 module without
39+
* residual SHA-256 integrity material. v5.3 and v6.x retain HMAC-SHA-256.
40+
*/
41+
#if defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(7,0)
42+
#ifdef WOLFSSL_SHA512
43+
#define FIPS_IN_CORE_DIGEST_SIZE 64
44+
#define FIPS_IN_CORE_HASH_TYPE WC_SHA512
45+
#define FIPS_IN_CORE_KEY_SZ 64
46+
#define FIPS_IN_CORE_VERIFY_SZ FIPS_IN_CORE_KEY_SZ
47+
#else
48+
#error FIPS v7+ integrity test requires WOLFSSL_SHA512
49+
#endif
50+
#elif defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3)
3651
/* Determine FIPS in core hash type and size */
3752
#ifndef NO_SHA256
3853
#define FIPS_IN_CORE_DIGEST_SIZE 32

0 commit comments

Comments
 (0)