Repository navigation
Conversation
|
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.
Adds a resumable, non-blocking mode for ML-DSA (keygen, sign, verify) and ML-KEM (keygen, encapsulate, decapsulate), the post-quantum analogue of
WC_ECC_NONBLOCK, for bare-metal targets with a cooperative scheduler that must regain the CPU during a long PQC operation.What it adds
WC_MLDSA_NONBLOCK/WC_MLKEM_NONBLOCKbuild options, each requiring the matching*_SMALL_MEMpaths, which already process one row or polynomial at a time.wc_MlDsaNonBlock/wc_MlKemNonBlockcaller-owned contexts andwc_MlDsaKey_set_nonblock()/wc_MlKemKey_set_nonblock(). With a context attached, each public operation runs one slice and returnsMP_WOULDBLOCKuntil it completes; the caller re-invokes it in a loop, as for ECC.wolfcrypt/src/wc_mldsa.c- resumable keygen, sign and verify on the small-memory paths; sign yields per matrix column inside each rejection attempt and again between attempts, so it always hands control back even when the first attempt succeeds.wolfcrypt/src/wc_mlkem.c,wc_mlkem_poly.c- the small-memory keygen and encapsulate cores from Reduce ML-KEM small memory heap use and allow caching matrix A with it #11565 are split into a one-time prelude plus per-row helpers (mlkem_keygen_seeds_row(),mlkem_encapsulate_seeds_row()and a tail for v); the blocking entry points keep calling the unchanged wrappers. Decapsulate drives the re-encryption through the same per-row core, carrying the block-wise ciphertext compare result across yields.wolfcrypt/test/test.c-mldsa_nonblock_testandmlkem_nonblock_test: every operation yields, results match the blocking path, tampered inputs are rejected, an abandoned operation is released and restarted..github/configs/pq-all.json-pq-nonblock-smallmemandpq-nonblock-smallmem-dynkeysbuilds somake checkexercises both, the second withWOLFSSL_MLKEM_CACHE_AandWOLFSSL_MLKEM_DYNAMIC_KEYS.Testing
testwolfcryptgreen in the combined non-blocking build, withWOLFSSL_MLKEM_CACHE_A, withCACHE_A+DYNAMIC_KEYS, withWC_MLDSA_FAULT_HARDEN+WC_MLKEM_FAULT_HARDEN, under ASan/UBSan, in the small-memory build without the options, and in the default build. Cross-built for Thumb-2 (--enable-armasm, armv7m) and run under qemu-arm with the non-blocking options, with and withoutCACHE_A. ML-DSA-44 certificate authentication in a TLS 1.3 loopback handshake verified against the non-blocking build (TLS uses the blocking path).Also fixes #12040: the Doxygen and source comments for
wc_MlDsaKey_Size(),wc_MlDsaKey_PrivSize()andwc_MlDsaKey_GetPrivLen()now say what each returns (private key alone versus private key with the public key appended),PrivSize()gets theelseits sibling level chains have, andtest_mldsa.cassertsPrivSize() == Size() + PubSize().