Reset executable bits on files where not needed.
[openssl.git] / test / recipes / 70-test_renegotiation.t
1 #! /usr/bin/env perl
2 # Copyright 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
9 use strict;
10 use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
11 use OpenSSL::Test::Utils;
12 use TLSProxy::Proxy;
13
14 my $test_name = "test_renegotiation";
15 setup($test_name);
16
17 plan skip_all => "TLSProxy isn't usable on $^O"
18     if $^O =~ /^(VMS|MSWin32)$/;
19
20 plan skip_all => "$test_name needs the dynamic engine feature enabled"
21     if disabled("engine") || disabled("dynamic-engine");
22
23 plan skip_all => "$test_name needs the sock feature enabled"
24     if disabled("sock");
25
26 plan skip_all => "$test_name needs TLS <= 1.2 enabled"
27     if alldisabled(("ssl3", "tls1", "tls1_1", "tls1_2"));
28
29 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
30 my $proxy = TLSProxy::Proxy->new(
31     undef,
32     cmdstr(app(["openssl"]), display => 1),
33     srctop_file("apps", "server.pem"),
34     (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
35 );
36
37 #Test 1: A basic renegotiation test
38 $proxy->clientflags("-no_tls1_3");
39 $proxy->reneg(1);
40 $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
41 plan tests => 2;
42 ok(TLSProxy::Message->success(), "Basic renegotiation");
43
44 #Test 2: Client does not send the Reneg SCSV. Reneg should fail
45 $proxy->clear();
46 $proxy->filter(\&reneg_filter);
47 $proxy->clientflags("-no_tls1_3");
48 $proxy->reneg(1);
49 $proxy->start();
50 ok(TLSProxy::Message->fail(), "No client SCSV");
51
52 sub reneg_filter
53 {
54     my $proxy = shift;
55
56     # We're only interested in the initial ClientHello message
57     if ($proxy->flight != 0) {
58         return;
59     }
60
61     foreach my $message (@{$proxy->message_list}) {
62         if ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO) {
63             #Remove any SCSV ciphersuites - just leave AES128-SHA (0x002f)
64             my @ciphersuite = (0x002f);
65             $message->ciphersuites(\@ciphersuite);
66             $message->ciphersuite_len(2);
67             $message->repack();
68         }
69     }
70 }