From 3d2f217c37716a78c8a84a0dc23b4506307d1c20 Mon Sep 17 00:00:00 2001 From: aidan garske Date: Tue, 7 Jul 2026 14:59:35 -0700 Subject: [PATCH] 6743 - Assert HMAC size before comparing against fixed KAT length --- tests/unit_tests.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit_tests.c b/tests/unit_tests.c index 5918c246..d7c96870 100644 --- a/tests/unit_tests.c +++ b/tests/unit_tests.c @@ -1883,7 +1883,8 @@ static void test_TPM2_CalcHmac(void) /* Pin the exact HMAC so the cpHash and sessionAttributes contributions * are verified, not just relative nonce ordering */ - AssertIntEQ(0, XMEMCMP(hmac1.buffer, hmacExp, hmac1.size)); + AssertIntEQ(hmac1.size, (int)sizeof(hmacExp)); + AssertIntEQ(0, XMEMCMP(hmac1.buffer, hmacExp, sizeof(hmacExp))); /* Compute HMAC with (nonceB, nonceA) — reversed order */ rc = TPM2_CalcHmac(TPM_ALG_SHA256, &auth, &hash, &nonceB, &nonceA,