Skip to content

Commit 544d02e

Browse files
authored
Merge branch 'main' into make-resource-tracker-reentrant-safe
2 parents 3331162 + fccf9ab commit 544d02e

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

Lib/test/test_ssl.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,6 +2782,14 @@ def try_protocol_combo(server_protocol, client_protocol, expect_success,
27822782
% (expect_success, stats['version']))
27832783

27842784

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+
27852793
class ThreadedTests(unittest.TestCase):
27862794

27872795
@support.requires_resource('walltime')
@@ -4042,8 +4050,13 @@ def test_no_legacy_server_connect(self):
40424050
sni_name=hostname)
40434051

40444052
def test_dh_params(self):
4045-
# Check we can get a connection with ephemeral Diffie-Hellman
4053+
# Check we can get a connection with ephemeral finite-field
4054+
# Diffie-Hellman (if supported).
40464055
client_context, server_context, hostname = testing_context()
4056+
dhe_aliases = {"ADH", "EDH", "DHE"}
4057+
if not (supports_kx_alias(client_context, dhe_aliases)
4058+
and supports_kx_alias(server_context, dhe_aliases)):
4059+
self.skipTest("libssl doesn't support ephemeral DH")
40474060
# test scenario needs TLS <= 1.2
40484061
client_context.maximum_version = ssl.TLSVersion.TLSv1_2
40494062
try:
@@ -4059,7 +4072,7 @@ def test_dh_params(self):
40594072
sni_name=hostname)
40604073
cipher = stats["cipher"][0]
40614074
parts = cipher.split("-")
4062-
if "ADH" not in parts and "EDH" not in parts and "DHE" not in parts:
4075+
if not dhe_aliases.intersection(parts):
40634076
self.fail("Non-DH key exchange: " + cipher[0])
40644077

40654078
def test_ecdh_curve(self):

Lib/test/test_tools/test_msgfmt.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for the Tools/i18n/msgfmt.py tool."""
22

33
import json
4+
import struct
45
import sys
56
import unittest
67
from gettext import GNUTranslations
@@ -40,6 +41,28 @@ def test_compilation(self):
4041

4142
self.assertDictEqual(actual._catalog, expected._catalog)
4243

44+
def test_binary_header(self):
45+
with open(data_dir / "general.mo", "rb") as f:
46+
mo_data = f.read()
47+
48+
(
49+
magic,
50+
version,
51+
num_strings,
52+
orig_table_offset,
53+
trans_table_offset,
54+
hash_table_size,
55+
hash_table_offset,
56+
) = struct.unpack("=Iiiiiii", mo_data[:28])
57+
58+
self.assertEqual(magic, 0x950412de)
59+
self.assertEqual(version, 0)
60+
self.assertEqual(num_strings, 9)
61+
self.assertEqual(orig_table_offset, 28)
62+
self.assertEqual(trans_table_offset, 100)
63+
self.assertEqual(hash_table_size, 0)
64+
self.assertEqual(hash_table_offset, 0)
65+
4366
def test_translations(self):
4467
with open(data_dir / 'general.mo', 'rb') as f:
4568
t = GNUTranslations(f)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``test_ssl.test_dh_params`` is skipped if the underlying TLS library does not support finite-field ephemeral Diffie-Hellman.

0 commit comments

Comments
 (0)