]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/70-test_tls13messages.t
c64e54e6f8b9313edf5a7968e4c61405983c028f
2 # Copyright 2015-2016 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
;
12 use File
::Temp
qw(tempfile);
14 my $test_name = "test_tls13messages";
17 plan skip_all
=> "TLSProxy isn't usable on $^O"
18 if $^O
=~ /^(VMS|MSWin32)$/;
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 TLSv1.3 enabled"
27 if disabled
("tls1_3");
29 $ENV{OPENSSL_ia32cap
} = '~0x200000200000000';
32 DEFAULT_HANDSHAKE
=> 1,
34 RESUME_HANDSHAKE
=> 4,
35 CLIENT_AUTH_HANDSHAKE
=> 8,
40 [TLSProxy
::Message
::MT_CLIENT_HELLO
, ALL_HANDSHAKES
],
41 [TLSProxy
::Message
::MT_SERVER_HELLO
, ALL_HANDSHAKES
],
42 [TLSProxy
::Message
::MT_ENCRYPTED_EXTENSIONS
, ALL_HANDSHAKES
],
43 [TLSProxy
::Message
::MT_CERTIFICATE_REQUEST
, CLIENT_AUTH_HANDSHAKE
],
44 [TLSProxy
::Message
::MT_CERTIFICATE
, ALL_HANDSHAKES
& ~RESUME_HANDSHAKE
],
45 [TLSProxy
::Message
::MT_CERTIFICATE_STATUS
, OCSP_HANDSHAKE
],
46 [TLSProxy
::Message
::MT_FINISHED
, ALL_HANDSHAKES
],
47 [TLSProxy
::Message
::MT_CERTIFICATE
, CLIENT_AUTH_HANDSHAKE
],
48 [TLSProxy
::Message
::MT_CERTIFICATE_VERIFY
, CLIENT_AUTH_HANDSHAKE
],
49 [TLSProxy
::Message
::MT_FINISHED
, ALL_HANDSHAKES
],
53 my $proxy = TLSProxy
::Proxy
->new(
55 cmdstr
(app
(["openssl"]), display
=> 1),
56 srctop_file
("apps", "server.pem"),
57 (!$ENV{HARNESS_ACTIVE
} || $ENV{HARNESS_VERBOSE
})
60 sub checkmessages
($$);
62 #Test 1: Check we get all the right messages for a default handshake
63 (undef, my $session) = tempfile
();
64 #$proxy->serverconnects(2);
65 $proxy->clientflags("-sess_out ".$session);
66 $proxy->start() or plan skip_all
=> "Unable to start up Proxy for tests";
68 checkmessages
(DEFAULT_HANDSHAKE
, "Default handshake test");
70 #TODO(TLS1.3): Test temporarily disabled until we implement TLS1.3 resumption
71 #Test 2: Resumption handshake
72 #$proxy->clearClient();
73 #$proxy->clientflags("-sess_in ".$session);
74 #$proxy->clientstart();
75 #checkmessages(RESUME_HANDSHAKE, "Resumption handshake test");
78 #Test 3: A default handshake, but with a CertificateStatus message
79 #TODO(TLS1.3): TLS1.3 doesn't actually have CertificateStatus messages. This is
80 #a temporary test until such time as we do proper TLS1.3 style certificate
83 $proxy->clientflags("-status");
84 $proxy->serverflags("-status_file "
85 .srctop_file
("test", "recipes", "ocsp-response.der"));
87 checkmessages
(OCSP_HANDSHAKE
, "OCSP handshake test");
89 #Test 4: A client auth handshake
91 $proxy->clientflags("-cert ".srctop_file
("apps", "server.pem"));
92 $proxy->serverflags("-Verify 5");
94 checkmessages
(CLIENT_AUTH_HANDSHAKE
, "Client auth handshake test");
98 my ($handtype, $testname) = @_;
100 subtest
$testname => sub {
104 #First count the number of tests
105 for ($numtests = 1; $handmessages[$loop][1] != 0; $loop++) {
106 $numtests++ if (($handmessages[$loop][1] & $handtype) != 0);
109 plan tests
=> $numtests;
112 foreach my $message (@
{$proxy->message_list}) {
113 for (; $handmessages[$loop][1] != 0
114 && ($handmessages[$loop][1] & $handtype) == 0; $loop++) {
117 ok
($handmessages[$loop][1] != 0
118 && $message->mt == $handmessages[$loop][0],
119 "Message type check. Got ".$message->mt
120 .", expected ".$handmessages[$loop][0]);
123 ok
($handmessages[$loop][1] == 0, "All expected messages processed");