@@ -257,12 +257,12 @@ ECC Curve Sizes:
257257
258258
259259/* macro guard for ecc_check_pubkey_order functionality */
260- #if !defined(WOLFSSL_SP_MATH ) && \
261- !defined(WOLFSSL_ATECC508A) && !defined(WOLFSSL_ATECC608A ) && \
262- !defined(WOLFSSL_CRYPTOCELL ) && !defined(WOLFSSL_SILABS_SE_ACCEL ) && \
263- !defined(WOLFSSL_SE050 ) && !defined(WOLFSSL_STM32_PKA ) && \
264- ( !defined(WOLF_CRYPTO_CB_ONLY_ECC) || defined(WOLFSSL_IMXRT1170_CAAM ) || \
265- defined(WOLFSSL_QNX_CAAM) )
260+ #if ( !defined(NO_ECC_CHECK_PUBKEY_ORDER ) && \
261+ !defined(WOLF_CRYPTO_CB_ONLY_ECC ) && \
262+ !defined(WOLFSSL_ATECC508A ) && !defined(WOLFSSL_ATECC608A ) && \
263+ !defined(WOLFSSL_CRYPTOCELL ) && !defined(WOLFSSL_SILABS_SE_ACCEL ) && \
264+ !defined(WOLFSSL_SE050) && ! defined(WOLFSSL_STM32_PKA) ) || \
265+ defined(WOLFSSL_IMXRT1170_CAAM) || defined(WOLFSSL_QNX_CAAM)
266266
267267 /* CAAM builds use public key validation as a means to check if an
268268 * imported private key is an encrypted black key or not */
@@ -1441,7 +1441,7 @@ size_t wc_ecc_get_sets_count(void) {
14411441#if defined(HAVE_COMP_KEY) && defined(HAVE_ECC_KEY_EXPORT)
14421442static int wc_ecc_export_x963_compressed(ecc_key* key, byte* out, word32* outLen);
14431443#endif
1444- #ifdef HAVE_ECC_CHECK_PUBKEY_ORDER
1444+ #if defined( HAVE_ECC_CHECK_PUBKEY_ORDER) && !defined(WOLFSSL_SP_MATH)
14451445static int ecc_check_pubkey_order(ecc_key* key, ecc_point* pubkey, mp_int* a,
14461446 mp_int* prime, mp_int* order);
14471447#endif
@@ -9944,11 +9944,7 @@ int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen,
99449944#endif /* HAVE_ECC_KEY_EXPORT */
99459945
99469946
9947- #if !defined(WOLFSSL_ATECC508A) && !defined(WOLFSSL_ATECC608A) && \
9948- !defined(WOLFSSL_CRYPTOCELL) && !defined(WOLFSSL_SE050) && \
9949- !defined(WOLFSSL_STM32_PKA) && \
9950- (!defined(WOLF_CRYPTO_CB_ONLY_ECC) || defined(WOLFSSL_QNX_CAAM) || \
9951- defined(WOLFSSL_IMXRT1170_CAAM))
9947+ #ifdef HAVE_ECC_CHECK_PUBKEY_ORDER
99529948
99539949/* is ecc point on curve described by dp ? */
99549950static int _ecc_is_point(ecc_point* ecp, mp_int* a, mp_int* b, mp_int* prime)
@@ -10385,9 +10381,10 @@ static int _ecc_pairwise_consistency_test(ecc_key* key, WC_RNG* rng)
1038510381
1038610382 return err;
1038710383}
10388- #endif /* (FIPS v5 or later || WOLFSSL_VALIDATE_ECC_KEYGEN) &&!WOLFSSL_KCAPI_ECC */
10384+ #endif /* (FIPS v5 or later || WOLFSSL_VALIDATE_ECC_KEYGEN) && \
10385+ !WOLFSSL_KCAPI_ECC */
1038910386
10390- #ifdef HAVE_ECC_CHECK_PUBKEY_ORDER
10387+ #ifndef WOLFSSL_SP_MATH
1039110388/* validate order * pubkey = point at infinity, 0 on success */
1039210389static int ecc_check_pubkey_order(ecc_key* key, ecc_point* pubkey, mp_int* a,
1039310390 mp_int* prime, mp_int* order)
@@ -10460,12 +10457,8 @@ static int ecc_check_pubkey_order(ecc_key* key, ecc_point* pubkey, mp_int* a,
1046010457 return err;
1046110458}
1046210459#endif /* !WOLFSSL_SP_MATH */
10460+ #endif /* HAVE_ECC_CHECK_PUBKEY_ORDER */
1046310461
10464- #endif /* !WOLFSSL_ATECC508A && !WOLFSSL_ATECC608A &&
10465- !WOLFSSL_CRYPTOCELL && !WOLFSSL_SE050 && !WOLFSSL_STM32_PKA &&
10466- (!WOLF_CRYPTO_CB_ONLY_ECC || WOLFSSL_QNX_CAAM ||
10467- WOLFSSL_IMXRT1170_CAAM)
10468- */
1046910462
1047010463#ifdef OPENSSL_EXTRA
1047110464int wc_ecc_get_generator(ecc_point* ecp, int curve_idx)
@@ -10493,7 +10486,7 @@ int wc_ecc_get_generator(ecc_point* ecp, int curve_idx)
1049310486
1049410487 return err;
1049510488}
10496- #endif /* OPENSSLALL */
10489+ #endif /* OPENSSL_EXTRA */
1049710490
1049810491
1049910492/* Validate the public key per SP 800-56Ar3 section 5.6.2.3.3,
@@ -10505,7 +10498,7 @@ int wc_ecc_get_generator(ecc_point* ecp, int curve_idx)
1050510498static int _ecc_validate_public_key(ecc_key* key, int partial, int priv)
1050610499{
1050710500 int err = MP_OKAY;
10508- #ifdef HAVE_ECC_CHECK_PUBKEY_ORDER
10501+ #if defined( HAVE_ECC_CHECK_PUBKEY_ORDER) && !defined(WOLFSSL_SP_MATH)
1050910502 mp_int* b = NULL;
1051010503 #ifdef USE_ECC_B_PARAM
1051110504 DECLARE_CURVE_SPECS(4);
@@ -10515,13 +10508,23 @@ static int _ecc_validate_public_key(ecc_key* key, int partial, int priv)
1051510508 #endif
1051610509 DECLARE_CURVE_SPECS(3);
1051710510 #endif /* USE_ECC_B_PARAM */
10518- #endif /* HAVE_ECC_CHECK_PUBKEY_ORDER */
10511+ #endif
1051910512
1052010513 ASSERT_SAVED_VECTOR_REGISTERS();
1052110514
1052210515 if (key == NULL)
1052310516 return BAD_FUNC_ARG;
1052410517
10518+ #ifndef HAVE_ECC_CHECK_PUBKEY_ORDER
10519+ /* consider key check success on HW crypto
10520+ * ex: ATECC508/608A, CryptoCell and Silabs
10521+ *
10522+ * consider key check success on most Crypt Cb only builds
10523+ */
10524+ err = MP_OKAY;
10525+
10526+ #else
10527+
1052510528#ifdef WOLFSSL_HAVE_SP_ECC
1052610529#ifndef WOLFSSL_SP_NO_256
1052710530 if (key->idx != ECC_CUSTOM_IDX && ecc_sets[key->idx].id == ECC_SECP256R1) {
@@ -10556,15 +10559,6 @@ static int _ecc_validate_public_key(ecc_key* key, int partial, int priv)
1055610559#endif
1055710560
1055810561#ifndef WOLFSSL_SP_MATH
10559- #ifndef HAVE_ECC_CHECK_PUBKEY_ORDER
10560- /* consider key check success on HW crypto
10561- * ex: ATECC508/608A, CryptoCell and Silabs
10562- *
10563- * consider key check success on most Crypt Cb only builds
10564- */
10565- err = MP_OKAY;
10566-
10567- #else
1056810562 #ifdef USE_ECC_B_PARAM
1056910563 ALLOC_CURVE_SPECS(4, err);
1057010564 #else
@@ -10688,11 +10682,13 @@ static int _ecc_validate_public_key(ecc_key* key, int partial, int priv)
1068810682#endif
1068910683
1069010684 FREE_CURVE_SPECS();
10691- #endif /* HAVE_ECC_CHECK_PUBKEY_ORDER */
1069210685
1069310686#else
10687+ /* The single precision math curve is not available */
1069410688 err = WC_KEY_SIZE_E;
1069510689#endif /* !WOLFSSL_SP_MATH */
10690+ #endif /* HAVE_ECC_CHECK_PUBKEY_ORDER */
10691+
1069610692 (void)partial;
1069710693 (void)priv;
1069810694 return err;
0 commit comments