Conversation
447359a to
24a3f6b
Compare
65c3cbb to
7aa8757
Compare
7aa8757 to
e459262
Compare
|
@cwyc reading through http://0pointer.net/blog/unlocking-luks2-volumes-with-tpm2-fido2-pkcs11-security-hardware-on-systemd-248.html, could we also use |
|
@Floki I also think systemd-cryptsetup is an ideal solution. |
This is what #120015 is doing. What's proposed here seems reasonable as a stop-gap solution before we switch to systemd for stage-1 (which may be a while). |
|
I'm a bit hesitant to add this now. Are we sure we do use the TPM the same way |
|
@Floki Yeah, it's not going to be a smooth transition from this method to systemd-cryptenroll. Here the user has to specify the handle and pcrs, with systemd I believe it's stored in the LUKS header. You'd have to remove the key and re-register it to convert from one to the other. Though I've noticed archwiki mentions that systemd-cryptsetup actually does have an executable:
So theoretically we can use that in the boot script now, and transition to the function built into systemd when we get a systemd initrd. But I can't find *any* other documentation on how to use this program. Running it with "--help" just gives me |
|
I don't think we should introduce our own TPM LUKS way of doing things, especially considering we want to switch to systemd-in-initrd. If we can use systemd-cryptsetup to do most of this already today (and migrate to using it more natively later), we should. Also, even without systemd in initrd, we can probably even make use of other (non-boot disks) being encrypted with keys stored in the TPM, similarly to how we already now support If we're worried about regressions, we can probably even add a VM test for this, considering QEMU does support emulating a TPM2. |
|
Sounds good. I've already been using TPM with QEMU to develop this patch. Once it's ready I'll open another PR. |
|
@cwyc I believe there isn't any support for LUKS encrypted root + TPM yet. |
|
I'm not sure my code can be merged. It's sort of hacky, and systemd already has a pretty good implementation of this feature. Too bad we can't use it until the OS transitions to a systemd-managed boot environment
A while ago I tried running the systemd-cryptenroll tools in initrd independently of systemd, but I was stuck on some linker issue.
Maybe this could be refactored into a standalone module, that can be easily dropped into a configuration.
|
Motivation for this change
This is an attempt to implement TPM unlocking for LUKS volumes.
The method is based on this guide: https://threat.tevora.com/secure-boot-tpm-2/
Set it up by generating a keyfile, registering it in a LUKS keyslot, and storing it in the TPM sealed with your selected PCRs:
Then, specify the handle and PCRs in your system configuration:
Once the system is rebuilt, it should unseal the volume without any intervention if the PCR values check out, or fall back to a password prompt.
I also have a version that supports transient keyfiles (stored on a disk but encrypted by the TPM) https://github.com/cwyc/nixpkgs/commits/tpmluks, but it's not working.
It's not a very elegant solution. Ideally, it should use systemd-cryptsetup, which can handle TPM unlocking without directly messing around with tpm commands, as well as replace the existing GPG, FIDO2, and Yubikey code. But it doesn't have a standalone executable.
Things done
sandboxinnix.confon non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"./result/bin/)