Fix ML-DSA cache import buffer sizing and test all security levels#6
Fix ML-DSA cache import buffer sizing and test all security levels#6Frauschi wants to merge 1 commit into
Conversation
b00c0c4 to
75eb07e
Compare
|
Pushed Root cause: the client-only example flow runs against the POSIX example server, whose key-cache Fix: set the example server's Verified locally by reproducing the exact client-only CI flow (build server → run → build+run client-only test with ASAN) for both TCP and TLS — both now pass with ML-DSA exercised across all three levels. Watching the new CI run. Generated by Claude Code |
The server ML-DSA cache-import buffer was sized with the private-key DER macro instead of the full-keypair macro (MLDSA_MAX_BOTH_KEY_DER_SIZE), so caching a generated keypair failed at ML-DSA-65/87. CI missed it because the ML-DSA tests only ran ML-DSA-44; the existing tests are now parameterized to run across all enabled levels (44/65/87). Also bump the POSIX example server's big key-cache buffer to hold the largest ML-DSA-87 keypair DER (7520 bytes), matching the other server configs, so the client-only example flow can cache keys at every level.
75eb07e to
764a627
Compare
Summary
wh_Server_MlDsaKeyCacheImport()sized its cache-import buffer with the private-key DER macro (WC_MLDSA_*_PRV_KEY_DER_SIZE) instead of the full-keypair macro (MLDSA_MAX_BOTH_KEY_DER_SIZE). Since a freshly generated key holds both public and private parts,wh_Crypto_MlDsaSerializeKeyDer()encodes the full keypair viawc_MlDsaKey_KeyToDer(), which is larger than the private key alone. As a result, caching a generated keypair fails at ML-DSA-65/87 (BUFFER_E).The value was used both to select/size the keystore cache slot and to bound the serialization. This now uses
MLDSA_MAX_BOTH_KEY_DER_SIZE, matching the client-side serialization buffers.Why CI missed it
The ML-DSA tests only exercised ML-DSA-44, whose keypair DER happens to fit within the (larger) private-key DER size of the highest enabled level. This PR parameterizes the existing ML-DSA test functions with a security level and loops the dispatcher over every enabled level (44/65/87), mirroring the ML-KEM test structure.
Verification
Built and run against wolfSSL master (5.9.1):
MakeCacheKeyreturnsBUFFER_E -173).-std=c90 -Werror -Wall -Wextra.Generated by Claude Code