1# -*- mode: perl; -*-
2# Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
3#
4# Licensed under the Apache License 2.0 (the "License").  You may not use
5# this file except in compliance with the License.  You can obtain a copy
6# in the file LICENSE in the source distribution or at
7# https://www.openssl.org/source/license.html
8
9
10## Test Compression
11
12use strict;
13use warnings;
14
15package ssltests;
16use OpenSSL::Test::Utils;
17
18our @tests = ();
19
20our @tests_tls1_3 = (
21    {
22        name => "tlsv1_3-both-compress",
23        server => {
24            "CipherString" => 'DEFAULT@SECLEVEL=1',
25            "Options" => "Compression"
26        },
27        client => {
28            "CipherString" => 'DEFAULT@SECLEVEL=1',
29            "Options" => "Compression"
30        },
31        test => {
32            "CompressionExpected" => "No",
33            "ExpectedResult" => "Success"
34        }
35    },
36    {
37        name => "tlsv1_3-client-compress",
38        server => {
39            "CipherString" => 'DEFAULT@SECLEVEL=1',
40        },
41        client => {
42            "CipherString" => 'DEFAULT@SECLEVEL=1',
43            "Options" => "Compression"
44        },
45        test => {
46            "CompressionExpected" => "No",
47            "ExpectedResult" => "Success"
48        }
49    },
50    {
51        name => "tlsv1_3-server-compress",
52        server => {
53            "CipherString" => 'DEFAULT@SECLEVEL=1',
54            "Options" => "Compression"
55        },
56        client => {
57            "CipherString" => 'DEFAULT@SECLEVEL=1',
58        },
59        test => {
60            "CompressionExpected" => "No",
61            "ExpectedResult" => "Success"
62        }
63    },
64    {
65        name => "tlsv1_3-neither-compress",
66        server => {
67            "CipherString" => 'DEFAULT@SECLEVEL=1',
68        },
69        client => {
70            "CipherString" => 'DEFAULT@SECLEVEL=1',
71        },
72        test => {
73            "CompressionExpected" => "No",
74            "ExpectedResult" => "Success"
75        }
76    },
77);
78our @tests_tls1_2 = (
79    {
80        name => "tlsv1_2-both-compress",
81        server => {
82            "CipherString" => 'DEFAULT@SECLEVEL=1',
83            "Options" => "Compression"
84        },
85        client => {
86            "CipherString" => 'DEFAULT@SECLEVEL=1',
87            "Options" => "Compression",
88            "MaxProtocol" => "TLSv1.2"
89        },
90        test => {
91            "CompressionExpected" => "Yes",
92            "ExpectedResult" => "Success"
93        }
94    },
95    {
96        name => "tlsv1_2-client-compress",
97        server => {
98            "CipherString" => 'DEFAULT@SECLEVEL=1',
99        },
100        client => {
101            "CipherString" => 'DEFAULT@SECLEVEL=1',
102            "Options" => "Compression",
103            "MaxProtocol" => "TLSv1.2"
104        },
105        test => {
106            "CompressionExpected" => "No",
107            "ExpectedResult" => "Success"
108        }
109    },
110    {
111        name => "tlsv1_2-server-compress",
112        server => {
113            "CipherString" => 'DEFAULT@SECLEVEL=1',
114            "Options" => "Compression"
115        },
116        client => {
117            "CipherString" => 'DEFAULT@SECLEVEL=1',
118            "MaxProtocol" => "TLSv1.2"
119        },
120        test => {
121            "CompressionExpected" => "No",
122            "ExpectedResult" => "Success"
123        }
124    },
125    {
126        name => "tlsv1_2-neither-compress",
127        server => {
128            "CipherString" => 'DEFAULT@SECLEVEL=1',
129        },
130        client => {
131            "CipherString" => 'DEFAULT@SECLEVEL=1',
132            "MaxProtocol" => "TLSv1.2"
133        },
134        test => {
135            "CompressionExpected" => "No",
136            "ExpectedResult" => "Success"
137        }
138    },
139);
140
141push @tests, @tests_tls1_3 unless disabled("tls1_3");
142push @tests, @tests_tls1_2 unless alldisabled(("tls1_2", "tls1_1", "tls1",
143                                               "ssl3"));
144