Repository navigation
Conversation
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
CMake’s ML-KEM small-memory mode fails compilation with Intel speedups or AArch64 assembly enabled through compiler flags because it omits the required WC_MLKEM_NO_ASM fallback.
1 open issue
What changed in this PR
Exposes post-quantum small-memory modes through wolfSSL’s build systems, layered on #12146’s non-blocking TLS 1.3 support.
Changes:
- Adds configure and CMake options for small-memory implementations.
- Exports memory-mode and Falcon definitions to generated headers, and adds configure’s ML-KEM assembly fallback.
- Expands build-option, reconfiguration, and handshake coverage.
| File | Description |
|---|---|
wolfssl/wolfcrypt/wc_mlkem.h |
Adds async key state and usage documentation. |
wolfssl/wolfcrypt/wc_mldsa.h |
Adds async key state and usage documentation. |
wolfssl/wolfcrypt/async.h |
Defines ML-DSA and ML-KEM async operations. |
wolfssl/internal.h |
Declares ML-DSA handshake helpers and verification state. |
wolfcrypt/test/test.c |
Tests software-async PQ operations. |
wolfcrypt/src/wc_mlkem.c |
Integrates non-blocking ML-KEM with software async. |
wolfcrypt/src/wc_mldsa.c |
Integrates non-blocking ML-DSA with software async. |
wolfcrypt/src/async.c |
Dispatches PQ operations and resets completed state. |
tests/api/test_tls13.h |
Registers the non-blocking PQ handshake test. |
tests/api/test_tls13.c |
Tests handshakes, resumption, and pending-operation cleanup. |
src/tls13.c |
Uses async-aware ML-DSA handshake helpers. |
src/tls.c |
Preserves pending ML-KEM shares and fixes encapsulate-only servers. |
src/internal.c |
Manages ML-DSA handshake operations and cleanup. |
configure.ac |
Adds memory modes, async prerequisites, and assembly fallback. |
CMakeLists.txt |
Adds four PQ small-memory options. |
cmake/options.h.in |
Exports memory-mode and Falcon definitions. |
.wolfssl_known_macro_extras |
Registers PQ async opt-out macros. |
.github/workflows/mlkem-encap-server.yml |
Adds encapsulate-only server interoperability coverage. |
.github/workflows/cmake.yml |
Checks memory-mode builds and reconfiguration. |
.github/configs/pq-all.json |
Adds memory-option, assembly, and non-blocking test configurations. |
Review effort: Balanced
Frauschi
force-pushed
the
pq-small-mem-build-options
branch
from
November 17, 2026 16:56
34fdc1f to
ead6a64
Compare
Member
Author
|
@claude review |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12156
Error: TimeoutExpired
Frauschi
force-pushed
the
pq-small-mem-build-options
branch
from
November 17, 2026 18:08
ead6a64 to
c1e3041
Compare
The ML-KEM and ML-DSA small memory paths could only be selected by passing their macros in CFLAGS, while Falcon and SLH-DSA already had small-mem configure options. Add: - --enable-mlkem=small-mem: WOLFSSL_MLKEM_MAKEKEY_SMALL_MEM and WOLFSSL_MLKEM_ENCAPSULATE_SMALL_MEM. - --enable-mldsa=small-mem: WOLFSSL_MLDSA_MAKE_KEY_SMALL_MEM, WOLFSSL_MLDSA_SIGN_SMALL_MEM and WOLFSSL_MLDSA_VERIFY_SMALL_MEM. - --enable-mldsa=smallest-mem: small memory key generation with the smallest memory signer and verifier (WOLFSSL_MLDSA_SIGN_SMALLEST_MEM, WOLFSSL_MLDSA_VERIFY_SMALLEST_MEM). Like --enable-falcon, smallest-mem implies small-mem. The existing small option is unchanged: it selects the code size reduction (WOLFSSL_MLKEM_SMALL / WOLFSSL_MLDSA_SMALL), not the RAM reduction. The nonblock options now select the small memory paths through the same flag instead of setting the macros themselves, so nonblock,smallest-mem runs the non-blocking state machine on the smallest memory signer and verifier. Plain nonblock produces the same macros as before. With --enable-intelasm, or --enable-armasm on AArch64, the ML-KEM small memory paths also define WC_MLKEM_NO_ASM: wc_mlkem.c rejects them with that assembly, so these builds failed with an #error. The nonblock option, which selects the small memory paths, had the same failure. WC_MLKEM_NO_ASM turns off the assembly for every ML-KEM operation, decapsulation included, so configure warns when it adds it. Add pq-all configs that build every PQC low-memory path from configure options alone, and the ML-KEM small memory paths with Intel and AArch64 assembly.
WOLFSSL_FALCON put -DHAVE_FALCON on the library target, but cmake/options.h.in had no entry for it, so wolfssl/options.h never defined it. The unit tests and any application built against an installed wolfSSL saw Falcon as disabled while the library had it compiled in, a feature-define mismatch between library and application. The entry is #ifndef-guarded rather than a bare #undef pair, so a HAVE_FALCON passed through CMAKE_C_FLAGS is not undefined again for code that includes options.h.
CMake had no way to select the low-memory implementations of any PQC algorithm. Add options matching the configure ones: - WOLFSSL_MLKEM_SMALL_MEM=yes (--enable-mlkem=small-mem) - WOLFSSL_MLDSA_SMALL_MEM=yes|smallest (--enable-mldsa=small-mem|smallest-mem) - WOLFSSL_SLHDSA_SMALL_MEM=yes (--enable-slhdsa=small-mem) - WOLFSSL_FALCON_SMALL_MEM=yes|smallest (--enable-falcon=small-mem|smallest-mem) The ML-DSA and Falcon options also accept the configure spellings small-mem and smallest-mem. add_option reduces any other value to yes or no. Each takes effect only with its algorithm enabled; set without it, the option is ignored with a warning. Every macro it sets has an options.h.in entry so it reaches wolfssl/options.h as well as the library. The entries are #ifndef-guarded like WOLFSSL_SLHDSA_VERIFY_ONLY: a bare #undef pair would undefine a macro passed through CMAKE_C_FLAGS for code including options.h while the library keeps it, and the ML-DSA verify macros change the size of wc_MlDsaKey. A default build's options.h defines nothing new. Like configure, ML-KEM small-mem adds WC_MLKEM_NO_ASM with a warning when x86_64 or AArch64 assembly is enabled (WOLFSSL_INTEL_ASM, WOLFSSL_ARM_ASM or the macros in CMAKE_C_FLAGS), since wc_mlkem.c has no assembly for the small memory paths. The CMake workflow gains a build with all four options at their smallest setting that checks every macro reaches options.h, then reconfigures with yes, checks the small variants replace the smallest ones and builds again. It does not run ctest: the slow small-memory signers would lengthen the sequential job, and the pq-all configs run their tests.
Frauschi
force-pushed
the
pq-small-mem-build-options
branch
from
December 4, 2026 08:24
c1e3041 to
826737d
Compare
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.

