Skip to content

Commit b2faa40

Browse files
committed
Document PQC parameter encryption in example READMEs
1 parent 1b9dc12 commit b2faa40

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

examples/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ The PKCS #7 and TLS examples require generating CSR's and signing them using a t
88

99
To enable parameter encryption use `-aes` for AES-CFB mode or `-xor` for XOR mode. Only some TPM commands / responses support parameter encryption. If the TPM2_ API has .flags `CMD_FLAG_ENC2` or `CMD_FLAG_DEC2` set then the command will use parameter encryption / decryption.
1010

11+
On a v1.85 PQC capable TPM the parameter encryption session can also be keyed with a post-quantum primary: pass `-mlkem` to salt the session with an ML-KEM key or `-mldsa` to bind it to an ML-DSA key (`keygen` uses `-paramkey=mlkem|mldsa` since `-mlkem`/`-mldsa` there select the child key). See "Parameter Encryption" below.
12+
1113
There are some vendor specific examples, like the TPM 2.0 extra GPIO examples for ST33 and NPCT75x.
1214

1315
## Native API Test
@@ -80,6 +82,17 @@ This behavior depends on the `sessionAttributes`:
8082

8183
Either one can be set separately or both can be set in one authorization session. This is up to the user (developer).
8284

85+
### Post-quantum session keys (v1.85)
86+
87+
The parameter encryption session can be keyed with a post-quantum primary instead of an RSA/ECC storage key. ML-KEM is decrypt capable and is used as the session salt key; ML-DSA is sign only and is used as the session bind key. The RSA/ECC storage key (where one is needed, such as the parent of a created child) is unchanged. `wrap_test`, `pcr/quote`, and `nvram/store` and `nvram/counter` accept `-mlkem[=512|768|1024]` and `-mldsa[=44|65|87]`; `keygen` uses `-paramkey=mlkem[=...]` / `-paramkey=mldsa[=...]` because `-mlkem`/`-mldsa` there select the child key. This requires a v1.85 PQC capable TPM.
88+
89+
```sh
90+
./examples/wrap/wrap_test -aes -mlkem=768
91+
./examples/pcr/quote 16 quote.blob -ecc -xor -mldsa=65
92+
./examples/nvram/counter -aes -mldsa=65
93+
./examples/keygen/keygen keyblob.bin -ecc -aes -paramkey=mlkem=768
94+
```
95+
8396
## CSR
8497

8598
Generates a Certificate Signing Request for building a certificate based on a TPM key pair.

examples/pqc/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,37 @@ by loading it back:
126126
A successful load prints `Loaded key to 0x80000000`. The full 18-way
127127
matrix (three variants x three parameter sets) is exercised by
128128
`examples/run_examples.sh` when v1.85 is detected in `config.h`.
129+
130+
### PQC keys for parameter encryption
131+
132+
A post-quantum primary can key a TPM 2.0 parameter-encryption session:
133+
ML-KEM (decrypt capable) is used as the session salt key and ML-DSA
134+
(sign only) as the session bind key. The session protects the command's
135+
first sized parameter the same way an RSA/ECC salted session does. Any
136+
RSA/ECC storage key the example needs (for example the parent of a
137+
created child) is unchanged.
138+
139+
`wrap_test`, `pcr/quote`, and `nvram/store` and `nvram/counter` take
140+
`-mlkem[=512|768|1024]` and `-mldsa[=44|65|87]`. `keygen` uses
141+
`-paramkey=mlkem[=...]` / `-paramkey=mldsa[=...]` because its `-mlkem` /
142+
`-mldsa` already select the child key algorithm.
143+
144+
```
145+
./examples/wrap/wrap_test -aes -mlkem=768
146+
./examples/pcr/quote 16 quote.blob -ecc -xor -mldsa=65
147+
./examples/nvram/counter -aes -mldsa=65
148+
./examples/keygen/keygen keyblob.bin -ecc -aes -paramkey=mlkem=768
149+
```
150+
151+
ML-KEM is a restricted decryption (salt) key, which requires a symmetric
152+
definition; the example helper sets AES-128-CFB on it (a TPM rejects a
153+
restricted key with no symmetric algorithm via `TPM_RC_SYMMETRIC`).
154+
155+
### `create_primary` ML-DSA primary
156+
157+
`examples/keygen/create_primary` can create an ML-DSA primary key:
158+
159+
```
160+
./examples/keygen/create_primary -mldsa # default MLDSA-65
161+
./examples/keygen/create_primary -mldsa=87 -oh
162+
```

0 commit comments

Comments
 (0)