@@ -3186,3 +3186,47 @@ int test_tls13_cert_req_sigalgs(void)
31863186 return EXPECT_RESULT ();
31873187}
31883188
3189+ /* Test that set_curves_list correctly resolves ECC curve names that fall
3190+ * through the kNistCurves table and reach the wc_ecc_get_curve_idx_from_name
3191+ * fallback path. The kNistCurves lookup uses a case-sensitive XSTRNCMP, so
3192+ * uppercase names like "SECP384R1" do not match the lowercase "secp384r1"
3193+ * entry; they fall through to the wolfCrypt ECC look-up which uses
3194+ * XSTRCASECMP. */
3195+ int test_set_curves_list_ecc_fallback (void )
3196+ {
3197+ EXPECT_DECLS ;
3198+ #if defined(WOLFSSL_TLS13 ) && defined(HAVE_ECC ) && \
3199+ (defined(OPENSSL_EXTRA ) || defined(HAVE_CURL )) && \
3200+ !defined(HAVE_FIPS ) && !defined(HAVE_SELFTEST ) && \
3201+ (defined(HAVE_ECC384 ) || defined(HAVE_ALL_CURVES )) && \
3202+ ECC_MIN_KEY_SZ <= 384
3203+ #ifndef NO_WOLFSSL_CLIENT
3204+ WOLFSSL_CTX * ctx = NULL ;
3205+ WOLFSSL * ssl = NULL ;
3206+
3207+ /* "SECP384R1" (uppercase) is NOT in kNistCurves (case-sensitive table),
3208+ * so set_curves_list must use the wc_ecc_get_curve_idx_from_name fallback.
3209+ */
3210+ ExpectNotNull (ctx = wolfSSL_CTX_new (wolfTLSv1_3_client_method ()));
3211+
3212+ /* CTX-level: set single curve via its wolfCrypt name (uppercase) */
3213+ ExpectIntEQ (wolfSSL_CTX_set1_curves_list (ctx , "SECP384R1" ),
3214+ WOLFSSL_SUCCESS );
3215+
3216+ /* Verify the correct curve was stored, not ecc_sets[0] */
3217+ ExpectIntEQ (ctx -> numGroups , 1 );
3218+ ExpectIntEQ (ctx -> group [0 ], WOLFSSL_ECC_SECP384R1 );
3219+
3220+ /* SSL-level: same check via wolfSSL_set1_curves_list */
3221+ ExpectNotNull (ssl = wolfSSL_new (ctx ));
3222+ ExpectIntEQ (wolfSSL_set1_curves_list (ssl , "SECP384R1" ), WOLFSSL_SUCCESS );
3223+ ExpectIntEQ (ssl -> numGroups , 1 );
3224+ ExpectIntEQ (ssl -> group [0 ], WOLFSSL_ECC_SECP384R1 );
3225+
3226+ wolfSSL_free (ssl );
3227+ wolfSSL_CTX_free (ctx );
3228+ #endif /* NO_WOLFSSL_CLIENT */
3229+ #endif
3230+ return EXPECT_RESULT ();
3231+ }
3232+
0 commit comments