Conversation
Frauschi
commented
Apr 7, 2026
- Use wc_mlkem.h instead of mlkem.h across all includes - Remove redundant sz from keygen request (determined by level) - Remove redundant ctSz/ssSz from encaps request and ssSz from decaps request (output sizes fixed by ML-KEM level) - Remove redundant size parameter from MakeExportKey/MakeCacheKey APIs, aligning non-DMA with DMA signatures - Move large ML-KEM key buffers from stack to heap via XMALLOC - Add WH_DEBUG_CLIENT_VERBOSE logging to all ML-KEM client methods - Add doxygen documentation comments to all ML-KEM function declarations in wh_client_crypto.h - Refactor _MlKemMakeKey to use early-exit pattern for readability - Fix encaps/decaps buffer size checks: error on insufficient buffers instead of silently truncating - Update server encaps/decaps handlers to compute output sizes from key level instead of request fields - Update tests and benchmarks for API changes https://claude.ai/code/session_011esueUzLf9urCUHRPEhyXb
- Fix missed test call with old 4-arg MakeExportKey signature - Zero sensitive key material with ForceZero before XFREE in all import/export/keygen functions to prevent key data remaining on the heap after deallocation - Add response buffer bounds validation in encaps/decaps to prevent reading past the comm buffer on corrupted server responses - Fix early returns in encaps/decaps (both DMA and non-DMA) that skipped key eviction when dataPtr was NULL after auto-import - Zero-initialize DMA response structs in server-side keygen, encaps, and decaps handlers to prevent leaking uninitialized stack memory to the client on error paths - Initialize evict and size variables in DMA server handlers https://claude.ai/code/session_011esueUzLf9urCUHRPEhyXb
3 tasks
- Change 0 == _IsMlKemLevelSupported() to !_IsMlKemLevelSupported()
across all 6 server handler call sites
- Fix uint32 overflow in Decapsulate total_len: use uint64_t to
prevent overflow when ct_len is large
- Fix server encaps bounds check: use ct_len + ss_len > max_out
to properly verify both ct and ss fit in response buffer
- Store original DMA buffer sizes for POST processing in
EncapsulateDma/DecapsulateDma to avoid using potentially modified
inout sizes
- Use exact key size (via wc_MlKemKey_PrivateKeySize) in ImportKey
XMALLOC instead of WC_ML_KEM_MAX_PRIVATE_KEY_SIZE to minimize
allocation
- Fix MlKemSerializeKey: try wc_MlKemKey_EncodePrivateKey first and
fall back to public key on failure, since PrivateKeySize always
returns a size regardless of whether a private key exists
- Remove unnecessary { } nesting in _MlKemMakeKey and
_MlKemMakeKeyDma, move variables to function scope
- Move DMA POST processing to end of _MlKemMakeKeyDma, after
response handling, consistent with other DMA functions
- Move shared secret from DmaBuffer to inline in DMA encaps/decaps
messages: ss is always 32 bytes (WC_ML_KEM_SS_SZ) so it fits
efficiently in the message like AES key data
- Fix MAX_BENCH_OPS: change from 128 to 119 (101 + 18 ML-KEM ops)
https://claude.ai/code/session_011esueUzLf9urCUHRPEhyXb
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.
Summary
Notes
Validation