From 212708e3b4012c0a1f341f88ad5b061a56f55723 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Thu, 19 Sep 2024 17:03:07 -0500 Subject: [PATCH] wolfssl/wolfcrypt/ecc.h and wolfcrypt/src/ecc.c: refactor ecc_sets and ecc_sets_count using accessor functions, to fix linker relocation errors in Fedora packaging test. --- wolfcrypt/src/ecc.c | 17 +++++++++++++++++ wolfcrypt/test/test.c | 2 +- wolfssl/wolfcrypt/ecc.h | 13 ++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 3d439e1cf7..037f53ba90 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -856,6 +856,14 @@ enum { /* This holds the key settings. ***MUST*** be organized by size from smallest to largest. */ +#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(6,0,0) + #undef ecc_sets + #undef ecc_sets_count +#endif + +#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(6,0,0) +static +#endif const ecc_set_type ecc_sets[] = { #ifdef ECC112 #ifndef NO_ECC_SECP @@ -1399,8 +1407,17 @@ const ecc_set_type ecc_sets[] = { } }; #define ECC_SET_COUNT (sizeof(ecc_sets)/sizeof(ecc_set_type)) +#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(6,0,0) +static +#endif const size_t ecc_sets_count = ECC_SET_COUNT - 1; +const ecc_set_type *wc_ecc_get_sets(void) { + return ecc_sets; +} +size_t wc_ecc_get_sets_count(void) { + return ecc_sets_count; +} #ifdef HAVE_OID_ENCODING /* encoded OID cache */ diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index c618423fc0..c14d712e2a 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -34481,7 +34481,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ecc_test_buffers(void) } while (ret == WC_NO_ERR_TRACE(WC_PENDING_E)); if (ret < 0) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done); -TEST_SLEEP(); + TEST_SLEEP(); XMEMSET(plain, 0, sizeof(plain)); diff --git a/wolfssl/wolfcrypt/ecc.h b/wolfssl/wolfcrypt/ecc.h index e73c10b9bd..ba8c88b882 100644 --- a/wolfssl/wolfcrypt/ecc.h +++ b/wolfssl/wolfcrypt/ecc.h @@ -641,8 +641,15 @@ WOLFSSL_ABI WOLFSSL_API void wc_ecc_key_free(ecc_key* key); /* ECC predefined curve sets */ -extern const ecc_set_type ecc_sets[]; -extern const size_t ecc_sets_count; +#if defined(HAVE_FIPS) && FIPS_VERSION3_LT(6,0,0) + extern const ecc_set_type ecc_sets[]; + extern const size_t ecc_sets_count; +#else + WOLFSSL_API const ecc_set_type *wc_ecc_get_sets(void); + WOLFSSL_API size_t wc_ecc_get_sets_count(void); + #define ecc_sets wc_ecc_get_sets() + #define ecc_sets_count wc_ecc_get_sets_count() +#endif WOLFSSL_API const char* wc_ecc_get_name(int curve_id); @@ -763,7 +770,7 @@ WOLFSSL_API int wc_ecc_set_flags(ecc_key* key, word32 flags); WOLFSSL_ABI WOLFSSL_API void wc_ecc_fp_free(void); -WOLFSSL_LOCAL +WOLFSSL_API void wc_ecc_fp_init(void); WOLFSSL_API int wc_ecc_set_rng(ecc_key* key, WC_RNG* rng);