From edef75c70f628752d1a0d3ded2b498b244f35200 Mon Sep 17 00:00:00 2001 From: Tesfa Mael Date: Wed, 24 Apr 2019 10:02:20 -0700 Subject: [PATCH] Wrapped new unit test API with FIPS macros --- tests/api.c | 13 +++++++++---- wolfcrypt/src/ecc.c | 7 +++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/api.c b/tests/api.c index 6753a45fb..0567febcc 100644 --- a/tests/api.c +++ b/tests/api.c @@ -22701,10 +22701,12 @@ static void test_wc_ecc_get_curve_id_from_name(void) #endif /* HAVE_ECC */ } -#if defined(OPENSSL_EXTRA) +#if defined(OPENSSL_EXTRA) && defined(HAVE_ECC) && \ + !defined(HAVE_SELFTEST) && \ + !(defined(HAVE_FIPS) || defined(HAVE_FIPS_VERSION)) + static void test_wc_ecc_get_curve_id_from_dp_params(void) { -#ifdef HAVE_ECC int id; int curve_id; int ret = 0; @@ -22739,9 +22741,8 @@ static void test_wc_ecc_get_curve_id_from_dp_params(void) AssertIntEQ(id, BAD_FUNC_ARG); printf(resultFmt, passed); -#endif /* HAVE_ECC */ } -#endif /* OPENSSL_EXTRA */ +#endif /* defined(OPENSSL_EXTRA) && defined(HAVE_ECC) */ static void test_wc_ecc_get_curve_id_from_params(void) { @@ -24689,6 +24690,10 @@ void ApiTest(void) test_wolfSSL_EVP_get_cipherbynid(); test_wolfSSL_EC(); test_wolfSSL_ECDSA_SIG(); +#endif +#if defined(OPENSSL_EXTRA) && defined(HAVE_ECC) && \ + !defined(HAVE_SELFTEST) && \ + !(defined(HAVE_FIPS) || defined(HAVE_FIPS_VERSION)) test_wc_ecc_get_curve_id_from_dp_params(); #endif diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 623f78ba1..faaf85759 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -3296,6 +3296,13 @@ int wc_ecc_get_curve_id_from_params(int fieldSize, return ecc_sets[idx].id; } +/* Returns the curve id in ecc_sets[] that corresponds + * to a given domain parameters pointer. + * + * dp domain parameters pointer + * + * return curve id, from ecc_sets[] on success, negative on error + */ int wc_ecc_get_curve_id_from_dp_params(const ecc_set_type* dp) { int idx;