Fix for wc_ecc_import_raw_private using 0 for key size. Add check in silabs_ecc.

This commit is contained in:
David Garske
2023-06-23 14:10:47 -07:00
parent cde4e8e13d
commit 48dc288b83
2 changed files with 3 additions and 3 deletions

View File

@@ -10865,7 +10865,7 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
#endif
#if defined(WOLFSSL_ATECC508A) || defined(WOLFSSL_ATECC608A) || \
defined(WOLFSSL_SILABS_SE_ACCEL) || defined(WOLFSSL_CRYPTOCELL)
defined(WOLFSSL_CRYPTOCELL)
word32 keySz = 0;
#endif
@@ -11116,7 +11116,7 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
}
#elif defined(WOLFSSL_SILABS_SE_ACCEL)
if (err == MP_OKAY) {
err = silabs_ecc_import(key, keySz, 1, (d != NULL));
err = silabs_ecc_import(key, key->dp->size, 1, (d != NULL));
}
#endif

View File

@@ -206,7 +206,7 @@ int silabs_ecc_import(ecc_key* key, word32 keysize, int pub, int priv)
word32 used;
key->key.type = silabs_map_key_type(key->dp->id);
if (key->key.type == SILABS_UNSUPPORTED_KEY_TYPE)
if (key->key.type == SILABS_UNSUPPORTED_KEY_TYPE || keysize == 0)
return WC_HW_E;
key->key.size = keysize;