Add ML-KEM and ML-DSA support#399
Conversation
Frauschi
left a comment
There was a problem hiding this comment.
Some smaller findings. The biggest "issue" imo is the usage of the now old ML-DSA API instead of the new one. But moving this to the new one should be easy.
|
Jenkins retest this please |
|
Jenkins retest this please |
| * a hostile caller from driving OOM via unbounded digest_sign_update. */ | ||
| #define WP_MLDSA_BUF_MAX (64UL * 1024UL * 1024UL) | ||
|
|
||
| static int wp_mldsa_buf_append(wp_MlDsaSigCtx* ctx, const unsigned char* data, |
There was a problem hiding this comment.
Use a digest object that is updated with the data.
Should be using wc_MlDsaKey_SignCtxHash() and wc_MlDsaKey_SignCtxHashWithSeed() and wc_MlDsaKey_VerifyCtxHash().
Leave the random generation to the MlDsa if possible - that is use different API when random is test random.
wc_MlDsaKey_SignMuWithSeed() - Mu contains the hash.
There was a problem hiding this comment.
I think I got the streaming sorted. The pure path doesn't buffer anymore; it runs the message straight through wc_Shake256_Update into mu and signs with SignMuWithSeed / verifies with VerifyMu (your "Mu contains the hash" route). SignCtxHash is in there too, just on the pre-hash path where it belongs.
I couldn't use SignCtxHash for the pure path though it's HashML-DSA and native OpenSSL rejects those sigs when it verifies pure ML-DSA, which is exactly what TLS and X509 do so it blows up interop (confirmed against 3.6.2).
Only thing I couldn't land is leaving the random to MlDsa on the streaming path. SignMuWithSeed forces a seed and there's no rng variant, so for now I generate it on the wolfProvider side (same DRBG, just one layer out). If you're open to adding a wc_MlDsaKey_SignMu(key, sig, sigLen, mu, muLen, rng) the mu version of SignCtx's rng path I could rip the seed gen out and hand it back to MlDsa.
…hybrid-group KEM; run all PQC unit tests in CI
…ify per group), validating the ML-DSA TLS signature algorithm end-to-end
…pply FIPS 204 sig params in all init paths, reject wrong-length keygen seed, close hybrid match fail-open
…t, reject wrong-length IKME/test-entropy, scrub hybrid shared secret on failure, fix fill_rnd log flag
…erive ECC public on hybrid private import, scrub ML-KEM shared secret on failure
…dersized buffer (early-return on size check), reject mismatched public on hybrid keypair import
…A public only when actually decoded, give hybrid variant tables internal linkage
….9.2); fix wget TLS by setting LD_LIBRARY_PATH after nginx download
…rray of GIDs, so the loop ran once with a GID); drop install-layout-dependent mime.types include; add startup debug
…per wolfSSL ref), loading wolfProvider via provider.conf in non-replace builds
…op self push/PR trigger
…yields the public via ExportPubRaw)
…re private first since its encode embeds the public
…eed only for test-entropy/deterministic signing
… wc_MlDsaKey_SignCtxHash/VerifyCtxHash (pure path unchanged for md=NULL)
…eject the external-mu + pre-hash combination both ways
…x (do not assume the enum is zero)
…uard sigLen/key in the prehash sign path
…nd NULL-guard the prehash verify path
…_Shake256_Update) and SignMuWithSeed/VerifyMu, instead of buffering the whole message
… gate lost with SignMuWithSeed) and reject context/mu/encoding changes after streaming starts
…nal-mu input has been buffered, not just after pure streaming starts
|
jenkins retest this please |
ML-KEM (FIPS 203) and ML-DSA (FIPS 204) via wolfSSL backend.
Algorithms: ML-KEM-512/768/1024, ML-DSA-44/65/87 hybrid schemes supported now as well
Opt-in:
./scripts/build-wolfprovider.sh --enable-pqc(adds--enable-mlkem --enable-mldsato wolfSSL).Validation: three independent paths cross-checked, all pass.
make testwc_*API (12 cross-pairs)CI: new
wolfssl-versions-pqc.ymlruns three matrix rows - pre-PQC wolfSSL, latest stable, master -- and the three-way interop validator on the PQC-enabled rows.supplemental PR for interop test in wolfCrypt: wolfSSL/wolfssl#10603
Test plan
make testpasses (all 11 PQC tests + existing suite)./test/pqc_interop.test-- ALL PASS (24 cross-pairs)make testclean