Skip to content

Commit 55bc029

Browse files
committed
tests/hmac: guard HmacSizeByType whole-function under FIPS/self-test
The frozen FIPS/self-test hmac's wc_HmacSizeByType returns HMAC_KAT_FIPS_E (-206) for any type it doesn't accept - not just the invalid 9999 case but also MD5 (not a FIPS HMAC type), which returned -206 instead of the digest size. Rather than chase each type, exclude the whole function under HAVE_SELFTEST/HAVE_FIPS (the campaign measures MC/DC on open builds only).
1 parent f133453 commit 55bc029

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

tests/api/test_hmac.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,11 @@ int test_tls_hmac_size_overflow(void)
794794
int test_wc_HmacSizeByType(void)
795795
{
796796
EXPECT_DECLS;
797-
#ifndef NO_HMAC
797+
/* The FIPS/self-test hmac's wc_HmacSizeByType returns HMAC_KAT_FIPS_E for any
798+
* type it doesn't accept (e.g. MD5 is not a FIPS HMAC type), and BAD_FUNC_ARG
799+
* differs too, so the size/invalid-type assertions here only hold on the open
800+
* builds the campaign actually measures. Exclude the frozen modules whole. */
801+
#if !defined(NO_HMAC) && !defined(HAVE_SELFTEST) && !defined(HAVE_FIPS)
798802
#ifndef NO_MD5
799803
ExpectIntEQ(wc_HmacSizeByType(WC_MD5), WC_MD5_DIGEST_SIZE);
800804
#endif
@@ -838,7 +842,7 @@ int test_wc_HmacSizeByType(void)
838842
#endif
839843
/* Invalid type: every operand false. */
840844
ExpectIntEQ(wc_HmacSizeByType(9999), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
841-
#endif /* !NO_HMAC */
845+
#endif /* !NO_HMAC && !HAVE_SELFTEST && !HAVE_FIPS */
842846
return EXPECT_RESULT();
843847
} /* END test_wc_HmacSizeByType */
844848

0 commit comments

Comments
 (0)