mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
Fix Cryptocell ECC tests
This commit is contained in:
@ -41,6 +41,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_CRYPTOCELL)
|
||||
/* see SASI_AES_KEY_MAX_SIZE_IN_BYTES in the nRF5 SDK */
|
||||
#define AES_MAX_KEY_SIZE 128
|
||||
#endif /* WOLFSSL_CRYPTOCELL*/
|
||||
|
||||
|
@ -4542,7 +4542,7 @@ int wc_ecc_make_key_ex2(WC_RNG* rng, int keysize, ecc_key* key, int curve_id,
|
||||
}
|
||||
#elif defined(WOLFSSL_CRYPTOCELL)
|
||||
|
||||
pDomain = CRYS_ECPKI_GetEcDomain(cc310_mapCurve(curve_id));
|
||||
pDomain = CRYS_ECPKI_GetEcDomain(cc310_mapCurve(key->dp->id));
|
||||
raw_size = (word32)(key->dp->size)*2 + 1;
|
||||
|
||||
/* generate first key pair */
|
||||
@ -7950,7 +7950,23 @@ int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key,
|
||||
#ifdef WOLFSSL_SILABS_SE_ACCEL
|
||||
err = silabs_ecc_import(key, keysize);
|
||||
#endif
|
||||
#ifdef WOLFSSL_CRYPTOCELL
|
||||
const CRYS_ECPKI_Domain_t* pDomain;
|
||||
CRYS_ECPKI_BUILD_TempData_t tempBuff;
|
||||
|
||||
pDomain = CRYS_ECPKI_GetEcDomain(cc310_mapCurve(key->dp->id));
|
||||
|
||||
/* create public key from external key buffer */
|
||||
err = CRYS_ECPKI_BuildPublKeyFullCheck(pDomain,
|
||||
(byte*)in-1, /* re-adjust */
|
||||
inLen+1, /* original input */
|
||||
&key->ctx.pubKey,
|
||||
&tempBuff);
|
||||
|
||||
if (err != SA_SILIB_RET_OK){
|
||||
WOLFSSL_MSG("CRYS_ECPKI_BuildPublKeyFullCheck failed");
|
||||
}
|
||||
#endif
|
||||
#ifdef WOLFSSL_VALIDATE_ECC_IMPORT
|
||||
if (err == MP_OKAY)
|
||||
err = wc_ecc_check_key(key);
|
||||
@ -8110,21 +8126,7 @@ int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
|
||||
return ret;
|
||||
|
||||
#ifdef WOLFSSL_CRYPTOCELL
|
||||
pDomain = CRYS_ECPKI_GetEcDomain(cc310_mapCurve(curve_id));
|
||||
|
||||
if (pub != NULL && pub[0] != '\0') {
|
||||
/* create public key from external key buffer */
|
||||
ret = CRYS_ECPKI_BuildPublKeyFullCheck(pDomain,
|
||||
(byte*)pub,
|
||||
pubSz,
|
||||
&key->ctx.pubKey,
|
||||
&tempBuff);
|
||||
|
||||
if (ret != SA_SILIB_RET_OK){
|
||||
WOLFSSL_MSG("CRYS_ECPKI_BuildPublKeyFullCheck failed");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
pDomain = CRYS_ECPKI_GetEcDomain(cc310_mapCurve(key->dp->id));
|
||||
/* import private key */
|
||||
if (priv != NULL && priv[0] != '\0') {
|
||||
|
||||
@ -8396,7 +8398,7 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
|
||||
}
|
||||
|
||||
if (err == MP_OKAY) {
|
||||
pDomain = CRYS_ECPKI_GetEcDomain(cc310_mapCurve(curve_id));
|
||||
pDomain = CRYS_ECPKI_GetEcDomain(cc310_mapCurve(key->dp->id));
|
||||
|
||||
/* create public key from external key buffer */
|
||||
err = CRYS_ECPKI_BuildPublKeyFullCheck(pDomain,
|
||||
|
@ -7700,7 +7700,8 @@ static int aes_key_size_test(void)
|
||||
if (ret != 0 || keySize != sizeof(key16))
|
||||
ERROR_OUT(-5310, out);
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_CRYPTOCELL)
|
||||
/* Cryptocell only supports AES-128 key size */
|
||||
ret = wc_AesSetKey(aes, key24, sizeof(key24), iv, AES_ENCRYPTION);
|
||||
#ifdef WOLFSSL_AES_192
|
||||
if (ret != 0)
|
||||
@ -7726,7 +7727,7 @@ static int aes_key_size_test(void)
|
||||
if (ret != 0 || keySize != sizeof(key32))
|
||||
ERROR_OUT(-5314, out);
|
||||
#endif
|
||||
|
||||
#endif /* !WOLFSSL_CRYPTOCELL */
|
||||
out:
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
@ -21367,7 +21368,9 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
#ifdef HAVE_ECC_SIGN
|
||||
/* ECC w/out Shamir has issue with all 0 digest */
|
||||
/* WC_BIGINT doesn't have 0 len well on hardware */
|
||||
#if defined(ECC_SHAMIR) && !defined(WOLFSSL_ASYNC_CRYPT)
|
||||
/* Cryptocell has issues with all 0 digest */
|
||||
#if defined(ECC_SHAMIR) && !defined(WOLFSSL_ASYNC_CRYPT) && \
|
||||
!defined(WOLFSSL_CRYPTOCELL)
|
||||
/* test DSA sign hash with zeros */
|
||||
for (i = 0; i < (int)ECC_DIGEST_SIZE; i++) {
|
||||
digest[i] = 0;
|
||||
@ -21404,7 +21407,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
TEST_SLEEP();
|
||||
}
|
||||
#endif /* HAVE_ECC_VERIFY */
|
||||
#endif /* ECC_SHAMIR && !WOLFSSL_ASYNC_CRYPT */
|
||||
#endif /* ECC_SHAMIR && !WOLFSSL_ASYNC_CRYPT && !WOLFSSL_CRYPTOCELL */
|
||||
|
||||
/* test DSA sign hash with sequence (0,1,2,3,4,...) */
|
||||
for (i = 0; i < (int)ECC_DIGEST_SIZE; i++) {
|
||||
|
Reference in New Issue
Block a user