Skip to content

Commit cb8e0b0

Browse files
committed
Add ML-KEM (FIPS 203) post-quantum KEM support
Implement full client-server ML-KEM (Module-Lattice-Based Key Encapsulation Mechanism) support across all wolfHSM layers, enabling post-quantum key exchange operations to be offloaded to the HSM. Client API (wh_client_crypto): - Key management: import, export, set/get key ID - Key generation: MakeExportKey (ephemeral) and MakeCacheKey (server-cached) - Encapsulation and decapsulation operations - DMA variants for all operations Server handling (wh_server_crypto): - Request handlers for ML-KEM keygen, encapsulate, and decapsulate - Auto-import with evict-after-use for uncached keys - DMA request handlers Crypto callback integration (wh_client_cryptocb): - Register PQC KEM keygen/encaps/decaps handlers so wolfCrypt ML-KEM calls are transparently forwarded to the HSM via WH_DEV_ID Message layer (wh_message_crypto): - Define request/response structures for keygen, encapsulate, decapsulate - Endian translation functions for cross-platform support Shared utilities (wh_crypto): - ML-KEM key serialization/deserialization with automatic level probing Supports all three ML-KEM parameter sets (512, 768, 1024). Includes tests for all operations and DMA paths, and benchmarks for keygen, encaps, and decaps at each security level. Also fixes key export response to use actual stored key length from NVM metadata instead of the request size.
1 parent 9e6cc82 commit cb8e0b0

19 files changed

Lines changed: 4233 additions & 345 deletions

benchmark/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The wolfHSM benchmarks provide a framework for testing and measuring the perform
1010
- Hash functions (SHA-2, SHA-3)
1111
- Message Authentication Codes (HMAC, CMAC)
1212
- Public Key Cryptography (RSA, ECC, Curve25519)
13-
- Post-Quantum Cryptography (ML-DSA)
13+
- Post-Quantum Cryptography (ML-DSA, ML-KEM)
1414
- Basic communication (Echo)
1515

1616
The benchmark system measures the runtime of registered operations, as well as reports the throughput in either operations per second or bytes per second depending on the algorithm.

benchmark/bench_modules/wh_bench_mod_all.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,4 +379,49 @@ int wh_Bench_Mod_MlDsa87KeyGen(whClientContext* client, whBenchOpContext* ctx,
379379
int wh_Bench_Mod_MlDsa87KeyGenDma(whClientContext* client,
380380
whBenchOpContext* ctx, int id, void* params);
381381

382+
/*
383+
* ML-KEM benchmark module prototypes (wh_bench_mod_mlkem.c)
384+
*/
385+
int wh_Bench_Mod_MlKem512KeyGen(whClientContext* client, whBenchOpContext* ctx,
386+
int id, void* params);
387+
int wh_Bench_Mod_MlKem512KeyGenDma(whClientContext* client,
388+
whBenchOpContext* ctx, int id, void* params);
389+
int wh_Bench_Mod_MlKem512Encaps(whClientContext* client, whBenchOpContext* ctx,
390+
int id, void* params);
391+
int wh_Bench_Mod_MlKem512EncapsDma(whClientContext* client,
392+
whBenchOpContext* ctx, int id, void* params);
393+
int wh_Bench_Mod_MlKem512Decaps(whClientContext* client, whBenchOpContext* ctx,
394+
int id, void* params);
395+
int wh_Bench_Mod_MlKem512DecapsDma(whClientContext* client,
396+
whBenchOpContext* ctx, int id, void* params);
397+
398+
int wh_Bench_Mod_MlKem768KeyGen(whClientContext* client, whBenchOpContext* ctx,
399+
int id, void* params);
400+
int wh_Bench_Mod_MlKem768KeyGenDma(whClientContext* client,
401+
whBenchOpContext* ctx, int id, void* params);
402+
int wh_Bench_Mod_MlKem768Encaps(whClientContext* client, whBenchOpContext* ctx,
403+
int id, void* params);
404+
int wh_Bench_Mod_MlKem768EncapsDma(whClientContext* client,
405+
whBenchOpContext* ctx, int id, void* params);
406+
int wh_Bench_Mod_MlKem768Decaps(whClientContext* client, whBenchOpContext* ctx,
407+
int id, void* params);
408+
int wh_Bench_Mod_MlKem768DecapsDma(whClientContext* client,
409+
whBenchOpContext* ctx, int id, void* params);
410+
411+
int wh_Bench_Mod_MlKem1024KeyGen(whClientContext* client,
412+
whBenchOpContext* ctx, int id, void* params);
413+
int wh_Bench_Mod_MlKem1024KeyGenDma(whClientContext* client,
414+
whBenchOpContext* ctx, int id,
415+
void* params);
416+
int wh_Bench_Mod_MlKem1024Encaps(whClientContext* client,
417+
whBenchOpContext* ctx, int id, void* params);
418+
int wh_Bench_Mod_MlKem1024EncapsDma(whClientContext* client,
419+
whBenchOpContext* ctx, int id,
420+
void* params);
421+
int wh_Bench_Mod_MlKem1024Decaps(whClientContext* client,
422+
whBenchOpContext* ctx, int id, void* params);
423+
int wh_Bench_Mod_MlKem1024DecapsDma(whClientContext* client,
424+
whBenchOpContext* ctx, int id,
425+
void* params);
426+
382427
#endif /* WH_BENCH_MOD_ALL_H_ */

0 commit comments

Comments
 (0)