1*e0c4386eSCy Schubert# -*- mode: perl; -*-
2*e0c4386eSCy Schubert# Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
3*e0c4386eSCy Schubert#
4*e0c4386eSCy Schubert# Licensed under the Apache License 2.0 (the "License").  You may not use
5*e0c4386eSCy Schubert# this file except in compliance with the License.  You can obtain a copy
6*e0c4386eSCy Schubert# in the file LICENSE in the source distribution or at
7*e0c4386eSCy Schubert# https://www.openssl.org/source/license.html
8*e0c4386eSCy Schubert
9*e0c4386eSCy Schubert
10*e0c4386eSCy Schubert## Test version negotiation
11*e0c4386eSCy Schubert
12*e0c4386eSCy Schubertuse strict;
13*e0c4386eSCy Schubertuse warnings;
14*e0c4386eSCy Schubert
15*e0c4386eSCy Schubertpackage ssltests;
16*e0c4386eSCy Schubert
17*e0c4386eSCy Schubert
18*e0c4386eSCy Schubertour @tests = (
19*e0c4386eSCy Schubert    {
20*e0c4386eSCy Schubert        name => "alpn-simple",
21*e0c4386eSCy Schubert        server => {
22*e0c4386eSCy Schubert            extra => {
23*e0c4386eSCy Schubert                "ALPNProtocols" => "foo",
24*e0c4386eSCy Schubert            },
25*e0c4386eSCy Schubert        },
26*e0c4386eSCy Schubert        client => {
27*e0c4386eSCy Schubert            extra => {
28*e0c4386eSCy Schubert                "ALPNProtocols" => "foo",
29*e0c4386eSCy Schubert            },
30*e0c4386eSCy Schubert        },
31*e0c4386eSCy Schubert        test => {
32*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => "foo",
33*e0c4386eSCy Schubert        },
34*e0c4386eSCy Schubert    },
35*e0c4386eSCy Schubert    {
36*e0c4386eSCy Schubert        name => "alpn-server-finds-match",
37*e0c4386eSCy Schubert        server => {
38*e0c4386eSCy Schubert            extra => {
39*e0c4386eSCy Schubert                "ALPNProtocols" => "baz,bar",
40*e0c4386eSCy Schubert            },
41*e0c4386eSCy Schubert        },
42*e0c4386eSCy Schubert        client => {
43*e0c4386eSCy Schubert            extra => {
44*e0c4386eSCy Schubert                "ALPNProtocols" => "foo,bar",
45*e0c4386eSCy Schubert            },
46*e0c4386eSCy Schubert        },
47*e0c4386eSCy Schubert        test => {
48*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => "bar",
49*e0c4386eSCy Schubert        },
50*e0c4386eSCy Schubert    },
51*e0c4386eSCy Schubert    {
52*e0c4386eSCy Schubert        name => "alpn-server-honours-server-pref",
53*e0c4386eSCy Schubert        server => {
54*e0c4386eSCy Schubert            extra => {
55*e0c4386eSCy Schubert                "ALPNProtocols" => "bar,foo",
56*e0c4386eSCy Schubert            },
57*e0c4386eSCy Schubert        },
58*e0c4386eSCy Schubert        client => {
59*e0c4386eSCy Schubert            extra => {
60*e0c4386eSCy Schubert                "ALPNProtocols" => "foo,bar",
61*e0c4386eSCy Schubert            },
62*e0c4386eSCy Schubert        },
63*e0c4386eSCy Schubert        test => {
64*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => "bar",
65*e0c4386eSCy Schubert        },
66*e0c4386eSCy Schubert    },
67*e0c4386eSCy Schubert    {
68*e0c4386eSCy Schubert        name => "alpn-alert-on-mismatch",
69*e0c4386eSCy Schubert        server => {
70*e0c4386eSCy Schubert            extra => {
71*e0c4386eSCy Schubert                "ALPNProtocols" => "baz",
72*e0c4386eSCy Schubert            },
73*e0c4386eSCy Schubert        },
74*e0c4386eSCy Schubert        client => {
75*e0c4386eSCy Schubert            extra => {
76*e0c4386eSCy Schubert                "ALPNProtocols" => "foo,bar",
77*e0c4386eSCy Schubert            },
78*e0c4386eSCy Schubert        },
79*e0c4386eSCy Schubert        test => {
80*e0c4386eSCy Schubert            "ExpectedResult" => "ServerFail",
81*e0c4386eSCy Schubert            "ExpectedServerAlert" => "NoApplicationProtocol",
82*e0c4386eSCy Schubert        },
83*e0c4386eSCy Schubert    },
84*e0c4386eSCy Schubert    {
85*e0c4386eSCy Schubert        name => "alpn-no-server-support",
86*e0c4386eSCy Schubert        server => { },
87*e0c4386eSCy Schubert        client => {
88*e0c4386eSCy Schubert            extra => {
89*e0c4386eSCy Schubert                "ALPNProtocols" => "foo",
90*e0c4386eSCy Schubert            },
91*e0c4386eSCy Schubert        },
92*e0c4386eSCy Schubert        test => {
93*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => undef,
94*e0c4386eSCy Schubert        },
95*e0c4386eSCy Schubert    },
96*e0c4386eSCy Schubert    {
97*e0c4386eSCy Schubert        name => "alpn-no-client-support",
98*e0c4386eSCy Schubert        server => {
99*e0c4386eSCy Schubert            extra => {
100*e0c4386eSCy Schubert                "ALPNProtocols" => "foo",
101*e0c4386eSCy Schubert            },
102*e0c4386eSCy Schubert        },
103*e0c4386eSCy Schubert        client => { },
104*e0c4386eSCy Schubert        test => {
105*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => undef,
106*e0c4386eSCy Schubert        },
107*e0c4386eSCy Schubert    },
108*e0c4386eSCy Schubert    {
109*e0c4386eSCy Schubert        name => "alpn-with-sni-no-context-switch",
110*e0c4386eSCy Schubert        server => {
111*e0c4386eSCy Schubert            extra => {
112*e0c4386eSCy Schubert                "ALPNProtocols" => "foo",
113*e0c4386eSCy Schubert                "ServerNameCallback" => "IgnoreMismatch",
114*e0c4386eSCy Schubert            },
115*e0c4386eSCy Schubert        },
116*e0c4386eSCy Schubert        server2 => {
117*e0c4386eSCy Schubert            extra => {
118*e0c4386eSCy Schubert                "ALPNProtocols" => "bar",
119*e0c4386eSCy Schubert            },
120*e0c4386eSCy Schubert        },
121*e0c4386eSCy Schubert        client => {
122*e0c4386eSCy Schubert            extra => {
123*e0c4386eSCy Schubert                "ALPNProtocols" => "foo,bar",
124*e0c4386eSCy Schubert                "ServerName" => "server1",
125*e0c4386eSCy Schubert            },
126*e0c4386eSCy Schubert        },
127*e0c4386eSCy Schubert        test => {
128*e0c4386eSCy Schubert            "ExpectedServerName" => "server1",
129*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => "foo",
130*e0c4386eSCy Schubert        },
131*e0c4386eSCy Schubert    },
132*e0c4386eSCy Schubert    {
133*e0c4386eSCy Schubert        name => "alpn-with-sni-context-switch",
134*e0c4386eSCy Schubert        server => {
135*e0c4386eSCy Schubert            extra => {
136*e0c4386eSCy Schubert                "ALPNProtocols" => "foo",
137*e0c4386eSCy Schubert                "ServerNameCallback" => "IgnoreMismatch",
138*e0c4386eSCy Schubert            },
139*e0c4386eSCy Schubert        },
140*e0c4386eSCy Schubert        server2 => {
141*e0c4386eSCy Schubert            extra => {
142*e0c4386eSCy Schubert                "ALPNProtocols" => "bar",
143*e0c4386eSCy Schubert            },
144*e0c4386eSCy Schubert        },
145*e0c4386eSCy Schubert        client => {
146*e0c4386eSCy Schubert            extra => {
147*e0c4386eSCy Schubert                "ALPNProtocols" => "foo,bar",
148*e0c4386eSCy Schubert                "ServerName" => "server2",
149*e0c4386eSCy Schubert            },
150*e0c4386eSCy Schubert        },
151*e0c4386eSCy Schubert        test => {
152*e0c4386eSCy Schubert            "ExpectedServerName" => "server2",
153*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => "bar",
154*e0c4386eSCy Schubert        },
155*e0c4386eSCy Schubert    },
156*e0c4386eSCy Schubert    {
157*e0c4386eSCy Schubert        name => "alpn-selected-sni-server-supports-alpn",
158*e0c4386eSCy Schubert        server => {
159*e0c4386eSCy Schubert            extra => {
160*e0c4386eSCy Schubert               "ServerNameCallback" => "IgnoreMismatch",
161*e0c4386eSCy Schubert            },
162*e0c4386eSCy Schubert        },
163*e0c4386eSCy Schubert        server2 => {
164*e0c4386eSCy Schubert            extra => {
165*e0c4386eSCy Schubert                "ALPNProtocols" => "bar",
166*e0c4386eSCy Schubert            },
167*e0c4386eSCy Schubert        },
168*e0c4386eSCy Schubert        client => {
169*e0c4386eSCy Schubert            extra => {
170*e0c4386eSCy Schubert                "ALPNProtocols" => "foo,bar",
171*e0c4386eSCy Schubert                "ServerName" => "server2",
172*e0c4386eSCy Schubert            },
173*e0c4386eSCy Schubert        },
174*e0c4386eSCy Schubert        test => {
175*e0c4386eSCy Schubert            "ExpectedServerName" => "server2",
176*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => "bar",
177*e0c4386eSCy Schubert        },
178*e0c4386eSCy Schubert    },
179*e0c4386eSCy Schubert    {
180*e0c4386eSCy Schubert        name => "alpn-selected-sni-server-does-not-support-alpn",
181*e0c4386eSCy Schubert        server => {
182*e0c4386eSCy Schubert            extra => {
183*e0c4386eSCy Schubert                "ALPNProtocols" => "bar",
184*e0c4386eSCy Schubert                "ServerNameCallback" => "IgnoreMismatch",
185*e0c4386eSCy Schubert            },
186*e0c4386eSCy Schubert        },
187*e0c4386eSCy Schubert        server2 => { },
188*e0c4386eSCy Schubert        client => {
189*e0c4386eSCy Schubert            extra => {
190*e0c4386eSCy Schubert                "ALPNProtocols" => "foo,bar",
191*e0c4386eSCy Schubert                "ServerName" => "server2",
192*e0c4386eSCy Schubert            },
193*e0c4386eSCy Schubert        },
194*e0c4386eSCy Schubert        test => {
195*e0c4386eSCy Schubert            "ExpectedServerName" => "server2",
196*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => undef,
197*e0c4386eSCy Schubert        },
198*e0c4386eSCy Schubert    },
199*e0c4386eSCy Schubert    {
200*e0c4386eSCy Schubert        name => "alpn-simple-resumption",
201*e0c4386eSCy Schubert        server => {
202*e0c4386eSCy Schubert            extra => {
203*e0c4386eSCy Schubert                "ALPNProtocols" => "foo",
204*e0c4386eSCy Schubert            },
205*e0c4386eSCy Schubert        },
206*e0c4386eSCy Schubert        client => {
207*e0c4386eSCy Schubert            extra => {
208*e0c4386eSCy Schubert                "ALPNProtocols" => "foo",
209*e0c4386eSCy Schubert            },
210*e0c4386eSCy Schubert        },
211*e0c4386eSCy Schubert        test => {
212*e0c4386eSCy Schubert            "HandshakeMode" => "Resume",
213*e0c4386eSCy Schubert            "ResumptionExpected" => "Yes",
214*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => "foo",
215*e0c4386eSCy Schubert        },
216*e0c4386eSCy Schubert    },
217*e0c4386eSCy Schubert    {
218*e0c4386eSCy Schubert        name => "alpn-server-switch-resumption",
219*e0c4386eSCy Schubert        server => {
220*e0c4386eSCy Schubert            extra => {
221*e0c4386eSCy Schubert                "ALPNProtocols" => "bar,foo",
222*e0c4386eSCy Schubert            },
223*e0c4386eSCy Schubert        },
224*e0c4386eSCy Schubert        resume_server => {
225*e0c4386eSCy Schubert            extra => {
226*e0c4386eSCy Schubert                "ALPNProtocols" => "baz,foo",
227*e0c4386eSCy Schubert            },
228*e0c4386eSCy Schubert        },
229*e0c4386eSCy Schubert        client => {
230*e0c4386eSCy Schubert            extra => {
231*e0c4386eSCy Schubert                "ALPNProtocols" => "foo,bar,baz",
232*e0c4386eSCy Schubert            },
233*e0c4386eSCy Schubert        },
234*e0c4386eSCy Schubert        test => {
235*e0c4386eSCy Schubert            "HandshakeMode" => "Resume",
236*e0c4386eSCy Schubert            "ResumptionExpected" => "Yes",
237*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => "baz",
238*e0c4386eSCy Schubert        },
239*e0c4386eSCy Schubert    },
240*e0c4386eSCy Schubert    {
241*e0c4386eSCy Schubert        name => "alpn-client-switch-resumption",
242*e0c4386eSCy Schubert        server => {
243*e0c4386eSCy Schubert            extra => {
244*e0c4386eSCy Schubert                "ALPNProtocols" => "foo,bar,baz",
245*e0c4386eSCy Schubert            },
246*e0c4386eSCy Schubert        },
247*e0c4386eSCy Schubert        client => {
248*e0c4386eSCy Schubert            extra => {
249*e0c4386eSCy Schubert                "ALPNProtocols" => "foo,baz",
250*e0c4386eSCy Schubert            },
251*e0c4386eSCy Schubert        },
252*e0c4386eSCy Schubert        resume_client => {
253*e0c4386eSCy Schubert            extra => {
254*e0c4386eSCy Schubert                "ALPNProtocols" => "bar,baz",
255*e0c4386eSCy Schubert            },
256*e0c4386eSCy Schubert        },
257*e0c4386eSCy Schubert        test => {
258*e0c4386eSCy Schubert            "HandshakeMode" => "Resume",
259*e0c4386eSCy Schubert            "ResumptionExpected" => "Yes",
260*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => "bar",
261*e0c4386eSCy Schubert        },
262*e0c4386eSCy Schubert    },
263*e0c4386eSCy Schubert    {
264*e0c4386eSCy Schubert        name => "alpn-alert-on-mismatch-resumption",
265*e0c4386eSCy Schubert        server => {
266*e0c4386eSCy Schubert            extra => {
267*e0c4386eSCy Schubert                "ALPNProtocols" => "bar",
268*e0c4386eSCy Schubert            },
269*e0c4386eSCy Schubert        },
270*e0c4386eSCy Schubert        resume_server => {
271*e0c4386eSCy Schubert            extra => {
272*e0c4386eSCy Schubert                "ALPNProtocols" => "baz",
273*e0c4386eSCy Schubert            },
274*e0c4386eSCy Schubert        },
275*e0c4386eSCy Schubert        client => {
276*e0c4386eSCy Schubert            extra => {
277*e0c4386eSCy Schubert                "ALPNProtocols" => "foo,bar",
278*e0c4386eSCy Schubert            },
279*e0c4386eSCy Schubert        },
280*e0c4386eSCy Schubert        test => {
281*e0c4386eSCy Schubert            "HandshakeMode" => "Resume",
282*e0c4386eSCy Schubert            "ExpectedResult" => "ServerFail",
283*e0c4386eSCy Schubert            "ExpectedServerAlert" => "NoApplicationProtocol",
284*e0c4386eSCy Schubert        },
285*e0c4386eSCy Schubert    },
286*e0c4386eSCy Schubert    {
287*e0c4386eSCy Schubert        name => "alpn-no-server-support-resumption",
288*e0c4386eSCy Schubert        server => {
289*e0c4386eSCy Schubert            extra => {
290*e0c4386eSCy Schubert                "ALPNProtocols" => "foo",
291*e0c4386eSCy Schubert            },
292*e0c4386eSCy Schubert        },
293*e0c4386eSCy Schubert        resume_server => { },
294*e0c4386eSCy Schubert        client => {
295*e0c4386eSCy Schubert            extra => {
296*e0c4386eSCy Schubert                "ALPNProtocols" => "foo",
297*e0c4386eSCy Schubert            },
298*e0c4386eSCy Schubert        },
299*e0c4386eSCy Schubert        test => {
300*e0c4386eSCy Schubert            "HandshakeMode" => "Resume",
301*e0c4386eSCy Schubert            "ResumptionExpected" => "Yes",
302*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => undef,
303*e0c4386eSCy Schubert        },
304*e0c4386eSCy Schubert    },
305*e0c4386eSCy Schubert    {
306*e0c4386eSCy Schubert        name => "alpn-no-client-support-resumption",
307*e0c4386eSCy Schubert        server => {
308*e0c4386eSCy Schubert            extra => {
309*e0c4386eSCy Schubert                "ALPNProtocols" => "foo",
310*e0c4386eSCy Schubert            },
311*e0c4386eSCy Schubert        },
312*e0c4386eSCy Schubert        client => {
313*e0c4386eSCy Schubert            extra => {
314*e0c4386eSCy Schubert                "ALPNProtocols" => "foo",
315*e0c4386eSCy Schubert            },
316*e0c4386eSCy Schubert        },
317*e0c4386eSCy Schubert        resume_client => {
318*e0c4386eSCy Schubert        },
319*e0c4386eSCy Schubert        test => {
320*e0c4386eSCy Schubert            "HandshakeMode" => "Resume",
321*e0c4386eSCy Schubert            "ResumptionExpected" => "Yes",
322*e0c4386eSCy Schubert            "ExpectedALPNProtocol" => undef,
323*e0c4386eSCy Schubert        },
324*e0c4386eSCy Schubert    },
325*e0c4386eSCy Schubert);
326