Commit 2151784
feat: Add ML-KEM-768 (FIPS 203) post-quantum KEM support
Integrates mlkem-native (Apache-2.0/MIT/ISC) for ML-KEM-768 key
encapsulation on the OnlyKey hardware token.
New capabilities:
- ML-KEM-768 keypair generation (KEYTYPE_MLKEM768 = 5)
- ML-KEM-768 decapsulation (recover shared secret from ciphertext)
- ML-KEM-768 public key retrieval from stored keypair
Implementation details:
- Uses mlkem-native v1.0.0 C-only portable backend (no assembly)
- All C code is CBMC-verified memory-safe
- RNG bridged to ArduinoLibs RNG.rand() via MLK_CONFIG_CUSTOM_RANDOMBYTES
- Secret key (2400 bytes) stored AES-GCM encrypted in flash sectors 10-11
(repurposed from FIDO2 resident key slots 5-8)
- Runtime scratch uses existing ctap_buffer (no new static allocations)
- PACKET_BUFFER_SIZE bumped 768->1088 for ML-KEM ciphertext transport
- LARGE_BUFFER_SIZE bumped 1024->1088 (no extra RAM, shifts within ctap_buffer)
- Total new RAM cost: 320 bytes
Protocol:
- Keygen: OKGENKEY slot=133 -> returns PK (1184 bytes)
- Get PK: OKGETPUBKEY slot=133 -> returns PK (1184 bytes)
- Decaps: OKDECRYPT slot=133, payload=CT (1088 bytes) -> returns SS (32 bytes)
Files added:
- mlkem_native/ - mlkem-native library (C90, FIPS 203 compliant)
Files modified:
- onlykey/okcore.h - KEYTYPE_MLKEM768, size defines, buffer size bumps
- onlykey/okcore.cpp - Flash storage for ML-KEM secret key
- onlykey/okcrypto.h - ML-KEM function declarations
- onlykey/okcrypto.cpp - ML-KEM operations and dispatch hooks1 parent 20e1623 commit 2151784
41 files changed
Lines changed: 10374 additions & 2 deletions
File tree
- mlkem_native
- src
- fips202
- test
- onlykey
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
22 | 33 | | |
23 | 34 | | |
24 | 35 | | |
| |||
0 commit comments