|
8 | 8 | from utils import invalid_test_parameters, get_parameter_name, to_bytes
|
9 | 9 | from global_flags import get_flag, S2N_PROVIDER_VERSION
|
10 | 10 |
|
| 11 | +PQ_ENABLED_FLAG = "PQ key exchange enabled" |
| 12 | + |
11 | 13 | CIPHERS = [
|
12 | 14 | None, # `None` will default to the appropriate `test_all` cipher preference in the S2N client provider
|
13 | 15 | Ciphers.KMS_PQ_TLS_1_0_2019_06,
|
|
31 | 33 | # The tuple keys have the form (client_{cipher, kem_group}, server_{cipher, kem_group})
|
32 | 34 | (Ciphers.KMS_PQ_TLS_1_0_2019_06, Ciphers.KMS_PQ_TLS_1_0_2019_06):
|
33 | 35 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
34 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 36 | + "kem": None, "kem_group": None}, |
35 | 37 | (Ciphers.KMS_PQ_TLS_1_0_2019_06, Ciphers.KMS_PQ_TLS_1_0_2020_02):
|
36 | 38 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
37 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 39 | + "kem": None, "kem_group": None}, |
38 | 40 | (Ciphers.KMS_PQ_TLS_1_0_2019_06, Ciphers.KMS_PQ_TLS_1_0_2020_07):
|
39 | 41 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
40 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 42 | + "kem": None, "kem_group": None}, |
41 | 43 |
|
42 | 44 | (Ciphers.KMS_PQ_TLS_1_0_2020_02, Ciphers.KMS_PQ_TLS_1_0_2019_06):
|
43 | 45 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
44 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 46 | + "kem": None, "kem_group": None}, |
45 | 47 | (Ciphers.KMS_PQ_TLS_1_0_2020_02, Ciphers.KMS_PQ_TLS_1_0_2020_02):
|
46 | 48 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
47 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 49 | + "kem": None, "kem_group": None}, |
48 | 50 | (Ciphers.KMS_PQ_TLS_1_0_2020_02, Ciphers.KMS_PQ_TLS_1_0_2020_07):
|
49 | 51 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
50 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 52 | + "kem": None, "kem_group": None}, |
51 | 53 |
|
52 | 54 | (Ciphers.KMS_PQ_TLS_1_0_2020_07, Ciphers.KMS_PQ_TLS_1_0_2019_06):
|
53 | 55 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
54 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 56 | + "kem": None, "kem_group": None}, |
55 | 57 | (Ciphers.KMS_PQ_TLS_1_0_2020_07, Ciphers.KMS_PQ_TLS_1_0_2020_02):
|
56 | 58 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
57 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 59 | + "kem": None, "kem_group": None}, |
58 | 60 | (Ciphers.KMS_PQ_TLS_1_0_2020_07, Ciphers.KMS_PQ_TLS_1_0_2020_07):
|
59 | 61 | {"cipher": "ECDHE-KYBER-RSA-AES256-GCM-SHA384",
|
60 |
| - "kem": "kyber512r3", "kem_group": "NONE"}, |
| 62 | + "kem": "kyber512r3", "kem_group": None}, |
61 | 63 |
|
62 | 64 | (Ciphers.PQ_SIKE_TEST_TLS_1_0_2019_11, Ciphers.KMS_PQ_TLS_1_0_2019_06):
|
63 | 65 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
64 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 66 | + "kem": None, "kem_group": None}, |
65 | 67 | (Ciphers.PQ_SIKE_TEST_TLS_1_0_2019_11, Ciphers.KMS_PQ_TLS_1_0_2020_02):
|
66 | 68 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
67 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 69 | + "kem": None, "kem_group": None}, |
68 | 70 | (Ciphers.PQ_SIKE_TEST_TLS_1_0_2019_11, Ciphers.KMS_PQ_TLS_1_0_2020_07):
|
69 | 71 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
70 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 72 | + "kem": None, "kem_group": None}, |
71 | 73 |
|
72 | 74 | (Ciphers.PQ_SIKE_TEST_TLS_1_0_2020_02, Ciphers.KMS_PQ_TLS_1_0_2019_06):
|
73 | 75 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
74 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 76 | + "kem": None, "kem_group": None}, |
75 | 77 | (Ciphers.PQ_SIKE_TEST_TLS_1_0_2020_02, Ciphers.KMS_PQ_TLS_1_0_2020_02):
|
76 | 78 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
77 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 79 | + "kem": None, "kem_group": None}, |
78 | 80 | (Ciphers.PQ_SIKE_TEST_TLS_1_0_2020_02, Ciphers.KMS_PQ_TLS_1_0_2020_07):
|
79 | 81 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
80 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 82 | + "kem": None, "kem_group": None}, |
81 | 83 |
|
82 | 84 | (Ciphers.KMS_PQ_TLS_1_0_2019_06, Ciphers.KMS_TLS_1_0_2018_10):
|
83 | 85 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
84 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 86 | + "kem": None, "kem_group": None}, |
85 | 87 | (Ciphers.KMS_PQ_TLS_1_0_2020_02, Ciphers.KMS_TLS_1_0_2018_10):
|
86 | 88 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
87 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 89 | + "kem": None, "kem_group": None}, |
88 | 90 | (Ciphers.KMS_PQ_TLS_1_0_2020_07, Ciphers.KMS_TLS_1_0_2018_10):
|
89 | 91 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
90 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 92 | + "kem": None, "kem_group": None}, |
91 | 93 |
|
92 | 94 | (Ciphers.KMS_TLS_1_0_2018_10, Ciphers.KMS_PQ_TLS_1_0_2019_06):
|
93 | 95 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
94 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 96 | + "kem": None, "kem_group": None}, |
95 | 97 | (Ciphers.KMS_TLS_1_0_2018_10, Ciphers.KMS_PQ_TLS_1_0_2020_02):
|
96 | 98 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
97 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 99 | + "kem": None, "kem_group": None}, |
98 | 100 | (Ciphers.KMS_TLS_1_0_2018_10, Ciphers.KMS_PQ_TLS_1_0_2020_07):
|
99 | 101 | {"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
|
100 |
| - "kem": "NONE", "kem_group": "NONE"}, |
| 102 | + "kem": None, "kem_group": None}, |
101 | 103 |
|
102 | 104 | # The expected kem_group string for this case purposefully excludes a curve;
|
103 | 105 | # depending on how s2n was compiled, the curve may be either x25519 or one
|
104 | 106 | # of the NIST curves.
|
105 | 107 | (Ciphers.PQ_TLS_1_0_2020_12, Ciphers.PQ_TLS_1_0_2020_12):
|
106 | 108 | {"cipher": "TLS_AES_256_GCM_SHA384",
|
107 |
| - "kem": "NONE", "kem_group": "_kyber-512-r3"}, |
| 109 | + "kem": None, "kem_group": "_kyber-512-r3"}, |
108 | 110 | (Ciphers.PQ_TLS_1_0_2020_12, Ciphers.PQ_TLS_1_0_2023_01):
|
109 | 111 | {"cipher": "TLS_AES_256_GCM_SHA384",
|
110 |
| - "kem": "NONE", "kem_group": "_kyber-512-r3"}, |
| 112 | + "kem": None, "kem_group": "_kyber-512-r3"}, |
111 | 113 | (Ciphers.PQ_TLS_1_0_2023_01, Ciphers.PQ_TLS_1_0_2023_01):
|
112 | 114 | {"cipher": "TLS_AES_256_GCM_SHA384",
|
113 |
| - "kem": "NONE", "kem_group": "_kyber-512-r3"}, |
| 115 | + "kem": None, "kem_group": "_kyber-512-r3"}, |
114 | 116 | (Ciphers.PQ_TLS_1_0_2023_01, Ciphers.PQ_TLS_1_0_2020_12):
|
115 | 117 | {"cipher": "TLS_AES_256_GCM_SHA384",
|
116 |
| - "kem": "NONE", "kem_group": "_kyber-512-r3"}, |
| 118 | + "kem": None, "kem_group": "_kyber-512-r3"}, |
117 | 119 | (Ciphers.PQ_TLS_1_0_2020_12, Ciphers.KMS_PQ_TLS_1_0_2020_07):
|
118 | 120 | {"cipher": "ECDHE-KYBER-RSA-AES256-GCM-SHA384",
|
119 |
| - "kem": "kyber512r3", "kem_group": "NONE"}, |
| 121 | + "kem": "kyber512r3", "kem_group": None}, |
120 | 122 | (Ciphers.KMS_PQ_TLS_1_0_2020_07, Ciphers.PQ_TLS_1_0_2020_12):
|
121 | 123 | {"cipher": "ECDHE-KYBER-RSA-AES256-GCM-SHA384",
|
122 |
| - "kem": "kyber512r3", "kem_group": "NONE"}, |
| 124 | + "kem": "kyber512r3", "kem_group": None}, |
123 | 125 | (Ciphers.PQ_TLS_1_0_2020_12, KemGroups.P256_KYBER512R3):
|
124 |
| - {"cipher": "AES256_GCM_SHA384", "kem": "NONE", |
| 126 | + {"cipher": "AES256_GCM_SHA384", "kem": None, |
125 | 127 | "kem_group": "secp256r1_kyber-512-r3"},
|
126 | 128 | (KemGroups.P256_KYBER512R3, Ciphers.PQ_TLS_1_0_2020_12):
|
127 |
| - {"cipher": "AES256_GCM_SHA384", "kem": "NONE", |
| 129 | + {"cipher": "AES256_GCM_SHA384", "kem": None, |
128 | 130 | "kem_group": "secp256r1_kyber-512-r3"},
|
129 | 131 | (KemGroups.P256_KYBER512R3, Ciphers.PQ_TLS_1_0_2023_01):
|
130 |
| - {"cipher": "AES256_GCM_SHA384", "kem": "NONE", |
| 132 | + {"cipher": "AES256_GCM_SHA384", "kem": None, |
131 | 133 | "kem_group": "secp256r1_kyber-512-r3"},
|
132 | 134 | (KemGroups.P256_KYBER512R3, Ciphers.PQ_TLS_1_3_2023_06_01):
|
133 |
| - {"cipher": "AES256_GCM_SHA384", "kem": "NONE", |
| 135 | + {"cipher": "AES256_GCM_SHA384", "kem": None, |
134 | 136 | "kem_group": "secp256r1_kyber-512-r3"},
|
135 | 137 | (KemGroups.P384_KYBER768R3, Ciphers.PQ_TLS_1_3_2023_06_01):
|
136 |
| - {"cipher": "AES256_GCM_SHA384", "kem": "NONE", |
| 138 | + {"cipher": "AES256_GCM_SHA384", "kem": None, |
137 | 139 | "kem_group": "secp384r1_kyber-768-r3"},
|
138 | 140 | (KemGroups.P521_KYBER1024R3, Ciphers.PQ_TLS_1_3_2023_06_01):
|
139 |
| - {"cipher": "AES256_GCM_SHA384", "kem": "NONE", |
| 141 | + {"cipher": "AES256_GCM_SHA384", "kem": None, |
140 | 142 | "kem_group": "secp521r1_kyber-1024-r3"},
|
141 | 143 | (Ciphers.PQ_TLS_1_3_2023_06_01, KemGroups.X25519Kyber768Draft00):
|
142 | 144 | {"cipher": "TLS_AES_256_GCM_SHA384",
|
143 |
| - "kem": "NONE", |
| 145 | + "kem": None, |
144 | 146 | "kem_group": "X25519Kyber768Draft00"},
|
145 | 147 | (Ciphers.PQ_TLS_1_3_2023_06_01, KemGroups.SecP256r1Kyber768Draft00):
|
146 | 148 | {"cipher": "TLS_AES_256_GCM_SHA384",
|
147 |
| - "kem": "NONE", |
| 149 | + "kem": None, |
148 | 150 | "kem_group": "SecP256r1Kyber768Draft00"},
|
149 | 151 | }
|
150 | 152 |
|
@@ -181,11 +183,18 @@ def assert_s2n_negotiation_parameters(s2n_results, expected_result):
|
181 | 183 | if expected_result is not None:
|
182 | 184 | assert to_bytes(
|
183 | 185 | ("Cipher negotiated: " + expected_result['cipher'])) in s2n_results.stdout
|
184 |
| - assert to_bytes( |
185 |
| - ("KEM: " + expected_result['kem'])) in s2n_results.stdout |
186 |
| - # Purposefully leave off the "KEM Group: " prefix in order to perform partial matches |
187 |
| - # without specifying the curve. |
188 |
| - assert to_bytes(expected_result['kem_group']) in s2n_results.stdout |
| 186 | + if expected_result['kem']: |
| 187 | + assert to_bytes( |
| 188 | + ("KEM: " + expected_result['kem'])) in s2n_results.stdout |
| 189 | + assert to_bytes(PQ_ENABLED_FLAG) in s2n_results.stdout |
| 190 | + if expected_result['kem_group']: |
| 191 | + # Purposefully leave off the "KEM Group: " prefix in order to perform partial matches |
| 192 | + # without specifying the curve. |
| 193 | + assert to_bytes(expected_result['kem_group']) in s2n_results.stdout |
| 194 | + assert to_bytes(PQ_ENABLED_FLAG) in s2n_results.stdout |
| 195 | + if not expected_result['kem'] and not expected_result['kem_group']: |
| 196 | + assert to_bytes(PQ_ENABLED_FLAG) not in s2n_results.stdout |
| 197 | + assert to_bytes("Curve:") in s2n_results.stdout |
189 | 198 |
|
190 | 199 |
|
191 | 200 | def assert_awslc_negotiation_parameters(awslc_results, expected_result):
|
@@ -256,7 +265,7 @@ def test_s2nc_to_s2nd_pq_handshake(managed_process, protocol, certificate, clien
|
256 | 265 | # If PQ is not enabled in s2n, we expect classic handshakes to be negotiated.
|
257 | 266 | # Leave the expected cipher blank, as there are multiple possibilities - the
|
258 | 267 | # important thing is that kem and kem_group are NONE.
|
259 |
| - expected_result = {"cipher": "", "kem": "NONE", "kem_group": "NONE"} |
| 268 | + expected_result = {"cipher": "", "kem": None, "kem_group": None} |
260 | 269 |
|
261 | 270 | # Client and server are both s2n; can make meaningful assertions about negotiation for both
|
262 | 271 | for results in client.get_results():
|
|
0 commit comments