Repository navigation
v7.0.0-user-space: EMS refusal in wc_PRF, hybrid group constants, RAND_load_file single reseed, -209 comment - #12248
Closed
jackctj117 wants to merge 1 commit into
Closed
jackctj117 wants to merge 1 commit into
jackctj117 wants to merge 1 commit into
Conversation
Contributor
Author
|
Superseded by the PR from branch v7-followups (branch renamed). |
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new assertions break ML-KEM builds by referencing constants absent from frozen FIPS v6 headers and comparing different enum types when GCC enum-comparison warnings are treated as errors.
2 open issues
What changed in this PR
This PR follows up on the FIPS v7 user-space work in #12170, tightening key derivation behavior and reducing file-based RNG reseeding overhead. The EMS refusal requires the companion changes in wolfSSL/fips#441.
Changes:
- Refuse non-EMS master-secret derivation in FIPS v7 and update test expectations.
- Introduce named hybrid-group constants and verify alignment with TLS group values.
- Hash file input before a single reseed where stir is unavailable, add portable coverage, and clarify DRBG error comments.
| File | Description |
|---|---|
wolfssl/wolfcrypt/kdf.h |
Define named ML-KEM hybrid-group constants. |
wolfssl/wolfcrypt/error-crypt.h |
Clarify self-test and health-test failure comments. |
wolfcrypt/test/test.c |
Update EMS refusal expectations and hybrid constants. |
wolfcrypt/src/kdf.c |
Enforce FIPS v7 EMS refusal and use named constants. |
tests/api/test_ossl_rand.c |
Add multi-chunk regular-file loading coverage. |
tests/api/test_kdf.c |
Use wolfCrypt hybrid-group constants. |
tests/api/test_curve25519.c |
Replace numeric hybrid groups with named constants. |
src/tls.c |
Assert agreement between wolfCrypt and TLS group values. |
src/ssl_crypto.c |
Hash file input and reseed once when stir is unavailable. |
Review effort: Balanced
|
|
||
| #ifndef NO_TLS | ||
|
|
||
| #ifdef WOLFSSL_HAVE_MLKEM |
Comment on lines
+168
to
+170
| wc_static_assert(WC_SECP256R1MLKEM768 == WOLFSSL_SECP256R1MLKEM768); | ||
| wc_static_assert(WC_X25519MLKEM768 == WOLFSSL_X25519MLKEM768); | ||
| wc_static_assert(WC_SECP384R1MLKEM1024 == WOLFSSL_SECP384R1MLKEM1024); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Follow-ups from the #12170 review, against
v7.0.0-user-space.EMS refusal in the module
wc_PRF()now refuses (BAD_FUNC_ARG) a PRF seed that starts with"master secret"under FIPS v7, where it used to derive the secret and have the wrapper flag itWC_FIPS_NOT_APPROVED(FIPS 140-3 IG D.Q, RFC 7627).wc_PRF_TLS()andwc_PRF_TLSv1()both passlabel || seedintowc_PRF(), so this one check covers the label argument, the label split across label and seed, and OpenSSL-style callers that put the label in the seed."extended master secret"is unaffected.The TLS-layer refusal (
WOLFSSL_EMS_ALWAYS_REQUIRED) is unchanged.tls12_kdf_testnow expects the refusal on v7 and still runs the KAT on other builds.Must merge together with a wolfSSL/fips change. In wolfSSL/fips#441, the TLS 1.2 KDF CAST (
TLSv12_KDF_KnownAnswerTestinfips_test.c) derives with"master secret"throughwc_PRF_TLS_fips(). With this PR, that CAST getsBAD_FUNC_ARG, and a v7 module would fail its self-test. The fips side has to:Tls12KdfResult()infips.cinto an up-front refusal, or drop it, since the module now refuses the request before deriving anythingHybrid group constants
Adds
WC_SECP256R1MLKEM768(4587),WC_X25519MLKEM768(4588) andWC_SECP384R1MLKEM1024(4589) towolfssl/wolfcrypt/kdf.h. They replace the bare numbers inkdf.c,test_kdf.c,test_curve25519.candwolfcrypt/test/test.c.tls.cstatic-asserts that they equal theWOLFSSL_*values inssl.h.RAND_load_file: one reseed per file
Under v7 there is no
wc_RNG_DRBG_Stir(), andwc_RNG_DRBG_Reseed()draws fresh entropy from the module on every call. That meantRAND_load_file()did a full reseed for every 256-byte chunk, which is up to 4096 reseeds for a 1 MB file. It now hashes the file as it reads it (SHA-256, or SHA-512 when there is no SHA-256) and passes the digest as additional input to a single reseed at the end. Builds that have stir are unchanged.RAND_egd()needs no change: it is compiled out underHAVE_FIPS, and it already reseeds once with at most 255 bytes.Added a portable
RAND_load_filecase that reads a cert file over several chunks. The existing data-reading cases only run on Linux and FreeBSD.-208 / -209 comments
Rewords the comments in
error-crypt.h:DRBG_KAT_FIPS_E(-208) is the DRBG self-test (CAST) failure, which rerunning the self-test can recover from.DRBG_CONT_FIPS_E(-209) is the health-test failure, which latches the module failed until it is reloaded.Testing
--enable-all --enable-debug CFLAGS=-Werror:make checkpasses.--disable-mlkem, with--enable-cryptonly, and with opensslextra + ML-KEM + X25519 andWOLFSSL_NO_TLS12.random.h, using--enable-all --enable-smallstack:testwolfcryptpasses, including the TLS 1.2 KDF refusal.RAND_load_fileshowed exactly one reseed per file (600 and 1286 bytes).