Skip to content

Commit aa2f320

Browse files
authored
docs(tpm): add more examples for key management
Signed-off-by: Boris Glimcher <36732377+glimchb@users.noreply.github.com>
1 parent 9d9e332 commit aa2f320

File tree

1 file changed

+55
-4
lines changed

1 file changed

+55
-4
lines changed

doc/qemu_tpm_setup.md

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,25 @@ Working with Keys, from <https://github.com/tpm2-software/tpm2-openssl/blob/mast
135135

136136
```bash
137137
[fedora@fed38 ~]$ sudo tpm2_createek -G rsa -c ek_rsa.ctx
138-
[fedora@fed38 ~]$ sudo tpm2_createak -C ek_rsa.ctx -G rsa -g sha256 -s rsassa -c ak_rsa.ctx
138+
[fedora@fed38 ~]$ sudo tpm2_createak -C ek_rsa.ctx -G rsa -g sha256 -s rsassa --ak-context ak_rsa.ctx
139139
loaded-key:
140140
name: 000b42319d115beaaa57c3f2b385d8cb1e2e6834b65e5da97be1e8339a74a053d7ff
141141
qualified name: 000b1f2b91b573baeb8d3e37b9ce48eafb0542bde0ff2fac9366f31bf178680440e6
142-
[fedora@fed38 ~]$ sudo tpm2_evictcontrol -c ak_rsa.ctx 0x81000000
142+
[fedora@fed38 ~]$ sudo tpm2_evictcontrol --object-context=ak_rsa.ctx 0x81000000
143143
persistent-handle: 0x81000000
144144
action: persisted
145145

146146
[fedora@fed38 ~]$ sudo tpm2_getcap handles-persistent
147147
- 0x81000000
148148

149-
[fedora@fed38 ~]$ sudo tpm2_evictcontrol -C o -c 0x81000000
149+
[fedora@fed38 ~]$ sudo tpm2_evictcontrol --hierarchy=o --object-context=0x81000000
150150
persistent-handle: 0x81000000
151151
action: evicted
152152
[fedora@fed38 ~]$ sudo tpm2_getcap handles-persistent
153153
[fedora@fed38 ~]$
154154

155+
# Primary key generation
156+
155157
[fedora@fed38 ~]$ sudo tpm2_createprimary --hierarchy=o --hash-algorithm=sha256 --key-algorithm=ecc256:aes128cfb --key-context=tpm_primary_key.ctx --attributes="decrypt|fixedtpm|fixedparent|sensitivedataorigin|userwithauth|noda|restricted" -V
156158
name-alg:
157159
value: sha256
@@ -186,11 +188,60 @@ sym-mode:
186188
sym-keybits: 128
187189
x: 50ae5635be637d617fb1d9499fda0b618b63e8f27cc750ec65bcb9d9655e08e2
188190
y: 531a72b1039f2441bfb59f9086119b0c50d3fa7acd86d432325dd8726b4b22e6
189-
[fedora@fed38 ~]$ sudo tpm2_evictcontrol -C o 0x81020004 -c tpm_primary_key.ctx -V
191+
[fedora@fed38 ~]$ sudo tpm2_evictcontrol --hierarchy=o 0x81020004 --object-context=tpm_primary_key.ctx -V
190192
persistent-handle: 0x81020004
191193
action: persisted
192194
[fedora@fed38 ~]$ sudo tpm2_getcap handles-persistent
193195
- 0x81000000
194196
- 0x81020004
195197

198+
# TPM ECDSA key generation (Device attestation key)
199+
200+
[fedora@fed38 ~]$ sudo tpm2_create --parent-context=0x81020004 --hash-algorithm=sha256 --key-algorithm=ecc256:ecdsa-sha256 --public=tpm_ecdsa_pub.key --private=tpm_ecdsa_priv.key --attributes="sign|fixedtpm|fixedparent|sensitivedataorigin|userwithauth|noda"
201+
name-alg:
202+
value: sha256
203+
raw: 0xb
204+
attributes:
205+
value: fixedtpm|fixedparent|sensitivedataorigin|userwithauth|noda|sign
206+
raw: 0x40472
207+
type:
208+
value: ecc
209+
raw: 0x23
210+
curve-id:
211+
value: NIST p256
212+
raw: 0x3
213+
kdfa-alg:
214+
value: null
215+
raw: 0x10
216+
kdfa-halg:
217+
value: (null)
218+
raw: 0x0
219+
scheme:
220+
value: ecdsa
221+
raw: 0x18
222+
scheme-halg:
223+
value: sha256
224+
raw: 0xb
225+
sym-alg:
226+
value: null
227+
raw: 0x10
228+
sym-mode:
229+
value: (null)
230+
raw: 0x0
231+
sym-keybits: 0
232+
x: 66d3f05041cd5b39ee5bb191ea1b1b61dfdb1d31040a3742c47db1395eb997e9
233+
y: 6a70ed0b486dd094a4bf37a2ef8051cc71c81c6e760025086f8bd44751bb690f
234+
235+
[fedora@fed38 ~]$ sudo tpm2_load --public=tpm_ecdsa_pub.key --private=tpm_ecdsa_priv.key --key-context tpm_ecdsa_key.ctx --parent-context=0x81020004
236+
name: 000b47b51aa53335f1521b45382f194d4ca9291daee4ba3d4f9191bbdf56e789c61f
237+
238+
[fedora@fed38 ~]$ sudo tpm2_evictcontrol --hierarchy=o 0x81000002 --object-context=tpm_ecdsa_key.ctx -V
239+
persistent-handle: 0x81000002
240+
action: persisted
241+
242+
# Flushing memory
243+
244+
[fedora@fed38 ~]$ sudo tpm2_flushcontext --transient-object -V
245+
INFO on line: "44" in file: "lib/tpm2_capability.c": GetCapability: capability: 0x1, property: 0x80000000
246+
196247
```

0 commit comments

Comments
 (0)