2 # Copyright 2017 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;
14 my $test_name = "test_tls13cookie";
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 TLS1.3 enabled"
27 if disabled("tls1_3");
29 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
31 my $proxy = TLSProxy::Proxy->new(
33 cmdstr(app(["openssl"]), display => 1),
34 srctop_file("apps", "server.pem"),
35 (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
40 #Test 1: Inserting a cookie into an HRR should see it echoed in the ClientHello
41 $proxy->filter(\&cookie_filter);
42 $proxy->serverflags("-curves P-256");
43 $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
45 ok(TLSProxy::Message->success() && $cookieseen == 1, "Cookie seen");
51 # We're only interested in the HRR and subsequent ClientHello
52 if ($proxy->flight != 1 && $proxy->flight != 2) {
57 0x00, 0x06, #Cookie Length
58 0x00, 0x01, #Dummy cookie data (6 bytes)
62 foreach my $message (@{$proxy->message_list}) {
63 if ($message->mt == TLSProxy::Message::MT_HELLO_RETRY_REQUEST) {
65 $message->set_extension(TLSProxy::Message::EXT_COOKIE, $ext);
67 } elsif ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO
68 && ${$message->records}[0]->flight == 2) {
69 #cmp can behave differently dependent on locale
72 $message->extension_data->{TLSProxy::Message::EXT_COOKIE};
74 return if !defined($cookie);
76 return if ($cookie cmp $ext) != 0;