@@ -666,3 +666,47 @@ int test_tls12_bad_cv_sig_alg(void)
666666 return EXPECT_RESULT ();
667667}
668668
669+ /* Test that set_curves_list correctly resolves ECC curve names that fall
670+ * through the kNistCurves table and reach the wc_ecc_get_curve_idx_from_name
671+ * fallback path. The kNistCurves lookup uses a case-sensitive XSTRNCMP, so
672+ * uppercase names like "SECP384R1" do not match the lowercase "secp384r1"
673+ * entry; they fall through to the wolfCrypt ECC look-up which uses
674+ * XSTRCASECMP. */
675+ int test_tls_set_curves_list_ecc_fallback (void )
676+ {
677+ EXPECT_DECLS ;
678+ #if defined(WOLFSSL_TLS13 ) && defined(HAVE_ECC ) && \
679+ (defined(OPENSSL_EXTRA ) || defined(HAVE_CURL )) && \
680+ !defined(HAVE_FIPS ) && !defined(HAVE_SELFTEST ) && \
681+ (defined(HAVE_ECC384 ) || defined(HAVE_ALL_CURVES )) && \
682+ ECC_MIN_KEY_SZ <= 384
683+ #ifndef NO_WOLFSSL_CLIENT
684+ WOLFSSL_CTX * ctx = NULL ;
685+ WOLFSSL * ssl = NULL ;
686+
687+ /* "SECP384R1" (uppercase) is NOT in kNistCurves (case-sensitive table),
688+ * so set_curves_list must use the wc_ecc_get_curve_idx_from_name fallback.
689+ */
690+ ExpectNotNull (ctx = wolfSSL_CTX_new (wolfTLSv1_3_client_method ()));
691+
692+ /* CTX-level: set single curve via its wolfCrypt name (uppercase) */
693+ ExpectIntEQ (wolfSSL_CTX_set1_curves_list (ctx , "SECP384R1" ),
694+ WOLFSSL_SUCCESS );
695+
696+ /* Verify the correct curve was stored, not ecc_sets[0] */
697+ ExpectIntEQ (ctx -> numGroups , 1 );
698+ ExpectIntEQ (ctx -> group [0 ], WOLFSSL_ECC_SECP384R1 );
699+
700+ /* SSL-level: same check via wolfSSL_set1_curves_list */
701+ ExpectNotNull (ssl = wolfSSL_new (ctx ));
702+ ExpectIntEQ (wolfSSL_set1_curves_list (ssl , "SECP384R1" ), WOLFSSL_SUCCESS );
703+ ExpectIntEQ (ssl -> numGroups , 1 );
704+ ExpectIntEQ (ssl -> group [0 ], WOLFSSL_ECC_SECP384R1 );
705+
706+ wolfSSL_free (ssl );
707+ wolfSSL_CTX_free (ctx );
708+ #endif /* NO_WOLFSSL_CLIENT */
709+ #endif
710+ return EXPECT_RESULT ();
711+ }
712+
0 commit comments