From 66e049a96b49cfa9b2be4d4c1fc39be6bdf68867 Mon Sep 17 00:00:00 2001
From: Dan Streetman <ddstreet@ieee.org>
Date: Thu, 8 Jun 2023 14:06:46 -0400
Subject: [PATCH] tpm2: replace magic number in hmac_sensitive initialization

Instead of setting hmac_sensitive.sensitive.data.size to '32' use the actual
hash size as set in the hmac_template.

(cherry picked from commit 180444b8851a8654771361b1494b5db286d8724e)

Related: RHEL-16182
---
 src/shared/tpm2-util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c
index 12a6036b1d..f7940bcf2e 100644
--- a/src/shared/tpm2-util.c
+++ b/src/shared/tpm2-util.c
@@ -2964,7 +2964,7 @@ int tpm2_seal(const char *device,
 
         TPM2B_SENSITIVE_CREATE hmac_sensitive = {
                 .size = sizeof(hmac_sensitive.sensitive),
-                .sensitive.data.size = 32,
+                .sensitive.data.size = hmac_template.publicArea.unique.keyedHash.size,
         };
 
         CLEANUP_ERASE(hmac_sensitive);