-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot unseal LUKS key #48
Comments
It seems I have found the culprit... The safeboot luks-seal script took the PCRs 17,18,14 to create policy. And in that same exact order the PCRs were dumped to $TMP/pcrs.bin. But what if the tpm2_createpolicy tool assumes that PCRs are in ascending order? That would obviously work in original safeboot case with PCRs 0,2,5,7,14, but not for 17,18,14 sequence. So I sorted the PCRs and the digests when sealing the LUKS key, only then the unsealing worked... |
Ah, right. DRTM uses the higher PCRs. 14 was selected to store the boot mode on the Lenovo platform I was developing on since it was a high number and unused. The value is precomputed as part of the The fix for DRTM is going to be a little tricky, since the |
No, the worst thing in this issue is that tpm2-tools takes the PCR number as a bitmask, but it doesn't account for the order of PCR digests in the pcrs file when passed to create a policy. If the tpm2 tools could parse the order of passed PCRs, this issue would net even exist You would have to iterate through all pcrs, sort them first, then itegrate again and then inject the calculated digest for PCR14 only. Doable in bash I think. |
Yeah, the
(also, note the byte order -- 0,1,2,4 => 0x170000) The fix would have to merge the parser in In the DRTM case do you ever use lower PCRs? One fix would be to modify |
This is basically what I did. Ignored the SRTM PCRs and just used PCRs 14,17,18. At this point it worked, but care must be taken to not choose the PCRs arbitrarily as the safeboot luks-seal allows to do so. |
I'm working on an overhaul of how the TPM PCRs are handled as part of #57, which will involve sorting the PCRs and precomputing the SRTM PCR4 as part of the process. This sorting will hopefully also fix your DRTM issue, although the PCR4 will not be correct for a tboot system, so you shouldn't use that one. |
Example how PCRs could be sorted:
|
I did some experiments with DRTM and tried to seal my LUKS key to DRTM PCRs. Although I have verified that my PCRs do not change after final modifications to initramfs and kernel commandline, I get a policy check failed.
NOTE: No UEFI here. The kernel is not packaged into EFI file, but is only measured by DRTM
Steps I have performed:
tpm.mode=linux tpm.pcrs=17,18
to the kernel commandline.sudo safeboot luks-seal 17,18
Could it be that tpm2-tools expect the PCRs to be sorted in ascending order when creating policy? Looking at luks-seal execution, the policy was created with PCRs 17,18,14.
What is more, I have checked with tpm2_nvreadpublic and there is not NV index with handle 0x81000000. Maybe the sealing process failed silently.
The text was updated successfully, but these errors were encountered: