]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/recipes/70-test_tls13messages.t
Add an s_server capability to read an OCSP Response from a file
[thirdparty/openssl.git] / test / recipes / 70-test_tls13messages.t
CommitLineData
c11237c2
MC
1#! /usr/bin/env perl
2# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
3#
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
8
9use strict;
10use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
11use OpenSSL::Test::Utils;
12use TLSProxy::Proxy;
13my $test_name = "test_tls13messages";
14setup($test_name);
15
16plan skip_all => "TLSProxy isn't usable on $^O"
17 if $^O =~ /^(VMS|MSWin32)$/;
18
19plan skip_all => "$test_name needs the dynamic engine feature enabled"
20 if disabled("engine") || disabled("dynamic-engine");
21
22plan skip_all => "$test_name needs the sock feature enabled"
23 if disabled("sock");
24
25plan skip_all => "$test_name needs TLSv1.3 enabled"
26 if disabled("tls1_3");
27
28$ENV{OPENSSL_ia32cap} = '~0x200000200000000';
29
30use constant {
31 DEFAULT_HANDSHAKE => 1
32};
33
34my @handmessages = (
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],
40 [0, 0]
41);
42
43my $proxy = TLSProxy::Proxy->new(
44 undef,
45 cmdstr(app(["openssl"]), display => 1),
46 srctop_file("apps", "server.pem"),
47 (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
48);
49
50sub checkmessages($$);
51
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";
54plan tests => 1;
55checkmessages(DEFAULT_HANDSHAKE, "Default handshake test");
56
57sub checkmessages($$)
58{
59 my ($handtype, $testname) = @_;
60
61 subtest $testname => sub {
62 my $loop = 0;
63 my $numtests;
64
65 #First count the number of tests
66 for ($numtests = 1; $handmessages[$loop][1] != 0; $loop++) {
67 $numtests++ if (($handmessages[$loop][1] & $handtype) != 0);
68 }
69
70 plan tests => $numtests;
71
72 $loop = 0;
73 foreach my $message (@{$proxy->message_list}) {
74 for (; $handmessages[$loop][1] != 0
75 && ($handmessages[$loop][1] & $handtype) == 0; $loop++) {
76 next;
77 }
78 ok($handmessages[$loop][1] != 0
79 && $message->mt == $handmessages[$loop][0],
80 "Message type check. Got ".$message->mt
81 .", expected ".$handmessages[$loop][0]);
82 $loop++;
83 }
84 ok($handmessages[$loop][1] == 0, "All expected messages processed");
85 }
86}