Merge pull request #4238 from dgarske/xc32

Fixes for building with Microchip XC32 and ATECC
This commit is contained in:
Sean Parkinson
2021-07-28 09:33:01 +10:00
committed by GitHub
5 changed files with 40 additions and 42 deletions

View File

@@ -39042,7 +39042,7 @@ static void test_wolfSSL_EVP_get_digestbynid(void)
} }
static void test_wolfSSL_EVP_PKEY_get0_EC_KEY(void) static void test_wolfSSL_EVP_PKEY_get0_EC_KEY(void)
{ {
#if defined(OPENSSL_ALL) #if defined(HAVE_ECC) && defined(OPENSSL_ALL)
WOLFSSL_EVP_PKEY* pkey; WOLFSSL_EVP_PKEY* pkey;
@@ -40626,7 +40626,7 @@ static void test_wolfSSL_RSA_padding_add_PKCS1_PSS(void)
static void test_wolfSSL_RSA_sign_sha3(void) static void test_wolfSSL_RSA_sign_sha3(void)
{ {
#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_256) #if !defined(NO_RSA) && defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_256)
#if defined(OPENSSL_ALL) && defined(WC_RSA_PSS) && !defined(WC_NO_RNG) #if defined(OPENSSL_ALL) && defined(WC_RSA_PSS) && !defined(WC_NO_RNG)
RSA *rsa; RSA *rsa;
const unsigned char *derBuf = client_key_der_2048; const unsigned char *derBuf = client_key_der_2048;
@@ -40649,7 +40649,7 @@ static void test_wolfSSL_RSA_sign_sha3(void)
printf(resultFmt, passed); printf(resultFmt, passed);
#endif /* OPENSSL_ALL && WC_RSA_PSS && !WC_NO_RNG*/ #endif /* OPENSSL_ALL && WC_RSA_PSS && !WC_NO_RNG*/
#endif /* WOLFSSL_NOSHA3_256*/ #endif /* !NO_RSA && WOLFSSL_SHA3 && !WOLFSSL_NOSHA3_256*/
} }
static void test_wolfSSL_EC_get_builtin_curves(void) static void test_wolfSSL_EC_get_builtin_curves(void)
@@ -44273,7 +44273,7 @@ static void test_wolfSSL_RSA_print(void)
AssertIntEQ(RSA_print(bio, rsa, 0), SSL_SUCCESS); AssertIntEQ(RSA_print(bio, rsa, 0), SSL_SUCCESS);
BIO_free(bio); BIO_free(bio);
wolfSSL_RSA_free(rsa); RSA_free(rsa);
printf(resultFmt, passed); printf(resultFmt, passed);
#endif #endif
} }

View File

