Skip to content

Commit

Permalink
wolfssl/wolfcrypt/ecc.h and wolfcrypt/src/ecc.c: refactor ecc_sets an…
Browse files Browse the repository at this point in the history
…d ecc_sets_count using accessor functions, to fix linker relocation errors in Fedora packaging test.
  • Loading branch information
douzzer committed Sep 19, 2024
1 parent 510d6a0 commit 212708e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
17 changes: 17 additions & 0 deletions wolfcrypt/src/ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion wolfcrypt/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
13 changes: 10 additions & 3 deletions wolfssl/wolfcrypt/ecc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 212708e

Please sign in to comment.