Repository navigation
Conversation
|
There was a problem hiding this comment.
🟡 Changes recommended
A critical issue allows non-blocking TLS with encoded-key storage, causing pending hybrid client decapsulation to leak the key/context and preventing retries from collecting the completed result.
1 open issue
What changed in this PR
Builds on #12052 by connecting chunked ML-DSA and ML-KEM operations to TLS 1.3 through the software async device, allowing handshake work to advance through wolfSSL_AsyncPoll().
Changes:
- Adds async dispatch for ML-DSA and ML-KEM, with handshake state retained across pending operations.
- Integrates ML-DSA CertificateVerify and standalone/hybrid ML-KEM key shares, including session resumption.
- Adds configure options, backend compatibility checks, crypto tests, handshake tests, and CI coverage.
| File | Description |
|---|---|
wolfssl/wolfcrypt/wc_mlkem.h |
Adds async key state and documents completion semantics. |
wolfssl/wolfcrypt/wc_mldsa.h |
Adds async key state and documents completion semantics. |
wolfssl/wolfcrypt/async.h |
Defines ML-DSA and ML-KEM async operations and markers. |
wolfssl/internal.h |
Declares ML-DSA handshake helpers and verification state. |
wolfcrypt/test/test.c |
Adds software-async crypto checks against blocking operations. |
wolfcrypt/src/wc_mlkem.c |
Adds async dispatch and device lifecycle handling. |
wolfcrypt/src/wc_mldsa.c |
Adds async dispatch and device lifecycle handling. |
wolfcrypt/src/async.c |
Dispatches pending ML-DSA and ML-KEM operations. |
tests/api/test_tls13.h |
Registers the non-blocking handshake test. |
tests/api/test_tls13.c |
Adds full and resumed post-quantum handshake tests. |
src/tls13.c |
Routes CertificateVerify through ML-DSA handshake helpers. |
src/tls.c |
Preserves ML-KEM keys and share data across pending operations. |
src/internal.c |
Manages ML-DSA non-blocking contexts and async handshake calls. |
configure.ac |
Adds non-blocking options and rejects conflicting async backends. |
.wolfssl_known_macro_extras |
Registers the new async opt-out macros. |
.github/configs/pq-all.json |
Adds a non-blocking post-quantum TLS CI configuration. |
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12146
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): .github/configs/pq-all.json, .wolfssl_known_macro_extras, configure.ac, tests/api/test_tls13.h
Coverage: 11 of 12 in-scope changed file(s) opened by the reviewer; not opened: tests/api/test_tls13.c
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
c13c920 to
066ac12
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Terminal ML-DSA verification errors leave stale async state that can break subsequent operations, and TLS 1.3 test guards incorrectly require async behavior in valid opt-out builds.
2 open issues
1 resolved since last review
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12146
Error: TimeoutExpired
066ac12 to
f8ab711
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12146
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): .github/configs/pq-all.json, .github/workflows/mlkem-encap-server.yml, .wolfssl_known_macro_extras, configure.ac, tests/api/test_tls13.h
Coverage: 4 of 5 in-scope changed file(s) opened by the reviewer; not opened: tests/api/test_tls13.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
Fenrir's latest completed scan found no issues; clearing the prior automated change request.
f8ab711 to
91774a0
Compare
91774a0 to
15d7c19
Compare
|
Jenkins retest this please |
Frauschi
left a comment
There was a problem hiding this comment.
Mostly free-while-pending handling, a make-only build break and test coverage.
| } | ||
| else if (WOLFSSL_NAMED_GROUP_IS_PQC(current->group)) { | ||
| #ifdef WOLFSSL_HAVE_MLKEM | ||
| TLSX_MlKemNbDetach(heap, (MlKemKey*)current->key); |
There was a problem hiding this comment.
Freeing the SSL while an ML-KEM key-share op or an ML-DSA hsKey sign is pending frees the key with its event still linked in ctx->event_queue, so the next CTX poll reads freed memory. Please detach these like peerMlDsaKey, or drop a pending ssl->asyncDev once in the SSL free path.
There was a problem hiding this comment.
Fixed: wolfSSL_ResourceFree() unlinks a pending ssl->asyncDev, under the queue lock.
| ret = wc_MlDsaKey_VerifyCtx(ssl->peerMlDsaKey, sig, args->sigSz, | ||
| NULL, 0, args->sigData, | ||
| args->sigDataSz, &res); | ||
| ret = MlDsaVerify(ssl, sig, args->sigSz, |
There was a problem hiding this comment.
Please add a memio test that corrupts the ML-DSA CertificateVerify with the async device open and checks the pended verify fails with SIG_VERIFY_E. The encap-only server fix is also only covered by the new workflow, not by make check.
There was a problem hiding this comment.
Added test_tls13_pq_nonblock_bad_sig and test_tls13_mlkem_encap_server (runs in enc-only builds).
| !defined(WOLFSSL_MLKEM_NO_ENCAPSULATE) && \ | ||
| !defined(WOLFSSL_MLKEM_NO_DECAPSULATE) && !defined(WC_ECC_NONBLOCK) && \ | ||
| !defined(WOLFSSL_SP_NONBLOCK) | ||
| /* Non-blocking ECC math livelocks the hybrid async re-drive. */ |
There was a problem hiding this comment.
Both hybrids complete here once the 2000-round cap in test_tls13_pq_nonblock_handshake is raised (X25519MLKEM768 with curve25519=nonblock, SecP256r1MLKEM768 with ecc=nonblock and sp=yes,nonblock). Please raise the cap and drop this exclusion.
There was a problem hiding this comment.
Done: cap is 100000, exclusion dropped, plus a CI row with ECC/X25519/SP nonblock.
| */ | ||
| static int TLSX_KeyShare_GenPqcKeyClient(WOLFSSL *ssl, KeyShareEntry* kse) | ||
| static int TLSX_KeyShare_GenPqcKeyClient(WOLFSSL *ssl, KeyShareEntry* kse, | ||
| int allowPend) |
There was a problem hiding this comment.
allowPend is 1 at every call site, so it can go along with the (void) casts. HandlePqcHybridKeyServer also has a nested duplicate if (ret == 0) left over from the split.
There was a problem hiding this comment.
Done: allowPend removed everywhere and the nested check flattened.
| * | ||
| * returns 0 on success and other values indicate failure. | ||
| */ | ||
| /* ct NULL builds the ciphertext in keyShareEntry->pubKey, the server's |
There was a problem hiding this comment.
Please fold this into the doc block above as ct and resume entries; ProcessPqcClient_ex's block also misses ct and ctLen. In test_tls13.c the "One handshake with an ML-DSA-44" comment sits above the resume test, not test_tls13_pq_nonblock_once.
There was a problem hiding this comment.
Done: folded into the doc blocks and the test comment moved.
| #ifdef WOLFSSL_TLSX_PQC_MLKEM_NONBLOCK | ||
| /* Attach a non-blocking context for one operation when an async device is | ||
| * active; it comes off when the operation completes or the key is freed. */ | ||
| static int TLSX_MlKemNbAttach(WOLFSSL* ssl, MlKemKey* kem) |
There was a problem hiding this comment.
--enable-mlkem=make,nonblock fails with -Werror here since none of the callers are compiled without encaps/decaps. Guard it like mlkem_id2type() or mark it WC_MAYBE_UNUSED.
There was a problem hiding this comment.
Guarded by its callers; added a build-only CI row for make,nonblock.
| AS_IF([test "$ENABLED_MLDSA_NONBLOCK" = "yes" && | ||
| test "$ENABLED_MLDSA_MAKE_KEY" = "yes"], | ||
| [AC_MSG_ERROR([ML-DSA nonblock with key generation is not available in FIPS v7 builds.])]) | ||
| AS_IF([test "$ENABLED_MLKEM_NONBLOCK" = "yes" && |
There was a problem hiding this comment.
This never fires: the FIPS v7 block resets ENABLED_MLKEM to yes before the ML-KEM option loop, dropping nonblock while asynccrypt-sw stays auto-enabled. Please check the raw option string instead, as the auto-enable at line 6633 does.
There was a problem hiding this comment.
Right, fixed: both checks now match nonblock in the raw option strings.
| #if defined(WC_MLDSA_NONBLOCK) && \ | ||
| defined(WOLFSSL_ASYNC_CRYPT_SW) && \ | ||
| defined(WC_ASYNC_ENABLE_MLDSA) | ||
| { |
There was a problem hiding this comment.
Bare scope block; please hoist nb to the top of FreeKey under the same #if or move this into a helper.
There was a problem hiding this comment.
Now calls MlDsaNbDetach() before wc_MlDsaKey_Free().
15d7c19 to
13ee731
Compare


Description
Follows #12052: the TLS 1.3 handshake now runs the non-blocking ML-DSA and ML-KEM operations a chunk per
wolfSSL_AsyncPoll(), through the software async device (WOLFSSL_ASYNC_CRYPT_SW) that ECC, X25519, RSA and DH non-blocking already use.What it adds
async.h/async.c,wc_mldsa.c,wc_mlkem.c- async-SW operation types and a prelude in the six public operations, active only when the key has a non-blocking context. As with X25519, the operation pends once and the poll completes it: wait withwc_AsyncWait(..., WC_ASYNC_FLAG_NONE)and do not call it again.internal.c/tls13.c-MlDsaSign()/MlDsaVerify()for CertificateVerify, attaching the non-blocking context for the operation only.tls.c- standalone and hybrid ML-KEM key shares, client and server, including resumption with a PSK key exchange. A pended operation keeps its key object and partial share on the key share entry.configure.ac---enable-mldsa=yes,nonblockand--enable-mlkem=yes,nonblock, auto-enablingasynccrypt-sw; rejects asynccrypt-sw with Intel QAT or Cavium.Also fixes
tls.c- a TLS 1.3 server built with ML-KEM encapsulation only (--enable-mlkem=enc) failed every ML-KEM and hybrid handshake withECC_PEERKEY_ERRORafter its ServerHello: the server's no-op inTLSX_KeyShare_Process()was compiled only with decapsulation, so it fell through to the ECC handler.Testing
test_tls13_pq_nonblock_async- ML-DSA-44 certificate with ML-KEM-768, SecP256r1MLKEM768 and X25519MLKEM768, full and resumed handshakes, asserting both sides pend.test.c- each operation through the async device, checked against the blocking path.pq-all.jsonrowpq-nonblock-tls.mlkem-encap-server.yml- an encapsulate-only server, blocking and non-blocking, against a full build's client for ML-KEM-768 and both hybrid groups.