Latest update - pre9
This commit is contained in:
@@ -67,6 +67,7 @@ static int test_standard_methods(void)
|
||||
const EVP_PKEY_ASN1_METHOD **tmp;
|
||||
int last_pkey_id = -1;
|
||||
size_t i;
|
||||
int ok = 1;
|
||||
|
||||
for (tmp = standard_methods, i = 0; i < OSSL_NELEM(standard_methods);
|
||||
i++, tmp++) {
|
||||
@@ -75,11 +76,26 @@ static int test_standard_methods(void)
|
||||
break;
|
||||
}
|
||||
last_pkey_id = (*tmp)->pkey_id;
|
||||
|
||||
/*
|
||||
* One of the following must be true:
|
||||
*
|
||||
* pem_str == NULL AND ASN1_PKEY_ALIAS is set
|
||||
* pem_str != NULL AND ASN1_PKEY_ALIAS is clear
|
||||
*
|
||||
* Anything else is an error and may lead to a corrupt ASN1 method table
|
||||
*/
|
||||
if (!TEST_true(((*tmp)->pem_str == NULL && ((*tmp)->pkey_flags & ASN1_PKEY_ALIAS) != 0)
|
||||
|| ((*tmp)->pem_str != NULL && ((*tmp)->pkey_flags & ASN1_PKEY_ALIAS) == 0))) {
|
||||
TEST_note("asn1 standard methods: Index %zu, pkey ID %d, Name=%s",
|
||||
i, (*tmp)->pkey_id, OBJ_nid2sn((*tmp)->pkey_id));
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (TEST_int_ne(last_pkey_id, 0)) {
|
||||
TEST_info("asn1 standard methods: Table order OK");
|
||||
return 1;
|
||||
return ok;
|
||||
}
|
||||
|
||||
TEST_note("asn1 standard methods: out of order");
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
# in the file LICENSE in the source distribution or at
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
use strict;
|
||||
use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
|
||||
use OpenSSL::Test::Utils;
|
||||
use TLSProxy::Proxy;
|
||||
|
||||
my $test_name = "test_tls13alerts";
|
||||
setup($test_name);
|
||||
|
||||
plan skip_all => "TLSProxy isn't usable on $^O"
|
||||
if $^O =~ /^(VMS)$/;
|
||||
|
||||
plan skip_all => "$test_name needs the dynamic engine feature enabled"
|
||||
if disabled("engine") || disabled("dynamic-engine");
|
||||
|
||||
plan skip_all => "$test_name needs the sock feature enabled"
|
||||
if disabled("sock");
|
||||
|
||||
plan skip_all => "$test_name needs TLS1.3 enabled"
|
||||
if disabled("tls1_3");
|
||||
|
||||
$ENV{OPENSSL_ia32cap} = '~0x200000200000000';
|
||||
|
||||
my $proxy = TLSProxy::Proxy->new(
|
||||
undef,
|
||||
cmdstr(app(["openssl"]), display => 1),
|
||||
srctop_file("apps", "server.pem"),
|
||||
(!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
|
||||
);
|
||||
|
||||
#Test 1: We test that a server can handle an unencrypted alert when normally the
|
||||
# next message is encrypted
|
||||
$proxy->filter(\&alert_filter);
|
||||
$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
|
||||
plan tests => 1;
|
||||
my $alert = TLSProxy::Message->alert();
|
||||
ok(TLSProxy::Message->fail() && !$alert->server() && !$alert->encrypted(), "Client sends an unecrypted alert");
|
||||
|
||||
sub alert_filter
|
||||
{
|
||||
my $proxy = shift;
|
||||
|
||||
if ($proxy->flight != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
${$proxy->message_list}[1]->session_id_len(1);
|
||||
${$proxy->message_list}[1]->repack();
|
||||
}
|
||||
@@ -41,14 +41,15 @@ my $proxy = TLSProxy::Proxy->new(
|
||||
|
||||
use constant {
|
||||
DOWNGRADE_TO_TLS_1_2 => 0,
|
||||
DOWNGRADE_TO_TLS_1_1 => 1
|
||||
DOWNGRADE_TO_TLS_1_1 => 1,
|
||||
FALLBACK_FROM_TLS_1_3 => 2,
|
||||
};
|
||||
|
||||
#Test 1: Downgrade from TLSv1.3 to TLSv1.2
|
||||
$proxy->filter(\&downgrade_filter);
|
||||
my $testtype = DOWNGRADE_TO_TLS_1_2;
|
||||
$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
|
||||
plan tests => 3;
|
||||
plan tests => 4;
|
||||
ok(TLSProxy::Message->fail(), "Downgrade TLSv1.3 to TLSv1.2");
|
||||
|
||||
#Test 2: Downgrade from TLSv1.3 to TLSv1.1
|
||||
@@ -64,6 +65,18 @@ $proxy->serverflags("-no_tls1_3");
|
||||
$proxy->start();
|
||||
ok(TLSProxy::Message->fail(), "Downgrade TLSv1.2 to TLSv1.1");
|
||||
|
||||
#Test 4: Client falls back from TLSv1.3 (server does not support the fallback
|
||||
# SCSV)
|
||||
$proxy->clear();
|
||||
$testtype = FALLBACK_FROM_TLS_1_3;
|
||||
$proxy->clientflags("-fallback_scsv -no_tls1_3");
|
||||
$proxy->start();
|
||||
my $alert = TLSProxy::Message->alert();
|
||||
ok(TLSProxy::Message->fail()
|
||||
&& !$alert->server()
|
||||
&& $alert->description() == TLSProxy::Message::AL_DESC_ILLEGAL_PARAMETER,
|
||||
"Fallback from TLSv1.3");
|
||||
|
||||
sub downgrade_filter
|
||||
{
|
||||
my $proxy = shift;
|
||||
@@ -76,17 +89,24 @@ sub downgrade_filter
|
||||
my $message = ${$proxy->message_list}[0];
|
||||
|
||||
my $ext;
|
||||
if ($testtype == DOWNGRADE_TO_TLS_1_2) {
|
||||
$ext = pack "C3",
|
||||
0x02, # Length
|
||||
0x03, 0x03; #TLSv1.2
|
||||
if ($testtype == FALLBACK_FROM_TLS_1_3) {
|
||||
#The default ciphersuite we use for TLSv1.2 without any SCSV
|
||||
my @ciphersuites = (TLSProxy::Message::CIPHER_RSA_WITH_AES_128_CBC_SHA);
|
||||
$message->ciphersuite_len(2 * scalar @ciphersuites);
|
||||
$message->ciphersuites(\@ciphersuites);
|
||||
} else {
|
||||
$ext = pack "C3",
|
||||
0x02, # Length
|
||||
0x03, 0x02; #TLSv1.1
|
||||
}
|
||||
if ($testtype == DOWNGRADE_TO_TLS_1_2) {
|
||||
$ext = pack "C3",
|
||||
0x02, # Length
|
||||
0x03, 0x03; #TLSv1.2
|
||||
} else {
|
||||
$ext = pack "C3",
|
||||
0x02, # Length
|
||||
0x03, 0x02; #TLSv1.1
|
||||
}
|
||||
|
||||
$message->set_extension(TLSProxy::Message::EXT_SUPPORTED_VERSIONS, $ext);
|
||||
$message->set_extension(TLSProxy::Message::EXT_SUPPORTED_VERSIONS, $ext);
|
||||
}
|
||||
|
||||
$message->repack();
|
||||
}
|
||||
|
||||
@@ -84,6 +84,11 @@ static int test_sanity_range(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int test_sanity_memcmp(void)
|
||||
{
|
||||
return CRYPTO_memcmp("ab","cd",2);
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_sanity_null_zero);
|
||||
@@ -92,6 +97,7 @@ int setup_tests(void)
|
||||
ADD_TEST(test_sanity_sign);
|
||||
ADD_TEST(test_sanity_unsigned_conversion);
|
||||
ADD_TEST(test_sanity_range);
|
||||
ADD_TEST(test_sanity_memcmp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -531,11 +531,6 @@ static int test_bn_output(int n)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int test_memcmp(void)
|
||||
{
|
||||
return CRYPTO_memcmp("ab","cd",2);
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_int);
|
||||
@@ -557,7 +552,6 @@ int setup_tests(void)
|
||||
ADD_TEST(test_messages);
|
||||
ADD_TEST(test_single_eval);
|
||||
ADD_TEST(test_output);
|
||||
ADD_TEST(test_memcmp);
|
||||
ADD_ALL_TESTS(test_bn_output, OSSL_NELEM(bn_output_tests));
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user