Home | History | Annotate | Line # | Download | only in recipes
      1      1.1  christos #! /usr/bin/env perl
      2  1.1.1.2  christos # Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
      3      1.1  christos #
      4  1.1.1.4  christos # Licensed under the Apache License 2.0 (the "License").  You may not use
      5      1.1  christos # this file except in compliance with the License.  You can obtain a copy
      6      1.1  christos # in the file LICENSE in the source distribution or at
      7      1.1  christos # https://www.openssl.org/source/license.html
      8      1.1  christos 
      9      1.1  christos use strict;
     10      1.1  christos use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
     11      1.1  christos use OpenSSL::Test::Utils;
     12      1.1  christos use TLSProxy::Proxy;
     13      1.1  christos 
     14      1.1  christos my $test_name = "test_sslskewith0p";
     15      1.1  christos setup($test_name);
     16      1.1  christos 
     17      1.1  christos plan skip_all => "TLSProxy isn't usable on $^O"
     18  1.1.1.2  christos     if $^O =~ /^(VMS)$/;
     19      1.1  christos 
     20      1.1  christos plan skip_all => "$test_name needs the dynamic engine feature enabled"
     21      1.1  christos     if disabled("engine") || disabled("dynamic-engine");
     22      1.1  christos 
     23      1.1  christos plan skip_all => "dh is not supported by this OpenSSL build"
     24      1.1  christos     if disabled("dh");
     25      1.1  christos 
     26      1.1  christos plan skip_all => "$test_name needs the sock feature enabled"
     27      1.1  christos     if disabled("sock");
     28      1.1  christos 
     29      1.1  christos plan skip_all => "$test_name needs TLS enabled"
     30      1.1  christos     if alldisabled(available_protocols("tls"));
     31      1.1  christos 
     32      1.1  christos $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
     33      1.1  christos my $proxy = TLSProxy::Proxy->new(
     34      1.1  christos     \&ske_0_p_filter,
     35      1.1  christos     cmdstr(app(["openssl"]), display => 1),
     36      1.1  christos     srctop_file("apps", "server.pem"),
     37      1.1  christos     (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
     38      1.1  christos );
     39      1.1  christos 
     40      1.1  christos #We must use an anon DHE cipher for this test
     41      1.1  christos $proxy->cipherc('ADH-AES128-SHA:@SECLEVEL=0');
     42      1.1  christos $proxy->ciphers('ADH-AES128-SHA:@SECLEVEL=0');
     43      1.1  christos 
     44  1.1.1.3  christos $proxy->clientflags("-no_tls1_3");
     45      1.1  christos $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
     46      1.1  christos plan tests => 1;
     47      1.1  christos ok(TLSProxy::Message->fail, "ServerKeyExchange with 0 p");
     48      1.1  christos 
     49      1.1  christos sub ske_0_p_filter
     50      1.1  christos {
     51      1.1  christos     my $proxy = shift;
     52      1.1  christos 
     53      1.1  christos     # We're only interested in the SKE - always in flight 1
     54      1.1  christos     if ($proxy->flight != 1) {
     55      1.1  christos         return;
     56      1.1  christos     }
     57      1.1  christos 
     58      1.1  christos     foreach my $message (@{$proxy->message_list}) {
     59      1.1  christos         if ($message->mt == TLSProxy::Message::MT_SERVER_KEY_EXCHANGE) {
     60      1.1  christos             #Set p to a value of 0
     61      1.1  christos             $message->p(pack('C', 0));
     62      1.1  christos 
     63      1.1  christos             $message->repack();
     64      1.1  christos         }
     65      1.1  christos     }
     66      1.1  christos }
     67