Repository navigation
Stricter mldsa contract for no public keys - #11644
Conversation
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The small-memory error path can process uninitialized accumulator data after rejection sampling fails.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Tightens ML-DSA public-key requirements and adds explicit public-key derivation from private keys.
Changes:
- Returns
PUBLIC_KEY_Ewhen verification/export lacks a public key. - Adds
wc_MlDsaKey_MakePublicKey()with fault-hardening support. - Expands API, white-box, OOM, and CI coverage.
| File | Description |
|---|---|
wolfssl/wolfcrypt/wc_mldsa.h |
Declares public-key derivation support. |
wolfcrypt/src/wc_mldsa.c |
Implements derivation and stricter validation. |
tests/unit-mcdc/test_wc_mldsa_whitebox.c |
Updates white-box coverage notes. |
tests/unit-mcdc/test_mldsa_hash_fault_whitebox.c |
Tests derivation hash failures. |
tests/include.am |
Documents shared fault allocator usage. |
tests/api/test_mldsa.h |
Registers new ML-DSA tests. |
tests/api/test_mldsa.c |
Adds derivation and error-path coverage. |
doc/dox_comments/header_files/wc_mldsa.h |
Documents API and error contracts. |
.github/configs/pq-all.json |
Adds fault-hardened CI configurations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
7d12a8a to
e731fac
Compare
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The cryptographic derivation and fault-hardening paths span numerous compile-time configurations and warrant final human validation.
Review effort: Balanced
Findings: None
Resolved since last review (1)
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11644
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Coverage: 2 of 5 in-scope changed file(s) opened by the reviewer; not opened: tests/api/test_mldsa.c, tests/unit-mcdc/test_mldsa_hash_fault_whitebox.c, tests/unit-mcdc/test_wc_mldsa_whitebox.c
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
|
Conflicts - please fix. |
e731fac to
44f2e82
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11644
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Coverage: 3 of 5 in-scope changed file(s) opened by the reviewer; not opened: tests/unit-mcdc/test_mldsa_hash_fault_whitebox.c, tests/unit-mcdc/test_wc_mldsa_whitebox.c
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
d7de8c8 to
934db28
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11644
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-bugs
Not reviewed (no scan target covers them): doc/dox_comments/header_files/wc_mldsa.h, tests/api/test_mldsa.h
Coverage: 3 of 3 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
934db28 to
277218e
Compare
277218e to
1204886
Compare
|
@claude review |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11644
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): ChangeLog.md, doc/dox_comments/header_files/wc_mldsa.h, tests/api/test_mldsa.h
Coverage: 4 of 5 in-scope changed file(s) opened by the reviewer; not opened: tests/unit-mcdc/test_mldsa_hash_fault_whitebox.c
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
There was a problem hiding this comment.
I reviewed this PR and found no bugs. It changes the error codes returned by the public ML-DSA verify and export APIs, and makes the OpenSSL compat layer check key pairs, so a maintainer should still look at it.
What was reviewed:
- Software verify paths (msg, ctx, ctx-hash, VerifyMu): they now return PUBLIC_KEY_E when no public key is set, before H(pk) is computed over an unset buffer.
mldsa_check_key_pair()and the wider#ifguard onmldsa_check_pub_tr(): the helper sits underWOLFSSL_MLDSA_PRIVATE_KEYplusWOLFSSL_MLDSA_PUBLIC_KEY, so it is defined in every build that uses it. The tr comparison uses ConstantCompare.- ExportKey and ExportPubRaw: buffer sizes are checked before anything is written, and both sizes are reported on BUFFER_E. Also checked the MakePublicKey calls added to
wolfSSL_X509_set_pubkeyandwolfssl_i_i2d_mldsapublickey, including the cleanup when they fail.
Extended reasoning...
The change touches the ML-DSA core in wolfcrypt/src/wc_mldsa.c, the PKCS#11 public-key path and two OpenSSL compat entry points (src/x509.c, wolfcrypt/src/evp_pk.c), plus about 700 lines of new tests. This is security-sensitive crypto code. Several public APIs now return PUBLIC_KEY_E where they used to return BAD_FUNC_ARG. wolfSSL_X509_set_pubkey and the i2d path can now fail on keys they used to accept. Those contract changes, and two earlier inline review threads that only the author resolved, are why this is a defer and not an approval.
1204886 to
f404bb7
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11644
Scan targets checked: none
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): ChangeLog.md, doc/dox_comments/header_files/wc_mldsa.h, tests/api/test_mldsa.h
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
f404bb7 to
049aadb
Compare
|
@claude review |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11644
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): ChangeLog.md, doc/dox_comments/header_files/wc_mldsa.h, tests/api/test_mldsa.h
Coverage: 3 of 6 in-scope changed file(s) opened by the reviewer; not opened: tests/unit-mcdc/test_mldsa_hash_fault_whitebox.c, tests/unit-mcdc/test_wc_mldsa_whitebox.c, wolfssl/wolfcrypt/wc_mldsa.h
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
There was a problem hiding this comment.
I reviewed the latest push and didn't find any bugs. A maintainer should still look at it, because it changes error codes that callers can see in ML-DSA verify and export. It also adds an H(pk) == tr check, so wc_MlDsaKey_ExportKey and wc_MlDsaKey_KeyToDer now reject mismatched key pairs that they used to accept.
What was reviewed:
mldsa_verify_key_checkis used in all three verify paths and in the non-callback path ofVerifyMu, so verify can no longer run against an unset public key.- The new guards for
mldsa_check_pub_trandmldsa_check_key_pairmatch where they are called (PRIVATE_KEY && PUBLIC_KEY, with the hash skipped under CB_ONLY), so neither helper is left defined but unused. - The
ExportKeyrewrite sets both sizes before returning BUFFER_E and copies nothing until both buffers fit.ExportPubRawnow gets its size fromwc_MlDsaKey_PubSize, which also covers the FIPS204-draft levels.
Extended reasoning...
This change edits error handling for ML-DSA verify, export and DER encoding in wolfcrypt/src/wc_mldsa.c, plus one line in wc_pkcs11.c. It also updates the doxygen docs and the ChangeLog and adds about 600 lines of tests. The security-sensitive surface is public-key presence checks and a new constant-time H(pk)/tr consistency check when exporting a key pair. No bugs were found. It is a deferral rather than an approval because this is crypto library code with error-code changes callers can see and new rejection behavior, which a maintainer should sign off on.


Description
Updated ML-DSA verify and export operations to strictly require a public key so a specific PUBLIC_KEY_E error is returned.
Depends on PR #10985
Testing
Added coverage to exercise PUBLIC_KEY_E cases.
Checklist