@@ -198,15 +198,6 @@ impl Config {
198198 None => true ,
199199 } )
200200 }
201-
202- /// Allowed key exchange groups for DTLS 1.2.
203- ///
204- /// Like [`kx_groups`](Self::kx_groups) but additionally restricted to
205- /// groups that DTLS 1.2 supports (currently P-256 and P-384).
206- pub fn dtls12_kx_groups ( & self ) -> impl Iterator < Item = & ' static dyn SupportedKxGroup > + ' _ {
207- self . kx_groups ( )
208- . filter ( |kx| matches ! ( kx. name( ) , NamedGroup :: Secp256r1 | NamedGroup :: Secp384r1 ) )
209- }
210201}
211202
212203/// Builder for [`Config`]. See each setter for defaults.
@@ -446,13 +437,13 @@ impl ConfigBuilder {
446437 } ;
447438 if dtls12_count > 0 {
448439 let dtls12_kx_count = crypto_provider
449- . supported_dtls12_kx_groups ( )
440+ . supported_kx_groups ( )
450441 . filter ( |kx| filtered_kx ( kx) )
451442 . count ( ) ;
452443 if dtls12_kx_count == 0 {
453444 return Err ( Error :: ConfigError (
454445 "DTLS 1.2 cipher suites are enabled but no compatible key exchange \
455- groups remain after filtering. DTLS 1.2 requires P-256 or P-384. "
446+ groups remain after filtering."
456447 . to_string ( ) ,
457448 ) ) ;
458449 }
@@ -635,23 +626,15 @@ mod tests {
635626 }
636627
637628 #[ test]
638- fn x25519_only_rejected_for_dtls12 ( ) {
639- // X25519 is not yet supported for DTLS 1.2, so filtering to X25519-only
640- // while DTLS 1.2 suites are enabled should fail.
641- match Config :: builder ( )
629+ fn x25519_only_accepted_for_dtls12 ( ) {
630+ // X25519 is supported for DTLS 1.2 and should be accepted.
631+ let config = Config :: builder ( )
642632 . dtls13_cipher_suites ( & [ ] )
643633 . kx_groups ( & [ NamedGroup :: X25519 ] )
644634 . build ( )
645- {
646- Err ( Error :: ConfigError ( msg) ) => {
647- assert ! (
648- msg. contains( "DTLS 1.2" ) && msg. contains( "P-256 or P-384" ) ,
649- "error should mention DTLS 1.2 and required groups: {msg}"
650- )
651- }
652- Err ( other) => panic ! ( "expected ConfigError, got: {other:?}" ) ,
653- Ok ( _) => panic ! ( "expected error for X25519-only with DTLS 1.2" ) ,
654- }
635+ . expect ( "X25519-only should be accepted for DTLS 1.2" ) ;
636+ let groups: Vec < _ > = config. kx_groups ( ) . map ( |g| g. name ( ) ) . collect ( ) ;
637+ assert_eq ! ( groups, & [ NamedGroup :: X25519 ] ) ;
655638 }
656639
657640 #[ test]
@@ -667,11 +650,15 @@ mod tests {
667650 }
668651
669652 #[ test]
670- fn dtls12_kx_groups_excludes_x25519 ( ) {
653+ fn kx_groups_match_provider_when_unfiltered ( ) {
671654 let config = Config :: default ( ) ;
672- let dtls12_groups: Vec < _ > = config. dtls12_kx_groups ( ) . map ( |g| g. name ( ) ) . collect ( ) ;
673- assert ! ( !dtls12_groups. contains( & NamedGroup :: X25519 ) ) ;
674- assert ! ( dtls12_groups. contains( & NamedGroup :: Secp256r1 ) ) ;
655+ let from_config: Vec < _ > = config. kx_groups ( ) . map ( |g| g. name ( ) ) . collect ( ) ;
656+ let from_provider: Vec < _ > = config
657+ . crypto_provider ( )
658+ . supported_kx_groups ( )
659+ . map ( |g| g. name ( ) )
660+ . collect ( ) ;
661+ assert_eq ! ( from_config, from_provider) ;
675662 }
676663
677664 #[ test]
0 commit comments