@@ -4037,16 +4037,15 @@ def test_dh_params(self):
40374037 # Check we can get a connection with ephemeral finite-field Diffie-
40384038 # Hellman (if supported).
40394039 client_context , server_context , hostname = testing_context ()
4040- dhe_aliases = [ "ADH" , "EDH" , "DHE" ]
4041- def supports_dhe (ctx , aliases ) -> bool :
4040+ dhe_aliases = { "ADH" , "EDH" , "DHE" }
4041+ def supports_dhe (ctx ) -> bool :
40424042 for cipher in ctx .get_ciphers ():
4043- for alias in aliases :
4044- if alias in cipher :
4043+ for alias in dhe_aliases :
4044+ if f"Kx= { alias } " in cipher [ 'description' ] :
40454045 return True
40464046 return False
4047- if not (supports_dhe (client_context , dhe_aliases ) and
4048- supports_dhe (server_context , dhe_aliases )):
4049- self .skipTest ("libssl doesn't support (finite-field) DHE" )
4047+ if not (supports_dhe (client_context ) and supports_dhe (server_context )):
4048+ self .skipTest ("libssl doesn't support ephemeral DH" )
40504049 # test scenario needs TLS <= 1.2
40514050 client_context .maximum_version = ssl .TLSVersion .TLSv1_2
40524051 server_context .load_dh_params (DHFILE )
@@ -4056,8 +4055,8 @@ def supports_dhe(ctx, aliases) -> bool:
40564055 chatty = True , connectionchatty = True ,
40574056 sni_name = hostname )
40584057 cipher = stats ["cipher" ][0 ]
4059- parts = cipher .split ("-" )
4060- if all ( a not in parts for a in aliases ):
4058+ parts = set ( cipher .split ("-" ) )
4059+ if not dhe_aliases . intersection ( parts ):
40614060 self .fail ("Non-DH key exchange: " + cipher [0 ])
40624061
40634062 def test_ecdh_curve (self ):
0 commit comments