@@ -1251,25 +1251,25 @@ int main(int argc, char **argv)
1251
1251
EXPECT_TRUE (large_test_data_records > 0 );
1252
1252
const size_t test_encryption_limit = large_test_data_records ;
1253
1253
1254
- /* Create a cipher_suite with an artificially lower encryption limit */
1255
1254
struct s2n_record_algorithm test_record_alg = * s2n_tls13_aes_128_gcm_sha256 .record_alg ;
1256
1255
test_record_alg .encryption_limit = test_encryption_limit ;
1257
1256
struct s2n_cipher_suite test_cipher_suite = s2n_tls13_aes_128_gcm_sha256 ;
1258
1257
test_cipher_suite .record_alg = & test_record_alg ;
1259
1258
1260
1259
for (s2n_mode mode = 0 ; mode <= 1 ; mode ++ ) {
1261
- /* Test: Sequence number tracked correctly */
1260
+ DEFER_CLEANUP (struct s2n_connection * conn = s2n_connection_new (mode ),
1261
+ s2n_connection_ptr_free );
1262
+ EXPECT_NOT_NULL (conn );
1263
+ EXPECT_OK (s2n_ktls_set_sendmsg_cb (conn , s2n_test_ktls_sendmsg_mark_all_sent , conn ));
1264
+ conn -> ktls_send_enabled = true;
1265
+ EXPECT_NOT_NULL (conn -> secure );
1266
+ conn -> secure -> cipher_suite = & test_cipher_suite ;
1267
+ conn -> actual_protocol_version = S2N_TLS13 ;
1268
+
1262
1269
s2n_blocked_status blocked = S2N_NOT_BLOCKED ;
1263
- {
1264
- DEFER_CLEANUP (struct s2n_connection * conn = s2n_connection_new (mode ),
1265
- s2n_connection_ptr_free );
1266
- EXPECT_NOT_NULL (conn );
1267
- EXPECT_OK (s2n_test_configure_connection_for_ktls (conn , S2N_TLS13 , & s2n_tls13_aes_128_gcm_sha256 ));
1268
- EXPECT_OK (s2n_ktls_set_setsockopt_cb (s2n_test_setsockopt_aes128_tx ));
1269
- EXPECT_OK (s2n_ktls_set_sendmsg_cb (conn , s2n_test_ktls_sendmsg_mark_all_sent , conn -> send_io_context ));
1270
- conn -> ktls_send_enabled = true;
1271
- conn -> secure -> cipher_suite = & test_cipher_suite ;
1272
1270
1271
+ /* Test: Sequence number tracked correctly */
1272
+ {
1273
1273
DEFER_CLEANUP (struct s2n_blob seq_num = { 0 }, s2n_blob_zero );
1274
1274
EXPECT_OK (s2n_connection_get_sequence_number (conn , conn -> mode , & seq_num ));
1275
1275
@@ -1301,30 +1301,14 @@ int main(int argc, char **argv)
1301
1301
EXPECT_OK (s2n_assert_seq_num_equal (seq_num , expected_seq_num ));
1302
1302
1303
1303
/* Test: Send enough data to hit the encryption limit */
1304
- if (s2n_ktls_keyupdate_is_supported_on_platform ()) {
1305
- EXPECT_SUCCESS (s2n_send (conn , large_test_data , sizeof (large_test_data ), & blocked ));
1306
- /* After a keyupdate, sequence number is reset to 0. Then the sequence number will
1307
- * be incremented to the number of records needed to send large_test_data. */
1308
- expected_seq_num = large_test_data_records ;
1309
- } else {
1310
- EXPECT_FAILURE_WITH_ERRNO (
1311
- s2n_send (conn , large_test_data , sizeof (large_test_data ), & blocked ),
1312
- S2N_ERR_KTLS_KEY_LIMIT );
1313
- }
1304
+ EXPECT_FAILURE_WITH_ERRNO (
1305
+ s2n_send (conn , large_test_data , sizeof (large_test_data ), & blocked ),
1306
+ S2N_ERR_KTLS_KEY_LIMIT );
1314
1307
EXPECT_OK (s2n_assert_seq_num_equal (seq_num , expected_seq_num ));
1315
1308
};
1316
1309
1317
1310
/* Test: Exact encryption limit boundary */
1318
1311
{
1319
- DEFER_CLEANUP (struct s2n_connection * conn = s2n_connection_new (S2N_SERVER ),
1320
- s2n_connection_ptr_free );
1321
- EXPECT_NOT_NULL (conn );
1322
- EXPECT_OK (s2n_test_configure_connection_for_ktls (conn , S2N_TLS13 , & s2n_tls13_aes_128_gcm_sha256 ));
1323
- EXPECT_OK (s2n_ktls_set_setsockopt_cb (s2n_test_setsockopt_aes128_tx ));
1324
- EXPECT_OK (s2n_ktls_set_sendmsg_cb (conn , s2n_test_ktls_sendmsg_mark_all_sent , conn -> send_io_context ));
1325
- conn -> ktls_send_enabled = true;
1326
- conn -> secure -> cipher_suite = & test_cipher_suite ;
1327
-
1328
1312
DEFER_CLEANUP (struct s2n_blob seq_num = { 0 }, s2n_blob_zero );
1329
1313
EXPECT_OK (s2n_connection_get_sequence_number (conn , conn -> mode , & seq_num ));
1330
1314
@@ -1335,27 +1319,14 @@ int main(int argc, char **argv)
1335
1319
EXPECT_OK (s2n_assert_seq_num_equal (seq_num , test_encryption_limit ));
1336
1320
1337
1321
/* One more record should exceed the encryption limit */
1338
- if (s2n_ktls_keyupdate_is_supported_on_platform ()) {
1339
- EXPECT_SUCCESS (s2n_send (conn , large_test_data , sizeof (large_test_data ), & blocked ));
1340
- } else {
1341
- EXPECT_FAILURE_WITH_ERRNO (
1342
- s2n_send (conn , large_test_data , sizeof (large_test_data ), & blocked ),
1343
- S2N_ERR_KTLS_KEY_LIMIT );
1344
- }
1322
+ EXPECT_FAILURE_WITH_ERRNO (
1323
+ s2n_send (conn , large_test_data , sizeof (large_test_data ), & blocked ),
1324
+ S2N_ERR_KTLS_KEY_LIMIT );
1345
1325
EXPECT_OK (s2n_assert_seq_num_equal (seq_num , test_encryption_limit ));
1346
1326
};
1347
1327
1348
1328
/* Test: Limit not tracked with TLS1.2 */
1349
1329
{
1350
- DEFER_CLEANUP (struct s2n_connection * conn = s2n_connection_new (S2N_SERVER ),
1351
- s2n_connection_ptr_free );
1352
- EXPECT_NOT_NULL (conn );
1353
- EXPECT_OK (s2n_test_configure_connection_for_ktls (conn , S2N_TLS13 , & s2n_tls13_aes_128_gcm_sha256 ));
1354
- EXPECT_OK (s2n_ktls_set_setsockopt_cb (s2n_test_setsockopt_aes128_tx ));
1355
- EXPECT_OK (s2n_ktls_set_sendmsg_cb (conn , s2n_test_ktls_sendmsg_mark_all_sent , conn -> send_io_context ));
1356
- conn -> ktls_send_enabled = true;
1357
- conn -> secure -> cipher_suite = & test_cipher_suite ;
1358
-
1359
1330
DEFER_CLEANUP (struct s2n_blob seq_num = { 0 }, s2n_blob_zero );
1360
1331
EXPECT_OK (s2n_connection_get_sequence_number (conn , conn -> mode , & seq_num ));
1361
1332
@@ -1375,13 +1346,10 @@ int main(int argc, char **argv)
1375
1346
1376
1347
/* Passing the limit with TLS1.3 is an error if key updated is not supported */
1377
1348
conn -> actual_protocol_version = S2N_TLS13 ;
1378
- if (s2n_ktls_keyupdate_is_supported_on_platform ()) {
1379
- EXPECT_SUCCESS (s2n_send (conn , large_test_data , sizeof (large_test_data ), & blocked ));
1380
- } else {
1381
- EXPECT_FAILURE_WITH_ERRNO (
1382
- s2n_send (conn , large_test_data , sizeof (large_test_data ), & blocked ),
1383
- S2N_ERR_KTLS_KEY_LIMIT );
1384
- }
1349
+ EXPECT_FAILURE_WITH_ERRNO (
1350
+ s2n_send (conn , large_test_data , sizeof (large_test_data ), & blocked ),
1351
+ S2N_ERR_KTLS_KEY_LIMIT );
1352
+
1385
1353
/* Passing the limit with TLS1.2 is NOT an error */
1386
1354
conn -> actual_protocol_version = S2N_TLS12 ;
1387
1355
EXPECT_EQUAL (s2n_send (conn , large_test_data , 1 , & blocked ), 1 );
0 commit comments