@@ -8186,20 +8186,21 @@ int wc_ecc_get_generator(ecc_point* ecp, int curve_idx)
/* perform sanity checks on ecc key validity, 0 on success */ /* perform sanity checks on ecc key validity, 0 on success */
int wc_ecc_check_key(ecc_key* key) int wc_ecc_check_key(ecc_key* key)
{ {
#ifndef WOLFSSL_SP_MATH
int err = MP_OKAY; int err = MP_OKAY;
#ifndef WOLFSSL_SP_MATH
#if !defined(WOLFSSL_ATECC508A) && !defined(WOLFSSL_ATECC608A) && \ #if !defined(WOLFSSL_ATECC508A) && !defined(WOLFSSL_ATECC608A) && \
!defined(WOLFSSL_CRYPTOCELL) !defined(WOLFSSL_CRYPTOCELL) && !defined(WOLFSSL_SILABS_SE_ACCEL)
mp_int* b = NULL; mp_int* b = NULL;
#ifdef USE_ECC_B_PARAM #ifdef USE_ECC_B_PARAM
DECLARE_CURVE_SPECS(curve, 4); DECLARE_CURVE_SPECS(curve, 4);
#else #else
#ifndef WOLFSSL_SMALL_STACK #ifndef WOLFSSL_SMALL_STACK
mp_int b_lcl; mp_int b_lcl;
#endif #endif
DECLARE_CURVE_SPECS(curve, 3); DECLARE_CURVE_SPECS(curve, 3);
#endif /* USE_ECC_B_PARAM */ #endif /* USE_ECC_B_PARAM */
#endif /* WOLFSSL_ATECC508A */ #endif /* !WOLFSSL_ATECC508A && !WOLFSSL_ATECC608A &&
!WOLFSSL_CRYPTOCELL && !WOLFSSL_SILABS_SE_ACCEL */
#endif /* !WOLFSSL_SP_MATH */ #endif /* !WOLFSSL_SP_MATH */
if (key == NULL) if (key == NULL)
@@ -8230,8 +8231,9 @@ int wc_ecc_check_key(ecc_key* key)
#if defined(WOLFSSL_ATECC508A) || defined(WOLFSSL_ATECC608A) || \ #if defined(WOLFSSL_ATECC508A) || defined(WOLFSSL_ATECC608A) || \
defined(WOLFSSL_CRYPTOCELL) || defined(WOLFSSL_SILABS_SE_ACCEL) defined(WOLFSSL_CRYPTOCELL) || defined(WOLFSSL_SILABS_SE_ACCEL)
err = 0; /* consider key check success on ATECC508/608A and CryptoCell */ /* consider key check success on HW crypto
(void)err; * ex: ATECC508/608A, CryptoCell and Silabs */
err = MP_OKAY;
#else #else
#ifdef USE_ECC_B_PARAM #ifdef USE_ECC_B_PARAM
@@ -8340,10 +8342,10 @@ int wc_ecc_check_key(ecc_key* key)
FREE_CURVE_SPECS(); FREE_CURVE_SPECS();
#endif /* WOLFSSL_ATECC508A */ #endif /* WOLFSSL_ATECC508A */
return err;
#else #else
return WC_KEY_SIZE_E; err = WC_KEY_SIZE_E;
#endif /* !WOLFSSL_SP_MATH */ #endif /* !WOLFSSL_SP_MATH */
return err;
} }
#ifdef HAVE_ECC_KEY_IMPORT #ifdef HAVE_ECC_KEY_IMPORT
@@ -8959,9 +8961,8 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
byte key_raw[ECC_MAX_CRYPTO_HW_SIZE*2 + 1]; byte key_raw[ECC_MAX_CRYPTO_HW_SIZE*2 + 1];
#endif #endif
#if (defined(WOLFSSL_CRYPTOCELL) && !defined(WOLFSSL_ATECC508A) && \ #if defined(WOLFSSL_ATECC508A) || defined(WOLFSSL_ATECC608A) || \
!defined(WOLFSSL_ATECC608A)) || \ defined(WOLFSSL_SILABS_SE_ACCEL) || defined(WOLFSSL_CRYPTOCELL)
defined(WOLFSSL_SILABS_SE_ACCEL)
word32 keySz = 0; word32 keySz = 0;
#endif #endif

View File

@@ -191,7 +191,7 @@ int wolfCrypt_ATECC_SetConfig(ATCAIfaceCfg* cfg)
cfg_ateccx08a_i2c_pi.iface_type = cfg->iface_type; cfg_ateccx08a_i2c_pi.iface_type = cfg->iface_type;
cfg_ateccx08a_i2c_pi.devtype = cfg->devtype; cfg_ateccx08a_i2c_pi.devtype = cfg->devtype;
#ifdef ATCA_ENABLE_DEPRECATED #ifdef ATCA_ENABLE_DEPRECATED
cfg_ateccx08a_i2c_pi.atcai2c.slave_address = cfg->atcai2c.slave_address; cfg_ateccx08a_i2c_pi.atcai2c.slave_address = cfg->atcai2c.slave_address;
#else #else
cfg_ateccx08a_i2c_pi.atcai2c.address = cfg->atcai2c.address; cfg_ateccx08a_i2c_pi.atcai2c.address = cfg->atcai2c.address;
#endif #endif
@@ -525,11 +525,11 @@ int atmel_init(void)
XMEMSET(&cfg_ateccx08a_i2c_pi, 0, sizeof(cfg_ateccx08a_i2c_pi)); XMEMSET(&cfg_ateccx08a_i2c_pi, 0, sizeof(cfg_ateccx08a_i2c_pi));
cfg_ateccx08a_i2c_pi.iface_type = ATCA_I2C_IFACE; cfg_ateccx08a_i2c_pi.iface_type = ATCA_I2C_IFACE;
cfg_ateccx08a_i2c_pi.devtype = ATECC_DEV_TYPE; cfg_ateccx08a_i2c_pi.devtype = ATECC_DEV_TYPE;
#ifdef ATCA_ENABLE_DEPRECATED #ifdef ATCA_ENABLE_DEPRECATED
cfg_ateccx08a_i2c_pi.atcai2c.slave_address = ATECC_I2C_ADDR; cfg_ateccx08a_i2c_pi.atcai2c.slave_address = ATECC_I2C_ADDR;
#else #else
cfg_ateccx08a_i2c_pi.atcai2c.address = ATECC_I2C_ADDR; cfg_ateccx08a_i2c_pi.atcai2c.address = ATECC_I2C_ADDR;
#endif #endif
cfg_ateccx08a_i2c_pi.atcai2c.bus = ATECC_I2C_BUS; cfg_ateccx08a_i2c_pi.atcai2c.bus = ATECC_I2C_BUS;
cfg_ateccx08a_i2c_pi.atcai2c.baud = 400000; cfg_ateccx08a_i2c_pi.atcai2c.baud = 400000;
cfg_ateccx08a_i2c_pi.wake_delay = 1500; cfg_ateccx08a_i2c_pi.wake_delay = 1500;

View File

@@ -506,8 +506,6 @@ extern const size_t ecc_sets_count;
WOLFSSL_API WOLFSSL_API
const char* wc_ecc_get_name(int curve_id); const char* wc_ecc_get_name(int curve_id);
#if !defined(WOLFSSL_ATECC508A) && !defined(WOLFSSL_ATECC608A)
#ifdef WOLFSSL_PUBLIC_ECC_ADD_DBL #ifdef WOLFSSL_PUBLIC_ECC_ADD_DBL
#define ECC_API WOLFSSL_API #define ECC_API WOLFSSL_API
#else #else
@@ -532,8 +530,6 @@ WOLFSSL_LOCAL
int ecc_projective_dbl_point_safe(ecc_point* P, ecc_point* R, mp_int* a, int ecc_projective_dbl_point_safe(ecc_point* P, ecc_point* R, mp_int* a,
mp_int* modulus, mp_digit mp); mp_int* modulus, mp_digit mp);
#endif
WOLFSSL_API WOLFSSL_API
int wc_ecc_make_key(WC_RNG* rng, int keysize, ecc_key* key); int wc_ecc_make_key(WC_RNG* rng, int keysize, ecc_key* key);
WOLFSSL_ABI WOLFSSL_API WOLFSSL_ABI WOLFSSL_API

View File

@@ -289,22 +289,23 @@ decouple library dependencies with standard string, memory and so on.
#define THREAD_LS_T #define THREAD_LS_T
#endif #endif
/* GCC 7 has new switch() fall-through detection */
/* default to FALL_THROUGH stub */
#ifndef FALL_THROUGH #ifndef FALL_THROUGH
#define FALL_THROUGH /* GCC 7 has new switch() fall-through detection */
#if defined(__GNUC__)
#if defined(__GNUC__) #if ((__GNUC__ > 7) || ((__GNUC__ == 7) && (__GNUC_MINOR__ >= 1)))
#if ((__GNUC__ > 7) || ((__GNUC__ == 7) && (__GNUC_MINOR__ >= 1))) #if defined(WOLFSSL_LINUXKM) && defined(fallthrough)
#undef FALL_THROUGH #define FALL_THROUGH fallthrough
#if defined(WOLFSSL_LINUXKM) && defined(fallthrough) #else
#define FALL_THROUGH fallthrough #define FALL_THROUGH ; __attribute__ ((fallthrough))
#else #endif
#define FALL_THROUGH ; __attribute__ ((fallthrough))
#endif #endif
#endif #endif
#endif
#endif /* FALL_THROUGH */ #endif /* FALL_THROUGH */
#if !defined(FALL_THROUGH) || defined(__XC32)
/* use stub for fall through by default or for Microchip compiler */
#undef FALL_THROUGH
#define FALL_THROUGH
#endif
/* Micrium will use Visual Studio for compilation but not the Win32 API */ /* Micrium will use Visual Studio for compilation but not the Win32 API */
#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) && \ #if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) && \