summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-11-21 16:22:00 +0000
committerMatt Caswell <matt@openssl.org>2016-12-05 17:05:40 +0000
commitb4c6e37e7428eec3d46b6737b60df8e423d0a8df (patch)
tree25b34b99586d8817ff9dfe2b18e4eb5c2ef6ff00 /test
parente60ce9c4513c432705c84b0efebf1421ee769eee (diff)
Add more TLS1.3 record tests
Add some tests for the new record construction Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'test')
-rw-r--r--test/recipes/70-test_sslrecords.t52
1 files changed, 46 insertions, 6 deletions
diff --git a/test/recipes/70-test_sslrecords.t b/test/recipes/70-test_sslrecords.t
index e6f7a36c05..f699058825 100644
--- a/test/recipes/70-test_sslrecords.t
+++ b/test/recipes/70-test_sslrecords.t
@@ -44,7 +44,7 @@ if (!disabled("tls1_1")) {
$num_tests++;
}
if (!disabled("tls1_3")) {
- $num_tests++;
+ $num_tests += 3;
}
plan tests => $num_tests;
ok(TLSProxy::Message->fail(), "Out of context empty records test");
@@ -148,13 +148,28 @@ $proxy->filter(\&change_version);
$proxy->start();
ok(TLSProxy::Message->fail(), "Changed record version in TLS1.2");
-#Test 13: Sending a different record version in TLS1.3 should succeed
+#TLS1.3 specific tests
if (!disabled("tls1_3")) {
+ #Test 13: Sending a different record version in TLS1.3 should succeed
$proxy->clear();
$proxy->filter(\&change_version);
$proxy->start();
ok(TLSProxy::Message->success(), "Changed record version in TLS1.3");
-}
+
+ #Test 14: Sending an unrecognised record type in TLS1.3 should fail
+ $proxy->clear();
+ $proxy->filter(\&add_unknown_record_type);
+ $proxy->start();
+ ok(TLSProxy::Message->fail(), "Unrecognised record type in TLS1.3");
+
+ #Test 15: Sending an outer record type other than app data once encrypted
+ #should fail
+ $proxy->clear();
+ $proxy->filter(\&change_outer_record_type);
+ $proxy->start();
+ ok(TLSProxy::Message->fail(), "Wrong outer record type in TLS1.3");
+ }
+
sub add_empty_recs_filter
{
@@ -388,13 +403,13 @@ sub add_unknown_record_type
my $proxy = shift;
# We'll change a record after the initial version neg has taken place
- if ($proxy->flight != 2) {
+ if ($proxy->flight != 1) {
return;
}
my $lastrec = ${$proxy->record_list}[-1];
my $record = TLSProxy::Record->new(
- 2,
+ 1,
TLSProxy::Record::RT_UNKNOWN,
$lastrec->version(),
1,
@@ -405,7 +420,14 @@ sub add_unknown_record_type
"X"
);
- unshift @{$proxy->record_list}, $record;
+ #Find ServerHello record and insert after that
+ my $i;
+ for ($i = 0; ${$proxy->record_list}[$i]->flight() < 1; $i++) {
+ next;
+ }
+ $i++;
+
+ splice @{$proxy->record_list}, $i, 0, $record;
}
sub change_version
@@ -419,3 +441,21 @@ sub change_version
(${$proxy->record_list}[-1])->version(TLSProxy::Record::VERS_TLS_1_1);
}
+
+sub change_outer_record_type
+{
+ my $proxy = shift;
+
+ # We'll change a record after the initial version neg has taken place
+ if ($proxy->flight != 1) {
+ return;
+ }
+
+ #Find ServerHello record and change record after that
+ my $i;
+ for ($i = 0; ${$proxy->record_list}[$i]->flight() < 1; $i++) {
+ next;
+ }
+ $i++;
+ ${$proxy->record_list}[$i]->outer_content_type(TLSProxy::Record::RT_HANDSHAKE);
+}