Example with multifactor authentication available?
Felix Rubio Dalmau
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.datWilliam 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.datI 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