Debian Codegraph @

crt/s2n/tests/unit/s2n_server_renegotiation_info_test.c

raw symbols SCIP
1 /*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0
9 *
10 * or in the "license" file accompanying this file. This file is distributed
11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 * express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16 #include "tls/extensions/s2n_server_renegotiation_info.h"
17
18 #include <stdint.h>
19
20 #include "s2n_test.h"
21 #include "stuffer/s2n_stuffer.h"
22 #include "testlib/s2n_testlib.h"
23 #include "tls/s2n_config.h"
24 #include "tls/s2n_connection.h"
25 #include "tls/s2n_tls.h"
26 #include "tls/s2n_tls13.h"
27 #include "utils/s2n_safety.h"
28
29 S2N_RESULT s2n_server_renegotiation_info_extension_write(struct s2n_stuffer *out,
30 const uint8_t *client_verify_data, const uint8_t *server_verify_data, uint8_t verify_data_len)
31 {
32 RESULT_GUARD_POSIX(s2n_stuffer_growable_alloc(out, verify_data_len * 3));
33
34 struct s2n_stuffer_reservation len = { 0 };
35 RESULT_GUARD_POSIX(s2n_stuffer_reserve_uint8(out, &len));
36 RESULT_GUARD_POSIX(s2n_stuffer_write_bytes(out, client_verify_data, verify_data_len));
37 RESULT_GUARD_POSIX(s2n_stuffer_write_bytes(out, server_verify_data, verify_data_len));
38 RESULT_GUARD_POSIX(s2n_stuffer_write_vector_size(&len));
39 return S2N_RESULT_OK;
40 }
41
42 int main(int argc, char **argv)
43 {
44 BEGIN_TEST();
45 EXPECT_SUCCESS(s2n_disable_tls13_in_test());
46
47 DEFER_CLEANUP(struct s2n_cert_chain_and_key *chain_and_key = NULL, s2n_cert_chain_and_key_ptr_free);
48 EXPECT_SUCCESS(s2n_test_cert_chain_and_key_new(&chain_and_key,
49 S2N_DEFAULT_TEST_CERT_CHAIN, S2N_DEFAULT_TEST_PRIVATE_KEY));
50
51 DEFER_CLEANUP(struct s2n_config *config = s2n_config_new(), s2n_config_ptr_free);
52 EXPECT_NOT_NULL(config);
53 EXPECT_SUCCESS(s2n_config_set_unsafe_for_testing(config));
54 EXPECT_SUCCESS(s2n_config_add_cert_chain_and_key_to_store(config, chain_and_key));
55 EXPECT_SUCCESS(s2n_config_set_cipher_preferences(config, "20240501"));
56
57 const uint8_t client_verify_data[] = "client verify data";
58 const uint8_t server_verify_data[] = "server verify data";
59 EXPECT_EQUAL(sizeof(client_verify_data), sizeof(server_verify_data));
60 const uint8_t verify_data_len = sizeof(server_verify_data);
61
62 /* Test should_send
63 *
64 *= https://www.rfc-editor.org/rfc/rfc5746#3.6
65 *= type=test
66 *# o If the secure_renegotiation flag is set to TRUE, the server MUST
67 *# include an empty "renegotiation_info" extension in the ServerHello
68 *# message.
69 */
70 {
71 struct s2n_connection *conn = NULL;
72 EXPECT_NOT_NULL(conn = s2n_connection_new(S2N_SERVER));
73
74 /* TLS1.2 and secure renegotiation not enabled -> DON'T send */
75 conn->actual_protocol_version = S2N_TLS12;
76 conn->secure_renegotiation = false;
77 EXPECT_FALSE(s2n_server_renegotiation_info_extension.should_send(conn));
78
79 /* TLS1.3 and secure renegotiation not enabled -> DON'T send */
80 conn->actual_protocol_version = S2N_TLS13;
81 conn->secure_renegotiation = false;
82 EXPECT_FALSE(s2n_server_renegotiation_info_extension.should_send(conn));
83
84 /* TLS1.3 and secure renegotiation enabled -> DON'T send */
85 conn->actual_protocol_version = S2N_TLS13;
86 conn->secure_renegotiation = true;
87 EXPECT_FALSE(s2n_server_renegotiation_info_extension.should_send(conn));
88
89 /* TLS1.2 and secure renegotiation enabled -> send */
90 conn->actual_protocol_version = S2N_TLS12;
91 conn->secure_renegotiation = true;
92 EXPECT_TRUE(s2n_server_renegotiation_info_extension.should_send(conn));
93
94 EXPECT_SUCCESS(s2n_connection_free(conn));
95 };
96
97 /* Test server_renegotiation_info send and recv during initial handshake
98 *
99 *= https://www.rfc-editor.org/rfc/rfc5746#4.3
100 *= type=test
101 *# In order to enable clients to probe, even servers that do not support
102 *# renegotiation MUST implement the minimal version of the extension
103 *# described in this document for initial handshakes, thus signaling
104 *# that they have been upgraded.
105 */
106 {
107 struct s2n_connection *server_conn = NULL, *client_conn = NULL;
108 EXPECT_NOT_NULL(server_conn = s2n_connection_new(S2N_SERVER));
109 EXPECT_NOT_NULL(client_conn = s2n_connection_new(S2N_CLIENT));
110
111 struct s2n_stuffer extension = { 0 };
112 EXPECT_SUCCESS(s2n_stuffer_growable_alloc(&extension, 0));
113
114 server_conn->actual_protocol_version = S2N_TLS12;
115 server_conn->secure_renegotiation = 1;
116
117 EXPECT_SUCCESS(s2n_server_renegotiation_info_extension.send(server_conn, &extension));
118 EXPECT_NOT_EQUAL(s2n_stuffer_data_available(&extension), 0);
119
120 EXPECT_SUCCESS(s2n_server_renegotiation_info_extension.recv(client_conn, &extension));
121 EXPECT_EQUAL(client_conn->secure_renegotiation, 1);
122 EXPECT_EQUAL(s2n_stuffer_data_available(&extension), 0);
123
124 EXPECT_SUCCESS(s2n_stuffer_free(&extension));
125 EXPECT_SUCCESS(s2n_connection_free(client_conn));
126 EXPECT_SUCCESS(s2n_connection_free(server_conn));
127 }
128
129 /* Test server_renegotiation_info recv when using SSLv3
130 *
131 *= https://www.rfc-editor.org/rfc/rfc5746#4.5
132 *= type=test
133 *# Clients that support SSLv3 and offer secure renegotiation (either via SCSV or
134 *# "renegotiation_info") MUST accept the "renegotiation_info" extension
135 *# from the server, even if the server version is {0x03, 0x00}, and
136 *# behave as described in this specification.
137 */
138 {
139 DEFER_CLEANUP(struct s2n_connection *server_conn = s2n_connection_new(S2N_SERVER),
140 s2n_connection_ptr_free);
141 EXPECT_NOT_NULL(server_conn);
142 DEFER_CLEANUP(struct s2n_connection *client_conn = s2n_connection_new(S2N_CLIENT),
143 s2n_connection_ptr_free);
144 EXPECT_NOT_NULL(client_conn);
145
146 DEFER_CLEANUP(struct s2n_stuffer extension = { 0 }, s2n_stuffer_free);
147 EXPECT_SUCCESS(s2n_stuffer_growable_alloc(&extension, 0));
148
149 server_conn->actual_protocol_version = S2N_TLS12;
150 server_conn->secure_renegotiation = true;
151 EXPECT_SUCCESS(s2n_server_renegotiation_info_extension.send(server_conn, &extension));
152 EXPECT_NOT_EQUAL(s2n_stuffer_data_available(&extension), 0);
153
154 client_conn->client_protocol_version = S2N_SSLv3;
155 client_conn->actual_protocol_version = S2N_SSLv3;
156 EXPECT_SUCCESS(s2n_server_renegotiation_info_extension.recv(client_conn, &extension));
157 EXPECT_EQUAL(client_conn->secure_renegotiation, 1);
158 EXPECT_EQUAL(s2n_stuffer_data_available(&extension), 0);
159 };
160
161 /* Test server_renegotiation_info recv during initial handshake - extension too long */
162 {
163 struct s2n_connection *server_conn = NULL, *client_conn = NULL;
164 EXPECT_NOT_NULL(server_conn = s2n_connection_new(S2N_SERVER));
165 EXPECT_NOT_NULL(client_conn = s2n_connection_new(S2N_CLIENT));
166
167 struct s2n_stuffer extension = { 0 };
168 EXPECT_SUCCESS(s2n_stuffer_growable_alloc(&extension, 0));
169
170 server_conn->actual_protocol_version = S2N_TLS12;
171 server_conn->secure_renegotiation = 1;
172
173 EXPECT_SUCCESS(s2n_server_renegotiation_info_extension.send(server_conn, &extension));
174 EXPECT_SUCCESS(s2n_stuffer_write_uint8(&extension, 0));
175
176 EXPECT_FAILURE_WITH_ERRNO(s2n_server_renegotiation_info_extension.recv(client_conn, &extension),
177 S2N_ERR_NON_EMPTY_RENEGOTIATION_INFO);
178 EXPECT_EQUAL(client_conn->secure_renegotiation, 0);
179
180 EXPECT_SUCCESS(s2n_stuffer_free(&extension));
181 EXPECT_SUCCESS(s2n_connection_free(client_conn));
182 EXPECT_SUCCESS(s2n_connection_free(server_conn));
183 };
184
185 /* Test server_renegotiation_info recv during initial handshake - extension length wrong
186 *
187 *= https://www.rfc-editor.org/rfc/rfc5746#3.4
188 *= type=test
189 *# * The client MUST then verify that the length of the
190 *# "renegotiated_connection" field is zero, and if it is not, MUST
191 *# abort the handshake (by sending a fatal handshake_failure alert).
192 */
193 {
194 struct s2n_connection *client_conn = NULL;
195 EXPECT_NOT_NULL(client_conn = s2n_connection_new(S2N_CLIENT));
196
197 struct s2n_stuffer extension = { 0 };
198 EXPECT_SUCCESS(s2n_stuffer_growable_alloc(&extension, 0));
199
200 EXPECT_SUCCESS(s2n_stuffer_write_uint8(&extension, 5));
201
202 EXPECT_FAILURE_WITH_ERRNO(s2n_server_renegotiation_info_extension.recv(client_conn, &extension),
203 S2N_ERR_NON_EMPTY_RENEGOTIATION_INFO);
204 EXPECT_EQUAL(client_conn->secure_renegotiation, 0);
205
206 EXPECT_SUCCESS(s2n_stuffer_free(&extension));
207 EXPECT_SUCCESS(s2n_connection_free(client_conn));
208 };
209
210 /* Test: if_missing during initial handshake is a no-op
211 *
212 *= https://www.rfc-editor.org/rfc/rfc5746#3.4
213 *= type=test
214 *# * If the extension is not present, the server does not support
215 *# secure renegotiation; set secure_renegotiation flag to FALSE.
216 */
217 {
218 DEFER_CLEANUP(struct s2n_connection *conn = s2n_connection_new(S2N_CLIENT),
219 s2n_connection_ptr_free);
220 EXPECT_NOT_NULL(conn);
221 EXPECT_SUCCESS(s2n_server_renegotiation_info_extension.if_missing(conn));
222 EXPECT_FALSE(conn->secure_renegotiation);
223 };
224
225 /* Test: if_missing during renegotiation handshake is an error
226 *
227 *= https://www.rfc-editor.org/rfc/rfc5746#3.5
228 *= type=test
229 *# o When a ServerHello is received, the client MUST verify that the
230 *# "renegotiation_info" extension is present; if it is not, the
231 *# client MUST abort the handshake.
232 */
233 {
234 DEFER_CLEANUP(struct s2n_connection *conn = s2n_connection_new(S2N_CLIENT),
235 s2n_connection_ptr_free);
236 EXPECT_NOT_NULL(conn);
237 conn->handshake.renegotiation = true;
238 EXPECT_FAILURE_WITH_ERRNO(s2n_server_renegotiation_info_extension.if_missing(conn),
239 S2N_ERR_NO_RENEGOTIATION);
240 };
241
242 /* Test: recv during renegotiation handshake
243 *
244 *= https://www.rfc-editor.org/rfc/rfc5746#3.5
245 *= type=test
246 *# o The client MUST then verify that the first half of the
247 *# "renegotiated_connection" field is equal to the saved
248 *# client_verify_data value, and the second half is equal to the
249 *# saved server_verify_data value. If they are not, the client MUST
250 *# abort the handshake.
251 */
252 {
253 DEFER_CLEANUP(struct s2n_connection *conn = s2n_connection_new(S2N_CLIENT),
254 s2n_connection_ptr_free);
255 EXPECT_NOT_NULL(conn);
256 conn->handshake.renegotiation = true;
257 conn->secure_renegotiation = true;
258
259 /* Setup verify_data */
260 EXPECT_MEMCPY_SUCCESS(conn->handshake.client_finished,
261 client_verify_data, sizeof(client_verify_data));
262 EXPECT_MEMCPY_SUCCESS(conn->handshake.server_finished,
263 server_verify_data, sizeof(server_verify_data));
264 conn->handshake.finished_len = verify_data_len;
265 uint8_t renegotiation_info_len = verify_data_len * 2;
266
267 /* Secure renegotiation not supported */
268 {
269 /* Write valid verify_data */
270 DEFER_CLEANUP(struct s2n_stuffer extension = { 0 }, s2n_stuffer_free);
271 EXPECT_OK(s2n_server_renegotiation_info_extension_write(&extension,
272 client_verify_data, server_verify_data, verify_data_len));
273
274 conn->secure_renegotiation = false;
275 EXPECT_FAILURE_WITH_ERRNO(s2n_server_renegotiation_info_extension.recv(conn, &extension),
276 S2N_ERR_NO_RENEGOTIATION);
277 };
278
279 /* Turn on secure renegotiation for the rest of the tests */
280 conn->secure_renegotiation = true;
281
282 /* Receive valid client and server verify_data */
283 {
284 /* Write valid verify_data */
285 DEFER_CLEANUP(struct s2n_stuffer extension = { 0 }, s2n_stuffer_free);
286 EXPECT_OK(s2n_server_renegotiation_info_extension_write(&extension,
287 client_verify_data, server_verify_data, verify_data_len));
288
289 EXPECT_SUCCESS(s2n_server_renegotiation_info_extension.recv(conn, &extension));
290 };
291
292 /* Receive incorrect length: too small */
293 {
294 /* Write valid verify_data */
295 DEFER_CLEANUP(struct s2n_stuffer extension = { 0 }, s2n_stuffer_free);
296 EXPECT_OK(s2n_server_renegotiation_info_extension_write(&extension,
297 client_verify_data, server_verify_data, verify_data_len));
298
299 /* Modify length */
300 EXPECT_SUCCESS(s2n_stuffer_rewrite(&extension));
301 EXPECT_SUCCESS(s2n_stuffer_write_uint8(&extension, renegotiation_info_len - 1));
302 EXPECT_SUCCESS(s2n_stuffer_skip_write(&extension, renegotiation_info_len));
303
304 EXPECT_FAILURE_WITH_ERRNO(s2n_server_renegotiation_info_extension.recv(conn, &extension),
305 S2N_ERR_BAD_MESSAGE);
306 };
307
308 /* Receive incorrect length: too large */
309 {
310 /* Write valid verify_data */
311 DEFER_CLEANUP(struct s2n_stuffer extension = { 0 }, s2n_stuffer_free);
312 EXPECT_OK(s2n_server_renegotiation_info_extension_write(&extension,
313 client_verify_data, server_verify_data, verify_data_len));
314
315 /* Modify length */
316 EXPECT_SUCCESS(s2n_stuffer_rewrite(&extension));
317 EXPECT_SUCCESS(s2n_stuffer_write_uint8(&extension, renegotiation_info_len + 1));
318 EXPECT_SUCCESS(s2n_stuffer_skip_write(&extension, renegotiation_info_len));
319
320 EXPECT_FAILURE_WITH_ERRNO(s2n_server_renegotiation_info_extension.recv(conn, &extension),
321 S2N_ERR_BAD_MESSAGE);
322 };
323
324 /* Receive incorrect client_verify_data */
325 {
326 DEFER_CLEANUP(struct s2n_stuffer extension = { 0 }, s2n_stuffer_free);
327 EXPECT_OK(s2n_server_renegotiation_info_extension_write(&extension,
328 server_verify_data, server_verify_data, verify_data_len));
329
330 EXPECT_FAILURE_WITH_ERRNO(s2n_server_renegotiation_info_extension.recv(conn, &extension),
331 S2N_ERR_BAD_MESSAGE);
332 };
333
334 /* Receive incorrect server_verify_data */
335 {
336 DEFER_CLEANUP(struct s2n_stuffer extension = { 0 }, s2n_stuffer_free);
337 EXPECT_OK(s2n_server_renegotiation_info_extension_write(&extension,
338 client_verify_data, client_verify_data, verify_data_len));
339
340 EXPECT_FAILURE_WITH_ERRNO(s2n_server_renegotiation_info_extension.recv(conn, &extension),
341 S2N_ERR_BAD_MESSAGE);
342 };
343
344 /* Receive initial handshake extension */
345 {
346 DEFER_CLEANUP(struct s2n_stuffer extension = { 0 }, s2n_stuffer_free);
347 EXPECT_SUCCESS(s2n_stuffer_growable_alloc(&extension, 0));
348
349 conn->handshake.renegotiation = false;
350 EXPECT_SUCCESS(s2n_server_renegotiation_info_extension.send(conn, &extension));
351 conn->handshake.renegotiation = true;
352 EXPECT_FAILURE_WITH_ERRNO(s2n_server_renegotiation_info_extension.recv(conn, &extension),
353 S2N_ERR_BAD_MESSAGE);
354 };
355 };
356
357 /* Test send during renegotiation handshake
358 *
359 *= https://www.rfc-editor.org/rfc/rfc5746#3.7
360 *= type=test
361 *# o The server MUST include a "renegotiation_info" extension
362 *# containing the saved client_verify_data and server_verify_data in
363 *# the ServerHello.
364 */
365 {
366 DEFER_CLEANUP(struct s2n_connection *client_conn = s2n_connection_new(S2N_CLIENT),
367 s2n_connection_ptr_free);
368 EXPECT_NOT_NULL(client_conn);
369 client_conn->handshake.renegotiation = true;
370 client_conn->secure_renegotiation = true;
371 EXPECT_MEMCPY_SUCCESS(client_conn->handshake.client_finished,
372 client_verify_data, sizeof(client_verify_data));
373 EXPECT_MEMCPY_SUCCESS(client_conn->handshake.server_finished,
374 server_verify_data, sizeof(server_verify_data));
375 client_conn->handshake.finished_len = verify_data_len;
376
377 DEFER_CLEANUP(struct s2n_connection *server_conn = s2n_connection_new(S2N_SERVER),
378 s2n_connection_ptr_free);
379 EXPECT_NOT_NULL(server_conn);
380 server_conn->handshake.renegotiation = true;
381 server_conn->secure_renegotiation = true;
382 EXPECT_MEMCPY_SUCCESS(server_conn->handshake.client_finished,
383 client_verify_data, sizeof(client_verify_data));
384 EXPECT_MEMCPY_SUCCESS(server_conn->handshake.server_finished,
385 server_verify_data, sizeof(server_verify_data));
386 server_conn->handshake.finished_len = verify_data_len;
387
388 DEFER_CLEANUP(struct s2n_stuffer sent_extension = { 0 }, s2n_stuffer_free);
389 EXPECT_SUCCESS(s2n_stuffer_growable_alloc(&sent_extension, 0));
390 EXPECT_TRUE(s2n_server_renegotiation_info_extension.should_send(client_conn));
391 EXPECT_SUCCESS(s2n_server_renegotiation_info_extension.send(client_conn, &sent_extension));
392
393 /* Verify matches test method */
394 DEFER_CLEANUP(struct s2n_stuffer test_extension = { 0 }, s2n_stuffer_free);
395 EXPECT_OK(s2n_server_renegotiation_info_extension_write(&test_extension,
396 client_verify_data, server_verify_data, verify_data_len));
397 EXPECT_EQUAL(s2n_stuffer_data_available(&sent_extension), s2n_stuffer_data_available(&test_extension));
398 EXPECT_BYTEARRAY_EQUAL(sent_extension.blob.data, test_extension.blob.data,
399 s2n_stuffer_data_available(&sent_extension));
400
401 /* Verify we can recv what we send */
402 EXPECT_SUCCESS(s2n_server_renegotiation_info_extension.recv(server_conn, &sent_extension));
403 };
404
405 /* Functional Test
406 *
407 *= https://www.rfc-editor.org/rfc/rfc5746#3.4
408 *= type=test
409 *# o When a ServerHello is received, the client MUST check if it
410 *# includes the "renegotiation_info" extension:
411 */
412 {
413 DEFER_CLEANUP(struct s2n_connection *client_conn = s2n_connection_new(S2N_CLIENT),
414 s2n_connection_ptr_free);
415 EXPECT_NOT_NULL(client_conn);
416 EXPECT_SUCCESS(s2n_connection_set_config(client_conn, config));
417
418 DEFER_CLEANUP(struct s2n_connection *server_conn = s2n_connection_new(S2N_SERVER),
419 s2n_connection_ptr_free);
420 EXPECT_NOT_NULL(server_conn);
421 EXPECT_SUCCESS(s2n_connection_set_config(server_conn, config));
422
423 /* Send and receive the ClientHello */
424 EXPECT_SUCCESS(s2n_client_hello_send(client_conn));
425 EXPECT_SUCCESS(s2n_stuffer_copy(&client_conn->handshake.io, &server_conn->handshake.io,
426 s2n_stuffer_data_available(&client_conn->handshake.io)));
427 EXPECT_SUCCESS(s2n_client_hello_recv(server_conn));
428
429 /* Test "renegotiation_info" extension NOT included during initial handshake */
430 {
431 EXPECT_FALSE(client_conn->secure_renegotiation);
432
433 server_conn->secure_renegotiation = false;
434 EXPECT_SUCCESS(s2n_server_hello_send(server_conn));
435 EXPECT_SUCCESS(s2n_stuffer_copy(&server_conn->handshake.io, &client_conn->handshake.io,
436 s2n_stuffer_data_available(&server_conn->handshake.io)));
437 EXPECT_SUCCESS(s2n_server_hello_recv(client_conn));
438
439 EXPECT_FALSE(client_conn->secure_renegotiation);
440 };
441
442 /* Test "renegotiation_info" extension included during initial handshake */
443 {
444 EXPECT_FALSE(client_conn->secure_renegotiation);
445
446 server_conn->secure_renegotiation = true;
447 EXPECT_SUCCESS(s2n_server_hello_send(server_conn));
448 EXPECT_SUCCESS(s2n_stuffer_copy(&server_conn->handshake.io, &client_conn->handshake.io,
449 s2n_stuffer_data_available(&server_conn->handshake.io)));
450 EXPECT_SUCCESS(s2n_server_hello_recv(client_conn));
451
452 EXPECT_TRUE(client_conn->secure_renegotiation);
453 };
454 };
455
456 /* Functional Test: SSLv3
457 *
458 *= https://www.rfc-editor.org/rfc/rfc5746#4.5
459 *= type=test
460 *# Clients that support SSLv3 and offer secure renegotiation (either via SCSV or
461 *# "renegotiation_info") MUST accept the "renegotiation_info" extension
462 *# from the server, even if the server version is {0x03, 0x00}, and
463 *# behave as described in this specification. TLS servers that support
464 *# secure renegotiation and support SSLv3 MUST accept SCSV or the
465 *# "renegotiation_info" extension and respond as described in this
466 *# specification even if the offered client version is {0x03, 0x00}.
467 **/
468 if (s2n_hash_is_available(S2N_HASH_MD5)) {
469 DEFER_CLEANUP(struct s2n_connection *client_conn = s2n_connection_new(S2N_CLIENT),
470 s2n_connection_ptr_free);
471 EXPECT_NOT_NULL(client_conn);
472 EXPECT_SUCCESS(s2n_connection_set_config(client_conn, config));
473 EXPECT_SUCCESS(s2n_connection_set_cipher_preferences(client_conn, "test_all"));
474 client_conn->client_protocol_version = S2N_SSLv3;
475 client_conn->actual_protocol_version = S2N_SSLv3;
476
477 DEFER_CLEANUP(struct s2n_connection *server_conn = s2n_connection_new(S2N_SERVER),
478 s2n_connection_ptr_free);
479 EXPECT_NOT_NULL(server_conn);
480 EXPECT_SUCCESS(s2n_connection_set_config(server_conn, config));
481 EXPECT_SUCCESS(s2n_connection_set_cipher_preferences(server_conn, "test_all"));
482 server_conn->server_protocol_version = S2N_SSLv3;
483 server_conn->actual_protocol_version = S2N_SSLv3;
484
485 DEFER_CLEANUP(struct s2n_test_io_pair io_pair = { 0 }, s2n_io_pair_close);
486 EXPECT_SUCCESS(s2n_io_pair_init_non_blocking(&io_pair));
487 EXPECT_SUCCESS(s2n_connections_set_io_pair(client_conn, server_conn, &io_pair));
488
489 EXPECT_SUCCESS(s2n_negotiate_test_server_and_client(server_conn, client_conn));
490 EXPECT_TRUE(client_conn->secure_renegotiation);
491 EXPECT_TRUE(server_conn->secure_renegotiation);
492 EXPECT_EQUAL(client_conn->actual_protocol_version, S2N_SSLv3);
493 EXPECT_EQUAL(server_conn->actual_protocol_version, S2N_SSLv3);
494 }
495
496 END_TEST();
497 }