@@ -2782,6 +2782,14 @@ def try_protocol_combo(server_protocol, client_protocol, expect_success,
2782
2782
% (expect_success , stats ['version' ]))
2783
2783
2784
2784
2785
+ def supports_kx_alias (ctx , aliases ):
2786
+ for cipher in ctx .get_ciphers ():
2787
+ for alias in aliases :
2788
+ if f"Kx={ alias } " in cipher ['description' ]:
2789
+ return True
2790
+ return False
2791
+
2792
+
2785
2793
class ThreadedTests (unittest .TestCase ):
2786
2794
2787
2795
@support .requires_resource ('walltime' )
@@ -3970,8 +3978,13 @@ def test_no_legacy_server_connect(self):
3970
3978
sni_name = hostname )
3971
3979
3972
3980
def test_dh_params (self ):
3973
- # Check we can get a connection with ephemeral Diffie-Hellman
3981
+ # Check we can get a connection with ephemeral finite-field
3982
+ # Diffie-Hellman (if supported).
3974
3983
client_context , server_context , hostname = testing_context ()
3984
+ dhe_aliases = {"ADH" , "EDH" , "DHE" }
3985
+ if not (supports_kx_alias (client_context , dhe_aliases )
3986
+ and supports_kx_alias (server_context , dhe_aliases )):
3987
+ self .skipTest ("libssl doesn't support ephemeral DH" )
3975
3988
# test scenario needs TLS <= 1.2
3976
3989
client_context .maximum_version = ssl .TLSVersion .TLSv1_2
3977
3990
try :
@@ -3987,7 +4000,7 @@ def test_dh_params(self):
3987
4000
sni_name = hostname )
3988
4001
cipher = stats ["cipher" ][0 ]
3989
4002
parts = cipher .split ("-" )
3990
- if "ADH" not in parts and "EDH" not in parts and "DHE" not in parts :
4003
+ if not dhe_aliases . intersection ( parts ) :
3991
4004
self .fail ("Non-DH key exchange: " + cipher [0 ])
3992
4005
3993
4006
def test_ecdh_curve (self ):
0 commit comments