1 1.1 christos # -*- mode: perl; -*- 2 1.1 christos # Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved. 3 1.1 christos # 4 1.1 christos # Licensed under the Apache License 2.0 (the "License"). You may not use 5 1.1 christos # this file except in compliance with the License. You can obtain a copy 6 1.1 christos # in the file LICENSE in the source distribution or at 7 1.1 christos # https://www.openssl.org/source/license.html 8 1.1 christos 9 1.1 christos 10 1.1 christos ## Test Renegotiation 11 1.1 christos 12 1.1 christos use strict; 13 1.1 christos use warnings; 14 1.1 christos 15 1.1 christos package ssltests; 16 1.1 christos use OpenSSL::Test::Utils; 17 1.1 christos 18 1.1 christos our $fips_mode; 19 1.1 christos 20 1.1 christos our @tests = (); 21 1.1 christos 22 1.1 christos foreach my $sctp ("No", "Yes") 23 1.1 christos { 24 1.1 christos next if disabled("sctp") && $sctp eq "Yes"; 25 1.1 christos next if disabled("dtls1_2") && $fips_mode; 26 1.1 christos 27 1.1 christos my $suffix = ($sctp eq "No") ? "" : "-sctp"; 28 1.1 christos our @tests_basic = ( 29 1.1 christos { 30 1.1 christos name => "renegotiate-client-no-resume".$suffix, 31 1.1 christos server => { 32 1.1 christos "CipherString" => 'DEFAULT:@SECLEVEL=0', 33 1.1 christos "Options" => "NoResumptionOnRenegotiation" 34 1.1 christos }, 35 1.1 christos client => { 36 1.1 christos "CipherString" => 'DEFAULT:@SECLEVEL=0' 37 1.1 christos }, 38 1.1 christos test => { 39 1.1 christos "Method" => "DTLS", 40 1.1 christos "UseSCTP" => $sctp, 41 1.1 christos "HandshakeMode" => "RenegotiateClient", 42 1.1 christos "ResumptionExpected" => "No", 43 1.1 christos "ExpectedResult" => "Success" 44 1.1 christos } 45 1.1 christos }, 46 1.1 christos { 47 1.1 christos name => "renegotiate-client-resume".$suffix, 48 1.1 christos server => { 49 1.1 christos "CipherString" => 'DEFAULT:@SECLEVEL=0' 50 1.1 christos }, 51 1.1 christos client => { 52 1.1 christos "CipherString" => 'DEFAULT:@SECLEVEL=0' 53 1.1 christos }, 54 1.1 christos test => { 55 1.1 christos "Method" => "DTLS", 56 1.1 christos "UseSCTP" => $sctp, 57 1.1 christos "HandshakeMode" => "RenegotiateClient", 58 1.1 christos "ResumptionExpected" => "Yes", 59 1.1 christos "ExpectedResult" => "Success" 60 1.1 christos } 61 1.1 christos }, 62 1.1 christos # Note: Unlike the TLS tests, we will never do resumption with server 63 1.1 christos # initiated reneg. This is because an OpenSSL DTLS client will always do a full 64 1.1 christos # handshake (i.e. it doesn't supply a session id) when it receives a 65 1.1 christos # HelloRequest. This is different to the OpenSSL TLS implementation where an 66 1.1 christos # OpenSSL client will always try an abbreviated handshake (i.e. it will supply 67 1.1 christos # the session id). This goes all the way to commit 48ae85b6f when abbreviated 68 1.1 christos # handshake support was first added. Neither behaviour is wrong, but the 69 1.1 christos # discrepancy is strange. TODO: Should we harmonise the TLS and DTLS behaviour, 70 1.1 christos # and if so, what to? 71 1.1 christos { 72 1.1 christos name => "renegotiate-server-resume".$suffix, 73 1.1 christos server => { 74 1.1 christos "CipherString" => 'DEFAULT:@SECLEVEL=0' 75 1.1 christos }, 76 1.1 christos client => { 77 1.1 christos "CipherString" => 'DEFAULT:@SECLEVEL=0' 78 1.1 christos }, 79 1.1 christos test => { 80 1.1 christos "Method" => "DTLS", 81 1.1 christos "UseSCTP" => $sctp, 82 1.1 christos "HandshakeMode" => "RenegotiateServer", 83 1.1 christos "ResumptionExpected" => "No", 84 1.1 christos "ExpectedResult" => "Success" 85 1.1 christos } 86 1.1 christos }, 87 1.1 christos { 88 1.1 christos name => "renegotiate-client-auth-require".$suffix, 89 1.1 christos server => { 90 1.1 christos "VerifyCAFile" => test_pem("root-cert.pem"), 91 1.1 christos "VerifyMode" => "Require", 92 1.1 christos "CipherString" => 'DEFAULT:@SECLEVEL=0' 93 1.1 christos }, 94 1.1 christos client => { 95 1.1 christos "Certificate" => test_pem("ee-client-chain.pem"), 96 1.1 christos "PrivateKey" => test_pem("ee-key.pem"), 97 1.1 christos "CipherString" => 'DEFAULT:@SECLEVEL=0' 98 1.1 christos }, 99 1.1 christos test => { 100 1.1 christos "Method" => "DTLS", 101 1.1 christos "UseSCTP" => $sctp, 102 1.1 christos "HandshakeMode" => "RenegotiateServer", 103 1.1 christos "ResumptionExpected" => "No", 104 1.1 christos "ExpectedResult" => "Success" 105 1.1 christos } 106 1.1 christos }, 107 1.1 christos { 108 1.1 christos name => "renegotiate-client-auth-once".$suffix, 109 1.1 christos server => { 110 1.1 christos "VerifyCAFile" => test_pem("root-cert.pem"), 111 1.1 christos "VerifyMode" => "Once", 112 1.1 christos "CipherString" => 'DEFAULT:@SECLEVEL=0' 113 1.1 christos }, 114 1.1 christos client => { 115 1.1 christos "Certificate" => test_pem("ee-client-chain.pem"), 116 1.1 christos "PrivateKey" => test_pem("ee-key.pem"), 117 1.1 christos "CipherString" => 'DEFAULT:@SECLEVEL=0' 118 1.1 christos }, 119 1.1 christos test => { 120 1.1 christos "Method" => "DTLS", 121 1.1 christos "UseSCTP" => $sctp, 122 1.1 christos "HandshakeMode" => "RenegotiateServer", 123 1.1 christos "ResumptionExpected" => "No", 124 1.1 christos "ExpectedResult" => "Success" 125 1.1 christos } 126 1.1 christos } 127 1.1 christos ); 128 1.1 christos push @tests, @tests_basic; 129 1.1 christos 130 1.1 christos next if disabled("dtls1_2"); 131 1.1 christos our @tests_dtls1_2 = ( 132 1.1 christos { 133 1.1 christos name => "renegotiate-aead-to-non-aead".$suffix, 134 1.1 christos server => { 135 1.1 christos "Options" => "NoResumptionOnRenegotiation" 136 1.1 christos }, 137 1.1 christos client => { 138 1.1 christos "CipherString" => "AES128-GCM-SHA256", 139 1.1 christos extra => { 140 1.1 christos "RenegotiateCiphers" => "AES128-SHA" 141 1.1 christos } 142 1.1 christos }, 143 1.1 christos test => { 144 1.1 christos "Method" => "DTLS", 145 1.1 christos "UseSCTP" => $sctp, 146 1.1 christos "HandshakeMode" => "RenegotiateClient", 147 1.1 christos "ResumptionExpected" => "No", 148 1.1 christos "ExpectedResult" => "Success" 149 1.1 christos } 150 1.1 christos }, 151 1.1 christos { 152 1.1 christos name => "renegotiate-non-aead-to-aead".$suffix, 153 1.1 christos server => { 154 1.1 christos "Options" => "NoResumptionOnRenegotiation" 155 1.1 christos }, 156 1.1 christos client => { 157 1.1 christos "CipherString" => "AES128-SHA", 158 1.1 christos extra => { 159 1.1 christos "RenegotiateCiphers" => "AES128-GCM-SHA256" 160 1.1 christos } 161 1.1 christos }, 162 1.1 christos test => { 163 1.1 christos "Method" => "DTLS", 164 1.1 christos "UseSCTP" => $sctp, 165 1.1 christos "HandshakeMode" => "RenegotiateClient", 166 1.1 christos "ResumptionExpected" => "No", 167 1.1 christos "ExpectedResult" => "Success" 168 1.1 christos } 169 1.1 christos }, 170 1.1 christos { 171 1.1 christos name => "renegotiate-non-aead-to-non-aead".$suffix, 172 1.1 christos server => { 173 1.1 christos "Options" => "NoResumptionOnRenegotiation" 174 1.1 christos }, 175 1.1 christos client => { 176 1.1 christos "CipherString" => "AES128-SHA", 177 1.1 christos extra => { 178 1.1 christos "RenegotiateCiphers" => "AES256-SHA" 179 1.1 christos } 180 1.1 christos }, 181 1.1 christos test => { 182 1.1 christos "Method" => "DTLS", 183 1.1 christos "UseSCTP" => $sctp, 184 1.1 christos "HandshakeMode" => "RenegotiateClient", 185 1.1 christos "ResumptionExpected" => "No", 186 1.1 christos "ExpectedResult" => "Success" 187 1.1 christos } 188 1.1 christos }, 189 1.1 christos { 190 1.1 christos name => "renegotiate-aead-to-aead".$suffix, 191 1.1 christos server => { 192 1.1 christos "Options" => "NoResumptionOnRenegotiation" 193 1.1 christos }, 194 1.1 christos client => { 195 1.1 christos "CipherString" => "AES128-GCM-SHA256", 196 1.1 christos extra => { 197 1.1 christos "RenegotiateCiphers" => "AES256-GCM-SHA384" 198 1.1 christos } 199 1.1 christos }, 200 1.1 christos test => { 201 1.1 christos "Method" => "DTLS", 202 1.1 christos "UseSCTP" => $sctp, 203 1.1 christos "HandshakeMode" => "RenegotiateClient", 204 1.1 christos "ResumptionExpected" => "No", 205 1.1 christos "ExpectedResult" => "Success" 206 1.1 christos } 207 1.1 christos }, 208 1.1 christos ); 209 1.1 christos push @tests, @tests_dtls1_2; 210 1.1 christos } 211