[tpm2] Re: How to initialize a used TPM2 module and thoughts on clevis

Roberts, William C <william.c.roberts at intel.com> Fri, 19 Aug 2022 16:17:39 +0000
Newsgroups dev.linux.lists.tpm2
Message-ID <SN6PR11MB343708BF532EF2E5B139288BB86C9@SN6PR11MB3437.namprd11.prod.outlook.com>
Thanks Javier,

Seems to have the same bug:
  - https://github.com/fedora-iot/clevis-pin-tpm2/blob/main/src/utils.rs#L99


I filled issue:
https://github.com/fedora-iot/clevis-pin-tpm2/issues/20

Thanks,
Bill
________________________________
From: Javier Martinez Canillas <javierm(a)redhat.com>
Sent: Tuesday, August 16, 2022 12:29 PM
To: Roberts, William C <william.c.roberts(a)intel.com>; tpm2(a)bitzap.e4ward.com <tpm2(a)bitzap.e4ward.com>; tpm2(a)lists.01.org <tpm2(a)lists.01.org>
Subject: Re: [tpm2] Re: How to initialize a used TPM2 module and thoughts on clevis

Hello Bill,

On 7/13/22 16:53, Roberts, William C wrote:
> + Javier
>
> On Tue, 2022-07-12 at 22:25 +0000, Tim K wrote:
>> Very useful, thank you!
>>
>>> and YES. This is required to keep someone from wiping all the keys
>>> in
>>> the owner hierarchy which would include your disk encryption keys.
>>> You also want to set the lockoutauth as well.
>>
>> It appears clevis uses the owner hierarchy by default. If I set an
>> owner password, what are the implications, does clevis need to know
>> the owner password when it creates its own key and then
>> encrypts/decrypts its own key?
>>
>> This is how I'm trying to use it to encrypt a single file on disk
>> (not the entire disk/LUKS):
>> https://manpages.ubuntu.com/manpages/focal/man1/clevis-encrypt-tpm2.1.html
>
>
> Looking at the source[1,2], it appears they call tpm2_createprimary on
> encrypt which would require owner auth, call tpm2_create save the key
> and then on decrypt call tpm2_createprimary which requires owner auth
> and then call tpm2_load to load the key under that primary object.
>
> I don't see an option to use the SRK, this looks like an oversight or I
> am missing something. Javier, do you know?
>

I don't remember anymore why this was done that way. I haven't worked on
TPM stuff for a while and paged out of my head all the details... sorry.

But in case is useful, there's a new clevis tpm2 pin that is a rewrite and
and supports more features such as PCR Authorized Policies. Please take a
look, since it maybe be doing the correct thing and if not, you can file
an issue for that:

https://github.com/fedora-iot/clevis-pin-tpm2
 --
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
attachment.htm (text/html, 4.9 KB)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Thanks Javier,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Seems to have the same bug:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
&nbsp; -&nbsp;<a href="https://github.com/fedora-iot/clevis-pin-tpm2/blob/main/src/utils.rs#L99" id="LPNoLPOWALinkPreview">https://github.com/fedora-iot/clevis-pin-tpm2/blob/main/src/utils.rs#L99</a></div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview _EReadonly_1"></div>
<br>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
I filled issue:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<a href="https://github.com/fedora-iot/clevis-pin-tpm2/issues/20" id="LPlnk609983">https://github.com/fedora-iot/clevis-pin-tpm2/issues/20</a><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Thanks,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Bill</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Javier Martinez Canillas &lt;[email protected]&gt;<br>
<b>Sent:</b> Tuesday, August 16, 2022 12:29 PM<br>
<b>To:</b> Roberts, William C &lt;[email protected]&gt;; [email protected] &lt;[email protected]&gt;; [email protected] &lt;[email protected]&gt;<br>
<b>Subject:</b> Re: [tpm2] Re: How to initialize a used TPM2 module and thoughts on clevis</font>
<div>&nbsp;</div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hello Bill,<br>
<br>
On 7/13/22 16:53, Roberts, William C wrote:<br>
&gt; + Javier<br>
&gt; <br>
&gt; On Tue, 2022-07-12 at 22:25 +0000, Tim K wrote:<br>
&gt;&gt; Very useful, thank you!<br>
&gt;&gt;<br>
&gt;&gt;&gt; and YES. This is required to keep someone from wiping all the keys<br>
&gt;&gt;&gt; in<br>
&gt;&gt;&gt; the owner hierarchy which would include your disk encryption keys.<br>
&gt;&gt;&gt; You also want to set the lockoutauth as well.<br>
&gt;&gt;<br>
&gt;&gt; It appears clevis uses the owner hierarchy by default. If I set an<br>
&gt;&gt; owner password, what are the implications, does clevis need to know<br>
&gt;&gt; the owner password when it creates its own key and then<br>
&gt;&gt; encrypts/decrypts its own key?<br>
&gt;&gt;<br>
&gt;&gt; This is how I'm trying to use it to encrypt a single file on disk<br>
&gt;&gt; (not the entire disk/LUKS):<br>
&gt;&gt; <a href="https://manpages.ubuntu.com/manpages/focal/man1/clevis-encrypt-tpm2.1.html">
https://manpages.ubuntu.com/manpages/focal/man1/clevis-encrypt-tpm2.1.html</a><br>
&gt; <br>
&gt; <br>
&gt; Looking at the source[1,2], it appears they call tpm2_createprimary on<br>
&gt; encrypt which would require owner auth, call tpm2_create save the key<br>
&gt; and then on decrypt call tpm2_createprimary which requires owner auth<br>
&gt; and then call tpm2_load to load the key under that primary object.<br>
&gt; <br>
&gt; I don't see an option to use the SRK, this looks like an oversight or I<br>
&gt; am missing something. Javier, do you know?<br>
&gt;<br>
<br>
I don't remember anymore why this was done that way. I haven't worked on<br>
TPM stuff for a while and paged out of my head all the details... sorry.<br>
<br>
But in case is useful, there's a new clevis tpm2 pin that is a rewrite and<br>
and supports more features such as PCR Authorized Policies. Please take a<br>
look, since it maybe be doing the correct thing and if not, you can file<br>
an issue for that:<br>
<br>
<a href="https://github.com/fedora-iot/clevis-pin-tpm2">https://github.com/fedora-iot/clevis-pin-tpm2</a><br>
&nbsp;-- <br>
Best regards,<br>
<br>
Javier Martinez Canillas<br>
Linux Engineering<br>
Red Hat<br>
<br>
</div>
</span></font></div>
</body>
</html>