From dfaca474ed05c6e1539f468dc3280760a021bb01 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Fri, 10 Jul 2026 09:41:24 +0200 Subject: [PATCH] tests/ecc: fix link failures in shared/non-public-mp builds test_wc_EccDecisionCoverage2 broke the unit.test link in several CI configs (net-snmp, C#/Rust wrappers, make check/analyze, etc.): - The wc_ecc_check_r_s_range block calls mp_init/mp_read_radix/mp_copy/ mp_clear, which resolve to sp_* under WOLFSSL_SP_MATH_ALL and are only exported with WOLFSSL_PUBLIC_MP. Add defined(WOLFSSL_PUBLIC_MP) to its guard (matching the other mp_*-using blocks in this file). - wc_ecc_export_point_der_compressed is WOLFSSL_LOCAL (hidden in a shared library) so it is not linkable from the shared-library unit test. Drop the four direct calls; its decision coverage is driven by the ecc white-box (which includes ecc.c). The public compressed path wc_ecc_export_x963_ex(...,1) is retained. Verified: --enable-net-snmp and --enable-all (+WOLFSSL_PUBLIC_MP) both build and link; unit.test passes. --- tests/api/test_ecc.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/tests/api/test_ecc.c b/tests/api/test_ecc.c index 1d33857c3f..275b5c58c7 100644 --- a/tests/api/test_ecc.c +++ b/tests/api/test_ecc.c @@ -2352,7 +2352,8 @@ int test_wc_EccDecisionCoverage2(void) #endif ExpectIntEQ(ret, 0); -#if defined(HAVE_ECC_VERIFY) && !defined(WOLFSSL_SP_MATH) +#if defined(HAVE_ECC_VERIFY) && !defined(WOLFSSL_SP_MATH) && \ + defined(WOLFSSL_PUBLIC_MP) /* ---- wc_ecc_check_r_s_range (via wc_ecc_verify_hash_ex): GAPS.md * 8939, 8942 ---- * if ((err == 0) && (mp_cmp(r, curve->order) != MP_LT)) -> r >= order @@ -2428,22 +2429,13 @@ int test_wc_EccDecisionCoverage2(void) #ifdef HAVE_COMP_KEY { - byte cder[DER_SZ(KEY32)]; - word32 cderSz = sizeof(cder); - word32 cLenOnly = 0; - - ExpectIntEQ(wc_ecc_export_point_der_compressed(key.idx, - &key.pubkey, NULL, &cLenOnly), WC_NO_ERR_TRACE(LENGTH_ONLY_E)); - ExpectIntGT(cLenOnly, 0); - ExpectIntEQ(wc_ecc_export_point_der_compressed(key.idx, - &key.pubkey, cder, &cderSz), 0); - ExpectIntEQ(wc_ecc_export_point_der_compressed(key.idx, NULL, - NULL, NULL), WC_NO_ERR_TRACE(ECC_BAD_ARG_E)); - ExpectIntEQ(wc_ecc_export_point_der_compressed(-1, &key.pubkey, - cder, &cderSz), WC_NO_ERR_TRACE(ECC_BAD_ARG_E)); - - /* wc_ecc_export_x963_ex(..., compressed=1): GAPS.md 16058 - * (the static wc_ecc_export_x963_compressed helper). */ + /* wc_ecc_export_point_der_compressed is WOLFSSL_LOCAL (hidden in a + * shared library), so it is not linkable from the shared-library + * unit test; its own decision coverage is driven by the campaign's + * ecc white-box (which includes ecc.c directly). The public + * compressed export path wc_ecc_export_x963_ex(..., 1) is exercised + * here (GAPS.md 16058, the static wc_ecc_export_x963_compressed + * helper). */ #ifdef HAVE_ECC_KEY_EXPORT { byte x963c[ECC_BUFSIZE];