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