@@ -10636,8 +10636,8 @@ int wc_ecc_check_key(ecc_key* key)
1063610636
1063710637#ifdef HAVE_ECC_KEY_IMPORT
1063810638/* import public ECC key in ANSI X9.63 format */
10639- int wc_ecc_import_x963_ex (const byte* in, word32 inLen, ecc_key* key,
10640- int curve_id)
10639+ int wc_ecc_import_x963_ex2 (const byte* in, word32 inLen, ecc_key* key,
10640+ int curve_id, int untrusted )
1064110641{
1064210642 int err = MP_OKAY;
1064310643#ifdef HAVE_COMP_KEY
@@ -10922,6 +10922,25 @@ int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key,
1092210922 if (err == MP_OKAY)
1092310923 err = wc_ecc_check_key(key);
1092410924#endif
10925+ #if (!defined(WOLFSSL_VALIDATE_ECC_IMPORT) || \
10926+ !defined(HAVE_ECC_CHECK_PUBKEY_ORDER)) && \
10927+ !defined(WOLFSSL_ATECC508A) && !defined(WOLFSSL_ATECC608A) && \
10928+ !defined(WOLFSSL_CRYPTOCELL) && \
10929+ (!defined(WOLF_CRYPTO_CB_ONLY_ECC) || defined(WOLFSSL_QNX_CAAM) || \
10930+ defined(WOLFSSL_IMXRT1170_CAAM))
10931+ if (untrusted) {
10932+ /* Only do quick checks. */
10933+ if ((err == MP_OKAY) && wc_ecc_point_is_at_infinity(&key->pubkey)) {
10934+ err = ECC_INF_E;
10935+ }
10936+ #ifdef USE_ECC_B_PARAM
10937+ if ((err == MP_OKAY) && (key->idx != ECC_CUSTOM_IDX)) {
10938+ err = wc_ecc_point_is_on_curve(&key->pubkey, key->idx);
10939+ }
10940+ #endif /* USE_ECC_B_PARAM */
10941+ }
10942+ #endif
10943+ (void)untrusted;
1092510944
1092610945#ifdef WOLFSSL_MAXQ10XX_CRYPTO
1092710946 if (err == MP_OKAY) {
@@ -10941,6 +10960,13 @@ int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key,
1094110960 return err;
1094210961}
1094310962
10963+ /* import public ECC key in ANSI X9.63 format */
10964+ int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key,
10965+ int curve_id)
10966+ {
10967+ return wc_ecc_import_x963_ex2(in, inLen, key, curve_id, 0);
10968+ }
10969+
1094410970WOLFSSL_ABI
1094510971int wc_ecc_import_x963(const byte* in, word32 inLen, ecc_key* key)
1094610972{
0 commit comments