]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/recipes/70-test_sslskewith0p.t
Update copyright year
[thirdparty/openssl.git] / test / recipes / 70-test_sslskewith0p.t
CommitLineData
596d6b7e 1#! /usr/bin/env perl
6738bf14 2# Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
c2a34c58 3#
596d6b7e
RS
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
c2a34c58
MC
8
9use strict;
42e0ccdf 10use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
94d61512 11use OpenSSL::Test::Utils;
c2a34c58
MC
12use TLSProxy::Proxy;
13
25be5f44
RL
14my $test_name = "test_sslskewith0p";
15setup($test_name);
16
60f9f1e1 17plan skip_all => "TLSProxy isn't usable on $^O"
c5856878 18 if $^O =~ /^(VMS)$/;
60f9f1e1 19
2dd400bd 20plan skip_all => "$test_name needs the dynamic engine feature enabled"
19ab5790 21 if disabled("engine") || disabled("dynamic-engine");
25be5f44 22
94d61512
BL
23plan skip_all => "dh is not supported by this OpenSSL build"
24 if disabled("dh");
25
f9e55034
MC
26plan skip_all => "$test_name needs the sock feature enabled"
27 if disabled("sock");
28
b273fcc5
MC
29plan skip_all => "$test_name needs TLS enabled"
30 if alldisabled(available_protocols("tls"));
31
25be5f44 32$ENV{OPENSSL_ia32cap} = '~0x200000200000000';
c2a34c58
MC
33my $proxy = TLSProxy::Proxy->new(
34 \&ske_0_p_filter,
25c78440 35 cmdstr(app(["openssl"]), display => 1),
b44b935e
RL
36 srctop_file("apps", "server.pem"),
37 (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
c2a34c58
MC
38);
39
40#We must use an anon DHE cipher for this test
41$proxy->cipherc('ADH-AES128-SHA:@SECLEVEL=0');
42$proxy->ciphers('ADH-AES128-SHA:@SECLEVEL=0');
43
79d8c167 44$proxy->clientflags("-no_tls1_3");
b02b5743
MC
45$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
46plan tests => 1;
25be5f44 47ok(TLSProxy::Message->fail, "ServerKeyExchange with 0 p");
c2a34c58
MC
48
49sub ske_0_p_filter
50{
51 my $proxy = shift;
52
53 # We're only interested in the SKE - always in flight 1
54 if ($proxy->flight != 1) {
55 return;
56 }
57
58 foreach my $message (@{$proxy->message_list}) {
59 if ($message->mt == TLSProxy::Message::MT_SERVER_KEY_EXCHANGE) {
60 #Set p to a value of 0
61 $message->p(pack('C', 0));
62
63 $message->repack();
64 }
65 }
66}