]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tpm2: allow tpm2_make_encryption_session() without bind key
authorDan Streetman <ddstreet@ieee.org>
Fri, 30 Jun 2023 16:57:23 +0000 (12:57 -0400)
committerDan Streetman <ddstreet@ieee.org>
Tue, 3 Oct 2023 16:56:55 +0000 (12:56 -0400)
Allow providing no bind key, and use ESYS_TR_NONE instead.

src/shared/tpm2-util.c

index ab7b58c34c27bcf85e0cf5fdc0e5fd353702ffc6..638e2e390f46b961470ad2f23f8e2a4fd5703208 100644 (file)
@@ -2854,6 +2854,7 @@ static int tpm2_make_encryption_session(
         int r;
 
         assert(c);
+        assert(primary);
         assert(ret_session);
 
         log_debug("Starting HMAC encryption session.");
@@ -2869,7 +2870,7 @@ static int tpm2_make_encryption_session(
         rc = sym_Esys_StartAuthSession(
                         c->esys_context,
                         primary->esys_handle,
-                        bind_key->esys_handle,
+                        bind_key ? bind_key->esys_handle : ESYS_TR_NONE,
                         ESYS_TR_NONE,
                         ESYS_TR_NONE,
                         ESYS_TR_NONE,
@@ -4021,7 +4022,7 @@ int tpm2_seal(Tpm2Context *c,
         }
 
         _cleanup_(tpm2_handle_freep) Tpm2Handle *encryption_session = NULL;
-        r = tpm2_make_encryption_session(c, primary_handle, &TPM2_HANDLE_NONE, &encryption_session);
+        r = tpm2_make_encryption_session(c, primary_handle, /* bind_key= */ NULL, &encryption_session);
         if (r < 0)
                 return r;