Description
The ML-KEM and ML-DSA small memory paths could only be selected through CFLAGS, and CMake had no small memory option for any PQC algorithm. This adds them to both build systems.
Stacked on #12146: the first commit is that PR's, rebased on current master. Review the last three, and merge after #12146.
--enable-mlkem=small-mem,--enable-mldsa=small-mem|smallest-mem;nonblocknow selects these through the same switchWOLFSSL_MLKEM_SMALL_MEM,WOLFSSL_MLDSA_SMALL_MEM(yes/smallest),WOLFSSL_SLHDSA_SMALL_MEM,WOLFSSL_FALCON_SMALL_MEM(yes/smallest), each withoptions.h.inentries; warns when the algorithm is offHAVE_FALCONtooptions.h, so apps saw Falcon as disabled#errorinwc_mlkem.c; configure now addsWC_MLKEM_NO_ASMand warnsFollow-up
WC_MLKEM_NO_ASMturns off all ML-KEM assembly, decapsulation included, about 2.5x slower on AArch64. A follow-up PR will keep the assembly for decapsulation and the NTT under small-mem inwc_mlkem.c, as AArch32 already does, and drop the configure workaround.Testing
pq-small-mem-options(all four algorithms from configure options),mlkem-small-mem-intelasm,mlkem-aarch64-armasm-small-memoptions.h, then reconfigures with yes and builds again