From 59ae436c75db3eebd45f508059d3a2ada2f6db65 Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Thu, 23 May 2024 11:49:37 -0600 Subject: [PATCH] Merge pull request #7570 from jackctj117/test Code Coverage for hpke.c test case HAVE_CURVE448 using test.c --- wolfcrypt/test/test.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 6272131886..a3f1a2020c 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -27626,10 +27626,24 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hpke_test(void) #endif #endif +/* Test coverage for wc_HpkeInit with Curve448, even though it is not supported */ +#if defined(HAVE_CURVE448) && \ + (defined(WOLFSSL_SHA384) || defined(WOLFSSL_SHA512)) + /* test with_curve448 */ + ret = wc_HpkeInit(hpke, DHKEM_X448_HKDF_SHA512, HKDF_SHA512, + HPKE_AES_256_GCM, NULL); + + if (ret != BAD_FUNC_ARG) /* Curve448 is not supported yet */ + ret = WC_TEST_RET_ENC_EC(ret); + else + ret = 0; +#endif + #if defined(HAVE_CURVE25519) /* test with curve25519 and aes256 */ - ret = wc_HpkeInit(hpke, DHKEM_X25519_HKDF_SHA256, HKDF_SHA256, - HPKE_AES_256_GCM, NULL); + if (ret == 0) + ret = wc_HpkeInit(hpke, DHKEM_X25519_HKDF_SHA256, HKDF_SHA256, + HPKE_AES_256_GCM, NULL); if (ret != 0) return WC_TEST_RET_ENC_EC(ret);