From fe5cc9589b70f3ae1189f4aefe42596f1329028d Mon Sep 17 00:00:00 2001 From: aidan garske Date: Wed, 22 May 2024 12:46:05 -0700 Subject: [PATCH] Add HPKE Curve448 test case, however HPKE does not support 448 yet, so expect bad function argument return code. --- wolfcrypt/test/test.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 78bf1cdc40..6272131886 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -27471,7 +27471,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t x963kdf_test(void) #endif /* HAVE_X963_KDF */ -#if defined(HAVE_HPKE) && (defined(HAVE_ECC) || defined(HAVE_CURVE25519)) && \ +#if defined(HAVE_HPKE) && \ + (defined(HAVE_ECC) || defined(HAVE_CURVE25519) || defined(HAVE_CURVE448)) && \ defined(HAVE_AESGCM) static wc_test_ret_t hpke_test_single(Hpke* hpke) @@ -27639,8 +27640,28 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hpke_test(void) return ret; #endif + +#if defined(HAVE_CURVE448) && \ + (defined(WOLFSSL_SHA384) || defined(WOLFSSL_SHA512)) + /* test with curve448 and aes256 */ + ret = wc_HpkeInit(hpke, DHKEM_X448_HKDF_SHA512, HKDF_SHA512, + HPKE_AES_256_GCM, NULL); + + /* HPKE does not support X448 yet, so expect failure */ + if (ret != BAD_FUNC_ARG) + return WC_TEST_RET_ENC_EC(ret); + + ret = hpke_test_single(hpke); + + /* HPKE does not support X448 yet, so expect failure */ + if (WC_TEST_RET_DEC_EC(ret) != BAD_FUNC_ARG) + return ret; + ret = 0; /* reset error code */ +#endif + + /* TODO: HPKE chacha20 is not implemented */ + return ret; -/* x448 and chacha20 are unimplemented */ } #endif /* HAVE_HPKE && HAVE_ECC && HAVE_AESGCM */