]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/70-test_tls13downgrade.t
2 # Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
10 use OpenSSL
::Test qw
/:DEFAULT cmdstr srctop_file bldtop_dir/;
11 use OpenSSL
::Test
::Utils
;
14 my $test_name = "test_tls13downgrade";
17 plan skip_all
=> "TLSProxy isn't usable on $^O"
20 plan skip_all
=> "$test_name needs the dynamic engine feature enabled"
21 if disabled
("engine") || disabled
("dynamic-engine");
23 plan skip_all
=> "$test_name needs the sock feature enabled"
26 plan skip_all
=> "$test_name needs TLS1.3 and TLS1.2 enabled"
27 if disabled
("tls1_3") || disabled
("tls1_2");
29 # TODO(TLS1.3): Enable this when TLSv1.3 comes out of draft
30 plan skip_all
=> "$test_name not run in pre TLSv1.3 RFC implementation"
31 if disabled
("tls13downgrade");
33 $ENV{OPENSSL_ia32cap
} = '~0x200000200000000';
35 my $proxy = TLSProxy
::Proxy
->new(
37 cmdstr
(app
(["openssl"]), display
=> 1),
38 srctop_file
("apps", "server.pem"),
39 (!$ENV{HARNESS_ACTIVE
} || $ENV{HARNESS_VERBOSE
})
43 DOWNGRADE_TO_TLS_1_2
=> 0,
44 DOWNGRADE_TO_TLS_1_1
=> 1
47 #Test 1: Downgrade from TLSv1.3 to TLSv1.2
48 $proxy->filter(\
&downgrade_filter
);
49 my $testtype = DOWNGRADE_TO_TLS_1_2
;
50 $proxy->start() or plan skip_all
=> "Unable to start up Proxy for tests";
52 ok
(TLSProxy
::Message
->fail(), "Downgrade TLSv1.3 to TLSv1.2");
54 #Test 2: Downgrade from TLSv1.3 to TLSv1.1
56 $testtype = DOWNGRADE_TO_TLS_1_1
;
58 ok
(TLSProxy
::Message
->fail(), "Downgrade TLSv1.3 to TLSv1.1");
60 #Test 3: Downgrade from TLSv1.2 to TLSv1.1
62 $proxy->clientflags("-no_tls1_3");
63 $proxy->serverflags("-no_tls1_3");
65 ok
(TLSProxy
::Message
->fail(), "Downgrade TLSv1.2 to TLSv1.1");
71 # We're only interested in the initial ClientHello
72 if ($proxy->flight != 0) {
76 my $message = ${$proxy->message_list}[0];
79 if ($testtype == DOWNGRADE_TO_TLS_1_2
) {
89 $message->set_extension(TLSProxy
::Message
::EXT_SUPPORTED_VERSIONS
, $ext);