Repository navigation
pqc: hold the key mutex around shared-key wolfCrypt calls - #535
Merged
Merged
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Shared-key cryptographic concurrency warrants TSan validation on supported wolfSSL versions, and unavailable backend ML-DSA raw/DER export code prevents full verification of interactions with the new sign/verify locks.
No open issues 🎉
What changed in this PR
Protects shared post-quantum keys in wolfProvider by extending per-key mutex coverage around wolfCrypt operations.
Changes:
- Serializes shared-key ML-KEM, hybrid KEM, and ML-DSA operations.
- Adds concurrency and hybrid-key equality regression tests.
- Enables post-quantum tests in ThreadSanitizer builds on supported wolfSSL versions.
| File | Description |
|---|---|
test/unit.h |
Declares new regression tests. |
test/unit.c |
Registers new regression tests. |
test/test_mlkem.c |
Adds shared-key concurrency and hybrid equality tests. |
test/test_mldsa.c |
Adds concurrent signing and verification tests. |
src/wp_mlx_kmgmt.c |
Locks hybrid-key encoding, duplication, and comparison reads. |
src/wp_mlx_kem.c |
Locks both hybrid components during KEM operations. |
src/wp_mlkem_kmgmt.c |
Adds locked key-encoding helpers. |
src/wp_mlkem_kem.c |
Locks encapsulation and decapsulation. |
src/wp_mldsa_sig.c |
Locks signing and verification across supported paths. |
src/wp_mldsa_kmgmt.c |
Exposes and documents the key mutex. |
include/wolfprovider/alg_funcs.h |
Declares key-mutex accessors. |
.github/workflows/sanitizers.yml |
Enables version-gated post-quantum testing under ThreadSanitizer. |
Review effort: Balanced
ML-KEM and ML-DSA keys carry SHA-3/SHAKE state that encapsulate, decapsulate, encode, sign and verify all mutate, so threads sharing one EVP_PKEY corrupted each other's results. Take the per-key mutex around those calls, covering both halves of the hybrid KEMs, and add concurrency tests that the TSan CI job now runs.
ColtonWilley
force-pushed
the
fix/pqc-key-mutex
branch
from
December 2, 2026 22:12
49253e8 to
797112e
Compare
aidangarske
approved these changes
Dec 3, 2026
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.
wolfCrypt's ML-KEM and ML-DSA keys hold SHA-3/SHAKE state that every encapsulate, decapsulate, encode, sign and verify mutates, so concurrent operations on one shared
EVP_PKEYreturned wrong shared secrets, invalid signatures and false verify failures. This takes the existing per-key mutex around those calls, adds concurrency tests that fail without the fix, and runs the PQC tests in the TSan job on wolfSSL versions that support them.