go-tpm-tools icon indicating copy to clipboard operation
go-tpm-tools copied to clipboard

Allow persistence `client.Key()`

Open salrashid123 opened this issue 2 years ago • 1 comments
trafficstars

FR to allow client.Key full persistence such that can be loadable after power cycles.

Right now the only way to reuse objects across reboots is to evictcontrol() and find one of the empty slots.

Key.read()
Key.write()

so that the library can load the entire chain cleanly.

also see

https://github.com/google/go-tpm/issues/342

salrashid123 avatar Aug 25 '23 19:08 salrashid123

if using tpm2_tools, it should be the something like if using ek

tpm2 flushcontext -t
tpm2 startauthsession --session session.ctx --policy-session
tpm2 policysecret --session session.ctx --object-context endorsement
$ ls
rsa.priv  rsa.pub
tpm2 createek --ek-context ek.ctx
tpm2_load -C ek.ctx -c rsa.ctx -u rsa.pub -r rsa.priv --auth session:session.ctx
tpm2_sign -c rsa.ctx -g sha256  -f plain -p testpassword -o sig.rss  file.txt

there's also the tree to account for since a Key object can be chained/leaf

update:

i ended up parsing improtblob , importing it and then persisting th pub, priv parts to files. then reload the whole context:

https://github.com/salrashid123/gcp_tpm_sealed_keys/tree/main#sealed-asymmetric-key-with-persistent-files

salrashid123 avatar Oct 23 '23 12:10 salrashid123