TPM2 (Trusted Platform Module) userspace development
 help / color / mirror / Atom feed
From: Felix Rubio Dalmau <felix at kngnt.org>
To: tpm2@lists.01.org
Subject: [tpm2] Re: Example with multifactor authentication available?
Date: Sun, 22 Aug 2021 09:57:02 +0200	[thread overview]
Message-ID: <2287518.OgVlmGemyz@polaris> (raw)
In-Reply-To: SN6PR11MB34379CDDBBFF49541ACF79F1B8319@SN6PR11MB3437.namprd11.prod.outlook.com

[-- Attachment #1: Type: text/plain, Size: 4854 bytes --]

Hi William,

	Sorry for answering so late after your last email. I had to jump to another subject, then holidays... yeah, life I guess! I have started again looking at this matter, and... I do not understand the part of the rescue password and how to use it. I see that using policysecret is the way to go, because it does not set any flag to require a password when the create is issued, but I still do not see how to use it to input a password. In the help of policysecret, it states:

     "/TPM2_PolicySecret/ command requires you to pass in the name of the object whose /password/ is required to satisfy the policy"

Does this mean that I should create an object, password-protected, just for the sake of using it later with policysecret?? It sounds weird to me, but I am not skilled enough to properly assess it.

Regards!
Felix

On Monday, 14 June 2021 20:51:14 CEST Roberts, William C wrote:
> Two things, if you need different PCR values than what's on the system, the TPM only cares about the hash of all the banks, so you can just specify that expected hash of the PCR state as argument 3 to tpm2_policypcr as shown in the man page (since 5.0). If on early versions, you can create a binary file, that's a list of binary hashes in order of the PCR selection. Ie if you did sha256:1,2,3, the file would be 3 * 32 bytes in size and contain the hashes of PCR1, 2, 3 in that order. This is the binary format from tpm2_pcrread -o, so if you have a system in the expected state, you can use that to output it, or hand jam it.
> 
> policy password just says, hey require a password for this object, and it will be found in the TPM header in the command.
> 
> So, the better way would be to look at policysecret, which effectively does the same thing, but puts it in the session
> over the command header. Thus, you can have multiple secrets for an object.
> 
> Typically, for a recovery password, folks couple it to the hierarchy the object belongs in via policyauthorize.
> 
> ________________________________
> From: Felix Rubio Dalmau <felix(a)kngnt.org>
> Sent: Saturday, June 12, 2021 12:58 AM
> To: tpm2(a)lists.01.org <tpm2(a)lists.01.org>
> Subject: [tpm2] Example with multifactor authentication available?
> 
> 
> Hi everybody!
> 
> 
> I am still learning about tpm and tpm2-tools. Following the advice from William Roberts, I set the authentication policy up as AND(pcr, password) by doing the following:
> 
> 
>     # create a policy that requires the pcr and the password
> 
>     tpm2_startauthsession -S session.dat
> 
>     tpm2_policypcr -S session.dat -l "sha1:0,1,2,3" -L policy.dat
> 
>     tpm2_policypassword -S session.dat -L policy.dat
> 
>     tpm2_flushcontext session.dat
> 
> 
>     # and the sealing goes with
> 
>     echo mysecret | tpm2_create -C primary.ctx -u key.pub -r key.priv -i- -p password -L policy.dat
> 
> 
> William suggested I should set up a signed policy so that when UEFI gets updated I can regenerate the policy and not find myself lock out off the system, which I understand, but the problem is: to prevent from further unlock attemps, after unsealing the secret protected by that policy, I will extend one of the pcr registers... so, if I generate the pcr policy with the live system, I will be using pcr values that have been altered.
> 
> 
> Now, I have thought in either forcing the EFI updates to happen during the system boot (I download the update, recreate a initramfs including it, and during the following boot, in the unlocking script, the UEFI gets updated and the policy gets created before unlocking), or in having a multi factor authentication that allows me to get in with either the previous policy or with another policy composed by the previous password and a rescue password. In this case, AND(password1, OR(password2, pcr)), I have written the following statements:
> 
> 
>     # session for auth based on pcr
>     tpm2_startauthsession -S session.dat
>     tpm2_policypcr -S session.dat -l "sha256:0,1" -L policy.pcr
>     tpm2_flushcontext session.dat
>     rm session.dat
> 
>     # session for auth based on rescue password
>     tpm2_startauthsession -S session.dat
>     tpm2_policypassword -S session.dat -L policy.rescue
>     tpm2_flushcontext session.dat
> 
>     rm session.dat
> 
>     # compound both policies using OR and require always the password
>     tpm2_startauthsession -S session.dat
>     tpm2_policyor -S session.dat -L policy.dat sha256:policy.pcr,policy.rescue
>     tpm2_policypassword -S session.dat -L policy.dat
>     tpm2_flushcontext session.dat
> 
>     rm session.dat
> 
> 
> 
> I think this is ok, but then.. I do not see how to initialize the password policies. Is there any example similar to what I want to achieve?
> 
> 
> Thank you!
> 
> Felix
> 



[-- Attachment #2: attachment.htm --]
[-- Type: text/html, Size: 11686 bytes --]

             reply	other threads:[~2021-08-22  7:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-22  7:57 Felix Rubio Dalmau [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-08-23 20:48 [tpm2] Re: Example with multifactor authentication available? Roberts, William C
2021-08-24 18:29 Felix Rubio Dalmau
2021-08-25  6:39 Felix Rubio Dalmau
2021-08-27 17:55 Roberts, William C
2021-08-27 18:05 Roberts, William C
2021-08-28  9:18 Felix Rubio Dalmau
2021-08-30 17:03 Roberts, William C

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2287518.OgVlmGemyz@polaris \
    --to=tpm2@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox