SiLabs: Fix tests and wc_ecc_import_private_key

pull/3497/head
Elms 2020-12-08 12:22:35 -08:00
parent 919c2a2dfb
commit 620fe2da14
2 changed files with 10 additions and 4 deletions

View File

@ -6231,7 +6231,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
word32 msgLenInBytes = hashlen; word32 msgLenInBytes = hashlen;
CRYS_ECPKI_HASH_OpMode_t hash_mode; CRYS_ECPKI_HASH_OpMode_t hash_mode;
#elif defined(WOLFSSL_SILABS_SE_ACCEL) #elif defined(WOLFSSL_SILABS_SE_ACCEL)
byte sigRS[ECC_MAX_CRYPTO_HW_SIZE * 2]; byte sigRS[ECC_MAX_CRYPTO_HW_SIZE * 4];
#elif !defined(WOLFSSL_SP_MATH) || defined(FREESCALE_LTC_ECC) #elif !defined(WOLFSSL_SP_MATH) || defined(FREESCALE_LTC_ECC)
int did_init = 0; int did_init = 0;
ecc_point *mG = NULL, *mQ = NULL; ecc_point *mG = NULL, *mQ = NULL;
@ -7975,8 +7975,13 @@ int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
} }
#elif defined(WOLFSSL_SILABS_SE_ACCEL) #elif defined(WOLFSSL_SILABS_SE_ACCEL)
if (ret == MP_OKAY) { if (ret == MP_OKAY) {
if (pub) {
ret = silabs_ecc_import(key, privSz);
} else
{
ret = silabs_ecc_import_private(key, privSz); ret = silabs_ecc_import_private(key, privSz);
} }
}
#else #else
ret = mp_read_unsigned_bin(&key->k, priv, privSz); ret = mp_read_unsigned_bin(&key->k, priv, privSz);

View File

@ -22337,19 +22337,20 @@ static int ecc_test_buffers(void)
TEST_SLEEP(); TEST_SLEEP();
XMEMSET(plain, 0, sizeof(plain)); XMEMSET(plain, 0, sizeof(plain));
verify = 1;
do { do {
#if defined(WOLFSSL_ASYNC_CRYPT) #if defined(WOLFSSL_ASYNC_CRYPT)
ret = wc_AsyncWait(ret, cliKey.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN); ret = wc_AsyncWait(ret, cliKey.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
#endif #endif
if (ret == 0) if (ret == 0)
ret = wc_ecc_verify_hash(out, x, plain, sizeof(plain), &verify, ret = wc_ecc_verify_hash(out, x, plain, inLen, &verify,
cliKey); cliKey);
} while (ret == WC_PENDING_E); } while (ret == WC_PENDING_E);
if (ret < 0) if (ret < 0)
ERROR_OUT(-10430, done); ERROR_OUT(-10430, done);
if (XMEMCMP(plain, in, (word32)ret)) if (verify != 0)
ERROR_OUT(-10431, done); ERROR_OUT(-10431, done);
TEST_SLEEP(); TEST_SLEEP();