2 # Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the Apache License 2.0 (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_renegotiation";
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 TLS <= 1.2 enabled"
27 if alldisabled(("ssl3", "tls1", "tls1_1", "tls1_2"));
29 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
30 my $proxy = TLSProxy::Proxy->new(
32 cmdstr(app(["openssl"]), display => 1),
33 srctop_file("apps", "server.pem"),
34 (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
37 #Test 1: A basic renegotiation test
38 $proxy->clientflags("-no_tls1_3");
40 $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
42 ok(TLSProxy::Message->success(), "Basic renegotiation");
44 #Test 2: Client does not send the Reneg SCSV. Reneg should fail
46 $proxy->filter(\&reneg_filter);
47 $proxy->clientflags("-no_tls1_3");
50 ok(TLSProxy::Message->fail(), "No client SCSV");
53 skip "TLSv1.2 or TLSv1.1 disabled", 1
54 if disabled("tls1_2") || disabled("tls1_1");
55 #Test 3: Check that the ClientHello version remains the same in the reneg
58 $proxy->filter(undef);
59 $proxy->ciphers("DEFAULT:\@SECLEVEL=0");
60 $proxy->clientflags("-no_tls1_3 -cipher AES128-SHA:\@SECLEVEL=0");
61 $proxy->serverflags("-no_tls1_3 -no_tls1_2");
66 foreach my $message (@{$proxy->message_list}) {
67 if ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO) {
68 if (!defined $chversion) {
69 $chversion = $message->client_version;
71 if ($chversion == $message->client_version) {
77 ok(TLSProxy::Message->success() && $chmatch,
78 "Check ClientHello version is the same");
85 # We're only interested in the initial ClientHello message
86 if ($proxy->flight != 0) {
90 foreach my $message (@{$proxy->message_list}) {
91 if ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO) {
92 #Remove any SCSV ciphersuites - just leave AES128-SHA (0x002f)
93 my @ciphersuite = (0x002f);
94 $message->ciphersuites(\@ciphersuite);
95 $message->ciphersuite_len(2);