go-tpm-tools
go-tpm-tools copied to clipboard
Support loading cached key
Is it possible to simply load a cached key without having to know extra parameters, e.g. a template matching the key?
Basically, I want a TPM client function like the following:
// LoadKey loads a key from the provided handle.
func LoadKey(rw io.ReadWriter, handle tpmutil.Handle) (*Key, error) {
cachedPub, _, _, err := tpm2.ReadPublic(rw, handle)
if err != nil {
return nil, err
}
k := &Key{
rw: rw,
handle: handle,
pubArea: cachedPub,
}
return k, k.finish()
}
The only function that does a similar thing is NewCachedKey
, but comes with the risk of overwriting a key at the given handle if the provided template does not match the existing key.