Skip to contentSkip to conversation

How to use tpm2 tool to unload an external key

tpm2 Chenxi Z 3 participants 5 messages Apr 21, 2021 – Apr 23, 2021

lore
Share & tools
lore

Chenxi Z

author
#0 lore raw

Hi,

I loaded an ecdsa P256 key, which was generated by openssl, into TPM. Once the key is not longer needed for my use case, I would like to unload the key. Can I know what tpm2 tool command that I can use to unload the external key? I am assuming if I don't unload the key, the key context/memory will forever be held by TPM (unless reboot). If I never release that and I keep loading new keys into TPM, the TPM will eventually run out of memory.

ref: https://github.com/tpm2-software/tpm2-tools/blob/master/man/tpm2_loadexternal.1.md

openssl ecparam -genkey -name prime256v1 -noout -out ec256-key-pair.pem tpm2_loadexternal -C n -G ecc -r ec256-key-pair.pem -c eckey.ctx

Thanks
Chenxi

#1 lore raw
Quoted 9 lines

From: "Chenxi Z" <cxzhang1981(a)hotmail.com>

I loaded an ecdsa P256 key, which was generated by openssl, into TPM. Once the key is not longer needed for my use case, I would like to unload the key. Can I know what tpm2 tool command that I can use to unload the external key?
I am assuming if I don't unload the key, the key context/memory will forever be held by TPM (unless reboot). If I never release that and I keep loading new keys into TPM, the TPM will eventually run out of

memory.

Quoted 1 line

Look for something like 'flushcontext'.

#2 lore raw

tpm2_flushcontent --transient-object

this removes all key object currently loaded into the TPM's RAM.

________________________________________
Von: Kenneth Goldman <kgoldman(a)us.ibm.com>
Gesendet: Donnerstag, 22. April 2021 00:29
Cc: tpm2(a)lists.01.org
Betreff: [tpm2] Re: How to use tpm2 tool to unload an external key

Quoted 10 lines

From: "Chenxi Z" <cxzhang1981(a)hotmail.com>

I loaded an ecdsa P256 key, which was generated by openssl, into TPM. Once the key is not longer needed for my use case, I would like to unload the key. Can I know what tpm2 tool command that I can use to unload the external key?
I am assuming if I don't unload the key, the key context/memory will forever be held by TPM (unless reboot). If I never release that and I keep loading new keys into TPM, the TPM will eventually run out of memory.

Look for something like 'flushcontext'.

author
#3 lore raw

Thank you, Andreas,

Would you know what command is used to list all objects currently loaded into the TPM? "tpm2_getcap handles-transient" doesn't work.

Steps:
openssl ecparam -genkey -name prime256v1 -noout -out ec256-key-pair.pem tpm2_loadexternal -C n -G ecc -r ec256-key-pair.pem -c eckey.ctx tpm2_getcap handles-transient ----> return nonthing.

#4 lore raw

You are probably going through a resource manager and that removes transient handles when a program (such as tpm2_loadexternal) exits. That also makes sense and is the default way of doing things.
For subseuent usage of the loaded key you will be using eckey.ctx anyways.

________________________________________
Von: Chenxi Z <cxzhang1981(a)hotmail.com>
Gesendet: Donnerstag, 22. April 2021 20:13
An: tpm2(a)lists.01.org
Betreff: [tpm2] Re: How to use tpm2 tool to unload an external key

Thank you, Andreas,

Would you know what command is used to list all objects currently loaded into the TPM? "tpm2_getcap handles-transient" doesn't work.

Steps:
openssl ecparam -genkey -name prime256v1 -noout -out ec256-key-pair.pem tpm2_loadexternal -C n -G ecc -r ec256-key-pair.pem -c eckey.ctx tpm2_getcap handles-transient ----> return nonthing.
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s