.. SPDX-License-Identifier: MIT .. Copyright (C) 2026 Szymon Wilczek ======================================= Sealed keys (offline local attestation) ======================================= Remote attestation proves state to a verifier over the network. Sealing is the local counterpart: the TPM releases a secret only when the host booted into the expected state, with no verifier round-trip. It is a local boundary the TPM enforces -- useful for single-player / offline DRM and for at-rest key storage -- but it does **not** replace remote attestation for competitive multiplayer, where the attacker owns the box. Seal a secret to the current boot state and recover it later: .. code-block:: sh # Seal: secret in on stdin, sealed blob out on stdout (root only). printf '%s' "$PER_TITLE_KEY" | sudo lota-agent --seal > title.sealed # Unseal: only succeeds when the host is in the sealed PCR state. sudo lota-agent --unseal < title.sealed The default PCR set is the platform: the firmware code, its configuration and the Secure Boot state, PCRs 0, 1 and 7. The threat at-rest sealing answers is a powered-off disk in someone else's hands, and the blob loads only under this TPM's primary key. A firmware or Secure Boot change makes the unseal fail closed. A kernel upgrade does not: PCR 4, which holds the kernel image on a shim and GRUB host, is not in the set. **PCR 14 is deliberately not in the default set.** It is LOTA's boot commitment, and its value is a function of the agent binary: it is stable from boot to boot, and it moves when the agent is updated. Binding it would make every agent upgrade destroy every sealed secret on the host, while adding nothing against a stolen disk. Ask for it explicitly with ``--seal-pcrs 0x4083`` when you want a secret a swapped agent cannot read and you accept losing it at each upgrade; pick any other set the same way (for example ``--seal-pcrs 0xC1`` for PCRs 0, 6 and 7). To harden the agent's own AIK userAuth at rest, enable sealing in ``lota.conf``: .. code-block:: ini seal_aik_auth = true # keep a sealed copy, prefer it on load seal_aik_auth_strict = true # store ONLY sealed; no plaintext on disk ``strict`` removes the plaintext sidecar, so a captured disk no longer yields the AIK auth even to an attacker with the same TPM in a different boot state. It protects this value and not the key: ``userAuth`` is no input to a primary, so a local root can create the same key with an authorization of its own. Leave both keys at their default ``false`` to keep the existing plaintext-sidecar behaviour. An already-enrolled host adopts sealing without re-enrolling: .. code-block:: sh # Set the keys in lota.conf, then seal the current auths in place: sudo lota-agent --seal-aik-auth **It seals every key the host attests with, and says how many.** A host that answers to publishers holds one attestation key per publisher, each with its own authorization, so the count is what tells an operator the adoption covered the fleet rather than one key. The second line is read back off the disk after the fact, not stated from the configuration: .. code-block:: text Sealed the authorization of 6 attestation keys to the platform state. 6 still keep a plaintext copy beside the sealed one; set seal_aik_auth_strict to drop it. A host with no publishers -- an operator-owned fleet reporting to a single verifier -- has one key, the pre-profile default, and seals that. On a host with publishers that key belongs to nobody and is left alone. Any key that could not be sealed is named with the state its authorization is actually in, read off the disk before the attempt, and the command exits non-zero. A key that is already sealed with no plaintext copy is the exception: there was nothing left to seal, which is the hardened state, so it is reported as such and does not take the exit status with it. Re-running the verb on a fleet that is already strict therefore succeeds. ``--reprovision-aik`` walks the same set: it rotates every publisher's authorization, and reports whether the new authorizations were sealed or written in the clear, read back. The *key* usually does not move. It is a primary derived from the hierarchy seed and a template carrying the publisher's identity; ``userAuth`` is not an input, so the same chip and publisher give the same key back. The verb compares the object's TPM Name before and after and reports which happened. An unmoved key leaves every certificate valid. A key that did change (a different template, as when moving a host onto per-publisher keys) is named with its publisher, to be re-enrolled against that publisher's CA. The rotation counter behind the D-Bus surface advances only for a moved key; an authorization rotation is recorded separately. What a refused unseal is about ============================== An unseal is refused either by the file or by the TPM, with opposite remedies. The blob's framing is checked before the TPM is opened, and a refusal names the field: a blob opens with ``LSEL`` and an envelope with ``LENV``, then a version, a PCR selection and the two body lengths, which must fill the file exactly. .. code-block:: text $ sudo lota-agent --unseal < truncated.sealed Not a sealed blob this build can read: the declared bodies do not fill the file exactly (1300, expected 1301). Look at the file, not the host: a truncated transfer, a copy cut from a larger archive, or a blob from a build with different framing. Key material behind the header that does not decode is the file's fault too: .. code-block:: text $ sudo lota-agent --unseal < damaged.sealed Unseal failed: Bad message A TPM refusal is what sealing exists for: .. code-block:: text $ sudo lota-agent --unseal < title.sealed Unseal failed: TPM policy not satisfied (host not in the sealed boot/PCR state) The sealed PCRs no longer hold their seal-time values: a firmware update, a Secure Boot change or, under the agent-bound mask, an agent upgrade. When the TPM refuses without naming a cause, the command prints a separate line pointing at the boot state. Auditing a fleet ================ Do not take a verb's word for it. ``--list-publishers`` reports how each publisher's authorization is kept at rest, which is the question sealing exists to answer: .. code-block:: text key auth sealed to the platform state, no plaintext copy key auth sealed, and a plaintext copy is kept beside it key auth plaintext on disk, not sealed key auth none stored Only the first is hardened. The second means sealing was adopted without ``seal_aik_auth_strict``, so a copy is still readable from a captured disk -- sealing a second copy protects nothing while the first one remains. The line reads the two files and nothing else, so it needs no TPM and reports the state rather than the intent. The sealed AIK auth is bound to the platform set, so a reboot and an agent upgrade both recover it. That is what makes ``strict`` usable at all: were the agent binary in the policy, a routine update would leave every host without an AIK authorization and force a re-enrollment with every publisher. The trade-off of ``strict``: a legitimate firmware or Secure Boot change makes the sealed auth unrecoverable. The agent will then **not** silently rotate the enrolled AIK; it reports the PolicyPCR mismatch and waits for an explicit recovery. Rotate and re-seal deliberately, then re-enroll: .. code-block:: sh sudo lota-agent --reprovision-aik sudo lota-agent --enroll --ca-server ca.example --ca-port 8444 --ca-cert ca.crt An authorization the agent cannot read is never a reason to replace the key =========================================================================== The rule is wider than the sealed case. The only failure that provisions a new attestation key is a record that is *absent*: no ``aik_auth.dat`` and no ``aik_auth.sealed``, which leaves the key on the chip with no authorization anywhere and no way to use it again. Every other failure -- a record at a version this build does not read, a short write, a wrong magic, an all-zero secret, a sealed blob that will not unseal -- describes a record that exists and a key that still works, so the agent reports it and stops: .. code-block:: text SECURITY: the attestation key's authorization could not be read (Operation not supported). The key is left as it is. SECURITY: /var/lib/lota/profiles//aik_auth.dat holds magic 0x41545541 version 2; this build reads magic 0x41545541 version 1. Replacing the key there would destroy the enrolled identity and orphan the certificate issued over it, and no backup brings it back: what a backup holds is the authorization, and the key it authorized is gone from the chip. Restore the record, or replace the key deliberately with ``--forget-publisher``, ``--allow-publisher`` and ``--enroll`` -- which issues a new certificate, because the current one names the key being replaced. With sealing on and no sealed copy yet, the same rule reads the plaintext sidecar as the record it is: the agent refuses rather than rotating, and names ``--seal-aik-auth`` as the way to seal what the host already has. Anti-rollback: what sealing binds, and what it does not ======================================================= LOTA sealing binds a secret to a boot/PCR **state**, and that is the intended contract. A few consequences worth stating plainly: * **Replaying a recurring good state is by design.** Rebooting into the same expected state releases the key every time. For offline DRM and at-rest storage that is the whole point. * **A different (tampered) state fails closed.** A firmware or Secure Boot change moves the bound PCRs and the unseal is denied. An agent change does not, unless the secret was sealed with the agent-bound mask above. * **What PCR binding does** *not* **cover:** revoking an *old* secret version while the host can still reproduce the PCR state it was sealed against -- i.e. a key/version *downgrade*. PCR binding has no notion of "newer than". LOTA core does not version or revoke sealed secrets, so it deliberately ships no monotonic-counter machinery (NV counters are a scarce, global TPM resource, and a compound PolicyPCR+PolicyNV path cannot be validated on the target hardware until the hardware bring-up above). If your use case *does* need downgrade protection, bind the secret to a TPM NV monotonic counter in addition to the PCRs and bump the counter to revoke. Complete, tested tpm2-tools recipe is in :ghsrc:`examples/sealed-key/anti-rollback-recipe.sh`.