Skip to content

Commit 212708e

Browse files
committed
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.
1 parent 510d6a0 commit 212708e

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

wolfcrypt/src/ecc.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,14 @@ enum {
856856
/* This holds the key settings.
857857
***MUST*** be organized by size from smallest to largest. */
858858

859+
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(6,0,0)
860+
#undef ecc_sets
861+
#undef ecc_sets_count
862+
#endif
863+
864+
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(6,0,0)
865+
static
866+
#endif
859867
const ecc_set_type ecc_sets[] = {
860868
#ifdef ECC112
861869
#ifndef NO_ECC_SECP
@@ -1399,8 +1407,17 @@ const ecc_set_type ecc_sets[] = {
13991407
}
14001408
};
14011409
#define ECC_SET_COUNT (sizeof(ecc_sets)/sizeof(ecc_set_type))
1410+
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(6,0,0)
1411+
static
1412+
#endif
14021413
const size_t ecc_sets_count = ECC_SET_COUNT - 1;
14031414

1415+
const ecc_set_type *wc_ecc_get_sets(void) {
1416+
return ecc_sets;
1417+
}
1418+
size_t wc_ecc_get_sets_count(void) {
1419+
return ecc_sets_count;
1420+
}
14041421

14051422
#ifdef HAVE_OID_ENCODING
14061423
/* encoded OID cache */

wolfcrypt/test/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34481,7 +34481,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ecc_test_buffers(void)
3448134481
} while (ret == WC_NO_ERR_TRACE(WC_PENDING_E));
3448234482
if (ret < 0)
3448334483
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
34484-
TEST_SLEEP();
34484+
TEST_SLEEP();
3448534485

3448634486
XMEMSET(plain, 0, sizeof(plain));
3448734487

wolfssl/wolfcrypt/ecc.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,15 @@ WOLFSSL_ABI WOLFSSL_API void wc_ecc_key_free(ecc_key* key);
641641

642642

643643
/* ECC predefined curve sets */
644-
extern const ecc_set_type ecc_sets[];
645-
extern const size_t ecc_sets_count;
644+
#if defined(HAVE_FIPS) && FIPS_VERSION3_LT(6,0,0)
645+
extern const ecc_set_type ecc_sets[];
646+
extern const size_t ecc_sets_count;
647+
#else
648+
WOLFSSL_API const ecc_set_type *wc_ecc_get_sets(void);
649+
WOLFSSL_API size_t wc_ecc_get_sets_count(void);
650+
#define ecc_sets wc_ecc_get_sets()
651+
#define ecc_sets_count wc_ecc_get_sets_count()
652+
#endif
646653

647654
WOLFSSL_API
648655
const char* wc_ecc_get_name(int curve_id);
@@ -763,7 +770,7 @@ WOLFSSL_API
763770
int wc_ecc_set_flags(ecc_key* key, word32 flags);
764771
WOLFSSL_ABI WOLFSSL_API
765772
void wc_ecc_fp_free(void);
766-
WOLFSSL_LOCAL
773+
WOLFSSL_API
767774
void wc_ecc_fp_init(void);
768775
WOLFSSL_API
769776
int wc_ecc_set_rng(ecc_key* key, WC_RNG* rng);

0 commit comments

Comments
 (0)