[tpm2] Re: seal with external public EK

David Challener <david.c.challener at gmail.com> Wed, 31 Aug 2022 17:32:09 -0400
Newsgroups dev.linux.lists.tpm2
Message-ID <CAAeabfbMPW2M3jZS-VM9qpmYg0j9-Ac_Y5xSS5cC6XuiH1H6OA@mail.gmail.com>
I have always wondered what the purpose of doing the encryption/decryption
on the TPM is. It may keep the key out of view, but it never keeps the
encrypted DATA out of view. (Presuming good practices are followed so the
key is only used once.) So the decrypted doc is going to be available on
both devices. Devices can encrypt/decrypt much faster than a TPM that can
do the encryption/decryption.
So what is the reason you want to do that?

On Wed, Aug 31, 2022 at 10:32 AM Gadacz, Henry <
henry.gadacz(a)sit.fraunhofer.de> wrote:

> Hello everyone,
>
>
>
> I want to encrypt a larger file on TPM A and decrypt it on TPM B. To share
> a symmetric key for that I have TPM B’s public endorsement keys on TPM A.
> The EK of TPM B is created and persisted as followed:
>
> tpm2_createek -P endPW -w ownerPW -c $EK_HANDLE -G rsa
>
>
>
> The public part is exported with:
>
> pm2_readpublic -c $EK_HANDLE -o B_EK.pem -f pem
>
>
>
> On TPM A I load the public EK key of TPM B:
>
> tpm2_loadexternal -C o -G rsa -u B_EK.pem -c B_EK.ctx
>
>
>
> To seal random data that is used as symmetric key to the TPM B EK I tried:
>
> tpm2_getrandom --hex 32 | tpm2_create -C B_EK.ctx -i- -u
> A_transportKey_pub.seal -r A_transportKey_priv.seal
>
>
>
> But I always get the following error:
>
> WARNING:esys:src/tss2-esys/api/Esys_Create.c:399:Esys_Create_Finish()
> Received TPM Error
>
> ERROR:esys:src/tss2-esys/api/Esys_Create.c:134:Esys_Create() Esys Finish
> ErrorCode (0x0000012f)
>
> ERROR: Esys_Create(0x12F) - tpm:error(2.0): authValue or authPolicy is not
> available for selected entity
>
> ERROR: Unable to run tpm2_create
>
>
>
> Why is an authValue or authPolicy required? I created the EK without
> authorization value or policy.
>
>
>
> I want to use the sealing method instead of tpm2_rsaencrypt to be able to
> process the symmetric key inside TPM B when doing the decryption and don’t
> need to store a file with the symmetric key on the disk.
>
>
>
> Any help on what’s the problem or other suggestions to solve this task are
> really appreciated.
>
>
>
> 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
>
attachment.htm (text/html, 3.8 KB)
<div dir="ltr"><div>I have always wondered what the purpose of doing the encryption/decryption on the TPM is. It may keep the key out of view, but it never keeps the encrypted DATA out of view. (Presuming good practices are followed so the key is only used once.) So the decrypted doc is going to be available on both devices. Devices can encrypt/decrypt much faster than a TPM that can do the encryption/decryption.</div><div>So what is the reason you want to do that?<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 31, 2022 at 10:32 AM Gadacz, Henry &lt;<a href="mailto:[email protected]">[email protected]</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg-8055604053279607809"><div style="overflow-wrap: break-word;" lang="EN-US"><div class="m_-8055604053279607809WordSection1"><p class="MsoNormal"><span lang="DE">Hello everyone,<u></u><u></u></span></p><p class="MsoNormal"><span lang="DE"><u></u> <u></u></span></p><p class="MsoNormal">I want to encrypt a larger file on TPM A and decrypt it on TPM B. To share a symmetric key for that I have TPM B’s public endorsement keys on TPM A. The EK of TPM B is created and persisted as followed:<u></u><u></u></p><p class="MsoNormal">tpm2_createek -P endPW -w ownerPW -c $EK_HANDLE -G rsa <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">The public part is exported with:<u></u><u></u></p><p class="MsoNormal">pm2_readpublic -c $EK_HANDLE -o B_EK.pem -f pem<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">On TPM A I load the public EK key of TPM B:<u></u><u></u></p><p class="MsoNormal">tpm2_loadexternal -C o -G rsa -u B_EK.pem -c B_EK.ctx<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">To seal random data that is used as symmetric key to the TPM B EK I tried:<u></u><u></u></p><p class="MsoNormal">tpm2_getrandom --hex 32 | tpm2_create -C B_EK.ctx -i- -u A_transportKey_pub.seal -r A_transportKey_priv.seal<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">But I always get the following error:<u></u><u></u></p><p class="MsoNormal">WARNING:esys:src/tss2-esys/api/Esys_Create.c:399:Esys_Create_Finish() Received TPM Error <u></u><u></u></p><p class="MsoNormal">ERROR:esys:src/tss2-esys/api/Esys_Create.c:134:Esys_Create() Esys Finish ErrorCode (0x0000012f) <u></u><u></u></p><p class="MsoNormal">ERROR: Esys_Create(0x12F) - tpm:error(2.0): authValue or authPolicy is not available for selected entity<u></u><u></u></p><p class="MsoNormal">ERROR: Unable to run tpm2_create<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Why is an authValue or authPolicy required? I created the EK without authorization value or policy. <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I want to use the sealing method instead of tpm2_rsaencrypt to be able to process the symmetric key inside TPM B when doing the decryption and don’t need to store a file with the symmetric key on the disk.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Any help on what’s the problem or other suggestions to solve this task are really appreciated.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Best Regards,<u></u><u></u></p><p class="MsoNormal">Henry<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p></div></div>_______________________________________________<br>
tpm2 mailing list -- <a href="mailto:[email protected]" target="_blank">[email protected]</a><br>
To unsubscribe send an email to <a href="mailto:[email protected]" target="_blank">[email protected]</a><br>
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s</div></blockquote></div>