Skip to content

Commit bf652e9

Browse files
committed
ECC: import point, always do some checks
Always check for infinity and, when B param available, whether the point is on the curve.
1 parent 6264c11 commit bf652e9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

wolfcrypt/src/ecc.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10922,6 +10922,22 @@ 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+
/* Only do quick checks. */
10932+
if ((err == MP_OKAY) && wc_ecc_point_is_at_infinity(&key->pubkey)) {
10933+
err = ECC_INF_E;
10934+
}
10935+
#ifdef USE_ECC_B_PARAM
10936+
if ((err == MP_OKAY) && (key->idx != ECC_CUSTOM_IDX)) {
10937+
err = wc_ecc_point_is_on_curve(&key->pubkey, key->idx);
10938+
}
10939+
#endif /* USE_ECC_B_PARAM */
10940+
#endif /* !WOLFSSL_VALIDATE_ECC_IMPORT || !HAVE_ECC_CHECK_PUBKEY_ORDER */
1092510941

1092610942
#ifdef WOLFSSL_MAXQ10XX_CRYPTO
1092710943
if (err == MP_OKAY) {

0 commit comments

Comments
 (0)