Fixes for building with ATECC508A. Allow ECC check key to pass if slot numb is valid.

This commit is contained in:
David Garske
2017-07-10 11:07:24 -07:00
parent b6854d620f
commit 58c05123da
2 changed files with 22 additions and 5 deletions

View File

@ -4707,8 +4707,11 @@ int wc_ecc_check_key(ecc_key* key)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
#ifdef WOLFSSL_ATECC508A #ifdef WOLFSSL_ATECC508A
/* TODO: Implement equiv call to ATECC508A */
err = BAD_COND_E; if (key->slot == ATECC_INVALID_SLOT)
return ECC_BAD_ARG_E;
err = 0; /* consider key check success on ECC508A */
#else #else
@ -5014,13 +5017,25 @@ static int wc_ecc_export_raw(ecc_key* key, byte* qx, word32* qxLen,
*dLen = numLen; *dLen = numLen;
XMEMSET(d, 0, *dLen); XMEMSET(d, 0, *dLen);
#ifdef WOLFSSL_ATECC508A
/* TODO: Implement equiv call to ATECC508A */
return BAD_COND_E;
#else
/* private key, d */ /* private key, d */
err = mp_to_unsigned_bin(&key->k, d + err = mp_to_unsigned_bin(&key->k, d +
(numLen - mp_unsigned_bin_size(&key->k))); (numLen - mp_unsigned_bin_size(&key->k)));
if (err != MP_OKAY) if (err != MP_OKAY)
return err; return err;
#endif /* WOLFSSL_ATECC508A */
} }
#ifdef WOLFSSL_ATECC508A
/* TODO: Implement equiv call to ATECC508A */
return BAD_COND_E;
#else
/* public x component */ /* public x component */
err = mp_to_unsigned_bin(key->pubkey.x, qx + err = mp_to_unsigned_bin(key->pubkey.x, qx +
(numLen - mp_unsigned_bin_size(key->pubkey.x))); (numLen - mp_unsigned_bin_size(key->pubkey.x)));
@ -5034,6 +5049,7 @@ static int wc_ecc_export_raw(ecc_key* key, byte* qx, word32* qxLen,
return err; return err;
return 0; return 0;
#endif /* WOLFSSL_ATECC508A */
} }

View File

@ -1088,6 +1088,7 @@ int asn_test()
return -1302; return -1302;
} }
if (now == 0) { if (now == 0) {
printf("RTC/Time not set!\n");
return -1303; return -1303;
} }
#endif #endif
@ -10664,6 +10665,7 @@ done:
} }
#endif /* HAVE_ECC_KEY_IMPORT && HAVE_ECC_KEY_EXPORT */ #endif /* HAVE_ECC_KEY_IMPORT && HAVE_ECC_KEY_EXPORT */
#ifndef WOLFSSL_ATECC508A
#ifdef HAVE_ECC_KEY_IMPORT #ifdef HAVE_ECC_KEY_IMPORT
static int ecc_mulmod_test(ecc_key* key1) static int ecc_mulmod_test(ecc_key* key1)
{ {
@ -10705,7 +10707,6 @@ done:
} }
#endif #endif
#ifndef WOLFSSL_ATECC508A
static int ecc_ssh_test(ecc_key* key) static int ecc_ssh_test(ecc_key* key)
{ {
int ret; int ret;
@ -10757,16 +10758,16 @@ static int ecc_def_curve_test(WC_RNG *rng)
if (ret < 0) if (ret < 0)
goto done; goto done;
#endif #endif
#ifndef WOLFSSL_ATECC508A
#ifdef HAVE_ECC_KEY_IMPORT #ifdef HAVE_ECC_KEY_IMPORT
ret = ecc_mulmod_test(&key); ret = ecc_mulmod_test(&key);
if (ret < 0) if (ret < 0)
goto done; goto done;
#endif #endif
#ifndef WOLFSSL_ATECC508A
ret = ecc_ssh_test(&key); ret = ecc_ssh_test(&key);
if (ret < 0) if (ret < 0)
goto done; goto done;
#endif #endif /* WOLFSSL_ATECC508A */
done: done:
wc_ecc_free(&key); wc_ecc_free(&key);
return ret; return ret;