Repository navigation
Fix verifying dual alg certs with WOLFSSL_SMALL_CERT_VERIFY. Fix async resume of dual-alg alternative signature verification. Bind TLS 1.3 ML-DSA/Falcon sig scheme to peer key level. - #12391
Conversation
|
@claude review |
|
There was a problem hiding this comment.
🟡 Changes recommended
The changes break TLS 1.3 sign-only ML-DSA builds, discard pending asynchronous certificate-verification state, and enable incompatible tests in reduced-parameter builds.
3 open issues
What changed in this PR
This PR strengthens dual-algorithm certificate verification and TLS 1.3 post-quantum signature validation.
Changes:
- Adds alternative-signature checks for small-certificate verification and tracks asynchronous progress.
- Binds ML-DSA/Falcon signature schemes and minimum key sizes to peer keys.
- Adds regression tests and fixes test-key cleanup.
| File | Description |
|---|---|
| wolfssl/wolfcrypt/asn.h | Adds alternative-signature pending state. |
| wolfcrypt/src/asn.c | Centralizes alternative verification and updates resume handling. |
| tests/api/test_tls13.h | Registers the ML-DSA regression test. |
| tests/api/test_tls13.c | Tests scheme binding and minimum key size. |
| tests/api.c | Adds dual-algorithm tests and key cleanup. |
| src/tls13.c | Checks signature schemes against peer key levels. |
| src/internal.c | Enforces minimum sizes using actual peer keys. |
Review effort: Balanced
There was a problem hiding this comment.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🟣
src/tls13.c— pre-existing: A dual-alg peer that authenticates with its alternative key still gets past the minimum ML-DSA/Falcon key size that this PR now enforces for native keys. decodeMlDsaKey and decodeFalconKey import the SAPKI key at the level of the peer's chosen scheme. Neither compares the key against minMlDsaKeySz or minFalconKeySz. Fix: after either helper decodes the alternative key in DoTls13CertificateVerify, return MLDSA_KEY_SIZE_E or FALCON_KEY_SIZE_E when the key is below the configured minimum. Use the same verifyNone/UsingChainVerifyCb gate as internal.c:19922 and cover both decode helpers.Why this was flagged
Trigger: a WOLFSSL_DUAL_ALG_CERTS build where MIN_MLDSAKEY_SZ is raised (for example to 4032, to require ML-DSA-65 or higher), CKS negotiated as WOLFSSL_CKS_SIGSPEC_ALTERNATIVE or BOTH, and a peer cert with an ECC native key plus an ML-DSA-44 SAPKI. DoTls13CertificateVerify calls decodeMlDsaKey(ssl, WC_ML_DSA_44) (tls13.c:13122-13130), which imports the key with no size check (tls13.c:12882-12890). Under ALTERNATIVE the native key is then freed (tls13.c:13168-13194), so the 2560-byte ML-DSA-44 key alone authenticates the handshake. The keySz check this PR adds in ProcessPeerCertDecodeKey (internal.c:19922-19928) only covers the native keyOID. The decodeFalconKey path (tls13.c:12899-12923) has the same gap. The base behaves the same way, so this is a path the key-size fix leaves open, not something it introduces.
Verification: decodeMlDsaKey (src/tls13.c:12868-12893) and decodeFalconKey (12897-12924) never compare the SAPKI key against ssl->options.minMlDsaKeySz or minFalconKeySz. Under WOLFSSL_CKS_SIGSPEC_ALTERNATIVE, the native key is then freed (13168 onward). ProcessPeerCertCheckKey (src/internal.c:18848) switches only on
args->dCert->keyOID, the native key.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12391
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): tests/api/test_tls13.h
Coverage: 6 of 6 in-scope changed file(s) opened by the reviewer
Findings: 3
3 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Max
33c26cf to
b066bd9
Compare
After verifying the first signature, the verify state was set to VERIFY_NAME which skipped verifying the second signature. Thanks to tcp-raw (https://github.com/tcp-raw) for the report.
Thanks to tcp-raw (https://github.com/tcp-raw) for the report.
Thanks to tcp-raw (https://github.com/tcp-raw) for the report.
- Under VERIFY_NAME, the alternative signature is now checked synchronously and even when a date error is pending. - Keep pre-TBS buffer until a pending check completes. - Fix sign-only ML-DSA build and ML-DSA level test under --enable-all.
b066bd9 to
1ef5b50
Compare


Description
Fixes zd#22928
Testing
How did you test?
Checklist