Skip to content

Commit 995f320

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 995f320

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

wolfcrypt/src/ecc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10922,6 +10922,18 @@ 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+
/* Only do quick checks. */
10928+
if ((err == MP_OKAY) && wc_ecc_point_is_at_infinity(&key->pubkey)) {
10929+
err = ECC_INF_E;
10930+
}
10931+
#ifdef USE_ECC_B_PARAM
10932+
if (err == MP_OKAY) {
10933+
err = wc_ecc_point_is_on_curve(&key->pubkey, key->idx);
10934+
}
10935+
#endif /* USE_ECC_B_PARAM */
10936+
#endif /* !WOLFSSL_VALIDATE_ECC_IMPORT || !HAVE_ECC_CHECK_PUBKEY_ORDER */
1092510937

1092610938
#ifdef WOLFSSL_MAXQ10XX_CRYPTO
1092710939
if (err == MP_OKAY) {

0 commit comments

Comments
 (0)