[tpm2] Re: import key in tss format into tpm2-pytss
Gadacz, Henry <henry.gadacz at sit.fraunhofer.de> Tue, 20 Sep 2022 14:14:00 +0000
| Newsgroups | dev.linux.lists.tpm2 |
|---|---|
| Message-ID | <FR0P281MB1706969EE03FF4D9250EBBC9D14C9@FR0P281MB1706.DEUP281.PROD.OUTLOOK.COM> |
Thank you for the hint and quick response. The TPM2B_PUBLIC.unmarshal() solves it.
Best Regards,
Henry
-----Ursprüngliche Nachricht-----
Von: Erik <who(a)cnackers.org>
Gesendet: Dienstag, 20. September 2022 15:30
An: Gadacz, Henry <henry.gadacz(a)sit.fraunhofer.de>; tpm2(a)lists.01.org
Betreff: Re: [tpm2] import key in tss format into tpm2-pytss
Hi,
You can use the unmarshal method for TPM2B_PUBLIC, so something like this (untested) might work:
from tpm2_pytss.types import TPM2B_PUBLIC
with open("tpm.pub", "rb") as f:
data = f.read()
pub, _ = TPM2B_PUBLIC.unmarshal(data)
print(pub.publicArea.type)
/Erik
On Tue, 2022-09-20 at 13:20 +0000, Gadacz, Henry wrote:
> Hello everyone,
>
> I have exported a public key with the tpm2-tools using tpm2_readpublic
> in the default tss format (I guess it is a TPM2B_PUBLIC structure).
>
> How can I load it into an TPM2B_PUBLIC or TPMT_PUBLIC object in
> tpm2-pytss, so I can load it with the
> ESAPI.load_external() function? I have seen the .from_pem() method,
> but I don’t want to use pem format, because it does not include the key attributes and other information.
>
> Best Regards,
> Henry
>
> _______________________________________________
> 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
smime.p7s
(application/pkcs7-signature, 7.7 KB) - not displayed