2016-05-31 14:42:58 +00:00
|
|
|
# -*- mode: perl; -*-
|
|
|
|
|
|
|
|
## SSL test configurations
|
|
|
|
|
|
|
|
package ssltests;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use OpenSSL::Test;
|
2017-04-24 10:19:05 +00:00
|
|
|
use OpenSSL::Test::Utils qw(anydisabled disabled);
|
2016-05-31 14:42:58 +00:00
|
|
|
setup("no_test_here");
|
|
|
|
|
|
|
|
# We test version-flexible negotiation (undef) and each protocol version.
|
2017-03-14 13:56:22 +00:00
|
|
|
my @protocols = (undef, "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2", "DTLSv1", "DTLSv1.2");
|
2016-05-31 14:42:58 +00:00
|
|
|
|
|
|
|
my @is_disabled = (0);
|
2017-03-14 13:56:22 +00:00
|
|
|
push @is_disabled, anydisabled("ssl3", "tls1", "tls1_1", "tls1_2", "dtls1", "dtls1_2");
|
2016-05-31 14:42:58 +00:00
|
|
|
|
|
|
|
our @tests = ();
|
|
|
|
|
|
|
|
sub generate_tests() {
|
|
|
|
foreach (0..$#protocols) {
|
|
|
|
my $protocol = $protocols[$_];
|
|
|
|
my $protocol_name = $protocol || "flex";
|
2016-06-22 18:41:03 +00:00
|
|
|
my $caalert;
|
2017-03-14 13:56:22 +00:00
|
|
|
my $method;
|
2017-04-24 10:19:05 +00:00
|
|
|
my $sctpenabled = 0;
|
2016-05-31 14:42:58 +00:00
|
|
|
if (!$is_disabled[$_]) {
|
2016-06-22 18:41:03 +00:00
|
|
|
if ($protocol_name eq "SSLv3") {
|
|
|
|
$caalert = "BadCertificate";
|
|
|
|
} else {
|
|
|
|
$caalert = "UnknownCA";
|
|
|
|
}
|
2017-03-14 13:56:22 +00:00
|
|
|
if ($protocol_name =~ m/^DTLS/) {
|
|
|
|
$method = "DTLS";
|
2017-04-24 10:19:05 +00:00
|
|
|
$sctpenabled = 1 if !disabled("sctp");
|
2017-03-14 13:56:22 +00:00
|
|
|
}
|
2017-01-15 15:59:48 +00:00
|
|
|
my $clihash;
|
2017-01-27 15:56:47 +00:00
|
|
|
my $clisigtype;
|
2017-01-15 15:59:48 +00:00
|
|
|
my $clisigalgs;
|
2017-01-27 15:56:47 +00:00
|
|
|
# TODO(TLS1.3) add TLSv1.3 versions
|
2017-01-15 15:59:48 +00:00
|
|
|
if ($protocol_name eq "TLSv1.2") {
|
|
|
|
$clihash = "SHA256";
|
2017-01-27 15:56:47 +00:00
|
|
|
$clisigtype = "RSA";
|
2017-01-15 15:59:48 +00:00
|
|
|
$clisigalgs = "SHA256+RSA";
|
|
|
|
}
|
2017-04-24 10:19:05 +00:00
|
|
|
for (my $sctp = 0; $sctp <= $sctpenabled; $sctp++) {
|
|
|
|
# Sanity-check simple handshake.
|
|
|
|
push @tests, {
|
|
|
|
name => "server-auth-${protocol_name}"
|
|
|
|
.($sctp ? "-sctp" : ""),
|
|
|
|
server => {
|
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol
|
|
|
|
},
|
|
|
|
client => {
|
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol
|
|
|
|
},
|
|
|
|
test => {
|
|
|
|
"ExpectedResult" => "Success",
|
|
|
|
"Method" => $method,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
$tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
|
2016-05-31 14:42:58 +00:00
|
|
|
|
2017-04-24 10:19:05 +00:00
|
|
|
# Handshake with client cert requested but not required or received.
|
|
|
|
push @tests, {
|
|
|
|
name => "client-auth-${protocol_name}-request"
|
|
|
|
.($sctp ? "-sctp" : ""),
|
|
|
|
server => {
|
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
|
|
|
"VerifyMode" => "Request"
|
|
|
|
},
|
|
|
|
client => {
|
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol
|
|
|
|
},
|
|
|
|
test => {
|
|
|
|
"ExpectedResult" => "Success",
|
|
|
|
"Method" => $method,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
$tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
|
2016-05-31 14:42:58 +00:00
|
|
|
|
2017-04-24 10:19:05 +00:00
|
|
|
# Handshake with client cert required but not present.
|
|
|
|
push @tests, {
|
|
|
|
name => "client-auth-${protocol_name}-require-fail"
|
|
|
|
.($sctp ? "-sctp" : ""),
|
|
|
|
server => {
|
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
|
|
|
"VerifyCAFile" => test_pem("root-cert.pem"),
|
|
|
|
"VerifyMode" => "Require",
|
|
|
|
},
|
|
|
|
client => {
|
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol
|
|
|
|
},
|
|
|
|
test => {
|
|
|
|
"ExpectedResult" => "ServerFail",
|
2018-07-30 08:13:14 +00:00
|
|
|
"ExpectedServerAlert" =>
|
|
|
|
($protocol_name eq "flex" && !disabled("tls1_3"))
|
|
|
|
? "CertificateRequired" : "HandshakeFailure",
|
2017-04-24 10:19:05 +00:00
|
|
|
"Method" => $method,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
$tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
|
2016-05-31 14:42:58 +00:00
|
|
|
|
2017-04-24 10:19:05 +00:00
|
|
|
# Successful handshake with client authentication.
|
|
|
|
push @tests, {
|
|
|
|
name => "client-auth-${protocol_name}-require"
|
|
|
|
.($sctp ? "-sctp" : ""),
|
|
|
|
server => {
|
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
|
|
|
"ClientSignatureAlgorithms" => $clisigalgs,
|
|
|
|
"VerifyCAFile" => test_pem("root-cert.pem"),
|
|
|
|
"VerifyMode" => "Request",
|
|
|
|
},
|
|
|
|
client => {
|
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
|
|
|
"Certificate" => test_pem("ee-client-chain.pem"),
|
|
|
|
"PrivateKey" => test_pem("ee-key.pem"),
|
|
|
|
},
|
|
|
|
test => {
|
|
|
|
"ExpectedResult" => "Success",
|
|
|
|
"ExpectedClientCertType" => "RSA",
|
|
|
|
"ExpectedClientSignType" => $clisigtype,
|
|
|
|
"ExpectedClientSignHash" => $clihash,
|
|
|
|
"ExpectedClientCANames" => "empty",
|
|
|
|
"Method" => $method,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
$tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
|
2017-03-15 17:26:05 +00:00
|
|
|
|
2017-04-24 10:19:05 +00:00
|
|
|
# Successful handshake with client authentication non-empty names
|
|
|
|
push @tests, {
|
|
|
|
name => "client-auth-${protocol_name}-require-non-empty-names"
|
|
|
|
.($sctp ? "-sctp" : ""),
|
|
|
|
server => {
|
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
|
|
|
"ClientSignatureAlgorithms" => $clisigalgs,
|
|
|
|
"ClientCAFile" => test_pem("root-cert.pem"),
|
|
|
|
"VerifyCAFile" => test_pem("root-cert.pem"),
|
|
|
|
"VerifyMode" => "Request",
|
|
|
|
},
|
|
|
|
client => {
|
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
|
|
|
"Certificate" => test_pem("ee-client-chain.pem"),
|
|
|
|
"PrivateKey" => test_pem("ee-key.pem"),
|
|
|
|
},
|
|
|
|
test => {
|
|
|
|
"ExpectedResult" => "Success",
|
|
|
|
"ExpectedClientCertType" => "RSA",
|
|
|
|
"ExpectedClientSignType" => $clisigtype,
|
|
|
|
"ExpectedClientSignHash" => $clihash,
|
|
|
|
"ExpectedClientCANames" => test_pem("root-cert.pem"),
|
|
|
|
"Method" => $method,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
$tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
|
2016-05-31 14:42:58 +00:00
|
|
|
|
2017-04-24 10:19:05 +00:00
|
|
|
# Handshake with client authentication but without the root certificate.
|
|
|
|
push @tests, {
|
|
|
|
name => "client-auth-${protocol_name}-noroot"
|
|
|
|
.($sctp ? "-sctp" : ""),
|
|
|
|
server => {
|
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
|
|
|
"VerifyMode" => "Require",
|
|
|
|
},
|
|
|
|
client => {
|
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
|
|
|
"Certificate" => test_pem("ee-client-chain.pem"),
|
|
|
|
"PrivateKey" => test_pem("ee-key.pem"),
|
|
|
|
},
|
|
|
|
test => {
|
|
|
|
"ExpectedResult" => "ServerFail",
|
|
|
|
"ExpectedServerAlert" => $caalert,
|
|
|
|
"Method" => $method,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
$tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
|
|
|
|
}
|
2016-05-31 14:42:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-14 13:56:22 +00:00
|
|
|
|
2016-05-31 14:42:58 +00:00
|
|
|
generate_tests();
|