mirror of
https://github.com/openssl/openssl.git
synced 2024-12-09 05:51:54 +08:00
0f1e51ea11
The previous commits put in place the logic to exchange key_share data. We now need to do something with that information. In <= TLSv1.2 the equivalent of the key_share extension is the ServerKeyExchange and ClientKeyExchange messages. With key_share those two messages are no longer necessary. The commit removes the SKE and CKE messages from the TLSv1.3 state machine. TLSv1.3 is completely different to TLSv1.2 in the messages that it sends and the transitions that are allowed. Therefore, rather than extend the existing <=TLS1.2 state transition functions, we create a whole new set for TLSv1.3. Intially these are still based on the TLSv1.2 ones, but over time they will be amended. The new TLSv1.3 transitions remove SKE and CKE completely. There's also some cleanup for some stuff which is not relevant to TLSv1.3 and is easy to remove, e.g. the DTLS support (we're not doing DTLSv1.3 yet) and NPN. I also disable EXTMS for TLSv1.3. Using it was causing some added complexity, so rather than fix it I removed it, since eventually it will not be needed anyway. Reviewed-by: Rich Salz <rsalz@openssl.org>
444 lines
11 KiB
Perl
444 lines
11 KiB
Perl
# -*- mode: perl; -*-
|
|
# Copyright 2016-2016 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
|
|
|
|
|
|
## Test NPN. Note that NPN is only supported up to TLSv1.2
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
package ssltests;
|
|
|
|
our @tests = (
|
|
{
|
|
name => "npn-simple",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "foo",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"ExpectedNPNProtocol" => "foo",
|
|
},
|
|
},
|
|
{
|
|
name => "npn-client-finds-match",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "baz,bar",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo,bar",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"ExpectedNPNProtocol" => "bar",
|
|
},
|
|
},
|
|
{
|
|
name => "npn-client-honours-server-pref",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "bar,foo",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo,bar",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"ExpectedNPNProtocol" => "bar",
|
|
},
|
|
},
|
|
{
|
|
name => "npn-client-first-pref-on-mismatch",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "baz",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo,bar",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"ExpectedNPNProtocol" => "foo",
|
|
},
|
|
},
|
|
{
|
|
name => "npn-no-server-support",
|
|
server => {},
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"ExpectedNPNProtocol" => undef,
|
|
},
|
|
},
|
|
{
|
|
name => "npn-no-client-support",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "foo",
|
|
},
|
|
},
|
|
client => {
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"ExpectedNPNProtocol" => undef,
|
|
},
|
|
},
|
|
{
|
|
name => "npn-with-sni-no-context-switch",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "foo",
|
|
"ServerNameCallback" => "IgnoreMismatch",
|
|
},
|
|
},
|
|
server2 => {
|
|
extra => {
|
|
"NPNProtocols" => "bar",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo,bar",
|
|
"ServerName" => "server1",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"ExpectedServerName" => "server1",
|
|
"ExpectedNPNProtocol" => "foo",
|
|
},
|
|
},
|
|
{
|
|
name => "npn-with-sni-context-switch",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "foo",
|
|
"ServerNameCallback" => "IgnoreMismatch",
|
|
},
|
|
},
|
|
server2 => {
|
|
extra => {
|
|
"NPNProtocols" => "bar",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo,bar",
|
|
"ServerName" => "server2",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"ExpectedServerName" => "server2",
|
|
"ExpectedNPNProtocol" => "bar",
|
|
},
|
|
},
|
|
{
|
|
name => "npn-selected-sni-server-supports-npn",
|
|
server => {
|
|
extra => {
|
|
"ServerNameCallback" => "IgnoreMismatch",
|
|
},
|
|
},
|
|
server2 => {
|
|
extra => {
|
|
"NPNProtocols" => "bar",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo,bar",
|
|
"ServerName" => "server2",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"ExpectedServerName" => "server2",
|
|
"ExpectedNPNProtocol" => "bar",
|
|
},
|
|
},
|
|
{
|
|
name => "npn-selected-sni-server-does-not-support-npn",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "bar",
|
|
"ServerNameCallback" => "IgnoreMismatch",
|
|
},
|
|
},
|
|
server2 => { },
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo,bar",
|
|
"ServerName" => "server2",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"ExpectedServerName" => "server2",
|
|
"ExpectedNPNProtocol" => undef,
|
|
},
|
|
},
|
|
{
|
|
name => "alpn-preferred-over-npn",
|
|
server => {
|
|
extra => {
|
|
"ALPNProtocols" => "foo",
|
|
"NPNProtocols" => "bar",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"ALPNProtocols" => "foo",
|
|
"NPNProtocols" => "bar",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"ExpectedALPNProtocol" => "foo",
|
|
"ExpectedNPNProtocol" => undef,
|
|
},
|
|
},
|
|
{
|
|
name => "sni-npn-preferred-over-alpn",
|
|
server => {
|
|
extra => {
|
|
"ServerNameCallback" => "IgnoreMismatch",
|
|
"ALPNProtocols" => "foo",
|
|
},
|
|
},
|
|
server2 => {
|
|
extra => {
|
|
"NPNProtocols" => "bar",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"ServerName" => "server2",
|
|
"ALPNProtocols" => "foo",
|
|
"NPNProtocols" => "bar",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"ExpectedALPNProtocol" => undef,
|
|
"ExpectedNPNProtocol" => "bar",
|
|
"ExpectedServerName" => "server2",
|
|
},
|
|
},
|
|
{
|
|
name => "npn-simple-resumption",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "foo",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"HandshakeMode" => "Resume",
|
|
"ResumptionExpected" => "Yes",
|
|
"ExpectedNPNProtocol" => "foo",
|
|
},
|
|
},
|
|
{
|
|
name => "npn-server-switch-resumption",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "bar,foo",
|
|
},
|
|
},
|
|
resume_server => {
|
|
extra => {
|
|
"NPNProtocols" => "baz,foo",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo,bar,baz",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"HandshakeMode" => "Resume",
|
|
"ResumptionExpected" => "Yes",
|
|
"ExpectedNPNProtocol" => "baz",
|
|
},
|
|
},
|
|
{
|
|
name => "npn-client-switch-resumption",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "foo,bar,baz",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo,baz",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
resume_client => {
|
|
extra => {
|
|
"NPNProtocols" => "bar,baz",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"HandshakeMode" => "Resume",
|
|
"ResumptionExpected" => "Yes",
|
|
"ExpectedNPNProtocol" => "bar",
|
|
},
|
|
},
|
|
{
|
|
name => "npn-client-first-pref-on-mismatch-resumption",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "bar",
|
|
},
|
|
},
|
|
resume_server => {
|
|
extra => {
|
|
"NPNProtocols" => "baz",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo,bar",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"HandshakeMode" => "Resume",
|
|
"ResumptionExpected" => "Yes",
|
|
"ExpectedNPNProtocol" => "foo",
|
|
},
|
|
},
|
|
{
|
|
name => "npn-no-server-support-resumption",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "foo",
|
|
},
|
|
},
|
|
resume_server => { },
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"HandshakeMode" => "Resume",
|
|
"ResumptionExpected" => "Yes",
|
|
"ExpectedNPNProtocol" => undef,
|
|
},
|
|
},
|
|
{
|
|
name => "npn-no-client-support-resumption",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "foo",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"NPNProtocols" => "foo",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
resume_client => {
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"HandshakeMode" => "Resume",
|
|
"ResumptionExpected" => "Yes",
|
|
"ExpectedNPNProtocol" => undef,
|
|
},
|
|
},
|
|
{
|
|
name => "alpn-preferred-over-npn-resumption",
|
|
server => {
|
|
extra => {
|
|
"NPNProtocols" => "bar",
|
|
},
|
|
},
|
|
resume_server => {
|
|
extra => {
|
|
"ALPNProtocols" => "foo",
|
|
"NPNProtocols" => "baz",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"ALPNProtocols" => "foo",
|
|
"NPNProtocols" => "bar,baz",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"HandshakeMode" => "Resume",
|
|
"ResumptionExpected" => "Yes",
|
|
"ExpectedALPNProtocol" => "foo",
|
|
"ExpectedNPNProtocol" => undef,
|
|
},
|
|
},
|
|
{
|
|
name => "npn-used-if-alpn-not-supported-resumption",
|
|
server => {
|
|
extra => {
|
|
"ALPNProtocols" => "foo",
|
|
"NPNProtocols" => "bar",
|
|
},
|
|
},
|
|
resume_server => {
|
|
extra => {
|
|
"NPNProtocols" => "baz",
|
|
},
|
|
},
|
|
client => {
|
|
extra => {
|
|
"ALPNProtocols" => "foo",
|
|
"NPNProtocols" => "bar,baz",
|
|
},
|
|
"MaxProtocol" => "TLSv1.2"
|
|
},
|
|
test => {
|
|
"HandshakeMode" => "Resume",
|
|
"ResumptionExpected" => "Yes",
|
|
"ExpectedALPNProtocol" => undef,
|
|
"ExpectedNPNProtocol" => "baz",
|
|
},
|
|
},
|
|
);
|