1e1051a39Sopenharmony_ci# -*- mode: perl; -*-
2e1051a39Sopenharmony_ci# Copyright 2017-2020 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_ci
10e1051a39Sopenharmony_ci## Test version negotiation
11e1051a39Sopenharmony_ci
12e1051a39Sopenharmony_ciuse strict;
13e1051a39Sopenharmony_ciuse warnings;
14e1051a39Sopenharmony_ci
15e1051a39Sopenharmony_cipackage ssltests;
16e1051a39Sopenharmony_ciuse OpenSSL::Test::Utils;
17e1051a39Sopenharmony_ci
18e1051a39Sopenharmony_ciour $fips_mode;
19e1051a39Sopenharmony_ci
20e1051a39Sopenharmony_ciour @tests = (
21e1051a39Sopenharmony_ci    {
22e1051a39Sopenharmony_ci        name => "cipher-server-1",
23e1051a39Sopenharmony_ci        server => {
24e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
25e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256",
26e1051a39Sopenharmony_ci    },
27e1051a39Sopenharmony_ci        client => {
28e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
29e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES256-SHA384"
30e1051a39Sopenharmony_ci        },
31e1051a39Sopenharmony_ci        test => {
32e1051a39Sopenharmony_ci            "ExpectedCipher" => "ECDHE-RSA-AES256-SHA384",
33e1051a39Sopenharmony_ci        },
34e1051a39Sopenharmony_ci    },
35e1051a39Sopenharmony_ci    {
36e1051a39Sopenharmony_ci        name => "cipher-server-2",
37e1051a39Sopenharmony_ci        server => {
38e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
39e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256",
40e1051a39Sopenharmony_ci        },
41e1051a39Sopenharmony_ci        client => {
42e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
43e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES128-SHA256"
44e1051a39Sopenharmony_ci        },
45e1051a39Sopenharmony_ci        test => {
46e1051a39Sopenharmony_ci            "ExpectedCipher" => "ECDHE-RSA-AES128-SHA256",
47e1051a39Sopenharmony_ci        },
48e1051a39Sopenharmony_ci    },
49e1051a39Sopenharmony_ci    {
50e1051a39Sopenharmony_ci        name => "cipher-server-client-list",
51e1051a39Sopenharmony_ci        server => {
52e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
53e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256",
54e1051a39Sopenharmony_ci        },
55e1051a39Sopenharmony_ci        client => {
56e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
57e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384",
58e1051a39Sopenharmony_ci        },
59e1051a39Sopenharmony_ci        test => {
60e1051a39Sopenharmony_ci            "ExpectedCipher" => "ECDHE-RSA-AES128-SHA256",
61e1051a39Sopenharmony_ci        },
62e1051a39Sopenharmony_ci    },
63e1051a39Sopenharmony_ci    {
64e1051a39Sopenharmony_ci        name => "cipher-server-pref-1",
65e1051a39Sopenharmony_ci        server => {
66e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
67e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256",
68e1051a39Sopenharmony_ci            "Options" => "ServerPreference",
69e1051a39Sopenharmony_ci        },
70e1051a39Sopenharmony_ci        client => {
71e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
72e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES256-SHA384"
73e1051a39Sopenharmony_ci        },
74e1051a39Sopenharmony_ci        test => {
75e1051a39Sopenharmony_ci            "ExpectedCipher" => "ECDHE-RSA-AES256-SHA384",
76e1051a39Sopenharmony_ci        },
77e1051a39Sopenharmony_ci    },
78e1051a39Sopenharmony_ci    {
79e1051a39Sopenharmony_ci        name => "cipher-server-pref-2",
80e1051a39Sopenharmony_ci        server => {
81e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
82e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256",
83e1051a39Sopenharmony_ci            "Options" => "ServerPreference",
84e1051a39Sopenharmony_ci        },
85e1051a39Sopenharmony_ci        client => {
86e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
87e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES128-SHA256"
88e1051a39Sopenharmony_ci        },
89e1051a39Sopenharmony_ci        test => {
90e1051a39Sopenharmony_ci            "ExpectedCipher" => "ECDHE-RSA-AES128-SHA256",
91e1051a39Sopenharmony_ci        },
92e1051a39Sopenharmony_ci    },
93e1051a39Sopenharmony_ci    {
94e1051a39Sopenharmony_ci        name => "cipher-server-pref-client-list",
95e1051a39Sopenharmony_ci        server => {
96e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
97e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256",
98e1051a39Sopenharmony_ci            "Options" => "ServerPreference",
99e1051a39Sopenharmony_ci        },
100e1051a39Sopenharmony_ci        client => {
101e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
102e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384",
103e1051a39Sopenharmony_ci        },
104e1051a39Sopenharmony_ci        test => {
105e1051a39Sopenharmony_ci            "ExpectedCipher" => "ECDHE-RSA-AES256-SHA384",
106e1051a39Sopenharmony_ci        },
107e1051a39Sopenharmony_ci    },
108e1051a39Sopenharmony_ci    {
109e1051a39Sopenharmony_ci        name => "cipher-server-pref-not-mobile",
110e1051a39Sopenharmony_ci        server => {
111e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
112e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-CHACHA20-POLY1305",
113e1051a39Sopenharmony_ci            "Options" => "ServerPreference",
114e1051a39Sopenharmony_ci        },
115e1051a39Sopenharmony_ci        client => {
116e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
117e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384",
118e1051a39Sopenharmony_ci        },
119e1051a39Sopenharmony_ci        test => {
120e1051a39Sopenharmony_ci            "ExpectedCipher" => "ECDHE-RSA-AES256-SHA384",
121e1051a39Sopenharmony_ci        },
122e1051a39Sopenharmony_ci    },
123e1051a39Sopenharmony_ci    {
124e1051a39Sopenharmony_ci        name => "cipher-server-pref-mobile",
125e1051a39Sopenharmony_ci        server => {
126e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
127e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-CHACHA20-POLY1305",
128e1051a39Sopenharmony_ci            "Options" => "ServerPreference,PrioritizeChaCha",
129e1051a39Sopenharmony_ci        },
130e1051a39Sopenharmony_ci        client => {
131e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
132e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-CHACHA20-POLY1305",
133e1051a39Sopenharmony_ci        },
134e1051a39Sopenharmony_ci        test => {
135e1051a39Sopenharmony_ci            "ExpectedCipher" => "ECDHE-RSA-AES256-SHA384",
136e1051a39Sopenharmony_ci        },
137e1051a39Sopenharmony_ci    },
138e1051a39Sopenharmony_ci);
139e1051a39Sopenharmony_ci
140e1051a39Sopenharmony_cimy @tests_poly1305 = (
141e1051a39Sopenharmony_ci    {
142e1051a39Sopenharmony_ci        name => "cipher-server-pref-mobile2",
143e1051a39Sopenharmony_ci        server => {
144e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
145e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-CHACHA20-POLY1305",
146e1051a39Sopenharmony_ci            "Options" => "ServerPreference,PrioritizeChaCha",
147e1051a39Sopenharmony_ci        },
148e1051a39Sopenharmony_ci        client => {
149e1051a39Sopenharmony_ci            "MaxProtocol" => "TLSv1.2",
150e1051a39Sopenharmony_ci            "CipherString" => "ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384",
151e1051a39Sopenharmony_ci        },
152e1051a39Sopenharmony_ci        test => {
153e1051a39Sopenharmony_ci            "ExpectedCipher" => "ECDHE-RSA-CHACHA20-POLY1305",
154e1051a39Sopenharmony_ci        },
155e1051a39Sopenharmony_ci    },
156e1051a39Sopenharmony_ci);
157e1051a39Sopenharmony_ci
158e1051a39Sopenharmony_cipush @tests, @tests_poly1305
159e1051a39Sopenharmony_ci    unless disabled("poly1305") || disabled("chacha") || $fips_mode;
160