]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tpm2: allow use of recoverable sealing keys
authorsafforddr <david.safford@gmail.com>
Tue, 13 Jan 2026 18:27:20 +0000 (13:27 -0500)
committerLennart Poettering <lennart@poettering.net>
Mon, 19 Jan 2026 21:00:45 +0000 (22:00 +0100)
In some use cases it is desirable to use a recoverable (ie duplicatable)
sealing key. Currently objects have the attribute TPMA_OBJECT_FIXEDTPM
and TPMA_OBJECT_FIXEDPARENT hard coded, which will not work with a
recoverable sealing key. This patch sets the object's attributes from
the sealing key's attributes, so that both types of sealing keys will work.

src/shared/tpm2-util.c

index 8592485bf478a2be187efbb64fef30b1aa9f7ad3..c751afb06b4af44355ce7618096fff896b4a05ab 100644 (file)
@@ -5441,6 +5441,11 @@ int tpm2_seal(Tpm2Context *c,
                                                seal_key_handle);
 
                 primary_alg = primary_public->publicArea.type;
+                
+                /* Propagate fixedTPM/fixedParent flags from sealing key to hmac key */
+                hmac_template.objectAttributes = (hmac_template.objectAttributes & ~(TPMA_OBJECT_FIXEDTPM|TPMA_OBJECT_FIXEDPARENT)) |
+                                                 (primary_public->publicArea.objectAttributes & (TPMA_OBJECT_FIXEDTPM|TPMA_OBJECT_FIXEDPARENT));
+
         } else {
                 if (seal_key_handle != 0)
                         log_debug("Using primary alg sealing, but seal key handle also provided; ignoring seal key handle.");