[tpm2] Re: import key in tss format into tpm2-pytss

Erik <who+01tpm at cnackers.org> Tue, 20 Sep 2022 15:33:41 +0200
Newsgroups dev.linux.lists.tpm2
Message-ID <[email protected]>
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