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;
13 my $test_name = "test_tls13messages";
16 plan skip_all => "TLSProxy isn't usable on $^O"
17 if $^O =~ /^(VMS|MSWin32)$/;
19 plan skip_all => "$test_name needs the dynamic engine feature enabled"
20 if disabled("engine") || disabled("dynamic-engine");
22 plan skip_all => "$test_name needs the sock feature enabled"
25 plan skip_all => "$test_name needs TLSv1.3 enabled"
26 if disabled("tls1_3");
28 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
31 DEFAULT_HANDSHAKE => 1
35 [TLSProxy::Message::MT_CLIENT_HELLO, DEFAULT_HANDSHAKE],
36 [TLSProxy::Message::MT_SERVER_HELLO, DEFAULT_HANDSHAKE],
37 [TLSProxy::Message::MT_CERTIFICATE, DEFAULT_HANDSHAKE],
38 [TLSProxy::Message::MT_FINISHED, DEFAULT_HANDSHAKE],
39 [TLSProxy::Message::MT_FINISHED, DEFAULT_HANDSHAKE],
43 my $proxy = TLSProxy::Proxy->new(
45 cmdstr(app(["openssl"]), display => 1),
46 srctop_file("apps", "server.pem"),
47 (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
50 sub checkmessages($$);
52 #Test 1: Check we get all the right messages for a default handshake
53 $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
55 checkmessages(DEFAULT_HANDSHAKE, "Default handshake test");
59 my ($handtype, $testname) = @_;
61 subtest $testname => sub {
65 #First count the number of tests
66 for ($numtests = 1; $handmessages[$loop][1] != 0; $loop++) {
67 $numtests++ if (($handmessages[$loop][1] & $handtype) != 0);
70 plan tests => $numtests;
73 foreach my $message (@{$proxy->message_list}) {
74 for (; $handmessages[$loop][1] != 0
75 && ($handmessages[$loop][1] & $handtype) == 0; $loop++) {
78 ok($handmessages[$loop][1] != 0
79 && $message->mt == $handmessages[$loop][0],
80 "Message type check. Got ".$message->mt
81 .", expected ".$handmessages[$loop][0]);
84 ok($handmessages[$loop][1] == 0, "All expected messages processed");