Skip to content

tpm2 disk encryption with systemd-cryptenroll #9756

Description

@osresearch

The problem you're addressing (if any)

When enabling TPM2 sealed disk encryption keys with systemd-cryptenroll (available as of systemd 248] it is fairly easy to seal the key (other than requiring that the user know the partition that is encrypted with LUKS):

systemd-cryptenroll \
  --wipe-slot=tpm2 \
  --tpm2-device=auto \
  --tpm2-pcrs=1+2+3+7 \
  --tpm2-with-pin=T \
  /dev/nvme0n1p3

There are three additional steps that need to be done once and are somewhat tricky. The first is that tpm2-tss has to be included in the initrd by creating a new dracut config file:

echo 'add_dracutmodules+=" tpm2-tss "' \
  | sudo tee /etc/dracut.conf.d/tpm2.conf

And the second is that /etc/crypttab has to specify that the tpm2 slot in LUKS should be used. Some guides suggest editing the file to add the option or use sed to try to do so automatically. If they get this wrong, the system might not be bootable.

sudo sed -i '/^luks-/s/$/,tpm2-device=auto' /etc/crypttab

And finally the user must rebuild the initrd with sudo dracut -f to pick up the new crypttab and include the tpm2-tss module in the image. If they are booting a signed UKI, they must also rebuild and re-sign their unifed Xen and dom0 vmlinux image.

The solution you'd like

The Qubes initrd could include the tpm2-tss module by default since hopefully many users will choose to use hardware protected keys.

The /etc/crypttab generation can include the tpm2-device=auto option for encrypted partitions even if no TPM2 sealed keys are created. The fallback behaviour is to ask for the passphrase anyway, so it does not change the boot time or user experience to have it included. Many of the guides also include the PCR list in the crypttab, although the default behaviour is to use the ones specified in the LUKS header (along with a PIN if used) so there is no need to do more than add the tpm2-device option.

The value to a user and who that user might be

Guides for enabling hardware sealed keys for new users can be as simple as running systemd-cryptenroll with the users choice of PCRs, without requiring extra steps to reconfigure dracut, hand editing the crypttab that could risk breaking the boot, or rebuilding the initrd.

Completion criteria checklist

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: bootThis issue pertains to boot-related issues in Qubes OS (e.g., system failing to boot).P: defaultPriority: default. Default priority for new issues, to be replaced given sufficient information.cryptographyThis issue pertains to the use of cryptography in Qubes OS.hardware supportThis issue pertains to the hardware that Qubes OS supports.securityThis issue pertains to the security of Qubes OS.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions