@@ -54685,6 +54685,7 @@ static wc_test_ret_t ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerif
5468554685 WC_DECLARE_VAR(sharedA, byte, ECC_SHARED_SIZE, HEAP_HINT);
5468654686 WC_DECLARE_VAR(sharedB, byte, ECC_SHARED_SIZE, HEAP_HINT);
5468754687 word32 y;
54688+ int doEcdh = 1;
5468854689#endif
5468954690#ifndef WC_NO_RNG
5469054691#ifdef HAVE_ECC_KEY_EXPORT
@@ -54854,7 +54855,27 @@ static wc_test_ret_t ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerif
5485454855 if (ret != 0)
5485554856 ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
5485654857#endif
54858+ #if FIPS_VERSION3_GE(7,0,0) && defined(WC_HAVE_FIPS_INDICATOR) && \
54859+ !defined(FIPS_NO_WRAPPERS)
54860+ /* v7 refuses ECDH outside P-256, P-384 and P-521: expect the refusal and
54861+ * skip only the shared secret steps for this curve. */
54862+ if (userA->dp != NULL &&
54863+ userA->dp->id != ECC_SECP256R1 &&
54864+ userA->dp->id != ECC_SECP384R1 &&
54865+ userA->dp->id != ECC_SECP521R1) {
54866+ x = ECC_SHARED_SIZE;
54867+ PRIVATE_KEY_UNLOCK();
54868+ ret = wc_ecc_shared_secret(userA, userB, sharedA, &x);
54869+ PRIVATE_KEY_LOCK();
54870+ if (ret != WC_NO_ERR_TRACE(ECC_CURVE_OID_E))
54871+ ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
54872+ ret = 0;
54873+ doEcdh = 0;
54874+ }
54875+ #endif
5485754876
54877+ if (doEcdh)
54878+ {
5485854879 x = ECC_SHARED_SIZE;
5485954880 PRIVATE_KEY_UNLOCK();
5486054881 do {
@@ -54932,6 +54953,7 @@ static wc_test_ret_t ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerif
5493254953 wc_ecc_set_flags(userA, 0);
5493354954 wc_ecc_set_flags(userB, 0);
5493454955#endif /* HAVE_ECC_CDH */
54956+ }
5493554957#endif /* HAVE_ECC_DHE */
5493654958#endif /* !WOLFSSL_ATECC508A && WOLFSSL_ATECC608A */
5493754959
@@ -54962,6 +54984,8 @@ static wc_test_ret_t ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerif
5496254984#if !defined(WOLFSSL_ATECC508A) && !defined(WOLFSSL_ATECC608A) && \
5496354985 !defined(WOLFSSL_MICROCHIP_TA100)
5496454986#ifdef HAVE_ECC_DHE
54987+ if (doEcdh)
54988+ {
5496554989 y = ECC_SHARED_SIZE;
5496654990 PRIVATE_KEY_UNLOCK();
5496754991 do {
@@ -54978,6 +55002,7 @@ static wc_test_ret_t ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerif
5497855002 if (XMEMCMP(sharedA, sharedB, y))
5497955003 ERROR_OUT(WC_TEST_RET_ENC_NC, done);
5498055004 TEST_SLEEP();
55005+ }
5498155006#endif /* HAVE_ECC_DHE */
5498255007
5498355008 #ifdef HAVE_COMP_KEY
@@ -55015,6 +55040,8 @@ static wc_test_ret_t ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerif
5501555040 ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
5501655041
5501755042 #ifdef HAVE_ECC_DHE
55043+ if (doEcdh)
55044+ {
5501855045 y = ECC_SHARED_SIZE;
5501955046 PRIVATE_KEY_UNLOCK();
5502055047 do {
@@ -55031,6 +55058,7 @@ static wc_test_ret_t ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerif
5503155058 if (XMEMCMP(sharedA, sharedB, y))
5503255059 ERROR_OUT(WC_TEST_RET_ENC_NC, done);
5503355060 TEST_SLEEP();
55061+ }
5503455062 #endif /* HAVE_ECC_DHE */
5503555063 }
5503655064 #endif /* HAVE_COMP_KEY */
0 commit comments