Unlocking with a TPM
Outcome: you understand what it
means to let the machine's TPM chip
hold a vault's key, how enrolment is
done, and what it trades away. Label
first, as plainly as chapter 9: the
lab machine has no TPM — transcript
t08 lists /dev/tpm0 among the
devices it does not have — so this
chapter is documented-only, taught
from the systemd and cryptsetup
documentation. Nothing here was run,
and the guide will not pretend
otherwise.
The idea
Most modern PCs and many small boards carry a TPM (Trusted Platform Module): a small security chip that can hold secrets and release them only when the machine's early boot state matches recorded measurements. Since systemd 248 and cryptsetup 2.4, a LUKS2 vault can use one: a key slot is created whose key is sealed inside the TPM, and a token in the header (chapter 2's dump has a Tokens section, empty in all our vaults) records that the slot exists and which measurements it demands.
At boot, the TPM compares the measurements of what actually loaded — firmware, boot manager, secure-boot state — against the sealed conditions. Match: the key comes out and the vault opens, with no human typing anything. Mismatch: the TPM refuses, and the vault stays shut until someone provides a passphrase or recovery key.
Enrolling, in outline
The tool is systemd-cryptenroll,
part of the same systemd your
distribution already runs:
sudo systemd-cryptenroll \
--tpm2-device=auto \
--tpm2-pcrs=7 \
/dev/disk/by-uuid/<uuid>
It authenticates with an existing
passphrase (chapter 6's rule 1 admits
no exceptions), creates the sealed
slot and its token, and leaves every
existing slot untouched. The
--tpm2-pcrs choice is the policy:
PCR 7 records the secure-boot
state and is the usual recommendation
because it survives kernel updates;
binding to more registers (firmware,
boot manager, kernel) tightens the
definition of "the same machine" at
the price of re-enrolling after
updates that change them. Two
companions matter:
--recovery-key— generates a long, high-entropy recovery passphrase in its own slot. Enrol one first. The TPM path will eventually fail you — a firmware update, a replaced motherboard, a changed boot config — and on that morning the recovery key (or a surviving ordinary passphrase) is the whole difference between an anecdote and a loss.--tpm2-with-pin=true— demands a PIN as well as a healthy TPM: the machine must be itself and the human must know something. This restores a knowledge factor the plain enrolment gives up, at some of the convenience it bought.
What it buys, and what it gives up
Be exact, because the marketing of this feature rarely is.
It buys protection against the disk leaving the machine: a drive pulled and attached elsewhere has no TPM that will speak for it, and a laptop stolen whole cannot simply have its disk read offline. It also buys a boot with no typing, which is not a triviality — it is why servers in cupboards and grandparents' laptops end up encrypted at all instead of "encrypted, in theory".
It gives up the powered-off promise of chapter 1 in its pure form. With TPM unlock, anyone who can power the machine on gets a machine that unlocks its disk and boots to a login screen. The data is then defended by the login screen, the screen lock, and the operating system — exactly the layers disk encryption exists because you cannot fully trust. Attacks that trick the TPM or sniff the key on its way out exist in the literature (the bus between a discrete TPM and the CPU is the famous one). None of this makes TPM unlock a bad idea. It makes it a different idea: it optimises for the removed-disk threat, not the stolen-running-machine threat. If your threat model from chapter 1 is "the laptop is taken and read elsewhere", TPM unlock serves it well, PIN included. If it is "no one reaches my data without my passphrase, ever", the TPM should hold nothing of yours.
The standing advice
Enrol a recovery key before the TPM. Keep at least one ordinary passphrase slot alive and proven. Treat every firmware or secure-boot change as a possible re-enrolment appointment. And keep the header backup current (chapter 8): the token lives in the header too, and a restored old header restores the TPM enrolment of its day — for better and for worse.