From a1c38478f2f2c2287b891aaf31071e8c7f6460ce Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 31 Aug 2026 20:59:20 +0100 Subject: [PATCH] [test] Allow for HMAC tests with partial expected output digest values Some public HMAC test vectors provide expected output digest values that are shorter than the digest size. Allow HMAC tests to provide expected output digest values of any non-zero length up to and including the digest size, so that we can use these public test vectors without needing to synthesize the remainder of the output digest value. Signed-off-by: Michael Brown --- src/tests/hmac_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/hmac_test.c b/src/tests/hmac_test.c index bf66e95e0..c720e410c 100644 --- a/src/tests/hmac_test.c +++ b/src/tests/hmac_test.c @@ -108,7 +108,8 @@ static void hmac_okx ( struct hmac_test *test, const char *file, okx ( sizeof ( ctx ) == ( digest->ctxsize + digest->blocksize ), file, line ); okx ( sizeof ( key ) == digest->blocksize, file, line ); - okx ( test->expected_len == digest->digestsize, file, line ); + okx ( test->expected_len > 0, file, line ); + okx ( test->expected_len <= digest->digestsize, file, line ); /* Calculate HMAC */ DBGC ( test, "HMAC-%s key:\n", digest->name );