blob: b6c03224efd0c1ad1b9be26fd85e228abf372e02 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Bence Szépkútia2947ac2020-08-19 16:37:36 +02005# Copyright The Mbed TLS Contributors
Bence Szépkútif744bd72020-06-05 13:02:18 +02006# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7#
8# This file is provided under the Apache License 2.0, or the
9# GNU General Public License v2.0 or later.
10#
11# **********
12# Apache License 2.0:
Bence Szépkúti51b41d52020-05-26 01:54:15 +020013#
14# Licensed under the Apache License, Version 2.0 (the "License"); you may
15# not use this file except in compliance with the License.
16# You may obtain a copy of the License at
17#
18# http://www.apache.org/licenses/LICENSE-2.0
19#
20# Unless required by applicable law or agreed to in writing, software
21# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23# See the License for the specific language governing permissions and
24# limitations under the License.
25#
Bence Szépkútif744bd72020-06-05 13:02:18 +020026# **********
27#
28# **********
29# GNU General Public License v2.0 or later:
30#
31# This program is free software; you can redistribute it and/or modify
32# it under the terms of the GNU General Public License as published by
33# the Free Software Foundation; either version 2 of the License, or
34# (at your option) any later version.
35#
36# This program is distributed in the hope that it will be useful,
37# but WITHOUT ANY WARRANTY; without even the implied warranty of
38# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39# GNU General Public License for more details.
40#
41# You should have received a copy of the GNU General Public License along
42# with this program; if not, write to the Free Software Foundation, Inc.,
43# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
44#
45# **********
46#
Simon Butcher58eddef2016-05-19 23:43:11 +010047# Purpose
48#
49# Executes tests to prove various TLS/SSL options and extensions.
50#
51# The goal is not to cover every ciphersuite/version, but instead to cover
52# specific options (max fragment length, truncated hmac, etc) or procedures
53# (session resumption from cache or ticket, renego, etc).
54#
55# The tests assume a build with default options, with exceptions expressed
56# with a dependency. The tests focus on functionality and do not consider
57# performance.
58#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010059
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010060set -u
61
Jaeden Ameroa258ccd2019-07-03 13:51:04 +010062# Limit the size of each log to 10 GiB, in case of failures with this script
63# where it may output seemingly unlimited length error logs.
64ulimit -f 20971520
65
Angus Grattonc4dd0732018-04-11 16:28:39 +100066if cd $( dirname $0 ); then :; else
67 echo "cd $( dirname $0 ) failed" >&2
68 exit 1
69fi
70
Antonin Décimod5f47592019-01-23 15:24:37 +010071# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010072: ${P_SRV:=../programs/ssl/ssl_server2}
73: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020074: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010075: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020076: ${GNUTLS_CLI:=gnutls-cli}
77: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020078: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010079
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020080O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010081O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020082G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010083G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020084TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010085
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020086# alternative versions of OpenSSL and GnuTLS (no default path)
87
88if [ -n "${OPENSSL_LEGACY:-}" ]; then
89 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
90 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
91else
92 O_LEGACY_SRV=false
93 O_LEGACY_CLI=false
94fi
95
Hanno Becker58e9dc32018-08-17 15:53:21 +010096if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020097 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
98else
99 G_NEXT_SRV=false
100fi
101
Hanno Becker58e9dc32018-08-17 15:53:21 +0100102if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200103 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
104else
105 G_NEXT_CLI=false
106fi
107
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100108TESTS=0
109FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200110SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100111
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000112CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +0200113
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100114MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100115FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200116EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100117
Paul Bakkere20310a2016-05-10 11:18:17 +0100118SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +0100119RUN_TEST_NUMBER=''
120
Paul Bakkeracaac852016-05-10 11:47:13 +0100121PRESERVE_LOGS=0
122
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200123# Pick a "unique" server port in the range 10000-19999, and a proxy
124# port which is this plus 10000. Each port number may be independently
125# overridden by a command line option.
126SRV_PORT=$(($$ % 10000 + 10000))
127PXY_PORT=$((SRV_PORT + 10000))
128
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100129print_usage() {
130 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100131 printf " -h|--help\tPrint this help.\n"
132 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskine663d0992020-08-26 22:50:38 +0200133 printf " -f|--filter\tOnly matching tests are executed (BRE)\n"
134 printf " -e|--exclude\tMatching tests are excluded (BRE)\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100135 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100136 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100137 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200138 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
139 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100140 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100141}
142
143get_options() {
144 while [ $# -gt 0 ]; do
145 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100146 -f|--filter)
147 shift; FILTER=$1
148 ;;
149 -e|--exclude)
150 shift; EXCLUDE=$1
151 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100152 -m|--memcheck)
153 MEMCHECK=1
154 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100155 -n|--number)
156 shift; RUN_TEST_NUMBER=$1
157 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100158 -s|--show-numbers)
159 SHOW_TEST_NUMBER=1
160 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100161 -p|--preserve-logs)
162 PRESERVE_LOGS=1
163 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200164 --port)
165 shift; SRV_PORT=$1
166 ;;
167 --proxy-port)
168 shift; PXY_PORT=$1
169 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100170 --seed)
171 shift; SEED="$1"
172 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100173 -h|--help)
174 print_usage
175 exit 0
176 ;;
177 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200178 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100179 print_usage
180 exit 1
181 ;;
182 esac
183 shift
184 done
185}
186
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100187# Skip next test; use this macro to skip tests which are legitimate
188# in theory and expected to be re-introduced at some point, but
189# aren't expected to succeed at the moment due to problems outside
190# our control (such as bugs in other TLS implementations).
191skip_next_test() {
192 SKIP_NEXT="YES"
193}
194
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100195# skip next test if the flag is not enabled in config.h
196requires_config_enabled() {
197 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
198 SKIP_NEXT="YES"
199 fi
200}
201
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200202# skip next test if the flag is enabled in config.h
203requires_config_disabled() {
204 if grep "^#define $1" $CONFIG_H > /dev/null; then
205 SKIP_NEXT="YES"
206 fi
207}
208
Hanno Becker7c48dd12018-08-28 16:09:22 +0100209get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100210 # This function uses the query_config command line option to query the
211 # required Mbed TLS compile time configuration from the ssl_server2
212 # program. The command will always return a success value if the
213 # configuration is defined and the value will be printed to stdout.
214 #
215 # Note that if the configuration is not defined or is defined to nothing,
216 # the output of this function will be an empty string.
217 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100218}
219
220requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100221 VAL="$( get_config_value_or_default "$1" )"
222 if [ -z "$VAL" ]; then
223 # Should never happen
224 echo "Mbed TLS configuration $1 is not defined"
225 exit 1
226 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100227 SKIP_NEXT="YES"
228 fi
229}
230
231requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100232 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100233 if [ -z "$VAL" ]; then
234 # Should never happen
235 echo "Mbed TLS configuration $1 is not defined"
236 exit 1
237 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100238 SKIP_NEXT="YES"
239 fi
240}
241
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200242# skip next test if OpenSSL doesn't support FALLBACK_SCSV
243requires_openssl_with_fallback_scsv() {
244 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
245 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
246 then
247 OPENSSL_HAS_FBSCSV="YES"
248 else
249 OPENSSL_HAS_FBSCSV="NO"
250 fi
251 fi
252 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
253 SKIP_NEXT="YES"
254 fi
255}
256
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200257# skip next test if GnuTLS isn't available
258requires_gnutls() {
259 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200260 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200261 GNUTLS_AVAILABLE="YES"
262 else
263 GNUTLS_AVAILABLE="NO"
264 fi
265 fi
266 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
267 SKIP_NEXT="YES"
268 fi
269}
270
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200271# skip next test if GnuTLS-next isn't available
272requires_gnutls_next() {
273 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
274 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
275 GNUTLS_NEXT_AVAILABLE="YES"
276 else
277 GNUTLS_NEXT_AVAILABLE="NO"
278 fi
279 fi
280 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
281 SKIP_NEXT="YES"
282 fi
283}
284
285# skip next test if OpenSSL-legacy isn't available
286requires_openssl_legacy() {
287 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
288 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
289 OPENSSL_LEGACY_AVAILABLE="YES"
290 else
291 OPENSSL_LEGACY_AVAILABLE="NO"
292 fi
293 fi
294 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
295 SKIP_NEXT="YES"
296 fi
297}
298
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200299# skip next test if IPv6 isn't available on this host
300requires_ipv6() {
301 if [ -z "${HAS_IPV6:-}" ]; then
302 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
303 SRV_PID=$!
304 sleep 1
305 kill $SRV_PID >/dev/null 2>&1
306 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
307 HAS_IPV6="NO"
308 else
309 HAS_IPV6="YES"
310 fi
311 rm -r $SRV_OUT
312 fi
313
314 if [ "$HAS_IPV6" = "NO" ]; then
315 SKIP_NEXT="YES"
316 fi
317}
318
Andrzej Kurekb4593462018-10-11 08:43:30 -0400319# skip next test if it's i686 or uname is not available
320requires_not_i686() {
321 if [ -z "${IS_I686:-}" ]; then
322 IS_I686="YES"
323 if which "uname" >/dev/null 2>&1; then
324 if [ -z "$(uname -a | grep i686)" ]; then
325 IS_I686="NO"
326 fi
327 fi
328 fi
329 if [ "$IS_I686" = "YES" ]; then
330 SKIP_NEXT="YES"
331 fi
332}
333
Angus Grattonc4dd0732018-04-11 16:28:39 +1000334# Calculate the input & output maximum content lengths set in the config
335MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
336MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
337MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
338
339if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
340 MAX_CONTENT_LEN="$MAX_IN_LEN"
341fi
342if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
343 MAX_CONTENT_LEN="$MAX_OUT_LEN"
344fi
345
346# skip the next test if the SSL output buffer is less than 16KB
347requires_full_size_output_buffer() {
348 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
349 SKIP_NEXT="YES"
350 fi
351}
352
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200353# skip the next test if valgrind is in use
354not_with_valgrind() {
355 if [ "$MEMCHECK" -gt 0 ]; then
356 SKIP_NEXT="YES"
357 fi
358}
359
Paul Bakker362689d2016-05-13 10:33:25 +0100360# skip the next test if valgrind is NOT in use
361only_with_valgrind() {
362 if [ "$MEMCHECK" -eq 0 ]; then
363 SKIP_NEXT="YES"
364 fi
365}
366
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200367# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100368client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200369 CLI_DELAY_FACTOR=$1
370}
371
Janos Follath74537a62016-09-02 13:45:28 +0100372# wait for the given seconds after the client finished in the next test
373server_needs_more_time() {
374 SRV_DELAY_SECONDS=$1
375}
376
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100377# print_name <name>
378print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100379 TESTS=$(( $TESTS + 1 ))
380 LINE=""
381
382 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
383 LINE="$TESTS "
384 fi
385
386 LINE="$LINE$1"
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200387 printf "%s " "$LINE"
Paul Bakkere20310a2016-05-10 11:18:17 +0100388 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100389 for i in `seq 1 $LEN`; do printf '.'; done
390 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100391
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100392}
393
394# fail <message>
395fail() {
396 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100397 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100398
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200399 mv $SRV_OUT o-srv-${TESTS}.log
400 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200401 if [ -n "$PXY_CMD" ]; then
402 mv $PXY_OUT o-pxy-${TESTS}.log
403 fi
404 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100405
Manuel Pégourié-Gonnarde63fc6d2020-06-08 11:49:05 +0200406 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200407 echo " ! server output:"
408 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200409 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200410 echo " ! client output:"
411 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200412 if [ -n "$PXY_CMD" ]; then
413 echo " ! ========================================================"
414 echo " ! proxy output:"
415 cat o-pxy-${TESTS}.log
416 fi
417 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200418 fi
419
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200420 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100421}
422
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100423# is_polar <cmd_line>
424is_polar() {
425 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
426}
427
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200428# openssl s_server doesn't have -www with DTLS
429check_osrv_dtls() {
430 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
431 NEEDS_INPUT=1
432 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
433 else
434 NEEDS_INPUT=0
435 fi
436}
437
438# provide input to commands that need it
439provide_input() {
440 if [ $NEEDS_INPUT -eq 0 ]; then
441 return
442 fi
443
444 while true; do
445 echo "HTTP/1.0 200 OK"
446 sleep 1
447 done
448}
449
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100450# has_mem_err <log_file_name>
451has_mem_err() {
452 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
453 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
454 then
455 return 1 # false: does not have errors
456 else
457 return 0 # true: has errors
458 fi
459}
460
Unknown43dc0d62019-09-02 10:42:57 -0400461# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100462if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400463 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100464 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200465 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100466 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200467 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100468 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200469 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100470 # Make a tight loop, server normally takes less than 1s to start.
471 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
472 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400473 echo "$3 START TIMEOUT"
474 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100475 break
476 fi
477 # Linux and *BSD support decimal arguments to sleep. On other
478 # OSes this may be a tight loop.
479 sleep 0.1 2>/dev/null || true
480 done
481 }
482else
Unknown43dc0d62019-09-02 10:42:57 -0400483 echo "Warning: lsof not available, wait_app_start = sleep"
484 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200485 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100486 }
487fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200488
Unknown43dc0d62019-09-02 10:42:57 -0400489# Wait for server process $2 to be listening on port $1.
490wait_server_start() {
491 wait_app_start $1 $2 "SERVER" $SRV_OUT
492}
493
494# Wait for proxy process $2 to be listening on port $1.
495wait_proxy_start() {
496 wait_app_start $1 $2 "PROXY" $PXY_OUT
497}
498
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100499# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100500# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100501# acceptable bounds
502check_server_hello_time() {
503 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100504 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100505 # Get the Unix timestamp for now
506 CUR_TIME=$(date +'%s')
507 THRESHOLD_IN_SECS=300
508
509 # Check if the ServerHello time was printed
510 if [ -z "$SERVER_HELLO_TIME" ]; then
511 return 1
512 fi
513
514 # Check the time in ServerHello is within acceptable bounds
515 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
516 # The time in ServerHello is at least 5 minutes before now
517 return 1
518 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100519 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100520 return 1
521 else
522 return 0
523 fi
524}
525
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200526# wait for client to terminate and set CLI_EXIT
527# must be called right after starting the client
528wait_client_done() {
529 CLI_PID=$!
530
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200531 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
532 CLI_DELAY_FACTOR=1
533
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200534 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200535 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200536
537 wait $CLI_PID
538 CLI_EXIT=$?
539
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200540 kill $DOG_PID >/dev/null 2>&1
541 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200542
543 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100544
545 sleep $SRV_DELAY_SECONDS
546 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200547}
548
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200549# check if the given command uses dtls and sets global variable DTLS
550detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200551 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200552 DTLS=1
553 else
554 DTLS=0
555 fi
556}
557
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200558# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100559# Options: -s pattern pattern that must be present in server output
560# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100561# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100562# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100563# -S pattern pattern that must be absent in server output
564# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100565# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100566# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100567run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100568 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200569 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100570
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100571 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
572 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200573 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100574 return
575 fi
576
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100577 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100578
Paul Bakkerb7584a52016-05-10 10:50:43 +0100579 # Do we only run numbered tests?
580 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
581 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
582 else
583 SKIP_NEXT="YES"
584 fi
585
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200586 # should we skip?
587 if [ "X$SKIP_NEXT" = "XYES" ]; then
588 SKIP_NEXT="NO"
589 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200590 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200591 return
592 fi
593
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200594 # does this test use a proxy?
595 if [ "X$1" = "X-p" ]; then
596 PXY_CMD="$2"
597 shift 2
598 else
599 PXY_CMD=""
600 fi
601
602 # get commands and client output
603 SRV_CMD="$1"
604 CLI_CMD="$2"
605 CLI_EXPECT="$3"
606 shift 3
607
Hanno Becker7a11e722019-05-10 14:38:42 +0100608 # Check if test uses files
609 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
610 if [ ! -z "$TEST_USES_FILES" ]; then
611 requires_config_enabled MBEDTLS_FS_IO
612 fi
613
614 # should we skip?
615 if [ "X$SKIP_NEXT" = "XYES" ]; then
616 SKIP_NEXT="NO"
617 echo "SKIP"
618 SKIPS=$(( $SKIPS + 1 ))
619 return
620 fi
621
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200622 # update DTLS variable
623 detect_dtls "$SRV_CMD"
624
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200625 # if the test uses DTLS but no custom proxy, add a simple proxy
626 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200627 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200628 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200629 case " $SRV_CMD " in
630 *' server_addr=::1 '*)
631 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
632 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200633 fi
634
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200635 # fix client port
636 if [ -n "$PXY_CMD" ]; then
637 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
638 else
639 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
640 fi
641
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100642 # prepend valgrind to our commands if active
643 if [ "$MEMCHECK" -gt 0 ]; then
644 if is_polar "$SRV_CMD"; then
645 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
646 fi
647 if is_polar "$CLI_CMD"; then
648 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
649 fi
650 fi
651
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200652 TIMES_LEFT=2
653 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200654 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200655
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200656 # run the commands
657 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda1919ad2020-07-27 09:45:32 +0200658 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200659 $PXY_CMD >> $PXY_OUT 2>&1 &
660 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400661 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200662 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200663
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200664 check_osrv_dtls
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200665 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200666 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
667 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100668 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200669
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200670 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200671 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
672 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100673
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100674 sleep 0.05
675
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200676 # terminate the server (and the proxy)
677 kill $SRV_PID
678 wait $SRV_PID
Gilles Peskine634fe272021-02-02 23:29:03 +0100679 SRV_RET=$?
Hanno Beckerd82d8462017-05-29 21:37:46 +0100680
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200681 if [ -n "$PXY_CMD" ]; then
682 kill $PXY_PID >/dev/null 2>&1
683 wait $PXY_PID
684 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100685
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200686 # retry only on timeouts
687 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
688 printf "RETRY "
689 else
690 TIMES_LEFT=0
691 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200692 done
693
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100694 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200695 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100696 # expected client exit to incorrectly succeed in case of catastrophic
697 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100698 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200699 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100700 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100701 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100702 return
703 fi
704 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100705 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200706 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100707 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100708 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100709 return
710 fi
711 fi
712
Gilles Peskine2cf44b62021-02-09 21:01:33 +0100713 # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
714 # exit with status 0 when interrupted by a signal, and we don't really
715 # care anyway), in case e.g. the server reports a memory leak.
716 if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then
Gilles Peskine634fe272021-02-02 23:29:03 +0100717 fail "Server exited with status $SRV_RET"
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100718 return
719 fi
720
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100721 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100722 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
723 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100724 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200725 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100726 return
727 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100728
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100729 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200730 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100731 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100732 while [ $# -gt 0 ]
733 do
734 case $1 in
735 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100736 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100737 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100738 return
739 fi
740 ;;
741
742 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100743 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100744 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100745 return
746 fi
747 ;;
748
749 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100750 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100751 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100752 return
753 fi
754 ;;
755
756 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100757 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100758 fail "pattern '$2' MUST NOT be present in the Client output"
759 return
760 fi
761 ;;
762
763 # The filtering in the following two options (-u and -U) do the following
764 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100765 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100766 # - keep one of each non-unique line
767 # - count how many lines remain
768 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
769 # if there were no duplicates.
770 "-U")
771 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
772 fail "lines following pattern '$2' must be unique in Server output"
773 return
774 fi
775 ;;
776
777 "-u")
778 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
779 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100780 return
781 fi
782 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100783 "-F")
784 if ! $2 "$SRV_OUT"; then
785 fail "function call to '$2' failed on Server output"
786 return
787 fi
788 ;;
789 "-f")
790 if ! $2 "$CLI_OUT"; then
791 fail "function call to '$2' failed on Client output"
792 return
793 fi
794 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100795
796 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200797 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100798 exit 1
799 esac
800 shift 2
801 done
802
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100803 # check valgrind's results
804 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200805 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100806 fail "Server has memory errors"
807 return
808 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200809 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100810 fail "Client has memory errors"
811 return
812 fi
813 fi
814
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100815 # if we're here, everything is ok
816 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100817 if [ "$PRESERVE_LOGS" -gt 0 ]; then
818 mv $SRV_OUT o-srv-${TESTS}.log
819 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100820 if [ -n "$PXY_CMD" ]; then
821 mv $PXY_OUT o-pxy-${TESTS}.log
822 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100823 fi
824
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200825 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100826}
827
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100828cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200829 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200830 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
831 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
832 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
833 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100834 exit 1
835}
836
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100837#
838# MAIN
839#
840
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100841get_options "$@"
842
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100843# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100844P_SRV_BIN="${P_SRV%%[ ]*}"
845P_CLI_BIN="${P_CLI%%[ ]*}"
846P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100847if [ ! -x "$P_SRV_BIN" ]; then
848 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100849 exit 1
850fi
Hanno Becker17c04932017-10-10 14:44:53 +0100851if [ ! -x "$P_CLI_BIN" ]; then
852 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100853 exit 1
854fi
Hanno Becker17c04932017-10-10 14:44:53 +0100855if [ ! -x "$P_PXY_BIN" ]; then
856 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200857 exit 1
858fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100859if [ "$MEMCHECK" -gt 0 ]; then
860 if which valgrind >/dev/null 2>&1; then :; else
861 echo "Memcheck not possible. Valgrind not found"
862 exit 1
863 fi
864fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100865if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
866 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100867 exit 1
868fi
869
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200870# used by watchdog
871MAIN_PID="$$"
872
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100873# We use somewhat arbitrary delays for tests:
874# - how long do we wait for the server to start (when lsof not available)?
875# - how long do we allow for the client to finish?
876# (not to check performance, just to avoid waiting indefinitely)
877# Things are slower with valgrind, so give extra time here.
878#
879# Note: without lsof, there is a trade-off between the running time of this
880# script and the risk of spurious errors because we didn't wait long enough.
881# The watchdog delay on the other hand doesn't affect normal running time of
882# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200883if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100884 START_DELAY=6
885 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200886else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100887 START_DELAY=2
888 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200889fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100890
891# some particular tests need more time:
892# - for the client, we multiply the usual watchdog limit by a factor
893# - for the server, we sleep for a number of seconds after the client exits
894# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200895CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100896SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200897
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200898# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000899# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200900P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
901P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100902P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200903O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200904O_CLI="$O_CLI -connect localhost:+SRV_PORT"
905G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200906G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200907
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200908if [ -n "${OPENSSL_LEGACY:-}" ]; then
909 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
910 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
911fi
912
Hanno Becker58e9dc32018-08-17 15:53:21 +0100913if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200914 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
915fi
916
Hanno Becker58e9dc32018-08-17 15:53:21 +0100917if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200918 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200919fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100920
Gilles Peskine62469d92017-05-10 10:13:59 +0200921# Allow SHA-1, because many of our test certificates use it
922P_SRV="$P_SRV allow_sha1=1"
923P_CLI="$P_CLI allow_sha1=1"
924
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200925# Also pick a unique name for intermediate files
926SRV_OUT="srv_out.$$"
927CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200928PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200929SESSION="session.$$"
930
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200931SKIP_NEXT="NO"
932
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100933trap cleanup INT TERM HUP
934
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200935# Basic test
936
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200937# Checks that:
938# - things work with all ciphersuites active (used with config-full in all.sh)
939# - the expected (highest security) parameters are selected
940# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200941run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200942 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200943 "$P_CLI" \
944 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200945 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200946 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200947 -s "client hello v3, signature_algorithm ext: 6" \
948 -s "ECDHE curve: secp521r1" \
949 -S "error" \
950 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200951
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000952run_test "Default, DTLS" \
953 "$P_SRV dtls=1" \
954 "$P_CLI dtls=1" \
955 0 \
956 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200957 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000958
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +0100959requires_config_enabled MBEDTLS_ZLIB_SUPPORT
960run_test "Default (compression enabled)" \
961 "$P_SRV debug_level=3" \
962 "$P_CLI debug_level=3" \
963 0 \
964 -s "Allocating compression buffer" \
965 -c "Allocating compression buffer" \
966 -s "Record expansion is unknown (compression)" \
967 -c "Record expansion is unknown (compression)" \
968 -S "error" \
969 -C "error"
970
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100971# Test current time in ServerHello
972requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200973run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100974 "$P_SRV debug_level=3" \
975 "$P_CLI debug_level=3" \
976 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100977 -f "check_server_hello_time" \
978 -F "check_server_hello_time"
979
Simon Butcher8e004102016-10-14 00:48:33 +0100980# Test for uniqueness of IVs in AEAD ciphersuites
981run_test "Unique IV in GCM" \
982 "$P_SRV exchanges=20 debug_level=4" \
983 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
984 0 \
985 -u "IV used" \
986 -U "IV used"
987
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100988# Tests for rc4 option
989
Simon Butchera410af52016-05-19 22:12:18 +0100990requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100991run_test "RC4: server disabled, client enabled" \
992 "$P_SRV" \
993 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
994 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100995 -s "SSL - The server has no ciphersuites in common"
996
Simon Butchera410af52016-05-19 22:12:18 +0100997requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100998run_test "RC4: server half, client enabled" \
999 "$P_SRV arc4=1" \
1000 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1001 1 \
1002 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001003
1004run_test "RC4: server enabled, client disabled" \
1005 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1006 "$P_CLI" \
1007 1 \
1008 -s "SSL - The server has no ciphersuites in common"
1009
1010run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001011 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001012 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1013 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001014 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001015 -S "SSL - The server has no ciphersuites in common"
1016
Hanno Beckerd26bb202018-08-17 09:54:10 +01001017# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1018
1019requires_gnutls
1020requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1021run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1022 "$G_SRV"\
1023 "$P_CLI force_version=tls1_1" \
1024 0
1025
1026requires_gnutls
1027requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1028run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1029 "$G_SRV"\
1030 "$P_CLI force_version=tls1" \
1031 0
1032
Gilles Peskinebc70a182017-05-09 15:59:24 +02001033# Tests for SHA-1 support
1034
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001035requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001036run_test "SHA-1 forbidden by default in server certificate" \
1037 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1038 "$P_CLI debug_level=2 allow_sha1=0" \
1039 1 \
1040 -c "The certificate is signed with an unacceptable hash"
1041
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001042requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1043run_test "SHA-1 forbidden by default in server certificate" \
1044 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1045 "$P_CLI debug_level=2 allow_sha1=0" \
1046 0
1047
Gilles Peskinebc70a182017-05-09 15:59:24 +02001048run_test "SHA-1 explicitly allowed in server certificate" \
1049 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1050 "$P_CLI allow_sha1=1" \
1051 0
1052
1053run_test "SHA-256 allowed by default in server certificate" \
1054 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1055 "$P_CLI allow_sha1=0" \
1056 0
1057
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001058requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001059run_test "SHA-1 forbidden by default in client certificate" \
1060 "$P_SRV auth_mode=required allow_sha1=0" \
1061 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1062 1 \
1063 -s "The certificate is signed with an unacceptable hash"
1064
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001065requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1066run_test "SHA-1 forbidden by default in client certificate" \
1067 "$P_SRV auth_mode=required allow_sha1=0" \
1068 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1069 0
1070
Gilles Peskinebc70a182017-05-09 15:59:24 +02001071run_test "SHA-1 explicitly allowed in client certificate" \
1072 "$P_SRV auth_mode=required allow_sha1=1" \
1073 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1074 0
1075
1076run_test "SHA-256 allowed by default in client certificate" \
1077 "$P_SRV auth_mode=required allow_sha1=0" \
1078 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1079 0
1080
Hanno Becker7ae8a762018-08-14 15:43:35 +01001081# Tests for datagram packing
1082run_test "DTLS: multiple records in same datagram, client and server" \
1083 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1084 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1085 0 \
1086 -c "next record in same datagram" \
1087 -s "next record in same datagram"
1088
1089run_test "DTLS: multiple records in same datagram, client only" \
1090 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1091 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1092 0 \
1093 -s "next record in same datagram" \
1094 -C "next record in same datagram"
1095
1096run_test "DTLS: multiple records in same datagram, server only" \
1097 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1098 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1099 0 \
1100 -S "next record in same datagram" \
1101 -c "next record in same datagram"
1102
1103run_test "DTLS: multiple records in same datagram, neither client nor server" \
1104 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1105 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1106 0 \
1107 -S "next record in same datagram" \
1108 -C "next record in same datagram"
1109
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001110# Tests for Truncated HMAC extension
1111
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001112run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001113 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001114 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001115 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001116 -s "dumping 'expected mac' (20 bytes)" \
1117 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001118
Hanno Becker32c55012017-11-10 08:42:54 +00001119requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001120run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001121 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001122 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001123 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001124 -s "dumping 'expected mac' (20 bytes)" \
1125 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001126
Hanno Becker32c55012017-11-10 08:42:54 +00001127requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001128run_test "Truncated HMAC: client enabled, server default" \
1129 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001130 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001131 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001132 -s "dumping 'expected mac' (20 bytes)" \
1133 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001134
Hanno Becker32c55012017-11-10 08:42:54 +00001135requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001136run_test "Truncated HMAC: client enabled, server disabled" \
1137 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001138 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001139 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001140 -s "dumping 'expected mac' (20 bytes)" \
1141 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001142
Hanno Becker32c55012017-11-10 08:42:54 +00001143requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001144run_test "Truncated HMAC: client disabled, server enabled" \
1145 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001146 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001147 0 \
1148 -s "dumping 'expected mac' (20 bytes)" \
1149 -S "dumping 'expected mac' (10 bytes)"
1150
1151requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001152run_test "Truncated HMAC: client enabled, server enabled" \
1153 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001154 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001155 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001156 -S "dumping 'expected mac' (20 bytes)" \
1157 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001158
Hanno Becker4c4f4102017-11-10 09:16:05 +00001159run_test "Truncated HMAC, DTLS: client default, server default" \
1160 "$P_SRV dtls=1 debug_level=4" \
1161 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1162 0 \
1163 -s "dumping 'expected mac' (20 bytes)" \
1164 -S "dumping 'expected mac' (10 bytes)"
1165
1166requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1167run_test "Truncated HMAC, DTLS: client disabled, server default" \
1168 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001169 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001170 0 \
1171 -s "dumping 'expected mac' (20 bytes)" \
1172 -S "dumping 'expected mac' (10 bytes)"
1173
1174requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1175run_test "Truncated HMAC, DTLS: client enabled, server default" \
1176 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001177 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001178 0 \
1179 -s "dumping 'expected mac' (20 bytes)" \
1180 -S "dumping 'expected mac' (10 bytes)"
1181
1182requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1183run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1184 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001185 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001186 0 \
1187 -s "dumping 'expected mac' (20 bytes)" \
1188 -S "dumping 'expected mac' (10 bytes)"
1189
1190requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1191run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1192 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001193 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001194 0 \
1195 -s "dumping 'expected mac' (20 bytes)" \
1196 -S "dumping 'expected mac' (10 bytes)"
1197
1198requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1199run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1200 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001201 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001202 0 \
1203 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001204 -s "dumping 'expected mac' (10 bytes)"
1205
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001206# Tests for Encrypt-then-MAC extension
1207
1208run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001209 "$P_SRV debug_level=3 \
1210 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001211 "$P_CLI debug_level=3" \
1212 0 \
1213 -c "client hello, adding encrypt_then_mac extension" \
1214 -s "found encrypt then mac extension" \
1215 -s "server hello, adding encrypt then mac extension" \
1216 -c "found encrypt_then_mac extension" \
1217 -c "using encrypt then mac" \
1218 -s "using encrypt then mac"
1219
1220run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001221 "$P_SRV debug_level=3 etm=0 \
1222 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001223 "$P_CLI debug_level=3 etm=1" \
1224 0 \
1225 -c "client hello, adding encrypt_then_mac extension" \
1226 -s "found encrypt then mac extension" \
1227 -S "server hello, adding encrypt then mac extension" \
1228 -C "found encrypt_then_mac extension" \
1229 -C "using encrypt then mac" \
1230 -S "using encrypt then mac"
1231
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001232run_test "Encrypt then MAC: client enabled, aead cipher" \
1233 "$P_SRV debug_level=3 etm=1 \
1234 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1235 "$P_CLI debug_level=3 etm=1" \
1236 0 \
1237 -c "client hello, adding encrypt_then_mac extension" \
1238 -s "found encrypt then mac extension" \
1239 -S "server hello, adding encrypt then mac extension" \
1240 -C "found encrypt_then_mac extension" \
1241 -C "using encrypt then mac" \
1242 -S "using encrypt then mac"
1243
1244run_test "Encrypt then MAC: client enabled, stream cipher" \
1245 "$P_SRV debug_level=3 etm=1 \
1246 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001247 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001248 0 \
1249 -c "client hello, adding encrypt_then_mac extension" \
1250 -s "found encrypt then mac extension" \
1251 -S "server hello, adding encrypt then mac extension" \
1252 -C "found encrypt_then_mac extension" \
1253 -C "using encrypt then mac" \
1254 -S "using encrypt then mac"
1255
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001256run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001257 "$P_SRV debug_level=3 etm=1 \
1258 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001259 "$P_CLI debug_level=3 etm=0" \
1260 0 \
1261 -C "client hello, adding encrypt_then_mac extension" \
1262 -S "found encrypt then mac extension" \
1263 -S "server hello, adding encrypt then mac extension" \
1264 -C "found encrypt_then_mac extension" \
1265 -C "using encrypt then mac" \
1266 -S "using encrypt then mac"
1267
Janos Follathe2681a42016-03-07 15:57:05 +00001268requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001269run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001270 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001271 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001272 "$P_CLI debug_level=3 force_version=ssl3" \
1273 0 \
1274 -C "client hello, adding encrypt_then_mac extension" \
1275 -S "found encrypt then mac extension" \
1276 -S "server hello, adding encrypt then mac extension" \
1277 -C "found encrypt_then_mac extension" \
1278 -C "using encrypt then mac" \
1279 -S "using encrypt then mac"
1280
Janos Follathe2681a42016-03-07 15:57:05 +00001281requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001282run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001283 "$P_SRV debug_level=3 force_version=ssl3 \
1284 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001285 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001286 0 \
1287 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001288 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001289 -S "server hello, adding encrypt then mac extension" \
1290 -C "found encrypt_then_mac extension" \
1291 -C "using encrypt then mac" \
1292 -S "using encrypt then mac"
1293
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001294# Tests for Extended Master Secret extension
1295
1296run_test "Extended Master Secret: default" \
1297 "$P_SRV debug_level=3" \
1298 "$P_CLI debug_level=3" \
1299 0 \
1300 -c "client hello, adding extended_master_secret extension" \
1301 -s "found extended master secret extension" \
1302 -s "server hello, adding extended master secret extension" \
1303 -c "found extended_master_secret extension" \
1304 -c "using extended master secret" \
1305 -s "using extended master secret"
1306
1307run_test "Extended Master Secret: client enabled, server disabled" \
1308 "$P_SRV debug_level=3 extended_ms=0" \
1309 "$P_CLI debug_level=3 extended_ms=1" \
1310 0 \
1311 -c "client hello, adding extended_master_secret extension" \
1312 -s "found extended master secret extension" \
1313 -S "server hello, adding extended master secret extension" \
1314 -C "found extended_master_secret extension" \
1315 -C "using extended master secret" \
1316 -S "using extended master secret"
1317
1318run_test "Extended Master Secret: client disabled, server enabled" \
1319 "$P_SRV debug_level=3 extended_ms=1" \
1320 "$P_CLI debug_level=3 extended_ms=0" \
1321 0 \
1322 -C "client hello, adding extended_master_secret extension" \
1323 -S "found extended master secret extension" \
1324 -S "server hello, adding extended master secret extension" \
1325 -C "found extended_master_secret extension" \
1326 -C "using extended master secret" \
1327 -S "using extended master secret"
1328
Janos Follathe2681a42016-03-07 15:57:05 +00001329requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001330run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001331 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001332 "$P_CLI debug_level=3 force_version=ssl3" \
1333 0 \
1334 -C "client hello, adding extended_master_secret extension" \
1335 -S "found extended master secret extension" \
1336 -S "server hello, adding extended master secret extension" \
1337 -C "found extended_master_secret extension" \
1338 -C "using extended master secret" \
1339 -S "using extended master secret"
1340
Janos Follathe2681a42016-03-07 15:57:05 +00001341requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001342run_test "Extended Master Secret: client enabled, server SSLv3" \
1343 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001344 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001345 0 \
1346 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001347 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001348 -S "server hello, adding extended master secret extension" \
1349 -C "found extended_master_secret extension" \
1350 -C "using extended master secret" \
1351 -S "using extended master secret"
1352
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001353# Tests for FALLBACK_SCSV
1354
1355run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001356 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001357 "$P_CLI debug_level=3 force_version=tls1_1" \
1358 0 \
1359 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001360 -S "received FALLBACK_SCSV" \
1361 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001362 -C "is a fatal alert message (msg 86)"
1363
1364run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001365 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001366 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1367 0 \
1368 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001369 -S "received FALLBACK_SCSV" \
1370 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001371 -C "is a fatal alert message (msg 86)"
1372
1373run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001374 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001375 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001376 1 \
1377 -c "adding FALLBACK_SCSV" \
1378 -s "received FALLBACK_SCSV" \
1379 -s "inapropriate fallback" \
1380 -c "is a fatal alert message (msg 86)"
1381
1382run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001383 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001384 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001385 0 \
1386 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001387 -s "received FALLBACK_SCSV" \
1388 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001389 -C "is a fatal alert message (msg 86)"
1390
1391requires_openssl_with_fallback_scsv
1392run_test "Fallback SCSV: default, openssl server" \
1393 "$O_SRV" \
1394 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1395 0 \
1396 -C "adding FALLBACK_SCSV" \
1397 -C "is a fatal alert message (msg 86)"
1398
1399requires_openssl_with_fallback_scsv
1400run_test "Fallback SCSV: enabled, openssl server" \
1401 "$O_SRV" \
1402 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1403 1 \
1404 -c "adding FALLBACK_SCSV" \
1405 -c "is a fatal alert message (msg 86)"
1406
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001407requires_openssl_with_fallback_scsv
1408run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001409 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001410 "$O_CLI -tls1_1" \
1411 0 \
1412 -S "received FALLBACK_SCSV" \
1413 -S "inapropriate fallback"
1414
1415requires_openssl_with_fallback_scsv
1416run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001417 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001418 "$O_CLI -tls1_1 -fallback_scsv" \
1419 1 \
1420 -s "received FALLBACK_SCSV" \
1421 -s "inapropriate fallback"
1422
1423requires_openssl_with_fallback_scsv
1424run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001425 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001426 "$O_CLI -fallback_scsv" \
1427 0 \
1428 -s "received FALLBACK_SCSV" \
1429 -S "inapropriate fallback"
1430
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001431# Test sending and receiving empty application data records
1432
1433run_test "Encrypt then MAC: empty application data record" \
1434 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1435 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1436 0 \
1437 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1438 -s "dumping 'input payload after decrypt' (0 bytes)" \
1439 -c "0 bytes written in 1 fragments"
1440
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001441run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001442 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1443 "$P_CLI auth_mode=none etm=0 request_size=0" \
1444 0 \
1445 -s "dumping 'input payload after decrypt' (0 bytes)" \
1446 -c "0 bytes written in 1 fragments"
1447
1448run_test "Encrypt then MAC, DTLS: empty application data record" \
1449 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1450 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1451 0 \
1452 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1453 -s "dumping 'input payload after decrypt' (0 bytes)" \
1454 -c "0 bytes written in 1 fragments"
1455
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001456run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001457 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1458 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1459 0 \
1460 -s "dumping 'input payload after decrypt' (0 bytes)" \
1461 -c "0 bytes written in 1 fragments"
1462
Gilles Peskined50177f2017-05-16 17:53:03 +02001463## ClientHello generated with
1464## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1465## then manually twiddling the ciphersuite list.
1466## The ClientHello content is spelled out below as a hex string as
1467## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1468## The expected response is an inappropriate_fallback alert.
1469requires_openssl_with_fallback_scsv
1470run_test "Fallback SCSV: beginning of list" \
1471 "$P_SRV debug_level=2" \
1472 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1473 0 \
1474 -s "received FALLBACK_SCSV" \
1475 -s "inapropriate fallback"
1476
1477requires_openssl_with_fallback_scsv
1478run_test "Fallback SCSV: end of list" \
1479 "$P_SRV debug_level=2" \
1480 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1481 0 \
1482 -s "received FALLBACK_SCSV" \
1483 -s "inapropriate fallback"
1484
1485## Here the expected response is a valid ServerHello prefix, up to the random.
1486requires_openssl_with_fallback_scsv
1487run_test "Fallback SCSV: not in list" \
1488 "$P_SRV debug_level=2" \
1489 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1490 0 \
1491 -S "received FALLBACK_SCSV" \
1492 -S "inapropriate fallback"
1493
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001494# Tests for CBC 1/n-1 record splitting
1495
1496run_test "CBC Record splitting: TLS 1.2, no splitting" \
1497 "$P_SRV" \
1498 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1499 request_size=123 force_version=tls1_2" \
1500 0 \
1501 -s "Read from client: 123 bytes read" \
1502 -S "Read from client: 1 bytes read" \
1503 -S "122 bytes read"
1504
1505run_test "CBC Record splitting: TLS 1.1, no splitting" \
1506 "$P_SRV" \
1507 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1508 request_size=123 force_version=tls1_1" \
1509 0 \
1510 -s "Read from client: 123 bytes read" \
1511 -S "Read from client: 1 bytes read" \
1512 -S "122 bytes read"
1513
1514run_test "CBC Record splitting: TLS 1.0, splitting" \
1515 "$P_SRV" \
1516 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1517 request_size=123 force_version=tls1" \
1518 0 \
1519 -S "Read from client: 123 bytes read" \
1520 -s "Read from client: 1 bytes read" \
1521 -s "122 bytes read"
1522
Janos Follathe2681a42016-03-07 15:57:05 +00001523requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001524run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001525 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001526 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1527 request_size=123 force_version=ssl3" \
1528 0 \
1529 -S "Read from client: 123 bytes read" \
1530 -s "Read from client: 1 bytes read" \
1531 -s "122 bytes read"
1532
1533run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001534 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001535 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1536 request_size=123 force_version=tls1" \
1537 0 \
1538 -s "Read from client: 123 bytes read" \
1539 -S "Read from client: 1 bytes read" \
1540 -S "122 bytes read"
1541
1542run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1543 "$P_SRV" \
1544 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1545 request_size=123 force_version=tls1 recsplit=0" \
1546 0 \
1547 -s "Read from client: 123 bytes read" \
1548 -S "Read from client: 1 bytes read" \
1549 -S "122 bytes read"
1550
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001551run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1552 "$P_SRV nbio=2" \
1553 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1554 request_size=123 force_version=tls1" \
1555 0 \
1556 -S "Read from client: 123 bytes read" \
1557 -s "Read from client: 1 bytes read" \
1558 -s "122 bytes read"
1559
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001560# Tests for Session Tickets
1561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001563 "$P_SRV debug_level=3 tickets=1" \
1564 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001565 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001566 -c "client hello, adding session ticket extension" \
1567 -s "found session ticket extension" \
1568 -s "server hello, adding session ticket extension" \
1569 -c "found session_ticket extension" \
1570 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001571 -S "session successfully restored from cache" \
1572 -s "session successfully restored from ticket" \
1573 -s "a session has been resumed" \
1574 -c "a session has been resumed"
1575
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001576run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001577 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1578 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001579 0 \
1580 -c "client hello, adding session ticket extension" \
1581 -s "found session ticket extension" \
1582 -s "server hello, adding session ticket extension" \
1583 -c "found session_ticket extension" \
1584 -c "parse new session ticket" \
1585 -S "session successfully restored from cache" \
1586 -s "session successfully restored from ticket" \
1587 -s "a session has been resumed" \
1588 -c "a session has been resumed"
1589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001590run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001591 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1592 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001593 0 \
1594 -c "client hello, adding session ticket extension" \
1595 -s "found session ticket extension" \
1596 -s "server hello, adding session ticket extension" \
1597 -c "found session_ticket extension" \
1598 -c "parse new session ticket" \
1599 -S "session successfully restored from cache" \
1600 -S "session successfully restored from ticket" \
1601 -S "a session has been resumed" \
1602 -C "a session has been resumed"
1603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001604run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001605 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001606 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001607 0 \
1608 -c "client hello, adding session ticket extension" \
1609 -c "found session_ticket extension" \
1610 -c "parse new session ticket" \
1611 -c "a session has been resumed"
1612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001613run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001614 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001615 "( $O_CLI -sess_out $SESSION; \
1616 $O_CLI -sess_in $SESSION; \
1617 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001618 0 \
1619 -s "found session ticket extension" \
1620 -s "server hello, adding session ticket extension" \
1621 -S "session successfully restored from cache" \
1622 -s "session successfully restored from ticket" \
1623 -s "a session has been resumed"
1624
Hanno Becker1d739932018-08-21 13:55:22 +01001625# Tests for Session Tickets with DTLS
1626
1627run_test "Session resume using tickets, DTLS: basic" \
1628 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001629 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001630 0 \
1631 -c "client hello, adding session ticket extension" \
1632 -s "found session ticket extension" \
1633 -s "server hello, adding session ticket extension" \
1634 -c "found session_ticket extension" \
1635 -c "parse new session ticket" \
1636 -S "session successfully restored from cache" \
1637 -s "session successfully restored from ticket" \
1638 -s "a session has been resumed" \
1639 -c "a session has been resumed"
1640
1641run_test "Session resume using tickets, DTLS: cache disabled" \
1642 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001643 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001644 0 \
1645 -c "client hello, adding session ticket extension" \
1646 -s "found session ticket extension" \
1647 -s "server hello, adding session ticket extension" \
1648 -c "found session_ticket extension" \
1649 -c "parse new session ticket" \
1650 -S "session successfully restored from cache" \
1651 -s "session successfully restored from ticket" \
1652 -s "a session has been resumed" \
1653 -c "a session has been resumed"
1654
1655run_test "Session resume using tickets, DTLS: timeout" \
1656 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001657 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Becker1d739932018-08-21 13:55:22 +01001658 0 \
1659 -c "client hello, adding session ticket extension" \
1660 -s "found session ticket extension" \
1661 -s "server hello, adding session ticket extension" \
1662 -c "found session_ticket extension" \
1663 -c "parse new session ticket" \
1664 -S "session successfully restored from cache" \
1665 -S "session successfully restored from ticket" \
1666 -S "a session has been resumed" \
1667 -C "a session has been resumed"
1668
1669run_test "Session resume using tickets, DTLS: openssl server" \
1670 "$O_SRV -dtls1" \
1671 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1672 0 \
1673 -c "client hello, adding session ticket extension" \
1674 -c "found session_ticket extension" \
1675 -c "parse new session ticket" \
1676 -c "a session has been resumed"
1677
1678run_test "Session resume using tickets, DTLS: openssl client" \
1679 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1680 "( $O_CLI -dtls1 -sess_out $SESSION; \
1681 $O_CLI -dtls1 -sess_in $SESSION; \
1682 rm -f $SESSION )" \
1683 0 \
1684 -s "found session ticket extension" \
1685 -s "server hello, adding session ticket extension" \
1686 -S "session successfully restored from cache" \
1687 -s "session successfully restored from ticket" \
1688 -s "a session has been resumed"
1689
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001690# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001692run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001693 "$P_SRV debug_level=3 tickets=0" \
1694 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001695 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001696 -c "client hello, adding session ticket extension" \
1697 -s "found session ticket extension" \
1698 -S "server hello, adding session ticket extension" \
1699 -C "found session_ticket extension" \
1700 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001701 -s "session successfully restored from cache" \
1702 -S "session successfully restored from ticket" \
1703 -s "a session has been resumed" \
1704 -c "a session has been resumed"
1705
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001706run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001707 "$P_SRV debug_level=3 tickets=1" \
1708 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001709 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001710 -C "client hello, adding session ticket extension" \
1711 -S "found session ticket extension" \
1712 -S "server hello, adding session ticket extension" \
1713 -C "found session_ticket extension" \
1714 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001715 -s "session successfully restored from cache" \
1716 -S "session successfully restored from ticket" \
1717 -s "a session has been resumed" \
1718 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001719
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001720run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001721 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1722 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001723 0 \
1724 -S "session successfully restored from cache" \
1725 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001726 -S "a session has been resumed" \
1727 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001729run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001730 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1731 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001732 0 \
1733 -s "session successfully restored from cache" \
1734 -S "session successfully restored from ticket" \
1735 -s "a session has been resumed" \
1736 -c "a session has been resumed"
1737
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001738run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001739 "$P_SRV debug_level=3 tickets=0" \
1740 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001741 0 \
1742 -s "session successfully restored from cache" \
1743 -S "session successfully restored from ticket" \
1744 -s "a session has been resumed" \
1745 -c "a session has been resumed"
1746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001747run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001748 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1749 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001750 0 \
1751 -S "session successfully restored from cache" \
1752 -S "session successfully restored from ticket" \
1753 -S "a session has been resumed" \
1754 -C "a session has been resumed"
1755
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001756run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001757 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1758 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001759 0 \
1760 -s "session successfully restored from cache" \
1761 -S "session successfully restored from ticket" \
1762 -s "a session has been resumed" \
1763 -c "a session has been resumed"
1764
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001765run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001766 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001767 "( $O_CLI -sess_out $SESSION; \
1768 $O_CLI -sess_in $SESSION; \
1769 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001770 0 \
1771 -s "found session ticket extension" \
1772 -S "server hello, adding session ticket extension" \
1773 -s "session successfully restored from cache" \
1774 -S "session successfully restored from ticket" \
1775 -s "a session has been resumed"
1776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001778 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001779 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001780 0 \
1781 -C "found session_ticket extension" \
1782 -C "parse new session ticket" \
1783 -c "a session has been resumed"
1784
Hanno Becker1d739932018-08-21 13:55:22 +01001785# Tests for Session Resume based on session-ID and cache, DTLS
1786
1787run_test "Session resume using cache, DTLS: tickets enabled on client" \
1788 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001789 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001790 0 \
1791 -c "client hello, adding session ticket extension" \
1792 -s "found session ticket extension" \
1793 -S "server hello, adding session ticket extension" \
1794 -C "found session_ticket extension" \
1795 -C "parse new session ticket" \
1796 -s "session successfully restored from cache" \
1797 -S "session successfully restored from ticket" \
1798 -s "a session has been resumed" \
1799 -c "a session has been resumed"
1800
1801run_test "Session resume using cache, DTLS: tickets enabled on server" \
1802 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001803 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001804 0 \
1805 -C "client hello, adding session ticket extension" \
1806 -S "found session ticket extension" \
1807 -S "server hello, adding session ticket extension" \
1808 -C "found session_ticket extension" \
1809 -C "parse new session ticket" \
1810 -s "session successfully restored from cache" \
1811 -S "session successfully restored from ticket" \
1812 -s "a session has been resumed" \
1813 -c "a session has been resumed"
1814
1815run_test "Session resume using cache, DTLS: cache_max=0" \
1816 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001817 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001818 0 \
1819 -S "session successfully restored from cache" \
1820 -S "session successfully restored from ticket" \
1821 -S "a session has been resumed" \
1822 -C "a session has been resumed"
1823
1824run_test "Session resume using cache, DTLS: cache_max=1" \
1825 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001826 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001827 0 \
1828 -s "session successfully restored from cache" \
1829 -S "session successfully restored from ticket" \
1830 -s "a session has been resumed" \
1831 -c "a session has been resumed"
1832
1833run_test "Session resume using cache, DTLS: timeout > delay" \
1834 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001835 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=0" \
Hanno Becker1d739932018-08-21 13:55:22 +01001836 0 \
1837 -s "session successfully restored from cache" \
1838 -S "session successfully restored from ticket" \
1839 -s "a session has been resumed" \
1840 -c "a session has been resumed"
1841
1842run_test "Session resume using cache, DTLS: timeout < delay" \
1843 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001844 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Becker1d739932018-08-21 13:55:22 +01001845 0 \
1846 -S "session successfully restored from cache" \
1847 -S "session successfully restored from ticket" \
1848 -S "a session has been resumed" \
1849 -C "a session has been resumed"
1850
1851run_test "Session resume using cache, DTLS: no timeout" \
1852 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001853 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Becker1d739932018-08-21 13:55:22 +01001854 0 \
1855 -s "session successfully restored from cache" \
1856 -S "session successfully restored from ticket" \
1857 -s "a session has been resumed" \
1858 -c "a session has been resumed"
1859
1860run_test "Session resume using cache, DTLS: openssl client" \
1861 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1862 "( $O_CLI -dtls1 -sess_out $SESSION; \
1863 $O_CLI -dtls1 -sess_in $SESSION; \
1864 rm -f $SESSION )" \
1865 0 \
1866 -s "found session ticket extension" \
1867 -S "server hello, adding session ticket extension" \
1868 -s "session successfully restored from cache" \
1869 -S "session successfully restored from ticket" \
1870 -s "a session has been resumed"
1871
1872run_test "Session resume using cache, DTLS: openssl server" \
1873 "$O_SRV -dtls1" \
1874 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1875 0 \
1876 -C "found session_ticket extension" \
1877 -C "parse new session ticket" \
1878 -c "a session has been resumed"
1879
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001880# Tests for Max Fragment Length extension
1881
Angus Grattonc4dd0732018-04-11 16:28:39 +10001882if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02001883 printf '%s defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n' "${CONFIG_H}"
Hanno Becker6428f8d2017-09-22 16:58:50 +01001884 exit 1
1885fi
1886
Angus Grattonc4dd0732018-04-11 16:28:39 +10001887if [ $MAX_CONTENT_LEN -ne 16384 ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02001888 echo "Using non-default maximum content length $MAX_CONTENT_LEN"
Angus Grattonc4dd0732018-04-11 16:28:39 +10001889fi
1890
Hanno Becker4aed27e2017-09-18 15:00:34 +01001891requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001892run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001893 "$P_SRV debug_level=3" \
1894 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001895 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001896 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1897 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001898 -C "client hello, adding max_fragment_length extension" \
1899 -S "found max fragment length extension" \
1900 -S "server hello, max_fragment_length extension" \
1901 -C "found max_fragment_length extension"
1902
Hanno Becker4aed27e2017-09-18 15:00:34 +01001903requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001904run_test "Max fragment length: enabled, default, larger message" \
1905 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001906 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001907 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001908 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1909 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001910 -C "client hello, adding max_fragment_length extension" \
1911 -S "found max fragment length extension" \
1912 -S "server hello, max_fragment_length extension" \
1913 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001914 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1915 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001916 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001917
1918requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1919run_test "Max fragment length, DTLS: enabled, default, larger message" \
1920 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001921 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001922 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001923 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1924 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001925 -C "client hello, adding max_fragment_length extension" \
1926 -S "found max fragment length extension" \
1927 -S "server hello, max_fragment_length extension" \
1928 -C "found max_fragment_length extension" \
1929 -c "fragment larger than.*maximum "
1930
Angus Grattonc4dd0732018-04-11 16:28:39 +10001931# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1932# (session fragment length will be 16384 regardless of mbedtls
1933# content length configuration.)
1934
Hanno Beckerc5266962017-09-18 15:01:50 +01001935requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1936run_test "Max fragment length: disabled, larger message" \
1937 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001938 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001939 0 \
1940 -C "Maximum fragment length is 16384" \
1941 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001942 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1943 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001944 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001945
1946requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1947run_test "Max fragment length DTLS: disabled, larger message" \
1948 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001949 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001950 1 \
1951 -C "Maximum fragment length is 16384" \
1952 -S "Maximum fragment length is 16384" \
1953 -c "fragment larger than.*maximum "
1954
1955requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001956run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001957 "$P_SRV debug_level=3" \
1958 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001959 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001960 -c "Maximum fragment length is 4096" \
1961 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001962 -c "client hello, adding max_fragment_length extension" \
1963 -s "found max fragment length extension" \
1964 -s "server hello, max_fragment_length extension" \
1965 -c "found max_fragment_length extension"
1966
Hanno Becker4aed27e2017-09-18 15:00:34 +01001967requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001968run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001969 "$P_SRV debug_level=3 max_frag_len=4096" \
1970 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001971 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001972 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001973 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001974 -C "client hello, adding max_fragment_length extension" \
1975 -S "found max fragment length extension" \
1976 -S "server hello, max_fragment_length extension" \
1977 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001978
Hanno Becker4aed27e2017-09-18 15:00:34 +01001979requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001980requires_gnutls
1981run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001982 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001983 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001984 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001985 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001986 -c "client hello, adding max_fragment_length extension" \
1987 -c "found max_fragment_length extension"
1988
Hanno Becker4aed27e2017-09-18 15:00:34 +01001989requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001990run_test "Max fragment length: client, message just fits" \
1991 "$P_SRV debug_level=3" \
1992 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1993 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001994 -c "Maximum fragment length is 2048" \
1995 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001996 -c "client hello, adding max_fragment_length extension" \
1997 -s "found max fragment length extension" \
1998 -s "server hello, max_fragment_length extension" \
1999 -c "found max_fragment_length extension" \
2000 -c "2048 bytes written in 1 fragments" \
2001 -s "2048 bytes read"
2002
Hanno Becker4aed27e2017-09-18 15:00:34 +01002003requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002004run_test "Max fragment length: client, larger message" \
2005 "$P_SRV debug_level=3" \
2006 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2007 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002008 -c "Maximum fragment length is 2048" \
2009 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002010 -c "client hello, adding max_fragment_length extension" \
2011 -s "found max fragment length extension" \
2012 -s "server hello, max_fragment_length extension" \
2013 -c "found max_fragment_length extension" \
2014 -c "2345 bytes written in 2 fragments" \
2015 -s "2048 bytes read" \
2016 -s "297 bytes read"
2017
Hanno Becker4aed27e2017-09-18 15:00:34 +01002018requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002019run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002020 "$P_SRV debug_level=3 dtls=1" \
2021 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2022 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002023 -c "Maximum fragment length is 2048" \
2024 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002025 -c "client hello, adding max_fragment_length extension" \
2026 -s "found max fragment length extension" \
2027 -s "server hello, max_fragment_length extension" \
2028 -c "found max_fragment_length extension" \
2029 -c "fragment larger than.*maximum"
2030
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002031# Tests for renegotiation
2032
Hanno Becker6a243642017-10-12 15:18:45 +01002033# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002034run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002035 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002036 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002037 0 \
2038 -C "client hello, adding renegotiation extension" \
2039 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2040 -S "found renegotiation extension" \
2041 -s "server hello, secure renegotiation extension" \
2042 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002043 -C "=> renegotiate" \
2044 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002045 -S "write hello request"
2046
Hanno Becker6a243642017-10-12 15:18:45 +01002047requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002048run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002049 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002050 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002051 0 \
2052 -c "client hello, adding renegotiation extension" \
2053 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2054 -s "found renegotiation extension" \
2055 -s "server hello, secure renegotiation extension" \
2056 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002057 -c "=> renegotiate" \
2058 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002059 -S "write hello request"
2060
Hanno Becker6a243642017-10-12 15:18:45 +01002061requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002062run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002063 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002064 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002065 0 \
2066 -c "client hello, adding renegotiation extension" \
2067 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2068 -s "found renegotiation extension" \
2069 -s "server hello, secure renegotiation extension" \
2070 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002071 -c "=> renegotiate" \
2072 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002073 -s "write hello request"
2074
Janos Follathb0f148c2017-10-05 12:29:42 +01002075# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2076# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2077# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002078requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002079run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2080 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2081 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2082 0 \
2083 -c "client hello, adding renegotiation extension" \
2084 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2085 -s "found renegotiation extension" \
2086 -s "server hello, secure renegotiation extension" \
2087 -c "found renegotiation extension" \
2088 -c "=> renegotiate" \
2089 -s "=> renegotiate" \
2090 -S "write hello request" \
2091 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2092
2093# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2094# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2095# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002096requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002097run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2098 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2099 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2100 0 \
2101 -c "client hello, adding renegotiation extension" \
2102 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2103 -s "found renegotiation extension" \
2104 -s "server hello, secure renegotiation extension" \
2105 -c "found renegotiation extension" \
2106 -c "=> renegotiate" \
2107 -s "=> renegotiate" \
2108 -s "write hello request" \
2109 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2110
Hanno Becker6a243642017-10-12 15:18:45 +01002111requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002112run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002113 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002114 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002115 0 \
2116 -c "client hello, adding renegotiation extension" \
2117 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2118 -s "found renegotiation extension" \
2119 -s "server hello, secure renegotiation extension" \
2120 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002121 -c "=> renegotiate" \
2122 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002123 -s "write hello request"
2124
Hanno Becker6a243642017-10-12 15:18:45 +01002125requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002126run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002127 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002128 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002129 1 \
2130 -c "client hello, adding renegotiation extension" \
2131 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2132 -S "found renegotiation extension" \
2133 -s "server hello, secure renegotiation extension" \
2134 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002135 -c "=> renegotiate" \
2136 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002137 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002138 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002139 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002140
Hanno Becker6a243642017-10-12 15:18:45 +01002141requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002142run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002143 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002144 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002145 0 \
2146 -C "client hello, adding renegotiation extension" \
2147 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2148 -S "found renegotiation extension" \
2149 -s "server hello, secure renegotiation extension" \
2150 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002151 -C "=> renegotiate" \
2152 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002153 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002154 -S "SSL - An unexpected message was received from our peer" \
2155 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002156
Hanno Becker6a243642017-10-12 15:18:45 +01002157requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002158run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002159 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002160 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002161 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002162 0 \
2163 -C "client hello, adding renegotiation extension" \
2164 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2165 -S "found renegotiation extension" \
2166 -s "server hello, secure renegotiation extension" \
2167 -c "found renegotiation extension" \
2168 -C "=> renegotiate" \
2169 -S "=> renegotiate" \
2170 -s "write hello request" \
2171 -S "SSL - An unexpected message was received from our peer" \
2172 -S "failed"
2173
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002174# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002175requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002176run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002177 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002178 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002179 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002180 0 \
2181 -C "client hello, adding renegotiation extension" \
2182 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2183 -S "found renegotiation extension" \
2184 -s "server hello, secure renegotiation extension" \
2185 -c "found renegotiation extension" \
2186 -C "=> renegotiate" \
2187 -S "=> renegotiate" \
2188 -s "write hello request" \
2189 -S "SSL - An unexpected message was received from our peer" \
2190 -S "failed"
2191
Hanno Becker6a243642017-10-12 15:18:45 +01002192requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002193run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002194 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002195 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002196 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002197 0 \
2198 -C "client hello, adding renegotiation extension" \
2199 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2200 -S "found renegotiation extension" \
2201 -s "server hello, secure renegotiation extension" \
2202 -c "found renegotiation extension" \
2203 -C "=> renegotiate" \
2204 -S "=> renegotiate" \
2205 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002206 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002207
Hanno Becker6a243642017-10-12 15:18:45 +01002208requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002209run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002210 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002211 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002212 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002213 0 \
2214 -c "client hello, adding renegotiation extension" \
2215 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2216 -s "found renegotiation extension" \
2217 -s "server hello, secure renegotiation extension" \
2218 -c "found renegotiation extension" \
2219 -c "=> renegotiate" \
2220 -s "=> renegotiate" \
2221 -s "write hello request" \
2222 -S "SSL - An unexpected message was received from our peer" \
2223 -S "failed"
2224
Hanno Becker6a243642017-10-12 15:18:45 +01002225requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002226run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002227 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002228 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2229 0 \
2230 -C "client hello, adding renegotiation extension" \
2231 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2232 -S "found renegotiation extension" \
2233 -s "server hello, secure renegotiation extension" \
2234 -c "found renegotiation extension" \
2235 -S "record counter limit reached: renegotiate" \
2236 -C "=> renegotiate" \
2237 -S "=> renegotiate" \
2238 -S "write hello request" \
2239 -S "SSL - An unexpected message was received from our peer" \
2240 -S "failed"
2241
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002242# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002243requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002244run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002245 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002246 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002247 0 \
2248 -c "client hello, adding renegotiation extension" \
2249 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2250 -s "found renegotiation extension" \
2251 -s "server hello, secure renegotiation extension" \
2252 -c "found renegotiation extension" \
2253 -s "record counter limit reached: renegotiate" \
2254 -c "=> renegotiate" \
2255 -s "=> renegotiate" \
2256 -s "write hello request" \
2257 -S "SSL - An unexpected message was received from our peer" \
2258 -S "failed"
2259
Hanno Becker6a243642017-10-12 15:18:45 +01002260requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002261run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002262 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002263 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002264 0 \
2265 -c "client hello, adding renegotiation extension" \
2266 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2267 -s "found renegotiation extension" \
2268 -s "server hello, secure renegotiation extension" \
2269 -c "found renegotiation extension" \
2270 -s "record counter limit reached: renegotiate" \
2271 -c "=> renegotiate" \
2272 -s "=> renegotiate" \
2273 -s "write hello request" \
2274 -S "SSL - An unexpected message was received from our peer" \
2275 -S "failed"
2276
Hanno Becker6a243642017-10-12 15:18:45 +01002277requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002278run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002279 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002280 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2281 0 \
2282 -C "client hello, adding renegotiation extension" \
2283 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2284 -S "found renegotiation extension" \
2285 -s "server hello, secure renegotiation extension" \
2286 -c "found renegotiation extension" \
2287 -S "record counter limit reached: renegotiate" \
2288 -C "=> renegotiate" \
2289 -S "=> renegotiate" \
2290 -S "write hello request" \
2291 -S "SSL - An unexpected message was received from our peer" \
2292 -S "failed"
2293
Hanno Becker6a243642017-10-12 15:18:45 +01002294requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002295run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002296 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002297 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002298 0 \
2299 -c "client hello, adding renegotiation extension" \
2300 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2301 -s "found renegotiation extension" \
2302 -s "server hello, secure renegotiation extension" \
2303 -c "found renegotiation extension" \
2304 -c "=> renegotiate" \
2305 -s "=> renegotiate" \
2306 -S "write hello request"
2307
Hanno Becker6a243642017-10-12 15:18:45 +01002308requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002309run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002310 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002311 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002312 0 \
2313 -c "client hello, adding renegotiation extension" \
2314 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2315 -s "found renegotiation extension" \
2316 -s "server hello, secure renegotiation extension" \
2317 -c "found renegotiation extension" \
2318 -c "=> renegotiate" \
2319 -s "=> renegotiate" \
2320 -s "write hello request"
2321
Hanno Becker6a243642017-10-12 15:18:45 +01002322requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002323run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002324 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002325 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002326 0 \
2327 -c "client hello, adding renegotiation extension" \
2328 -c "found renegotiation extension" \
2329 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002330 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002331 -C "error" \
2332 -c "HTTP/1.0 200 [Oo][Kk]"
2333
Paul Bakker539d9722015-02-08 16:18:35 +01002334requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002335requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002336run_test "Renegotiation: gnutls server strict, client-initiated" \
2337 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002338 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002339 0 \
2340 -c "client hello, adding renegotiation extension" \
2341 -c "found renegotiation extension" \
2342 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002343 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002344 -C "error" \
2345 -c "HTTP/1.0 200 [Oo][Kk]"
2346
Paul Bakker539d9722015-02-08 16:18:35 +01002347requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002348requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002349run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2350 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2351 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2352 1 \
2353 -c "client hello, adding renegotiation extension" \
2354 -C "found renegotiation extension" \
2355 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002356 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002357 -c "error" \
2358 -C "HTTP/1.0 200 [Oo][Kk]"
2359
Paul Bakker539d9722015-02-08 16:18:35 +01002360requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002361requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002362run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2363 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2364 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2365 allow_legacy=0" \
2366 1 \
2367 -c "client hello, adding renegotiation extension" \
2368 -C "found renegotiation extension" \
2369 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002370 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002371 -c "error" \
2372 -C "HTTP/1.0 200 [Oo][Kk]"
2373
Paul Bakker539d9722015-02-08 16:18:35 +01002374requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002375requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002376run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2377 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2378 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2379 allow_legacy=1" \
2380 0 \
2381 -c "client hello, adding renegotiation extension" \
2382 -C "found renegotiation extension" \
2383 -c "=> renegotiate" \
2384 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002385 -C "error" \
2386 -c "HTTP/1.0 200 [Oo][Kk]"
2387
Hanno Becker6a243642017-10-12 15:18:45 +01002388requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002389run_test "Renegotiation: DTLS, client-initiated" \
2390 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2391 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2392 0 \
2393 -c "client hello, adding renegotiation extension" \
2394 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2395 -s "found renegotiation extension" \
2396 -s "server hello, secure renegotiation extension" \
2397 -c "found renegotiation extension" \
2398 -c "=> renegotiate" \
2399 -s "=> renegotiate" \
2400 -S "write hello request"
2401
Hanno Becker6a243642017-10-12 15:18:45 +01002402requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002403run_test "Renegotiation: DTLS, server-initiated" \
2404 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002405 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2406 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002407 0 \
2408 -c "client hello, adding renegotiation extension" \
2409 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2410 -s "found renegotiation extension" \
2411 -s "server hello, secure renegotiation extension" \
2412 -c "found renegotiation extension" \
2413 -c "=> renegotiate" \
2414 -s "=> renegotiate" \
2415 -s "write hello request"
2416
Hanno Becker6a243642017-10-12 15:18:45 +01002417requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002418run_test "Renegotiation: DTLS, renego_period overflow" \
2419 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2420 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2421 0 \
2422 -c "client hello, adding renegotiation extension" \
2423 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2424 -s "found renegotiation extension" \
2425 -s "server hello, secure renegotiation extension" \
2426 -s "record counter limit reached: renegotiate" \
2427 -c "=> renegotiate" \
2428 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002429 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002430
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002431requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002432requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002433run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2434 "$G_SRV -u --mtu 4096" \
2435 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2436 0 \
2437 -c "client hello, adding renegotiation extension" \
2438 -c "found renegotiation extension" \
2439 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002440 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002441 -C "error" \
2442 -s "Extra-header:"
2443
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002444# Test for the "secure renegotation" extension only (no actual renegotiation)
2445
Paul Bakker539d9722015-02-08 16:18:35 +01002446requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002447run_test "Renego ext: gnutls server strict, client default" \
2448 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2449 "$P_CLI debug_level=3" \
2450 0 \
2451 -c "found renegotiation extension" \
2452 -C "error" \
2453 -c "HTTP/1.0 200 [Oo][Kk]"
2454
Paul Bakker539d9722015-02-08 16:18:35 +01002455requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002456run_test "Renego ext: gnutls server unsafe, client default" \
2457 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2458 "$P_CLI debug_level=3" \
2459 0 \
2460 -C "found renegotiation extension" \
2461 -C "error" \
2462 -c "HTTP/1.0 200 [Oo][Kk]"
2463
Paul Bakker539d9722015-02-08 16:18:35 +01002464requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002465run_test "Renego ext: gnutls server unsafe, client break legacy" \
2466 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2467 "$P_CLI debug_level=3 allow_legacy=-1" \
2468 1 \
2469 -C "found renegotiation extension" \
2470 -c "error" \
2471 -C "HTTP/1.0 200 [Oo][Kk]"
2472
Paul Bakker539d9722015-02-08 16:18:35 +01002473requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002474run_test "Renego ext: gnutls client strict, server default" \
2475 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002476 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002477 0 \
2478 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2479 -s "server hello, secure renegotiation extension"
2480
Paul Bakker539d9722015-02-08 16:18:35 +01002481requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002482run_test "Renego ext: gnutls client unsafe, server default" \
2483 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002484 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002485 0 \
2486 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2487 -S "server hello, secure renegotiation extension"
2488
Paul Bakker539d9722015-02-08 16:18:35 +01002489requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002490run_test "Renego ext: gnutls client unsafe, server break legacy" \
2491 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002492 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002493 1 \
2494 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2495 -S "server hello, secure renegotiation extension"
2496
Janos Follath0b242342016-02-17 10:11:21 +00002497# Tests for silently dropping trailing extra bytes in .der certificates
2498
2499requires_gnutls
2500run_test "DER format: no trailing bytes" \
2501 "$P_SRV crt_file=data_files/server5-der0.crt \
2502 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002503 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002504 0 \
2505 -c "Handshake was completed" \
2506
2507requires_gnutls
2508run_test "DER format: with a trailing zero byte" \
2509 "$P_SRV crt_file=data_files/server5-der1a.crt \
2510 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002511 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002512 0 \
2513 -c "Handshake was completed" \
2514
2515requires_gnutls
2516run_test "DER format: with a trailing random byte" \
2517 "$P_SRV crt_file=data_files/server5-der1b.crt \
2518 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002519 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002520 0 \
2521 -c "Handshake was completed" \
2522
2523requires_gnutls
2524run_test "DER format: with 2 trailing random bytes" \
2525 "$P_SRV crt_file=data_files/server5-der2.crt \
2526 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002527 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002528 0 \
2529 -c "Handshake was completed" \
2530
2531requires_gnutls
2532run_test "DER format: with 4 trailing random bytes" \
2533 "$P_SRV crt_file=data_files/server5-der4.crt \
2534 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002535 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002536 0 \
2537 -c "Handshake was completed" \
2538
2539requires_gnutls
2540run_test "DER format: with 8 trailing random bytes" \
2541 "$P_SRV crt_file=data_files/server5-der8.crt \
2542 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002543 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002544 0 \
2545 -c "Handshake was completed" \
2546
2547requires_gnutls
2548run_test "DER format: with 9 trailing random bytes" \
2549 "$P_SRV crt_file=data_files/server5-der9.crt \
2550 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002551 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002552 0 \
2553 -c "Handshake was completed" \
2554
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002555# Tests for auth_mode
2556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002557run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002558 "$P_SRV crt_file=data_files/server5-badsign.crt \
2559 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002560 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002561 1 \
2562 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002563 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002564 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002565 -c "X509 - Certificate verification failed"
2566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002567run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002568 "$P_SRV crt_file=data_files/server5-badsign.crt \
2569 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002570 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002571 0 \
2572 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002573 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002574 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002575 -C "X509 - Certificate verification failed"
2576
Hanno Beckere6706e62017-05-15 16:05:15 +01002577run_test "Authentication: server goodcert, client optional, no trusted CA" \
2578 "$P_SRV" \
2579 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2580 0 \
2581 -c "x509_verify_cert() returned" \
2582 -c "! The certificate is not correctly signed by the trusted CA" \
2583 -c "! Certificate verification flags"\
2584 -C "! mbedtls_ssl_handshake returned" \
2585 -C "X509 - Certificate verification failed" \
2586 -C "SSL - No CA Chain is set, but required to operate"
2587
2588run_test "Authentication: server goodcert, client required, no trusted CA" \
2589 "$P_SRV" \
2590 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2591 1 \
2592 -c "x509_verify_cert() returned" \
2593 -c "! The certificate is not correctly signed by the trusted CA" \
2594 -c "! Certificate verification flags"\
2595 -c "! mbedtls_ssl_handshake returned" \
2596 -c "SSL - No CA Chain is set, but required to operate"
2597
2598# The purpose of the next two tests is to test the client's behaviour when receiving a server
2599# certificate with an unsupported elliptic curve. This should usually not happen because
2600# the client informs the server about the supported curves - it does, though, in the
2601# corner case of a static ECDH suite, because the server doesn't check the curve on that
2602# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2603# different means to have the server ignoring the client's supported curve list.
2604
2605requires_config_enabled MBEDTLS_ECP_C
2606run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2607 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2608 crt_file=data_files/server5.ku-ka.crt" \
2609 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2610 1 \
2611 -c "bad certificate (EC key curve)"\
2612 -c "! Certificate verification flags"\
2613 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2614
2615requires_config_enabled MBEDTLS_ECP_C
2616run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2617 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2618 crt_file=data_files/server5.ku-ka.crt" \
2619 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2620 1 \
2621 -c "bad certificate (EC key curve)"\
2622 -c "! Certificate verification flags"\
2623 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002625run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002626 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002627 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002628 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002629 0 \
2630 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002631 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002632 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002633 -C "X509 - Certificate verification failed"
2634
Simon Butcher99000142016-10-13 17:21:01 +01002635run_test "Authentication: client SHA256, server required" \
2636 "$P_SRV auth_mode=required" \
2637 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2638 key_file=data_files/server6.key \
2639 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2640 0 \
2641 -c "Supported Signature Algorithm found: 4," \
2642 -c "Supported Signature Algorithm found: 5,"
2643
2644run_test "Authentication: client SHA384, server required" \
2645 "$P_SRV auth_mode=required" \
2646 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2647 key_file=data_files/server6.key \
2648 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2649 0 \
2650 -c "Supported Signature Algorithm found: 4," \
2651 -c "Supported Signature Algorithm found: 5,"
2652
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002653requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2654run_test "Authentication: client has no cert, server required (SSLv3)" \
2655 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2656 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2657 key_file=data_files/server5.key" \
2658 1 \
2659 -S "skip write certificate request" \
2660 -C "skip parse certificate request" \
2661 -c "got a certificate request" \
2662 -c "got no certificate to send" \
2663 -S "x509_verify_cert() returned" \
2664 -s "client has no certificate" \
2665 -s "! mbedtls_ssl_handshake returned" \
2666 -c "! mbedtls_ssl_handshake returned" \
2667 -s "No client certification received from the client, but required by the authentication mode"
2668
2669run_test "Authentication: client has no cert, server required (TLS)" \
2670 "$P_SRV debug_level=3 auth_mode=required" \
2671 "$P_CLI debug_level=3 crt_file=none \
2672 key_file=data_files/server5.key" \
2673 1 \
2674 -S "skip write certificate request" \
2675 -C "skip parse certificate request" \
2676 -c "got a certificate request" \
2677 -c "= write certificate$" \
2678 -C "skip write certificate$" \
2679 -S "x509_verify_cert() returned" \
2680 -s "client has no certificate" \
2681 -s "! mbedtls_ssl_handshake returned" \
2682 -c "! mbedtls_ssl_handshake returned" \
2683 -s "No client certification received from the client, but required by the authentication mode"
2684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002685run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002686 "$P_SRV debug_level=3 auth_mode=required" \
2687 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002688 key_file=data_files/server5.key" \
2689 1 \
2690 -S "skip write certificate request" \
2691 -C "skip parse certificate request" \
2692 -c "got a certificate request" \
2693 -C "skip write certificate" \
2694 -C "skip write certificate verify" \
2695 -S "skip parse certificate verify" \
2696 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002697 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002698 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002699 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002700 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002701 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002702# We don't check that the client receives the alert because it might
2703# detect that its write end of the connection is closed and abort
2704# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002705
Janos Follath89baba22017-04-10 14:34:35 +01002706run_test "Authentication: client cert not trusted, server required" \
2707 "$P_SRV debug_level=3 auth_mode=required" \
2708 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2709 key_file=data_files/server5.key" \
2710 1 \
2711 -S "skip write certificate request" \
2712 -C "skip parse certificate request" \
2713 -c "got a certificate request" \
2714 -C "skip write certificate" \
2715 -C "skip write certificate verify" \
2716 -S "skip parse certificate verify" \
2717 -s "x509_verify_cert() returned" \
2718 -s "! The certificate is not correctly signed by the trusted CA" \
2719 -s "! mbedtls_ssl_handshake returned" \
2720 -c "! mbedtls_ssl_handshake returned" \
2721 -s "X509 - Certificate verification failed"
2722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002723run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002724 "$P_SRV debug_level=3 auth_mode=optional" \
2725 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002726 key_file=data_files/server5.key" \
2727 0 \
2728 -S "skip write certificate request" \
2729 -C "skip parse certificate request" \
2730 -c "got a certificate request" \
2731 -C "skip write certificate" \
2732 -C "skip write certificate verify" \
2733 -S "skip parse certificate verify" \
2734 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002735 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002736 -S "! mbedtls_ssl_handshake returned" \
2737 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002738 -S "X509 - Certificate verification failed"
2739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002740run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002741 "$P_SRV debug_level=3 auth_mode=none" \
2742 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002743 key_file=data_files/server5.key" \
2744 0 \
2745 -s "skip write certificate request" \
2746 -C "skip parse certificate request" \
2747 -c "got no certificate request" \
2748 -c "skip write certificate" \
2749 -c "skip write certificate verify" \
2750 -s "skip parse certificate verify" \
2751 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002752 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002753 -S "! mbedtls_ssl_handshake returned" \
2754 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002755 -S "X509 - Certificate verification failed"
2756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002757run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002758 "$P_SRV debug_level=3 auth_mode=optional" \
2759 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002760 0 \
2761 -S "skip write certificate request" \
2762 -C "skip parse certificate request" \
2763 -c "got a certificate request" \
2764 -C "skip write certificate$" \
2765 -C "got no certificate to send" \
2766 -S "SSLv3 client has no certificate" \
2767 -c "skip write certificate verify" \
2768 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002769 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002770 -S "! mbedtls_ssl_handshake returned" \
2771 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002772 -S "X509 - Certificate verification failed"
2773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002774run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002775 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002776 "$O_CLI" \
2777 0 \
2778 -S "skip write certificate request" \
2779 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002780 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002781 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002782 -S "X509 - Certificate verification failed"
2783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002784run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002785 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002786 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002787 0 \
2788 -C "skip parse certificate request" \
2789 -c "got a certificate request" \
2790 -C "skip write certificate$" \
2791 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002792 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002793
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002794run_test "Authentication: client no cert, openssl server required" \
2795 "$O_SRV -Verify 10" \
2796 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2797 1 \
2798 -C "skip parse certificate request" \
2799 -c "got a certificate request" \
2800 -C "skip write certificate$" \
2801 -c "skip write certificate verify" \
2802 -c "! mbedtls_ssl_handshake returned"
2803
Janos Follathe2681a42016-03-07 15:57:05 +00002804requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002805run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002806 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002807 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002808 0 \
2809 -S "skip write certificate request" \
2810 -C "skip parse certificate request" \
2811 -c "got a certificate request" \
2812 -C "skip write certificate$" \
2813 -c "skip write certificate verify" \
2814 -c "got no certificate to send" \
2815 -s "SSLv3 client has no certificate" \
2816 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002817 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002818 -S "! mbedtls_ssl_handshake returned" \
2819 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002820 -S "X509 - Certificate verification failed"
2821
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002822# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2823# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002824
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002825MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002826MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002827
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002828if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002829 cat <<EOF
2830${CONFIG_H} contains a value for the configuration of
2831MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script's
2832test value of ${MAX_IM_CA}.
Simon Butcher06b78632017-07-28 01:00:17 +01002833
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002834The tests assume this value and if it changes, the tests in this
2835script should also be adjusted.
2836EOF
Simon Butcher06b78632017-07-28 01:00:17 +01002837 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002838fi
2839
Angus Grattonc4dd0732018-04-11 16:28:39 +10002840requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002841run_test "Authentication: server max_int chain, client default" \
2842 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2843 key_file=data_files/dir-maxpath/09.key" \
2844 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2845 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002846 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002847
Angus Grattonc4dd0732018-04-11 16:28:39 +10002848requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002849run_test "Authentication: server max_int+1 chain, client default" \
2850 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2851 key_file=data_files/dir-maxpath/10.key" \
2852 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2853 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002854 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002855
Angus Grattonc4dd0732018-04-11 16:28:39 +10002856requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002857run_test "Authentication: server max_int+1 chain, client optional" \
2858 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2859 key_file=data_files/dir-maxpath/10.key" \
2860 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2861 auth_mode=optional" \
2862 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002863 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002864
Angus Grattonc4dd0732018-04-11 16:28:39 +10002865requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002866run_test "Authentication: server max_int+1 chain, client none" \
2867 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2868 key_file=data_files/dir-maxpath/10.key" \
2869 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2870 auth_mode=none" \
2871 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002872 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002873
Angus Grattonc4dd0732018-04-11 16:28:39 +10002874requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002875run_test "Authentication: client max_int+1 chain, server default" \
2876 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2877 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2878 key_file=data_files/dir-maxpath/10.key" \
2879 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002880 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002881
Angus Grattonc4dd0732018-04-11 16:28:39 +10002882requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002883run_test "Authentication: client max_int+1 chain, server optional" \
2884 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2885 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2886 key_file=data_files/dir-maxpath/10.key" \
2887 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002888 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002889
Angus Grattonc4dd0732018-04-11 16:28:39 +10002890requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002891run_test "Authentication: client max_int+1 chain, server required" \
2892 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2893 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2894 key_file=data_files/dir-maxpath/10.key" \
2895 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002896 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002897
Angus Grattonc4dd0732018-04-11 16:28:39 +10002898requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002899run_test "Authentication: client max_int chain, server required" \
2900 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2901 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2902 key_file=data_files/dir-maxpath/09.key" \
2903 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002904 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002905
Janos Follath89baba22017-04-10 14:34:35 +01002906# Tests for CA list in CertificateRequest messages
2907
2908run_test "Authentication: send CA list in CertificateRequest (default)" \
2909 "$P_SRV debug_level=3 auth_mode=required" \
2910 "$P_CLI crt_file=data_files/server6.crt \
2911 key_file=data_files/server6.key" \
2912 0 \
2913 -s "requested DN"
2914
2915run_test "Authentication: do not send CA list in CertificateRequest" \
2916 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2917 "$P_CLI crt_file=data_files/server6.crt \
2918 key_file=data_files/server6.key" \
2919 0 \
2920 -S "requested DN"
2921
2922run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2923 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2924 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2925 key_file=data_files/server5.key" \
2926 1 \
2927 -S "requested DN" \
2928 -s "x509_verify_cert() returned" \
2929 -s "! The certificate is not correctly signed by the trusted CA" \
2930 -s "! mbedtls_ssl_handshake returned" \
2931 -c "! mbedtls_ssl_handshake returned" \
2932 -s "X509 - Certificate verification failed"
2933
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002934# Tests for certificate selection based on SHA verson
2935
2936run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2937 "$P_SRV crt_file=data_files/server5.crt \
2938 key_file=data_files/server5.key \
2939 crt_file2=data_files/server5-sha1.crt \
2940 key_file2=data_files/server5.key" \
2941 "$P_CLI force_version=tls1_2" \
2942 0 \
2943 -c "signed using.*ECDSA with SHA256" \
2944 -C "signed using.*ECDSA with SHA1"
2945
2946run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2947 "$P_SRV crt_file=data_files/server5.crt \
2948 key_file=data_files/server5.key \
2949 crt_file2=data_files/server5-sha1.crt \
2950 key_file2=data_files/server5.key" \
2951 "$P_CLI force_version=tls1_1" \
2952 0 \
2953 -C "signed using.*ECDSA with SHA256" \
2954 -c "signed using.*ECDSA with SHA1"
2955
2956run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2957 "$P_SRV crt_file=data_files/server5.crt \
2958 key_file=data_files/server5.key \
2959 crt_file2=data_files/server5-sha1.crt \
2960 key_file2=data_files/server5.key" \
2961 "$P_CLI force_version=tls1" \
2962 0 \
2963 -C "signed using.*ECDSA with SHA256" \
2964 -c "signed using.*ECDSA with SHA1"
2965
2966run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2967 "$P_SRV crt_file=data_files/server5.crt \
2968 key_file=data_files/server5.key \
2969 crt_file2=data_files/server6.crt \
2970 key_file2=data_files/server6.key" \
2971 "$P_CLI force_version=tls1_1" \
2972 0 \
2973 -c "serial number.*09" \
2974 -c "signed using.*ECDSA with SHA256" \
2975 -C "signed using.*ECDSA with SHA1"
2976
2977run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2978 "$P_SRV crt_file=data_files/server6.crt \
2979 key_file=data_files/server6.key \
2980 crt_file2=data_files/server5.crt \
2981 key_file2=data_files/server5.key" \
2982 "$P_CLI force_version=tls1_1" \
2983 0 \
2984 -c "serial number.*0A" \
2985 -c "signed using.*ECDSA with SHA256" \
2986 -C "signed using.*ECDSA with SHA1"
2987
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002988# tests for SNI
2989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002990run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002991 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002992 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002993 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002994 0 \
2995 -S "parse ServerName extension" \
2996 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2997 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002999run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003000 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003001 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003002 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003003 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003004 0 \
3005 -s "parse ServerName extension" \
3006 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3007 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003008
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003009run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003010 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003011 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003012 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003013 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003014 0 \
3015 -s "parse ServerName extension" \
3016 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3017 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003019run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003020 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003021 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003022 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003023 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003024 1 \
3025 -s "parse ServerName extension" \
3026 -s "ssl_sni_wrapper() returned" \
3027 -s "mbedtls_ssl_handshake returned" \
3028 -c "mbedtls_ssl_handshake returned" \
3029 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003030
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003031run_test "SNI: client auth no override: optional" \
3032 "$P_SRV debug_level=3 auth_mode=optional \
3033 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3034 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3035 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003036 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003037 -S "skip write certificate request" \
3038 -C "skip parse certificate request" \
3039 -c "got a certificate request" \
3040 -C "skip write certificate" \
3041 -C "skip write certificate verify" \
3042 -S "skip parse certificate verify"
3043
3044run_test "SNI: client auth override: none -> optional" \
3045 "$P_SRV debug_level=3 auth_mode=none \
3046 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3047 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3048 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003049 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003050 -S "skip write certificate request" \
3051 -C "skip parse certificate request" \
3052 -c "got a certificate request" \
3053 -C "skip write certificate" \
3054 -C "skip write certificate verify" \
3055 -S "skip parse certificate verify"
3056
3057run_test "SNI: client auth override: optional -> none" \
3058 "$P_SRV debug_level=3 auth_mode=optional \
3059 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3060 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3061 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003062 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003063 -s "skip write certificate request" \
3064 -C "skip parse certificate request" \
3065 -c "got no certificate request" \
3066 -c "skip write certificate" \
3067 -c "skip write certificate verify" \
3068 -s "skip parse certificate verify"
3069
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003070run_test "SNI: CA no override" \
3071 "$P_SRV debug_level=3 auth_mode=optional \
3072 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3073 ca_file=data_files/test-ca.crt \
3074 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3075 "$P_CLI debug_level=3 server_name=localhost \
3076 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3077 1 \
3078 -S "skip write certificate request" \
3079 -C "skip parse certificate request" \
3080 -c "got a certificate request" \
3081 -C "skip write certificate" \
3082 -C "skip write certificate verify" \
3083 -S "skip parse certificate verify" \
3084 -s "x509_verify_cert() returned" \
3085 -s "! The certificate is not correctly signed by the trusted CA" \
3086 -S "The certificate has been revoked (is on a CRL)"
3087
3088run_test "SNI: CA override" \
3089 "$P_SRV debug_level=3 auth_mode=optional \
3090 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3091 ca_file=data_files/test-ca.crt \
3092 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3093 "$P_CLI debug_level=3 server_name=localhost \
3094 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3095 0 \
3096 -S "skip write certificate request" \
3097 -C "skip parse certificate request" \
3098 -c "got a certificate request" \
3099 -C "skip write certificate" \
3100 -C "skip write certificate verify" \
3101 -S "skip parse certificate verify" \
3102 -S "x509_verify_cert() returned" \
3103 -S "! The certificate is not correctly signed by the trusted CA" \
3104 -S "The certificate has been revoked (is on a CRL)"
3105
3106run_test "SNI: CA override with CRL" \
3107 "$P_SRV debug_level=3 auth_mode=optional \
3108 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3109 ca_file=data_files/test-ca.crt \
3110 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3111 "$P_CLI debug_level=3 server_name=localhost \
3112 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3113 1 \
3114 -S "skip write certificate request" \
3115 -C "skip parse certificate request" \
3116 -c "got a certificate request" \
3117 -C "skip write certificate" \
3118 -C "skip write certificate verify" \
3119 -S "skip parse certificate verify" \
3120 -s "x509_verify_cert() returned" \
3121 -S "! The certificate is not correctly signed by the trusted CA" \
3122 -s "The certificate has been revoked (is on a CRL)"
3123
Andres AG1a834452016-12-07 10:01:30 +00003124# Tests for SNI and DTLS
3125
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003126run_test "SNI: DTLS, no SNI callback" \
3127 "$P_SRV debug_level=3 dtls=1 \
3128 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3129 "$P_CLI server_name=localhost dtls=1" \
3130 0 \
3131 -S "parse ServerName extension" \
3132 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3133 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3134
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003135run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003136 "$P_SRV debug_level=3 dtls=1 \
3137 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3138 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3139 "$P_CLI server_name=localhost dtls=1" \
3140 0 \
3141 -s "parse ServerName extension" \
3142 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3143 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3144
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003145run_test "SNI: DTLS, matching cert 2" \
3146 "$P_SRV debug_level=3 dtls=1 \
3147 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3148 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3149 "$P_CLI server_name=polarssl.example dtls=1" \
3150 0 \
3151 -s "parse ServerName extension" \
3152 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3153 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3154
3155run_test "SNI: DTLS, no matching cert" \
3156 "$P_SRV debug_level=3 dtls=1 \
3157 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3158 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3159 "$P_CLI server_name=nonesuch.example dtls=1" \
3160 1 \
3161 -s "parse ServerName extension" \
3162 -s "ssl_sni_wrapper() returned" \
3163 -s "mbedtls_ssl_handshake returned" \
3164 -c "mbedtls_ssl_handshake returned" \
3165 -c "SSL - A fatal alert message was received from our peer"
3166
3167run_test "SNI: DTLS, client auth no override: optional" \
3168 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3169 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3170 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3171 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3172 0 \
3173 -S "skip write certificate request" \
3174 -C "skip parse certificate request" \
3175 -c "got a certificate request" \
3176 -C "skip write certificate" \
3177 -C "skip write certificate verify" \
3178 -S "skip parse certificate verify"
3179
3180run_test "SNI: DTLS, client auth override: none -> optional" \
3181 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3182 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3183 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3184 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3185 0 \
3186 -S "skip write certificate request" \
3187 -C "skip parse certificate request" \
3188 -c "got a certificate request" \
3189 -C "skip write certificate" \
3190 -C "skip write certificate verify" \
3191 -S "skip parse certificate verify"
3192
3193run_test "SNI: DTLS, client auth override: optional -> none" \
3194 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3195 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3196 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3197 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3198 0 \
3199 -s "skip write certificate request" \
3200 -C "skip parse certificate request" \
3201 -c "got no certificate request" \
3202 -c "skip write certificate" \
3203 -c "skip write certificate verify" \
3204 -s "skip parse certificate verify"
3205
3206run_test "SNI: DTLS, CA no override" \
3207 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3208 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3209 ca_file=data_files/test-ca.crt \
3210 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3211 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3212 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3213 1 \
3214 -S "skip write certificate request" \
3215 -C "skip parse certificate request" \
3216 -c "got a certificate request" \
3217 -C "skip write certificate" \
3218 -C "skip write certificate verify" \
3219 -S "skip parse certificate verify" \
3220 -s "x509_verify_cert() returned" \
3221 -s "! The certificate is not correctly signed by the trusted CA" \
3222 -S "The certificate has been revoked (is on a CRL)"
3223
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003224run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003225 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3226 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3227 ca_file=data_files/test-ca.crt \
3228 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3229 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3230 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3231 0 \
3232 -S "skip write certificate request" \
3233 -C "skip parse certificate request" \
3234 -c "got a certificate request" \
3235 -C "skip write certificate" \
3236 -C "skip write certificate verify" \
3237 -S "skip parse certificate verify" \
3238 -S "x509_verify_cert() returned" \
3239 -S "! The certificate is not correctly signed by the trusted CA" \
3240 -S "The certificate has been revoked (is on a CRL)"
3241
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003242run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003243 "$P_SRV debug_level=3 auth_mode=optional \
3244 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3245 ca_file=data_files/test-ca.crt \
3246 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3247 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3248 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3249 1 \
3250 -S "skip write certificate request" \
3251 -C "skip parse certificate request" \
3252 -c "got a certificate request" \
3253 -C "skip write certificate" \
3254 -C "skip write certificate verify" \
3255 -S "skip parse certificate verify" \
3256 -s "x509_verify_cert() returned" \
3257 -S "! The certificate is not correctly signed by the trusted CA" \
3258 -s "The certificate has been revoked (is on a CRL)"
3259
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003260# Tests for non-blocking I/O: exercise a variety of handshake flows
3261
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003262run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003263 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3264 "$P_CLI nbio=2 tickets=0" \
3265 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003266 -S "mbedtls_ssl_handshake returned" \
3267 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003268 -c "Read from server: .* bytes read"
3269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003270run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003271 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3272 "$P_CLI nbio=2 tickets=0" \
3273 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003274 -S "mbedtls_ssl_handshake returned" \
3275 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003276 -c "Read from server: .* bytes read"
3277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003278run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003279 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3280 "$P_CLI nbio=2 tickets=1" \
3281 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003282 -S "mbedtls_ssl_handshake returned" \
3283 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003284 -c "Read from server: .* bytes read"
3285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003286run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003287 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3288 "$P_CLI nbio=2 tickets=1" \
3289 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003290 -S "mbedtls_ssl_handshake returned" \
3291 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003292 -c "Read from server: .* bytes read"
3293
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003294run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003295 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3296 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3297 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003298 -S "mbedtls_ssl_handshake returned" \
3299 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003300 -c "Read from server: .* bytes read"
3301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003302run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003303 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3304 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3305 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003306 -S "mbedtls_ssl_handshake returned" \
3307 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003308 -c "Read from server: .* bytes read"
3309
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003310run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003311 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3312 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3313 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003314 -S "mbedtls_ssl_handshake returned" \
3315 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003316 -c "Read from server: .* bytes read"
3317
Hanno Becker00076712017-11-15 16:39:08 +00003318# Tests for event-driven I/O: exercise a variety of handshake flows
3319
3320run_test "Event-driven I/O: basic handshake" \
3321 "$P_SRV event=1 tickets=0 auth_mode=none" \
3322 "$P_CLI event=1 tickets=0" \
3323 0 \
3324 -S "mbedtls_ssl_handshake returned" \
3325 -C "mbedtls_ssl_handshake returned" \
3326 -c "Read from server: .* bytes read"
3327
3328run_test "Event-driven I/O: client auth" \
3329 "$P_SRV event=1 tickets=0 auth_mode=required" \
3330 "$P_CLI event=1 tickets=0" \
3331 0 \
3332 -S "mbedtls_ssl_handshake returned" \
3333 -C "mbedtls_ssl_handshake returned" \
3334 -c "Read from server: .* bytes read"
3335
3336run_test "Event-driven I/O: ticket" \
3337 "$P_SRV event=1 tickets=1 auth_mode=none" \
3338 "$P_CLI event=1 tickets=1" \
3339 0 \
3340 -S "mbedtls_ssl_handshake returned" \
3341 -C "mbedtls_ssl_handshake returned" \
3342 -c "Read from server: .* bytes read"
3343
3344run_test "Event-driven I/O: ticket + client auth" \
3345 "$P_SRV event=1 tickets=1 auth_mode=required" \
3346 "$P_CLI event=1 tickets=1" \
3347 0 \
3348 -S "mbedtls_ssl_handshake returned" \
3349 -C "mbedtls_ssl_handshake returned" \
3350 -c "Read from server: .* bytes read"
3351
3352run_test "Event-driven I/O: ticket + client auth + resume" \
3353 "$P_SRV event=1 tickets=1 auth_mode=required" \
3354 "$P_CLI event=1 tickets=1 reconnect=1" \
3355 0 \
3356 -S "mbedtls_ssl_handshake returned" \
3357 -C "mbedtls_ssl_handshake returned" \
3358 -c "Read from server: .* bytes read"
3359
3360run_test "Event-driven I/O: ticket + resume" \
3361 "$P_SRV event=1 tickets=1 auth_mode=none" \
3362 "$P_CLI event=1 tickets=1 reconnect=1" \
3363 0 \
3364 -S "mbedtls_ssl_handshake returned" \
3365 -C "mbedtls_ssl_handshake returned" \
3366 -c "Read from server: .* bytes read"
3367
3368run_test "Event-driven I/O: session-id resume" \
3369 "$P_SRV event=1 tickets=0 auth_mode=none" \
3370 "$P_CLI event=1 tickets=0 reconnect=1" \
3371 0 \
3372 -S "mbedtls_ssl_handshake returned" \
3373 -C "mbedtls_ssl_handshake returned" \
3374 -c "Read from server: .* bytes read"
3375
Hanno Becker6a33f592018-03-13 11:38:46 +00003376run_test "Event-driven I/O, DTLS: basic handshake" \
3377 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3378 "$P_CLI dtls=1 event=1 tickets=0" \
3379 0 \
3380 -c "Read from server: .* bytes read"
3381
3382run_test "Event-driven I/O, DTLS: client auth" \
3383 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3384 "$P_CLI dtls=1 event=1 tickets=0" \
3385 0 \
3386 -c "Read from server: .* bytes read"
3387
3388run_test "Event-driven I/O, DTLS: ticket" \
3389 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3390 "$P_CLI dtls=1 event=1 tickets=1" \
3391 0 \
3392 -c "Read from server: .* bytes read"
3393
3394run_test "Event-driven I/O, DTLS: ticket + client auth" \
3395 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3396 "$P_CLI dtls=1 event=1 tickets=1" \
3397 0 \
3398 -c "Read from server: .* bytes read"
3399
3400run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3401 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003402 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003403 0 \
3404 -c "Read from server: .* bytes read"
3405
3406run_test "Event-driven I/O, DTLS: ticket + resume" \
3407 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003408 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003409 0 \
3410 -c "Read from server: .* bytes read"
3411
3412run_test "Event-driven I/O, DTLS: session-id resume" \
3413 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003414 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003415 0 \
3416 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003417
3418# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3419# During session resumption, the client will send its ApplicationData record
3420# within the same datagram as the Finished messages. In this situation, the
3421# server MUST NOT idle on the underlying transport after handshake completion,
3422# because the ApplicationData request has already been queued internally.
3423run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003424 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003425 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003426 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003427 0 \
3428 -c "Read from server: .* bytes read"
3429
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003430# Tests for version negotiation
3431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003432run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003433 "$P_SRV" \
3434 "$P_CLI" \
3435 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003436 -S "mbedtls_ssl_handshake returned" \
3437 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003438 -s "Protocol is TLSv1.2" \
3439 -c "Protocol is TLSv1.2"
3440
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003441run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003442 "$P_SRV" \
3443 "$P_CLI max_version=tls1_1" \
3444 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003445 -S "mbedtls_ssl_handshake returned" \
3446 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003447 -s "Protocol is TLSv1.1" \
3448 -c "Protocol is TLSv1.1"
3449
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003450run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003451 "$P_SRV max_version=tls1_1" \
3452 "$P_CLI" \
3453 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003454 -S "mbedtls_ssl_handshake returned" \
3455 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003456 -s "Protocol is TLSv1.1" \
3457 -c "Protocol is TLSv1.1"
3458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003459run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003460 "$P_SRV max_version=tls1_1" \
3461 "$P_CLI max_version=tls1_1" \
3462 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003463 -S "mbedtls_ssl_handshake returned" \
3464 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003465 -s "Protocol is TLSv1.1" \
3466 -c "Protocol is TLSv1.1"
3467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003468run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003469 "$P_SRV min_version=tls1_1" \
3470 "$P_CLI max_version=tls1_1" \
3471 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003472 -S "mbedtls_ssl_handshake returned" \
3473 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003474 -s "Protocol is TLSv1.1" \
3475 -c "Protocol is TLSv1.1"
3476
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003477run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003478 "$P_SRV max_version=tls1_1" \
3479 "$P_CLI min_version=tls1_1" \
3480 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003481 -S "mbedtls_ssl_handshake returned" \
3482 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003483 -s "Protocol is TLSv1.1" \
3484 -c "Protocol is TLSv1.1"
3485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003486run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003487 "$P_SRV max_version=tls1_1" \
3488 "$P_CLI min_version=tls1_2" \
3489 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003490 -s "mbedtls_ssl_handshake returned" \
3491 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003492 -c "SSL - Handshake protocol not within min/max boundaries"
3493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003494run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003495 "$P_SRV min_version=tls1_2" \
3496 "$P_CLI max_version=tls1_1" \
3497 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003498 -s "mbedtls_ssl_handshake returned" \
3499 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003500 -s "SSL - Handshake protocol not within min/max boundaries"
3501
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003502# Tests for ALPN extension
3503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003504run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003505 "$P_SRV debug_level=3" \
3506 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003507 0 \
3508 -C "client hello, adding alpn extension" \
3509 -S "found alpn extension" \
3510 -C "got an alert message, type: \\[2:120]" \
3511 -S "server hello, adding alpn extension" \
3512 -C "found alpn extension " \
3513 -C "Application Layer Protocol is" \
3514 -S "Application Layer Protocol is"
3515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003516run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003517 "$P_SRV debug_level=3" \
3518 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003519 0 \
3520 -c "client hello, adding alpn extension" \
3521 -s "found alpn extension" \
3522 -C "got an alert message, type: \\[2:120]" \
3523 -S "server hello, adding alpn extension" \
3524 -C "found alpn extension " \
3525 -c "Application Layer Protocol is (none)" \
3526 -S "Application Layer Protocol is"
3527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003528run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003529 "$P_SRV debug_level=3 alpn=abc,1234" \
3530 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003531 0 \
3532 -C "client hello, adding alpn extension" \
3533 -S "found alpn extension" \
3534 -C "got an alert message, type: \\[2:120]" \
3535 -S "server hello, adding alpn extension" \
3536 -C "found alpn extension " \
3537 -C "Application Layer Protocol is" \
3538 -s "Application Layer Protocol is (none)"
3539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003540run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003541 "$P_SRV debug_level=3 alpn=abc,1234" \
3542 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003543 0 \
3544 -c "client hello, adding alpn extension" \
3545 -s "found alpn extension" \
3546 -C "got an alert message, type: \\[2:120]" \
3547 -s "server hello, adding alpn extension" \
3548 -c "found alpn extension" \
3549 -c "Application Layer Protocol is abc" \
3550 -s "Application Layer Protocol is abc"
3551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003552run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003553 "$P_SRV debug_level=3 alpn=abc,1234" \
3554 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003555 0 \
3556 -c "client hello, adding alpn extension" \
3557 -s "found alpn extension" \
3558 -C "got an alert message, type: \\[2:120]" \
3559 -s "server hello, adding alpn extension" \
3560 -c "found alpn extension" \
3561 -c "Application Layer Protocol is abc" \
3562 -s "Application Layer Protocol is abc"
3563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003564run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003565 "$P_SRV debug_level=3 alpn=abc,1234" \
3566 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003567 0 \
3568 -c "client hello, adding alpn extension" \
3569 -s "found alpn extension" \
3570 -C "got an alert message, type: \\[2:120]" \
3571 -s "server hello, adding alpn extension" \
3572 -c "found alpn extension" \
3573 -c "Application Layer Protocol is 1234" \
3574 -s "Application Layer Protocol is 1234"
3575
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003576run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003577 "$P_SRV debug_level=3 alpn=abc,123" \
3578 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003579 1 \
3580 -c "client hello, adding alpn extension" \
3581 -s "found alpn extension" \
3582 -c "got an alert message, type: \\[2:120]" \
3583 -S "server hello, adding alpn extension" \
3584 -C "found alpn extension" \
3585 -C "Application Layer Protocol is 1234" \
3586 -S "Application Layer Protocol is 1234"
3587
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003588
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003589# Tests for keyUsage in leaf certificates, part 1:
3590# server-side certificate/suite selection
3591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003592run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003593 "$P_SRV key_file=data_files/server2.key \
3594 crt_file=data_files/server2.ku-ds.crt" \
3595 "$P_CLI" \
3596 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003597 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003598
3599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003600run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003601 "$P_SRV key_file=data_files/server2.key \
3602 crt_file=data_files/server2.ku-ke.crt" \
3603 "$P_CLI" \
3604 0 \
3605 -c "Ciphersuite is TLS-RSA-WITH-"
3606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003607run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003608 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003609 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003610 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003611 1 \
3612 -C "Ciphersuite is "
3613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003614run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003615 "$P_SRV key_file=data_files/server5.key \
3616 crt_file=data_files/server5.ku-ds.crt" \
3617 "$P_CLI" \
3618 0 \
3619 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3620
3621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003622run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003623 "$P_SRV key_file=data_files/server5.key \
3624 crt_file=data_files/server5.ku-ka.crt" \
3625 "$P_CLI" \
3626 0 \
3627 -c "Ciphersuite is TLS-ECDH-"
3628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003629run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003630 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003631 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003632 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003633 1 \
3634 -C "Ciphersuite is "
3635
3636# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003637# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003639run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003640 "$O_SRV -key data_files/server2.key \
3641 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003642 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003643 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3644 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003645 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003646 -C "Processing of the Certificate handshake message failed" \
3647 -c "Ciphersuite is TLS-"
3648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003649run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003650 "$O_SRV -key data_files/server2.key \
3651 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003652 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003653 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3654 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003655 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003656 -C "Processing of the Certificate handshake message failed" \
3657 -c "Ciphersuite is TLS-"
3658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003659run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003660 "$O_SRV -key data_files/server2.key \
3661 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003662 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003663 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3664 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003665 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003666 -C "Processing of the Certificate handshake message failed" \
3667 -c "Ciphersuite is TLS-"
3668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003669run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003670 "$O_SRV -key data_files/server2.key \
3671 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003672 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003673 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3674 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003675 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003676 -c "Processing of the Certificate handshake message failed" \
3677 -C "Ciphersuite is TLS-"
3678
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003679run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3680 "$O_SRV -key data_files/server2.key \
3681 -cert data_files/server2.ku-ke.crt" \
3682 "$P_CLI debug_level=1 auth_mode=optional \
3683 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3684 0 \
3685 -c "bad certificate (usage extensions)" \
3686 -C "Processing of the Certificate handshake message failed" \
3687 -c "Ciphersuite is TLS-" \
3688 -c "! Usage does not match the keyUsage extension"
3689
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003690run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003691 "$O_SRV -key data_files/server2.key \
3692 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003693 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003694 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3695 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003696 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003697 -C "Processing of the Certificate handshake message failed" \
3698 -c "Ciphersuite is TLS-"
3699
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003700run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003701 "$O_SRV -key data_files/server2.key \
3702 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003703 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003704 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3705 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003706 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003707 -c "Processing of the Certificate handshake message failed" \
3708 -C "Ciphersuite is TLS-"
3709
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003710run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3711 "$O_SRV -key data_files/server2.key \
3712 -cert data_files/server2.ku-ds.crt" \
3713 "$P_CLI debug_level=1 auth_mode=optional \
3714 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3715 0 \
3716 -c "bad certificate (usage extensions)" \
3717 -C "Processing of the Certificate handshake message failed" \
3718 -c "Ciphersuite is TLS-" \
3719 -c "! Usage does not match the keyUsage extension"
3720
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003721# Tests for keyUsage in leaf certificates, part 3:
3722# server-side checking of client cert
3723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003724run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003725 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003726 "$O_CLI -key data_files/server2.key \
3727 -cert data_files/server2.ku-ds.crt" \
3728 0 \
3729 -S "bad certificate (usage extensions)" \
3730 -S "Processing of the Certificate handshake message failed"
3731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003732run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003733 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003734 "$O_CLI -key data_files/server2.key \
3735 -cert data_files/server2.ku-ke.crt" \
3736 0 \
3737 -s "bad certificate (usage extensions)" \
3738 -S "Processing of the Certificate handshake message failed"
3739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003740run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003741 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003742 "$O_CLI -key data_files/server2.key \
3743 -cert data_files/server2.ku-ke.crt" \
3744 1 \
3745 -s "bad certificate (usage extensions)" \
3746 -s "Processing of the Certificate handshake message failed"
3747
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003748run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003749 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003750 "$O_CLI -key data_files/server5.key \
3751 -cert data_files/server5.ku-ds.crt" \
3752 0 \
3753 -S "bad certificate (usage extensions)" \
3754 -S "Processing of the Certificate handshake message failed"
3755
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003756run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003757 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003758 "$O_CLI -key data_files/server5.key \
3759 -cert data_files/server5.ku-ka.crt" \
3760 0 \
3761 -s "bad certificate (usage extensions)" \
3762 -S "Processing of the Certificate handshake message failed"
3763
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003764# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003766run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003767 "$P_SRV key_file=data_files/server5.key \
3768 crt_file=data_files/server5.eku-srv.crt" \
3769 "$P_CLI" \
3770 0
3771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003772run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003773 "$P_SRV key_file=data_files/server5.key \
3774 crt_file=data_files/server5.eku-srv.crt" \
3775 "$P_CLI" \
3776 0
3777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003778run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003779 "$P_SRV key_file=data_files/server5.key \
3780 crt_file=data_files/server5.eku-cs_any.crt" \
3781 "$P_CLI" \
3782 0
3783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003784run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003785 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003786 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003787 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003788 1
3789
3790# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003792run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003793 "$O_SRV -key data_files/server5.key \
3794 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003795 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003796 0 \
3797 -C "bad certificate (usage extensions)" \
3798 -C "Processing of the Certificate handshake message failed" \
3799 -c "Ciphersuite is TLS-"
3800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003801run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003802 "$O_SRV -key data_files/server5.key \
3803 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003804 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003805 0 \
3806 -C "bad certificate (usage extensions)" \
3807 -C "Processing of the Certificate handshake message failed" \
3808 -c "Ciphersuite is TLS-"
3809
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003810run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003811 "$O_SRV -key data_files/server5.key \
3812 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003813 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003814 0 \
3815 -C "bad certificate (usage extensions)" \
3816 -C "Processing of the Certificate handshake message failed" \
3817 -c "Ciphersuite is TLS-"
3818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003819run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003820 "$O_SRV -key data_files/server5.key \
3821 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003822 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003823 1 \
3824 -c "bad certificate (usage extensions)" \
3825 -c "Processing of the Certificate handshake message failed" \
3826 -C "Ciphersuite is TLS-"
3827
3828# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003830run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003831 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003832 "$O_CLI -key data_files/server5.key \
3833 -cert data_files/server5.eku-cli.crt" \
3834 0 \
3835 -S "bad certificate (usage extensions)" \
3836 -S "Processing of the Certificate handshake message failed"
3837
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003838run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003839 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003840 "$O_CLI -key data_files/server5.key \
3841 -cert data_files/server5.eku-srv_cli.crt" \
3842 0 \
3843 -S "bad certificate (usage extensions)" \
3844 -S "Processing of the Certificate handshake message failed"
3845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003846run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003847 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003848 "$O_CLI -key data_files/server5.key \
3849 -cert data_files/server5.eku-cs_any.crt" \
3850 0 \
3851 -S "bad certificate (usage extensions)" \
3852 -S "Processing of the Certificate handshake message failed"
3853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003854run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003855 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003856 "$O_CLI -key data_files/server5.key \
3857 -cert data_files/server5.eku-cs.crt" \
3858 0 \
3859 -s "bad certificate (usage extensions)" \
3860 -S "Processing of the Certificate handshake message failed"
3861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003862run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003863 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003864 "$O_CLI -key data_files/server5.key \
3865 -cert data_files/server5.eku-cs.crt" \
3866 1 \
3867 -s "bad certificate (usage extensions)" \
3868 -s "Processing of the Certificate handshake message failed"
3869
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003870# Tests for DHM parameters loading
3871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003872run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003873 "$P_SRV" \
3874 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3875 debug_level=3" \
3876 0 \
3877 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003878 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003880run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003881 "$P_SRV dhm_file=data_files/dhparams.pem" \
3882 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3883 debug_level=3" \
3884 0 \
3885 -c "value of 'DHM: P ' (1024 bits)" \
3886 -c "value of 'DHM: G ' (2 bits)"
3887
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003888# Tests for DHM client-side size checking
3889
3890run_test "DHM size: server default, client default, OK" \
3891 "$P_SRV" \
3892 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3893 debug_level=1" \
3894 0 \
3895 -C "DHM prime too short:"
3896
3897run_test "DHM size: server default, client 2048, OK" \
3898 "$P_SRV" \
3899 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3900 debug_level=1 dhmlen=2048" \
3901 0 \
3902 -C "DHM prime too short:"
3903
3904run_test "DHM size: server 1024, client default, OK" \
3905 "$P_SRV dhm_file=data_files/dhparams.pem" \
3906 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3907 debug_level=1" \
3908 0 \
3909 -C "DHM prime too short:"
3910
3911run_test "DHM size: server 1000, client default, rejected" \
3912 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3913 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3914 debug_level=1" \
3915 1 \
3916 -c "DHM prime too short:"
3917
3918run_test "DHM size: server default, client 2049, rejected" \
3919 "$P_SRV" \
3920 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3921 debug_level=1 dhmlen=2049" \
3922 1 \
3923 -c "DHM prime too short:"
3924
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003925# Tests for PSK callback
3926
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003927run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003928 "$P_SRV psk=abc123 psk_identity=foo" \
3929 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3930 psk_identity=foo psk=abc123" \
3931 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003932 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003933 -S "SSL - Unknown identity received" \
3934 -S "SSL - Verification of the message MAC failed"
3935
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003936run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003937 "$P_SRV" \
3938 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3939 psk_identity=foo psk=abc123" \
3940 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003941 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003942 -S "SSL - Unknown identity received" \
3943 -S "SSL - Verification of the message MAC failed"
3944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003945run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003946 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3947 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3948 psk_identity=foo psk=abc123" \
3949 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003950 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003951 -s "SSL - Unknown identity received" \
3952 -S "SSL - Verification of the message MAC failed"
3953
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003954run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003955 "$P_SRV psk_list=abc,dead,def,beef" \
3956 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3957 psk_identity=abc psk=dead" \
3958 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003959 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003960 -S "SSL - Unknown identity received" \
3961 -S "SSL - Verification of the message MAC failed"
3962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003963run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003964 "$P_SRV psk_list=abc,dead,def,beef" \
3965 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3966 psk_identity=def psk=beef" \
3967 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003968 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003969 -S "SSL - Unknown identity received" \
3970 -S "SSL - Verification of the message MAC failed"
3971
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003972run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003973 "$P_SRV psk_list=abc,dead,def,beef" \
3974 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3975 psk_identity=ghi psk=beef" \
3976 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003977 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003978 -s "SSL - Unknown identity received" \
3979 -S "SSL - Verification of the message MAC failed"
3980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003981run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003982 "$P_SRV psk_list=abc,dead,def,beef" \
3983 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3984 psk_identity=abc psk=beef" \
3985 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003986 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003987 -S "SSL - Unknown identity received" \
3988 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003989
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003990# Tests for EC J-PAKE
3991
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003992requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003993run_test "ECJPAKE: client not configured" \
3994 "$P_SRV debug_level=3" \
3995 "$P_CLI debug_level=3" \
3996 0 \
3997 -C "add ciphersuite: c0ff" \
3998 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003999 -S "found ecjpake kkpp extension" \
4000 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004001 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004002 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004003 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004004 -S "None of the common ciphersuites is usable"
4005
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004006requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004007run_test "ECJPAKE: server not configured" \
4008 "$P_SRV debug_level=3" \
4009 "$P_CLI debug_level=3 ecjpake_pw=bla \
4010 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4011 1 \
4012 -c "add ciphersuite: c0ff" \
4013 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004014 -s "found ecjpake kkpp extension" \
4015 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004016 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004017 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004018 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004019 -s "None of the common ciphersuites is usable"
4020
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004021requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004022run_test "ECJPAKE: working, TLS" \
4023 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4024 "$P_CLI debug_level=3 ecjpake_pw=bla \
4025 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004026 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004027 -c "add ciphersuite: c0ff" \
4028 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004029 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004030 -s "found ecjpake kkpp extension" \
4031 -S "skip ecjpake kkpp extension" \
4032 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004033 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004034 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004035 -S "None of the common ciphersuites is usable" \
4036 -S "SSL - Verification of the message MAC failed"
4037
Janos Follath74537a62016-09-02 13:45:28 +01004038server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004039requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004040run_test "ECJPAKE: password mismatch, TLS" \
4041 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4042 "$P_CLI debug_level=3 ecjpake_pw=bad \
4043 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4044 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004045 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004046 -s "SSL - Verification of the message MAC failed"
4047
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004048requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004049run_test "ECJPAKE: working, DTLS" \
4050 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4051 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4052 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4053 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004054 -c "re-using cached ecjpake parameters" \
4055 -S "SSL - Verification of the message MAC failed"
4056
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004057requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004058run_test "ECJPAKE: working, DTLS, no cookie" \
4059 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4060 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4061 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4062 0 \
4063 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004064 -S "SSL - Verification of the message MAC failed"
4065
Janos Follath74537a62016-09-02 13:45:28 +01004066server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004067requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004068run_test "ECJPAKE: password mismatch, DTLS" \
4069 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4070 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4071 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4072 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004073 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004074 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004075
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004076# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004077requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004078run_test "ECJPAKE: working, DTLS, nolog" \
4079 "$P_SRV dtls=1 ecjpake_pw=bla" \
4080 "$P_CLI dtls=1 ecjpake_pw=bla \
4081 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4082 0
4083
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004084# Tests for ciphersuites per version
4085
Janos Follathe2681a42016-03-07 15:57:05 +00004086requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004087requires_config_enabled MBEDTLS_CAMELLIA_C
4088requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004089run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004090 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004091 "$P_CLI force_version=ssl3" \
4092 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004093 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004094
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004095requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4096requires_config_enabled MBEDTLS_CAMELLIA_C
4097requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004098run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004099 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01004100 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004101 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004102 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004103
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004104requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4105requires_config_enabled MBEDTLS_CAMELLIA_C
4106requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004107run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004108 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004109 "$P_CLI force_version=tls1_1" \
4110 0 \
4111 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4112
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004113requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4114requires_config_enabled MBEDTLS_CAMELLIA_C
4115requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004116run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004117 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004118 "$P_CLI force_version=tls1_2" \
4119 0 \
4120 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4121
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004122# Test for ClientHello without extensions
4123
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004124requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004125run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004126 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004127 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004128 0 \
4129 -s "dumping 'client hello extensions' (0 bytes)"
4130
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004131# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004132
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004133run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004134 "$P_SRV" \
4135 "$P_CLI request_size=100" \
4136 0 \
4137 -s "Read from client: 100 bytes read$"
4138
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004139run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004140 "$P_SRV" \
4141 "$P_CLI request_size=500" \
4142 0 \
4143 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004144
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004145# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004146
Janos Follathe2681a42016-03-07 15:57:05 +00004147requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004148run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004149 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004150 "$P_CLI request_size=1 force_version=ssl3 \
4151 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4152 0 \
4153 -s "Read from client: 1 bytes read"
4154
Janos Follathe2681a42016-03-07 15:57:05 +00004155requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004156run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004157 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004158 "$P_CLI request_size=1 force_version=ssl3 \
4159 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4160 0 \
4161 -s "Read from client: 1 bytes read"
4162
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004163run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004164 "$P_SRV" \
4165 "$P_CLI request_size=1 force_version=tls1 \
4166 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4167 0 \
4168 -s "Read from client: 1 bytes read"
4169
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004170run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004171 "$P_SRV" \
4172 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4173 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4174 0 \
4175 -s "Read from client: 1 bytes read"
4176
Hanno Becker32c55012017-11-10 08:42:54 +00004177requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004178run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004179 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004180 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004181 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004182 0 \
4183 -s "Read from client: 1 bytes read"
4184
Hanno Becker32c55012017-11-10 08:42:54 +00004185requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004186run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004187 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004188 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004189 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004190 0 \
4191 -s "Read from client: 1 bytes read"
4192
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004193run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004194 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004195 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004196 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4197 0 \
4198 -s "Read from client: 1 bytes read"
4199
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004200run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004201 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4202 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004203 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004204 0 \
4205 -s "Read from client: 1 bytes read"
4206
4207requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004208run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004209 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004210 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004211 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004212 0 \
4213 -s "Read from client: 1 bytes read"
4214
Hanno Becker8501f982017-11-10 08:59:04 +00004215requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004216run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004217 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4218 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4219 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004220 0 \
4221 -s "Read from client: 1 bytes read"
4222
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004223run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004224 "$P_SRV" \
4225 "$P_CLI request_size=1 force_version=tls1_1 \
4226 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4227 0 \
4228 -s "Read from client: 1 bytes read"
4229
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004230run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004231 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004232 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004233 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004234 0 \
4235 -s "Read from client: 1 bytes read"
4236
4237requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004238run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004239 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004240 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004241 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004242 0 \
4243 -s "Read from client: 1 bytes read"
4244
4245requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004246run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004247 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004248 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004249 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004250 0 \
4251 -s "Read from client: 1 bytes read"
4252
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004253run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004254 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004255 "$P_CLI request_size=1 force_version=tls1_1 \
4256 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4257 0 \
4258 -s "Read from client: 1 bytes read"
4259
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004260run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004261 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004262 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004263 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004264 0 \
4265 -s "Read from client: 1 bytes read"
4266
Hanno Becker8501f982017-11-10 08:59:04 +00004267requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004268run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004269 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004270 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004271 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004272 0 \
4273 -s "Read from client: 1 bytes read"
4274
Hanno Becker32c55012017-11-10 08:42:54 +00004275requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004276run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004277 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004278 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004279 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004280 0 \
4281 -s "Read from client: 1 bytes read"
4282
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004283run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004284 "$P_SRV" \
4285 "$P_CLI request_size=1 force_version=tls1_2 \
4286 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4287 0 \
4288 -s "Read from client: 1 bytes read"
4289
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004290run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004291 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004292 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004293 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004294 0 \
4295 -s "Read from client: 1 bytes read"
4296
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004297run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004298 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004299 "$P_CLI request_size=1 force_version=tls1_2 \
4300 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004301 0 \
4302 -s "Read from client: 1 bytes read"
4303
Hanno Becker32c55012017-11-10 08:42:54 +00004304requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004305run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004306 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004307 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004308 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004309 0 \
4310 -s "Read from client: 1 bytes read"
4311
Hanno Becker8501f982017-11-10 08:59:04 +00004312requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004313run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004314 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004315 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004316 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004317 0 \
4318 -s "Read from client: 1 bytes read"
4319
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004320run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004321 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004322 "$P_CLI request_size=1 force_version=tls1_2 \
4323 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4324 0 \
4325 -s "Read from client: 1 bytes read"
4326
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004327run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004328 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004329 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004330 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004331 0 \
4332 -s "Read from client: 1 bytes read"
4333
Hanno Becker32c55012017-11-10 08:42:54 +00004334requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004335run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004336 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004337 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004338 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004339 0 \
4340 -s "Read from client: 1 bytes read"
4341
Hanno Becker8501f982017-11-10 08:59:04 +00004342requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004343run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004344 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004345 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004346 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004347 0 \
4348 -s "Read from client: 1 bytes read"
4349
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004350run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004351 "$P_SRV" \
4352 "$P_CLI request_size=1 force_version=tls1_2 \
4353 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4354 0 \
4355 -s "Read from client: 1 bytes read"
4356
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004357run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004358 "$P_SRV" \
4359 "$P_CLI request_size=1 force_version=tls1_2 \
4360 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4361 0 \
4362 -s "Read from client: 1 bytes read"
4363
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004364# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004365
4366requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004367run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004368 "$P_SRV dtls=1 force_version=dtls1" \
4369 "$P_CLI dtls=1 request_size=1 \
4370 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4371 0 \
4372 -s "Read from client: 1 bytes read"
4373
4374requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004375run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004376 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4377 "$P_CLI dtls=1 request_size=1 \
4378 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4379 0 \
4380 -s "Read from client: 1 bytes read"
4381
4382requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4383requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004384run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004385 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4386 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004387 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4388 0 \
4389 -s "Read from client: 1 bytes read"
4390
4391requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4392requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004393run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004394 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004395 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004396 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004397 0 \
4398 -s "Read from client: 1 bytes read"
4399
4400requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004401run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004402 "$P_SRV dtls=1 force_version=dtls1_2" \
4403 "$P_CLI dtls=1 request_size=1 \
4404 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4405 0 \
4406 -s "Read from client: 1 bytes read"
4407
4408requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004409run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004410 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004411 "$P_CLI dtls=1 request_size=1 \
4412 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4413 0 \
4414 -s "Read from client: 1 bytes read"
4415
4416requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4417requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004418run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004419 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004420 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004421 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004422 0 \
4423 -s "Read from client: 1 bytes read"
4424
4425requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4426requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004427run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004428 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004429 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004430 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004431 0 \
4432 -s "Read from client: 1 bytes read"
4433
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004434# Tests for small server packets
4435
4436requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4437run_test "Small server packet SSLv3 BlockCipher" \
4438 "$P_SRV response_size=1 min_version=ssl3" \
4439 "$P_CLI force_version=ssl3 \
4440 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4441 0 \
4442 -c "Read from server: 1 bytes read"
4443
4444requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4445run_test "Small server packet SSLv3 StreamCipher" \
4446 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4447 "$P_CLI force_version=ssl3 \
4448 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4449 0 \
4450 -c "Read from server: 1 bytes read"
4451
4452run_test "Small server packet TLS 1.0 BlockCipher" \
4453 "$P_SRV response_size=1" \
4454 "$P_CLI force_version=tls1 \
4455 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4456 0 \
4457 -c "Read from server: 1 bytes read"
4458
4459run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4460 "$P_SRV response_size=1" \
4461 "$P_CLI force_version=tls1 etm=0 \
4462 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4463 0 \
4464 -c "Read from server: 1 bytes read"
4465
4466requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4467run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4468 "$P_SRV response_size=1 trunc_hmac=1" \
4469 "$P_CLI force_version=tls1 \
4470 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4471 0 \
4472 -c "Read from server: 1 bytes read"
4473
4474requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4475run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4476 "$P_SRV response_size=1 trunc_hmac=1" \
4477 "$P_CLI force_version=tls1 \
4478 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4479 0 \
4480 -c "Read from server: 1 bytes read"
4481
4482run_test "Small server packet TLS 1.0 StreamCipher" \
4483 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4484 "$P_CLI force_version=tls1 \
4485 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4486 0 \
4487 -c "Read from server: 1 bytes read"
4488
4489run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4490 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4491 "$P_CLI force_version=tls1 \
4492 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4493 0 \
4494 -c "Read from server: 1 bytes read"
4495
4496requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4497run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4498 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4499 "$P_CLI force_version=tls1 \
4500 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4501 0 \
4502 -c "Read from server: 1 bytes read"
4503
4504requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4505run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4506 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4507 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4508 trunc_hmac=1 etm=0" \
4509 0 \
4510 -c "Read from server: 1 bytes read"
4511
4512run_test "Small server packet TLS 1.1 BlockCipher" \
4513 "$P_SRV response_size=1" \
4514 "$P_CLI force_version=tls1_1 \
4515 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4516 0 \
4517 -c "Read from server: 1 bytes read"
4518
4519run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4520 "$P_SRV response_size=1" \
4521 "$P_CLI force_version=tls1_1 \
4522 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4523 0 \
4524 -c "Read from server: 1 bytes read"
4525
4526requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4527run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4528 "$P_SRV response_size=1 trunc_hmac=1" \
4529 "$P_CLI force_version=tls1_1 \
4530 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4531 0 \
4532 -c "Read from server: 1 bytes read"
4533
4534requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4535run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4536 "$P_SRV response_size=1 trunc_hmac=1" \
4537 "$P_CLI force_version=tls1_1 \
4538 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4539 0 \
4540 -c "Read from server: 1 bytes read"
4541
4542run_test "Small server packet TLS 1.1 StreamCipher" \
4543 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4544 "$P_CLI force_version=tls1_1 \
4545 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4546 0 \
4547 -c "Read from server: 1 bytes read"
4548
4549run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4550 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4551 "$P_CLI force_version=tls1_1 \
4552 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4553 0 \
4554 -c "Read from server: 1 bytes read"
4555
4556requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4557run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4558 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4559 "$P_CLI force_version=tls1_1 \
4560 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4561 0 \
4562 -c "Read from server: 1 bytes read"
4563
4564requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4565run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4566 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4567 "$P_CLI force_version=tls1_1 \
4568 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4569 0 \
4570 -c "Read from server: 1 bytes read"
4571
4572run_test "Small server packet TLS 1.2 BlockCipher" \
4573 "$P_SRV response_size=1" \
4574 "$P_CLI force_version=tls1_2 \
4575 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4576 0 \
4577 -c "Read from server: 1 bytes read"
4578
4579run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4580 "$P_SRV response_size=1" \
4581 "$P_CLI force_version=tls1_2 \
4582 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4583 0 \
4584 -c "Read from server: 1 bytes read"
4585
4586run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4587 "$P_SRV response_size=1" \
4588 "$P_CLI force_version=tls1_2 \
4589 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4590 0 \
4591 -c "Read from server: 1 bytes read"
4592
4593requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4594run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4595 "$P_SRV response_size=1 trunc_hmac=1" \
4596 "$P_CLI force_version=tls1_2 \
4597 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4598 0 \
4599 -c "Read from server: 1 bytes read"
4600
4601requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4602run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4603 "$P_SRV response_size=1 trunc_hmac=1" \
4604 "$P_CLI force_version=tls1_2 \
4605 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4606 0 \
4607 -c "Read from server: 1 bytes read"
4608
4609run_test "Small server packet TLS 1.2 StreamCipher" \
4610 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4611 "$P_CLI force_version=tls1_2 \
4612 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4613 0 \
4614 -c "Read from server: 1 bytes read"
4615
4616run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4617 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4618 "$P_CLI force_version=tls1_2 \
4619 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4620 0 \
4621 -c "Read from server: 1 bytes read"
4622
4623requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4624run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4625 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4626 "$P_CLI force_version=tls1_2 \
4627 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4628 0 \
4629 -c "Read from server: 1 bytes read"
4630
4631requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4632run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4633 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4634 "$P_CLI force_version=tls1_2 \
4635 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4636 0 \
4637 -c "Read from server: 1 bytes read"
4638
4639run_test "Small server packet TLS 1.2 AEAD" \
4640 "$P_SRV response_size=1" \
4641 "$P_CLI force_version=tls1_2 \
4642 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4643 0 \
4644 -c "Read from server: 1 bytes read"
4645
4646run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4647 "$P_SRV response_size=1" \
4648 "$P_CLI force_version=tls1_2 \
4649 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4650 0 \
4651 -c "Read from server: 1 bytes read"
4652
4653# Tests for small server packets in DTLS
4654
4655requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4656run_test "Small server packet DTLS 1.0" \
4657 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4658 "$P_CLI dtls=1 \
4659 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4660 0 \
4661 -c "Read from server: 1 bytes read"
4662
4663requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4664run_test "Small server packet DTLS 1.0, without EtM" \
4665 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4666 "$P_CLI dtls=1 \
4667 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4668 0 \
4669 -c "Read from server: 1 bytes read"
4670
4671requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4672requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4673run_test "Small server packet DTLS 1.0, truncated hmac" \
4674 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4675 "$P_CLI dtls=1 trunc_hmac=1 \
4676 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4677 0 \
4678 -c "Read from server: 1 bytes read"
4679
4680requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4681requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4682run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4683 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4684 "$P_CLI dtls=1 \
4685 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4686 0 \
4687 -c "Read from server: 1 bytes read"
4688
4689requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4690run_test "Small server packet DTLS 1.2" \
4691 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4692 "$P_CLI dtls=1 \
4693 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4694 0 \
4695 -c "Read from server: 1 bytes read"
4696
4697requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4698run_test "Small server packet DTLS 1.2, without EtM" \
4699 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4700 "$P_CLI dtls=1 \
4701 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4702 0 \
4703 -c "Read from server: 1 bytes read"
4704
4705requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4706requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4707run_test "Small server packet DTLS 1.2, truncated hmac" \
4708 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4709 "$P_CLI dtls=1 \
4710 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4711 0 \
4712 -c "Read from server: 1 bytes read"
4713
4714requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4715requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4716run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4717 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4718 "$P_CLI dtls=1 \
4719 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4720 0 \
4721 -c "Read from server: 1 bytes read"
4722
Janos Follath00efff72016-05-06 13:48:23 +01004723# A test for extensions in SSLv3
4724
4725requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4726run_test "SSLv3 with extensions, server side" \
4727 "$P_SRV min_version=ssl3 debug_level=3" \
4728 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4729 0 \
4730 -S "dumping 'client hello extensions'" \
4731 -S "server hello, total extension length:"
4732
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004733# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004734
Angus Grattonc4dd0732018-04-11 16:28:39 +10004735# How many fragments do we expect to write $1 bytes?
4736fragments_for_write() {
4737 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4738}
4739
Janos Follathe2681a42016-03-07 15:57:05 +00004740requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004741run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004742 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004743 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004744 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4745 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004746 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4747 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004748
Janos Follathe2681a42016-03-07 15:57:05 +00004749requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004750run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004751 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004752 "$P_CLI request_size=16384 force_version=ssl3 \
4753 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4754 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004755 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4756 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004757
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004758run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004759 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004760 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004761 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4762 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004763 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4764 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004765
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004766run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004767 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004768 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4769 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4770 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004771 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004772
Hanno Becker32c55012017-11-10 08:42:54 +00004773requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004774run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004775 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004776 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004777 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004778 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004779 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4780 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004781
Hanno Becker32c55012017-11-10 08:42:54 +00004782requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004783run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004784 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004785 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004786 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004787 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004788 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004789
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004790run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004791 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004792 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004793 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4794 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004795 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004796
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004797run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004798 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4799 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004800 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004801 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004802 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004803
4804requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004805run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004806 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004807 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004808 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004809 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004810 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004811
Hanno Becker278fc7a2017-11-10 09:16:28 +00004812requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004813run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004814 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004815 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004816 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004817 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004818 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4819 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004820
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004821run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004822 "$P_SRV" \
4823 "$P_CLI request_size=16384 force_version=tls1_1 \
4824 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4825 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004826 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4827 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004828
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004829run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004830 "$P_SRV" \
4831 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4832 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004833 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004834 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004835
Hanno Becker32c55012017-11-10 08:42:54 +00004836requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004837run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004838 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004839 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004840 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004841 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004842 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004843
Hanno Becker32c55012017-11-10 08:42:54 +00004844requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004845run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004846 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004847 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004848 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004849 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004850 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004851
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004852run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004853 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4854 "$P_CLI request_size=16384 force_version=tls1_1 \
4855 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4856 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004857 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4858 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004859
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004860run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004861 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004862 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004863 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004864 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004865 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4866 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004867
Hanno Becker278fc7a2017-11-10 09:16:28 +00004868requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004869run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004870 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004871 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004872 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004873 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004874 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004875
Hanno Becker278fc7a2017-11-10 09:16:28 +00004876requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004877run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004878 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004879 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004880 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004881 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004882 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4883 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004884
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004885run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004886 "$P_SRV" \
4887 "$P_CLI request_size=16384 force_version=tls1_2 \
4888 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4889 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004890 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4891 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004892
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004893run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004894 "$P_SRV" \
4895 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4896 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4897 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004898 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004899
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004900run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004901 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004902 "$P_CLI request_size=16384 force_version=tls1_2 \
4903 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004904 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004905 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4906 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004907
Hanno Becker32c55012017-11-10 08:42:54 +00004908requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004909run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004910 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004911 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004912 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004913 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004914 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004915
Hanno Becker278fc7a2017-11-10 09:16:28 +00004916requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004917run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004918 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004919 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004920 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004921 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004922 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4923 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004924
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004925run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004926 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004927 "$P_CLI request_size=16384 force_version=tls1_2 \
4928 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4929 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004930 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4931 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004932
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004933run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004934 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004935 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004936 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4937 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004938 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004939
Hanno Becker32c55012017-11-10 08:42:54 +00004940requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004941run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004942 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004943 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004944 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004945 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004946 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004947
Hanno Becker278fc7a2017-11-10 09:16:28 +00004948requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004949run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004950 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004951 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004952 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004953 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004954 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4955 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004956
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004957run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004958 "$P_SRV" \
4959 "$P_CLI request_size=16384 force_version=tls1_2 \
4960 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4961 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004962 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4963 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004964
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004965run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004966 "$P_SRV" \
4967 "$P_CLI request_size=16384 force_version=tls1_2 \
4968 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4969 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004970 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4971 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004972
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004973# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004974requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4975run_test "Large server packet SSLv3 StreamCipher" \
4976 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4977 "$P_CLI force_version=ssl3 \
4978 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4979 0 \
4980 -c "Read from server: 16384 bytes read"
4981
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04004982# Checking next 4 tests logs for 1n-1 split against BEAST too
4983requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4984run_test "Large server packet SSLv3 BlockCipher" \
4985 "$P_SRV response_size=16384 min_version=ssl3" \
4986 "$P_CLI force_version=ssl3 recsplit=0 \
4987 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4988 0 \
4989 -c "Read from server: 1 bytes read"\
4990 -c "16383 bytes read"\
4991 -C "Read from server: 16384 bytes read"
4992
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004993run_test "Large server packet TLS 1.0 BlockCipher" \
4994 "$P_SRV response_size=16384" \
4995 "$P_CLI force_version=tls1 recsplit=0 \
4996 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4997 0 \
4998 -c "Read from server: 1 bytes read"\
4999 -c "16383 bytes read"\
5000 -C "Read from server: 16384 bytes read"
5001
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005002run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5003 "$P_SRV response_size=16384" \
5004 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5005 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5006 0 \
5007 -c "Read from server: 1 bytes read"\
5008 -c "16383 bytes read"\
5009 -C "Read from server: 16384 bytes read"
5010
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005011requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5012run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5013 "$P_SRV response_size=16384" \
5014 "$P_CLI force_version=tls1 recsplit=0 \
5015 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5016 trunc_hmac=1" \
5017 0 \
5018 -c "Read from server: 1 bytes read"\
5019 -c "16383 bytes read"\
5020 -C "Read from server: 16384 bytes read"
5021
5022requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5023run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5024 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5025 "$P_CLI force_version=tls1 \
5026 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5027 trunc_hmac=1" \
5028 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005029 -s "16384 bytes written in 1 fragments" \
5030 -c "Read from server: 16384 bytes read"
5031
5032run_test "Large server packet TLS 1.0 StreamCipher" \
5033 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5034 "$P_CLI force_version=tls1 \
5035 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5036 0 \
5037 -s "16384 bytes written in 1 fragments" \
5038 -c "Read from server: 16384 bytes read"
5039
5040run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5041 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5042 "$P_CLI force_version=tls1 \
5043 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5044 0 \
5045 -s "16384 bytes written in 1 fragments" \
5046 -c "Read from server: 16384 bytes read"
5047
5048requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5049run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5050 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5051 "$P_CLI force_version=tls1 \
5052 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5053 0 \
5054 -s "16384 bytes written in 1 fragments" \
5055 -c "Read from server: 16384 bytes read"
5056
5057requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5058run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5059 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5060 "$P_CLI force_version=tls1 \
5061 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5062 0 \
5063 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005064 -c "Read from server: 16384 bytes read"
5065
5066run_test "Large server packet TLS 1.1 BlockCipher" \
5067 "$P_SRV response_size=16384" \
5068 "$P_CLI force_version=tls1_1 \
5069 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5070 0 \
5071 -c "Read from server: 16384 bytes read"
5072
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005073run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5074 "$P_SRV response_size=16384" \
5075 "$P_CLI force_version=tls1_1 etm=0 \
5076 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005077 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005078 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005079 -c "Read from server: 16384 bytes read"
5080
5081requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5082run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5083 "$P_SRV response_size=16384" \
5084 "$P_CLI force_version=tls1_1 \
5085 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5086 trunc_hmac=1" \
5087 0 \
5088 -c "Read from server: 16384 bytes read"
5089
5090requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005091run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5092 "$P_SRV response_size=16384 trunc_hmac=1" \
5093 "$P_CLI force_version=tls1_1 \
5094 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5095 0 \
5096 -s "16384 bytes written in 1 fragments" \
5097 -c "Read from server: 16384 bytes read"
5098
5099run_test "Large server packet TLS 1.1 StreamCipher" \
5100 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5101 "$P_CLI force_version=tls1_1 \
5102 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5103 0 \
5104 -c "Read from server: 16384 bytes read"
5105
5106run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5107 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5108 "$P_CLI force_version=tls1_1 \
5109 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5110 0 \
5111 -s "16384 bytes written in 1 fragments" \
5112 -c "Read from server: 16384 bytes read"
5113
5114requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005115run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5116 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5117 "$P_CLI force_version=tls1_1 \
5118 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5119 trunc_hmac=1" \
5120 0 \
5121 -c "Read from server: 16384 bytes read"
5122
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005123run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5124 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5125 "$P_CLI force_version=tls1_1 \
5126 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5127 0 \
5128 -s "16384 bytes written in 1 fragments" \
5129 -c "Read from server: 16384 bytes read"
5130
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005131run_test "Large server packet TLS 1.2 BlockCipher" \
5132 "$P_SRV response_size=16384" \
5133 "$P_CLI force_version=tls1_2 \
5134 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5135 0 \
5136 -c "Read from server: 16384 bytes read"
5137
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005138run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5139 "$P_SRV response_size=16384" \
5140 "$P_CLI force_version=tls1_2 etm=0 \
5141 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5142 0 \
5143 -s "16384 bytes written in 1 fragments" \
5144 -c "Read from server: 16384 bytes read"
5145
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005146run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5147 "$P_SRV response_size=16384" \
5148 "$P_CLI force_version=tls1_2 \
5149 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5150 0 \
5151 -c "Read from server: 16384 bytes read"
5152
5153requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5154run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5155 "$P_SRV response_size=16384" \
5156 "$P_CLI force_version=tls1_2 \
5157 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5158 trunc_hmac=1" \
5159 0 \
5160 -c "Read from server: 16384 bytes read"
5161
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005162run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5163 "$P_SRV response_size=16384 trunc_hmac=1" \
5164 "$P_CLI force_version=tls1_2 \
5165 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5166 0 \
5167 -s "16384 bytes written in 1 fragments" \
5168 -c "Read from server: 16384 bytes read"
5169
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005170run_test "Large server packet TLS 1.2 StreamCipher" \
5171 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5172 "$P_CLI force_version=tls1_2 \
5173 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5174 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005175 -s "16384 bytes written in 1 fragments" \
5176 -c "Read from server: 16384 bytes read"
5177
5178run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5179 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5180 "$P_CLI force_version=tls1_2 \
5181 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5182 0 \
5183 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005184 -c "Read from server: 16384 bytes read"
5185
5186requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5187run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5188 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5189 "$P_CLI force_version=tls1_2 \
5190 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5191 trunc_hmac=1" \
5192 0 \
5193 -c "Read from server: 16384 bytes read"
5194
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005195requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5196run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5197 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5198 "$P_CLI force_version=tls1_2 \
5199 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5200 0 \
5201 -s "16384 bytes written in 1 fragments" \
5202 -c "Read from server: 16384 bytes read"
5203
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005204run_test "Large server packet TLS 1.2 AEAD" \
5205 "$P_SRV response_size=16384" \
5206 "$P_CLI force_version=tls1_2 \
5207 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5208 0 \
5209 -c "Read from server: 16384 bytes read"
5210
5211run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5212 "$P_SRV response_size=16384" \
5213 "$P_CLI force_version=tls1_2 \
5214 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5215 0 \
5216 -c "Read from server: 16384 bytes read"
5217
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005218# Tests for restartable ECC
5219
5220requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5221run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005222 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005223 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005224 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005225 debug_level=1" \
5226 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005227 -C "x509_verify_cert.*4b00" \
5228 -C "mbedtls_pk_verify.*4b00" \
5229 -C "mbedtls_ecdh_make_public.*4b00" \
5230 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005231
5232requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5233run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005234 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005235 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005236 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005237 debug_level=1 ec_max_ops=0" \
5238 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005239 -C "x509_verify_cert.*4b00" \
5240 -C "mbedtls_pk_verify.*4b00" \
5241 -C "mbedtls_ecdh_make_public.*4b00" \
5242 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005243
5244requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5245run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005246 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005247 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005248 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005249 debug_level=1 ec_max_ops=65535" \
5250 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005251 -C "x509_verify_cert.*4b00" \
5252 -C "mbedtls_pk_verify.*4b00" \
5253 -C "mbedtls_ecdh_make_public.*4b00" \
5254 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005255
5256requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5257run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005258 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005259 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005260 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005261 debug_level=1 ec_max_ops=1000" \
5262 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005263 -c "x509_verify_cert.*4b00" \
5264 -c "mbedtls_pk_verify.*4b00" \
5265 -c "mbedtls_ecdh_make_public.*4b00" \
5266 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005267
5268requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005269run_test "EC restart: TLS, max_ops=1000, badsign" \
5270 "$P_SRV auth_mode=required \
5271 crt_file=data_files/server5-badsign.crt \
5272 key_file=data_files/server5.key" \
5273 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5274 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5275 debug_level=1 ec_max_ops=1000" \
5276 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005277 -c "x509_verify_cert.*4b00" \
5278 -C "mbedtls_pk_verify.*4b00" \
5279 -C "mbedtls_ecdh_make_public.*4b00" \
5280 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005281 -c "! The certificate is not correctly signed by the trusted CA" \
5282 -c "! mbedtls_ssl_handshake returned" \
5283 -c "X509 - Certificate verification failed"
5284
5285requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5286run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5287 "$P_SRV auth_mode=required \
5288 crt_file=data_files/server5-badsign.crt \
5289 key_file=data_files/server5.key" \
5290 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5291 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5292 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5293 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005294 -c "x509_verify_cert.*4b00" \
5295 -c "mbedtls_pk_verify.*4b00" \
5296 -c "mbedtls_ecdh_make_public.*4b00" \
5297 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005298 -c "! The certificate is not correctly signed by the trusted CA" \
5299 -C "! mbedtls_ssl_handshake returned" \
5300 -C "X509 - Certificate verification failed"
5301
5302requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5303run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5304 "$P_SRV auth_mode=required \
5305 crt_file=data_files/server5-badsign.crt \
5306 key_file=data_files/server5.key" \
5307 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5308 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5309 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5310 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005311 -C "x509_verify_cert.*4b00" \
5312 -c "mbedtls_pk_verify.*4b00" \
5313 -c "mbedtls_ecdh_make_public.*4b00" \
5314 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005315 -C "! The certificate is not correctly signed by the trusted CA" \
5316 -C "! mbedtls_ssl_handshake returned" \
5317 -C "X509 - Certificate verification failed"
5318
5319requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005320run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005321 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005322 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005323 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005324 dtls=1 debug_level=1 ec_max_ops=1000" \
5325 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005326 -c "x509_verify_cert.*4b00" \
5327 -c "mbedtls_pk_verify.*4b00" \
5328 -c "mbedtls_ecdh_make_public.*4b00" \
5329 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005330
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005331requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5332run_test "EC restart: TLS, max_ops=1000 no client auth" \
5333 "$P_SRV" \
5334 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5335 debug_level=1 ec_max_ops=1000" \
5336 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005337 -c "x509_verify_cert.*4b00" \
5338 -c "mbedtls_pk_verify.*4b00" \
5339 -c "mbedtls_ecdh_make_public.*4b00" \
5340 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005341
5342requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5343run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5344 "$P_SRV psk=abc123" \
5345 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5346 psk=abc123 debug_level=1 ec_max_ops=1000" \
5347 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005348 -C "x509_verify_cert.*4b00" \
5349 -C "mbedtls_pk_verify.*4b00" \
5350 -C "mbedtls_ecdh_make_public.*4b00" \
5351 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005352
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005353# Tests of asynchronous private key support in SSL
5354
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005355requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005356run_test "SSL async private: sign, delay=0" \
5357 "$P_SRV \
5358 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005359 "$P_CLI" \
5360 0 \
5361 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005362 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005363
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005364requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005365run_test "SSL async private: sign, delay=1" \
5366 "$P_SRV \
5367 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005368 "$P_CLI" \
5369 0 \
5370 -s "Async sign callback: using key slot " \
5371 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005372 -s "Async resume (slot [0-9]): sign done, status=0"
5373
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005374requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5375run_test "SSL async private: sign, delay=2" \
5376 "$P_SRV \
5377 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5378 "$P_CLI" \
5379 0 \
5380 -s "Async sign callback: using key slot " \
5381 -U "Async sign callback: using key slot " \
5382 -s "Async resume (slot [0-9]): call 1 more times." \
5383 -s "Async resume (slot [0-9]): call 0 more times." \
5384 -s "Async resume (slot [0-9]): sign done, status=0"
5385
Gilles Peskined3268832018-04-26 06:23:59 +02005386# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5387# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5388requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5389requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5390run_test "SSL async private: sign, RSA, TLS 1.1" \
5391 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5392 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5393 "$P_CLI force_version=tls1_1" \
5394 0 \
5395 -s "Async sign callback: using key slot " \
5396 -s "Async resume (slot [0-9]): sign done, status=0"
5397
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005398requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005399run_test "SSL async private: sign, SNI" \
5400 "$P_SRV debug_level=3 \
5401 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5402 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5403 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5404 "$P_CLI server_name=polarssl.example" \
5405 0 \
5406 -s "Async sign callback: using key slot " \
5407 -s "Async resume (slot [0-9]): sign done, status=0" \
5408 -s "parse ServerName extension" \
5409 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5410 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5411
5412requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005413run_test "SSL async private: decrypt, delay=0" \
5414 "$P_SRV \
5415 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5416 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5417 0 \
5418 -s "Async decrypt callback: using key slot " \
5419 -s "Async resume (slot [0-9]): decrypt done, status=0"
5420
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005421requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005422run_test "SSL async private: decrypt, delay=1" \
5423 "$P_SRV \
5424 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5425 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5426 0 \
5427 -s "Async decrypt callback: using key slot " \
5428 -s "Async resume (slot [0-9]): call 0 more times." \
5429 -s "Async resume (slot [0-9]): decrypt done, status=0"
5430
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005431requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005432run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5433 "$P_SRV psk=abc123 \
5434 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5435 "$P_CLI psk=abc123 \
5436 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5437 0 \
5438 -s "Async decrypt callback: using key slot " \
5439 -s "Async resume (slot [0-9]): decrypt done, status=0"
5440
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005441requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005442run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5443 "$P_SRV psk=abc123 \
5444 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5445 "$P_CLI psk=abc123 \
5446 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5447 0 \
5448 -s "Async decrypt callback: using key slot " \
5449 -s "Async resume (slot [0-9]): call 0 more times." \
5450 -s "Async resume (slot [0-9]): decrypt done, status=0"
5451
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005452requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005453run_test "SSL async private: sign callback not present" \
5454 "$P_SRV \
5455 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5456 "$P_CLI; [ \$? -eq 1 ] &&
5457 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5458 0 \
5459 -S "Async sign callback" \
5460 -s "! mbedtls_ssl_handshake returned" \
5461 -s "The own private key or pre-shared key is not set, but needed" \
5462 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5463 -s "Successful connection"
5464
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005465requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005466run_test "SSL async private: decrypt callback not present" \
5467 "$P_SRV debug_level=1 \
5468 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5469 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5470 [ \$? -eq 1 ] && $P_CLI" \
5471 0 \
5472 -S "Async decrypt callback" \
5473 -s "! mbedtls_ssl_handshake returned" \
5474 -s "got no RSA private key" \
5475 -s "Async resume (slot [0-9]): sign done, status=0" \
5476 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005477
5478# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005479requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005480run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005481 "$P_SRV \
5482 async_operations=s async_private_delay1=1 \
5483 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5484 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005485 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5486 0 \
5487 -s "Async sign callback: using key slot 0," \
5488 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005489 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005490
5491# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005492requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005493run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005494 "$P_SRV \
5495 async_operations=s async_private_delay2=1 \
5496 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5497 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005498 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5499 0 \
5500 -s "Async sign callback: using key slot 0," \
5501 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005502 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005503
5504# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005505requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005506run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005507 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005508 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005509 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5510 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005511 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5512 0 \
5513 -s "Async sign callback: using key slot 1," \
5514 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005515 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005516
5517# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005518requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005519run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005520 "$P_SRV \
5521 async_operations=s async_private_delay1=1 \
5522 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5523 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005524 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5525 0 \
5526 -s "Async sign callback: no key matches this certificate."
5527
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005528requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005529run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005530 "$P_SRV \
5531 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5532 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005533 "$P_CLI" \
5534 1 \
5535 -s "Async sign callback: injected error" \
5536 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005537 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005538 -s "! mbedtls_ssl_handshake returned"
5539
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005540requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005541run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005542 "$P_SRV \
5543 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5544 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005545 "$P_CLI" \
5546 1 \
5547 -s "Async sign callback: using key slot " \
5548 -S "Async resume" \
5549 -s "Async cancel"
5550
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005551requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005552run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005553 "$P_SRV \
5554 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5555 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005556 "$P_CLI" \
5557 1 \
5558 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005559 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005560 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005561 -s "! mbedtls_ssl_handshake returned"
5562
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005563requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005564run_test "SSL async private: decrypt, error in start" \
5565 "$P_SRV \
5566 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5567 async_private_error=1" \
5568 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5569 1 \
5570 -s "Async decrypt callback: injected error" \
5571 -S "Async resume" \
5572 -S "Async cancel" \
5573 -s "! mbedtls_ssl_handshake returned"
5574
5575requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5576run_test "SSL async private: decrypt, cancel after start" \
5577 "$P_SRV \
5578 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5579 async_private_error=2" \
5580 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5581 1 \
5582 -s "Async decrypt callback: using key slot " \
5583 -S "Async resume" \
5584 -s "Async cancel"
5585
5586requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5587run_test "SSL async private: decrypt, error in resume" \
5588 "$P_SRV \
5589 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5590 async_private_error=3" \
5591 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5592 1 \
5593 -s "Async decrypt callback: using key slot " \
5594 -s "Async resume callback: decrypt done but injected error" \
5595 -S "Async cancel" \
5596 -s "! mbedtls_ssl_handshake returned"
5597
5598requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005599run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005600 "$P_SRV \
5601 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5602 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005603 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5604 0 \
5605 -s "Async cancel" \
5606 -s "! mbedtls_ssl_handshake returned" \
5607 -s "Async resume" \
5608 -s "Successful connection"
5609
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005610requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005611run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005612 "$P_SRV \
5613 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5614 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005615 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5616 0 \
5617 -s "! mbedtls_ssl_handshake returned" \
5618 -s "Async resume" \
5619 -s "Successful connection"
5620
5621# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005622requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005623run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005624 "$P_SRV \
5625 async_operations=s async_private_delay1=1 async_private_error=-2 \
5626 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5627 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005628 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5629 [ \$? -eq 1 ] &&
5630 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5631 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005632 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005633 -S "Async resume" \
5634 -s "Async cancel" \
5635 -s "! mbedtls_ssl_handshake returned" \
5636 -s "Async sign callback: no key matches this certificate." \
5637 -s "Successful connection"
5638
5639# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005640requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005641run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005642 "$P_SRV \
5643 async_operations=s async_private_delay1=1 async_private_error=-3 \
5644 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5645 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005646 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5647 [ \$? -eq 1 ] &&
5648 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5649 0 \
5650 -s "Async resume" \
5651 -s "! mbedtls_ssl_handshake returned" \
5652 -s "Async sign callback: no key matches this certificate." \
5653 -s "Successful connection"
5654
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005655requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005656requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005657run_test "SSL async private: renegotiation: client-initiated; sign" \
5658 "$P_SRV \
5659 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005660 exchanges=2 renegotiation=1" \
5661 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5662 0 \
5663 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005664 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005665
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005666requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005667requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005668run_test "SSL async private: renegotiation: server-initiated; sign" \
5669 "$P_SRV \
5670 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005671 exchanges=2 renegotiation=1 renegotiate=1" \
5672 "$P_CLI exchanges=2 renegotiation=1" \
5673 0 \
5674 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005675 -s "Async resume (slot [0-9]): sign done, status=0"
5676
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005677requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005678requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5679run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5680 "$P_SRV \
5681 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5682 exchanges=2 renegotiation=1" \
5683 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5684 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5685 0 \
5686 -s "Async decrypt callback: using key slot " \
5687 -s "Async resume (slot [0-9]): decrypt done, status=0"
5688
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005689requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005690requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5691run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5692 "$P_SRV \
5693 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5694 exchanges=2 renegotiation=1 renegotiate=1" \
5695 "$P_CLI exchanges=2 renegotiation=1 \
5696 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5697 0 \
5698 -s "Async decrypt callback: using key slot " \
5699 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005700
Ron Eldor58093c82018-06-28 13:22:05 +03005701# Tests for ECC extensions (rfc 4492)
5702
Ron Eldor643df7c2018-06-28 16:17:00 +03005703requires_config_enabled MBEDTLS_AES_C
5704requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5705requires_config_enabled MBEDTLS_SHA256_C
5706requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005707run_test "Force a non ECC ciphersuite in the client side" \
5708 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005709 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005710 0 \
5711 -C "client hello, adding supported_elliptic_curves extension" \
5712 -C "client hello, adding supported_point_formats extension" \
5713 -S "found supported elliptic curves extension" \
5714 -S "found supported point formats extension"
5715
Ron Eldor643df7c2018-06-28 16:17:00 +03005716requires_config_enabled MBEDTLS_AES_C
5717requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5718requires_config_enabled MBEDTLS_SHA256_C
5719requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005720run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005721 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005722 "$P_CLI debug_level=3" \
5723 0 \
5724 -C "found supported_point_formats extension" \
5725 -S "server hello, supported_point_formats extension"
5726
Ron Eldor643df7c2018-06-28 16:17:00 +03005727requires_config_enabled MBEDTLS_AES_C
5728requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5729requires_config_enabled MBEDTLS_SHA256_C
5730requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005731run_test "Force an ECC ciphersuite in the client side" \
5732 "$P_SRV debug_level=3" \
5733 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5734 0 \
5735 -c "client hello, adding supported_elliptic_curves extension" \
5736 -c "client hello, adding supported_point_formats extension" \
5737 -s "found supported elliptic curves extension" \
5738 -s "found supported point formats extension"
5739
Ron Eldor643df7c2018-06-28 16:17:00 +03005740requires_config_enabled MBEDTLS_AES_C
5741requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5742requires_config_enabled MBEDTLS_SHA256_C
5743requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005744run_test "Force an ECC ciphersuite in the server side" \
5745 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5746 "$P_CLI debug_level=3" \
5747 0 \
5748 -c "found supported_point_formats extension" \
5749 -s "server hello, supported_point_formats extension"
5750
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005751# Tests for DTLS HelloVerifyRequest
5752
5753run_test "DTLS cookie: enabled" \
5754 "$P_SRV dtls=1 debug_level=2" \
5755 "$P_CLI dtls=1 debug_level=2" \
5756 0 \
5757 -s "cookie verification failed" \
5758 -s "cookie verification passed" \
5759 -S "cookie verification skipped" \
5760 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005761 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005762 -S "SSL - The requested feature is not available"
5763
5764run_test "DTLS cookie: disabled" \
5765 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5766 "$P_CLI dtls=1 debug_level=2" \
5767 0 \
5768 -S "cookie verification failed" \
5769 -S "cookie verification passed" \
5770 -s "cookie verification skipped" \
5771 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005772 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005773 -S "SSL - The requested feature is not available"
5774
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005775run_test "DTLS cookie: default (failing)" \
5776 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5777 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5778 1 \
5779 -s "cookie verification failed" \
5780 -S "cookie verification passed" \
5781 -S "cookie verification skipped" \
5782 -C "received hello verify request" \
5783 -S "hello verification requested" \
5784 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005785
5786requires_ipv6
5787run_test "DTLS cookie: enabled, IPv6" \
5788 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5789 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5790 0 \
5791 -s "cookie verification failed" \
5792 -s "cookie verification passed" \
5793 -S "cookie verification skipped" \
5794 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005795 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005796 -S "SSL - The requested feature is not available"
5797
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005798run_test "DTLS cookie: enabled, nbio" \
5799 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5800 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5801 0 \
5802 -s "cookie verification failed" \
5803 -s "cookie verification passed" \
5804 -S "cookie verification skipped" \
5805 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005806 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005807 -S "SSL - The requested feature is not available"
5808
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005809# Tests for client reconnecting from the same port with DTLS
5810
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005811not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005812run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005813 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5814 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005815 0 \
5816 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005817 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005818 -S "Client initiated reconnection from same port"
5819
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005820not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005821run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005822 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5823 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005824 0 \
5825 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005826 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005827 -s "Client initiated reconnection from same port"
5828
Paul Bakker362689d2016-05-13 10:33:25 +01005829not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5830run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005831 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5832 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005833 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005834 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005835 -s "Client initiated reconnection from same port"
5836
Paul Bakker362689d2016-05-13 10:33:25 +01005837only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5838run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5839 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5840 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5841 0 \
5842 -S "The operation timed out" \
5843 -s "Client initiated reconnection from same port"
5844
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005845run_test "DTLS client reconnect from same port: no cookies" \
5846 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005847 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5848 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005849 -s "The operation timed out" \
5850 -S "Client initiated reconnection from same port"
5851
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005852run_test "DTLS client reconnect from same port: attacker-injected" \
5853 -p "$P_PXY inject_clihlo=1" \
5854 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5855 "$P_CLI dtls=1 exchanges=2" \
5856 0 \
5857 -s "possible client reconnect from the same port" \
5858 -S "Client initiated reconnection from same port"
5859
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005860# Tests for various cases of client authentication with DTLS
5861# (focused on handshake flows and message parsing)
5862
5863run_test "DTLS client auth: required" \
5864 "$P_SRV dtls=1 auth_mode=required" \
5865 "$P_CLI dtls=1" \
5866 0 \
5867 -s "Verifying peer X.509 certificate... ok"
5868
5869run_test "DTLS client auth: optional, client has no cert" \
5870 "$P_SRV dtls=1 auth_mode=optional" \
5871 "$P_CLI dtls=1 crt_file=none key_file=none" \
5872 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005873 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005874
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005875run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005876 "$P_SRV dtls=1 auth_mode=none" \
5877 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5878 0 \
5879 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005880 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005881
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005882run_test "DTLS wrong PSK: badmac alert" \
5883 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5884 "$P_CLI dtls=1 psk=abc124" \
5885 1 \
5886 -s "SSL - Verification of the message MAC failed" \
5887 -c "SSL - A fatal alert message was received from our peer"
5888
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005889# Tests for receiving fragmented handshake messages with DTLS
5890
5891requires_gnutls
5892run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5893 "$G_SRV -u --mtu 2048 -a" \
5894 "$P_CLI dtls=1 debug_level=2" \
5895 0 \
5896 -C "found fragmented DTLS handshake message" \
5897 -C "error"
5898
5899requires_gnutls
5900run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5901 "$G_SRV -u --mtu 512" \
5902 "$P_CLI dtls=1 debug_level=2" \
5903 0 \
5904 -c "found fragmented DTLS handshake message" \
5905 -C "error"
5906
5907requires_gnutls
5908run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5909 "$G_SRV -u --mtu 128" \
5910 "$P_CLI dtls=1 debug_level=2" \
5911 0 \
5912 -c "found fragmented DTLS handshake message" \
5913 -C "error"
5914
5915requires_gnutls
5916run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5917 "$G_SRV -u --mtu 128" \
5918 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5919 0 \
5920 -c "found fragmented DTLS handshake message" \
5921 -C "error"
5922
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005923requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005924requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005925run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5926 "$G_SRV -u --mtu 256" \
5927 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5928 0 \
5929 -c "found fragmented DTLS handshake message" \
5930 -c "client hello, adding renegotiation extension" \
5931 -c "found renegotiation extension" \
5932 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005933 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005934 -C "error" \
5935 -s "Extra-header:"
5936
5937requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005938requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005939run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5940 "$G_SRV -u --mtu 256" \
5941 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5942 0 \
5943 -c "found fragmented DTLS handshake message" \
5944 -c "client hello, adding renegotiation extension" \
5945 -c "found renegotiation extension" \
5946 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005947 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005948 -C "error" \
5949 -s "Extra-header:"
5950
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005951run_test "DTLS reassembly: no fragmentation (openssl server)" \
5952 "$O_SRV -dtls1 -mtu 2048" \
5953 "$P_CLI dtls=1 debug_level=2" \
5954 0 \
5955 -C "found fragmented DTLS handshake message" \
5956 -C "error"
5957
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005958run_test "DTLS reassembly: some fragmentation (openssl server)" \
5959 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005960 "$P_CLI dtls=1 debug_level=2" \
5961 0 \
5962 -c "found fragmented DTLS handshake message" \
5963 -C "error"
5964
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005965run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005966 "$O_SRV -dtls1 -mtu 256" \
5967 "$P_CLI dtls=1 debug_level=2" \
5968 0 \
5969 -c "found fragmented DTLS handshake message" \
5970 -C "error"
5971
5972run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5973 "$O_SRV -dtls1 -mtu 256" \
5974 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5975 0 \
5976 -c "found fragmented DTLS handshake message" \
5977 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005978
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005979# Tests for sending fragmented handshake messages with DTLS
5980#
5981# Use client auth when we need the client to send large messages,
5982# and use large cert chains on both sides too (the long chains we have all use
5983# both RSA and ECDSA, but ideally we should have long chains with either).
5984# Sizes reached (UDP payload):
5985# - 2037B for server certificate
5986# - 1542B for client certificate
5987# - 1013B for newsessionticket
5988# - all others below 512B
5989# All those tests assume MAX_CONTENT_LEN is at least 2048
5990
5991requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5992requires_config_enabled MBEDTLS_RSA_C
5993requires_config_enabled MBEDTLS_ECDSA_C
5994requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
5995run_test "DTLS fragmenting: none (for reference)" \
5996 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
5997 crt_file=data_files/server7_int-ca.crt \
5998 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005999 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006000 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006001 "$P_CLI dtls=1 debug_level=2 \
6002 crt_file=data_files/server8_int-ca2.crt \
6003 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006004 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006005 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006006 0 \
6007 -S "found fragmented DTLS handshake message" \
6008 -C "found fragmented DTLS handshake message" \
6009 -C "error"
6010
6011requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6012requires_config_enabled MBEDTLS_RSA_C
6013requires_config_enabled MBEDTLS_ECDSA_C
6014requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006015run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006016 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6017 crt_file=data_files/server7_int-ca.crt \
6018 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006019 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006020 max_frag_len=1024" \
6021 "$P_CLI dtls=1 debug_level=2 \
6022 crt_file=data_files/server8_int-ca2.crt \
6023 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006024 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006025 max_frag_len=2048" \
6026 0 \
6027 -S "found fragmented DTLS handshake message" \
6028 -c "found fragmented DTLS handshake message" \
6029 -C "error"
6030
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006031# With the MFL extension, the server has no way of forcing
6032# the client to not exceed a certain MTU; hence, the following
6033# test can't be replicated with an MTU proxy such as the one
6034# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006035requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6036requires_config_enabled MBEDTLS_RSA_C
6037requires_config_enabled MBEDTLS_ECDSA_C
6038requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006039run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006040 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6041 crt_file=data_files/server7_int-ca.crt \
6042 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006043 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006044 max_frag_len=512" \
6045 "$P_CLI dtls=1 debug_level=2 \
6046 crt_file=data_files/server8_int-ca2.crt \
6047 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006048 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006049 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006050 0 \
6051 -S "found fragmented DTLS handshake message" \
6052 -c "found fragmented DTLS handshake message" \
6053 -C "error"
6054
6055requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6056requires_config_enabled MBEDTLS_RSA_C
6057requires_config_enabled MBEDTLS_ECDSA_C
6058requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006059run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006060 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6061 crt_file=data_files/server7_int-ca.crt \
6062 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006063 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006064 max_frag_len=2048" \
6065 "$P_CLI dtls=1 debug_level=2 \
6066 crt_file=data_files/server8_int-ca2.crt \
6067 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006068 hs_timeout=2500-60000 \
6069 max_frag_len=1024" \
6070 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006071 -S "found fragmented DTLS handshake message" \
6072 -c "found fragmented DTLS handshake message" \
6073 -C "error"
6074
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006075# While not required by the standard defining the MFL extension
6076# (according to which it only applies to records, not to datagrams),
6077# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6078# as otherwise there wouldn't be any means to communicate MTU restrictions
6079# to the peer.
6080# The next test checks that no datagrams significantly larger than the
6081# negotiated MFL are sent.
6082requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6083requires_config_enabled MBEDTLS_RSA_C
6084requires_config_enabled MBEDTLS_ECDSA_C
6085requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6086run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006087 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006088 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6089 crt_file=data_files/server7_int-ca.crt \
6090 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006091 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006092 max_frag_len=2048" \
6093 "$P_CLI dtls=1 debug_level=2 \
6094 crt_file=data_files/server8_int-ca2.crt \
6095 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006096 hs_timeout=2500-60000 \
6097 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006098 0 \
6099 -S "found fragmented DTLS handshake message" \
6100 -c "found fragmented DTLS handshake message" \
6101 -C "error"
6102
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006103requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6104requires_config_enabled MBEDTLS_RSA_C
6105requires_config_enabled MBEDTLS_ECDSA_C
6106requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006107run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006108 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6109 crt_file=data_files/server7_int-ca.crt \
6110 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006111 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006112 max_frag_len=2048" \
6113 "$P_CLI dtls=1 debug_level=2 \
6114 crt_file=data_files/server8_int-ca2.crt \
6115 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006116 hs_timeout=2500-60000 \
6117 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006118 0 \
6119 -s "found fragmented DTLS handshake message" \
6120 -c "found fragmented DTLS handshake message" \
6121 -C "error"
6122
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006123# While not required by the standard defining the MFL extension
6124# (according to which it only applies to records, not to datagrams),
6125# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6126# as otherwise there wouldn't be any means to communicate MTU restrictions
6127# to the peer.
6128# The next test checks that no datagrams significantly larger than the
6129# negotiated MFL are sent.
6130requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6131requires_config_enabled MBEDTLS_RSA_C
6132requires_config_enabled MBEDTLS_ECDSA_C
6133requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6134run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006135 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006136 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6137 crt_file=data_files/server7_int-ca.crt \
6138 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006139 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006140 max_frag_len=2048" \
6141 "$P_CLI dtls=1 debug_level=2 \
6142 crt_file=data_files/server8_int-ca2.crt \
6143 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006144 hs_timeout=2500-60000 \
6145 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006146 0 \
6147 -s "found fragmented DTLS handshake message" \
6148 -c "found fragmented DTLS handshake message" \
6149 -C "error"
6150
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006151requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6152requires_config_enabled MBEDTLS_RSA_C
6153requires_config_enabled MBEDTLS_ECDSA_C
6154run_test "DTLS fragmenting: none (for reference) (MTU)" \
6155 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6156 crt_file=data_files/server7_int-ca.crt \
6157 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006158 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006159 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006160 "$P_CLI dtls=1 debug_level=2 \
6161 crt_file=data_files/server8_int-ca2.crt \
6162 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006163 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006164 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006165 0 \
6166 -S "found fragmented DTLS handshake message" \
6167 -C "found fragmented DTLS handshake message" \
6168 -C "error"
6169
6170requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6171requires_config_enabled MBEDTLS_RSA_C
6172requires_config_enabled MBEDTLS_ECDSA_C
6173run_test "DTLS fragmenting: client (MTU)" \
6174 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6175 crt_file=data_files/server7_int-ca.crt \
6176 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006177 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006178 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006179 "$P_CLI dtls=1 debug_level=2 \
6180 crt_file=data_files/server8_int-ca2.crt \
6181 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006182 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006183 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006184 0 \
6185 -s "found fragmented DTLS handshake message" \
6186 -C "found fragmented DTLS handshake message" \
6187 -C "error"
6188
6189requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6190requires_config_enabled MBEDTLS_RSA_C
6191requires_config_enabled MBEDTLS_ECDSA_C
6192run_test "DTLS fragmenting: server (MTU)" \
6193 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6194 crt_file=data_files/server7_int-ca.crt \
6195 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006196 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006197 mtu=512" \
6198 "$P_CLI dtls=1 debug_level=2 \
6199 crt_file=data_files/server8_int-ca2.crt \
6200 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006201 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006202 mtu=2048" \
6203 0 \
6204 -S "found fragmented DTLS handshake message" \
6205 -c "found fragmented DTLS handshake message" \
6206 -C "error"
6207
6208requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6209requires_config_enabled MBEDTLS_RSA_C
6210requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006211run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006212 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006213 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6214 crt_file=data_files/server7_int-ca.crt \
6215 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006216 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006217 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006218 "$P_CLI dtls=1 debug_level=2 \
6219 crt_file=data_files/server8_int-ca2.crt \
6220 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006221 hs_timeout=2500-60000 \
6222 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006223 0 \
6224 -s "found fragmented DTLS handshake message" \
6225 -c "found fragmented DTLS handshake message" \
6226 -C "error"
6227
Andrzej Kurek77826052018-10-11 07:34:08 -04006228# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006229requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6230requires_config_enabled MBEDTLS_RSA_C
6231requires_config_enabled MBEDTLS_ECDSA_C
6232requires_config_enabled MBEDTLS_SHA256_C
6233requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6234requires_config_enabled MBEDTLS_AES_C
6235requires_config_enabled MBEDTLS_GCM_C
6236run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006237 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006238 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6239 crt_file=data_files/server7_int-ca.crt \
6240 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006241 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006242 mtu=512" \
6243 "$P_CLI dtls=1 debug_level=2 \
6244 crt_file=data_files/server8_int-ca2.crt \
6245 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006246 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6247 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006248 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006249 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006250 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006251 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006252 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006253
Andrzej Kurek7311c782018-10-11 06:49:41 -04006254# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006255# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006256# The ratio of max/min timeout should ideally equal 4 to accept two
6257# retransmissions, but in some cases (like both the server and client using
6258# fragmentation and auto-reduction) an extra retransmission might occur,
6259# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006260not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006261requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6262requires_config_enabled MBEDTLS_RSA_C
6263requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006264requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6265requires_config_enabled MBEDTLS_AES_C
6266requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006267run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6268 -p "$P_PXY mtu=508" \
6269 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6270 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006271 key_file=data_files/server7.key \
6272 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006273 "$P_CLI dtls=1 debug_level=2 \
6274 crt_file=data_files/server8_int-ca2.crt \
6275 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006276 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6277 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006278 0 \
6279 -s "found fragmented DTLS handshake message" \
6280 -c "found fragmented DTLS handshake message" \
6281 -C "error"
6282
Andrzej Kurek77826052018-10-11 07:34:08 -04006283# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006284only_with_valgrind
6285requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6286requires_config_enabled MBEDTLS_RSA_C
6287requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006288requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6289requires_config_enabled MBEDTLS_AES_C
6290requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006291run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6292 -p "$P_PXY mtu=508" \
6293 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6294 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006295 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006296 hs_timeout=250-10000" \
6297 "$P_CLI dtls=1 debug_level=2 \
6298 crt_file=data_files/server8_int-ca2.crt \
6299 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006300 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006301 hs_timeout=250-10000" \
6302 0 \
6303 -s "found fragmented DTLS handshake message" \
6304 -c "found fragmented DTLS handshake message" \
6305 -C "error"
6306
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006307# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
Manuel Pégourié-Gonnard3d183ce2018-08-22 09:56:22 +02006308# OTOH the client might resend if the server is to slow to reset after sending
6309# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006310not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006311requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6312requires_config_enabled MBEDTLS_RSA_C
6313requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006314run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006315 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006316 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6317 crt_file=data_files/server7_int-ca.crt \
6318 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006319 hs_timeout=10000-60000 \
6320 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006321 "$P_CLI dtls=1 debug_level=2 \
6322 crt_file=data_files/server8_int-ca2.crt \
6323 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006324 hs_timeout=10000-60000 \
6325 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006326 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006327 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006328 -s "found fragmented DTLS handshake message" \
6329 -c "found fragmented DTLS handshake message" \
6330 -C "error"
6331
Andrzej Kurek77826052018-10-11 07:34:08 -04006332# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006333# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6334# OTOH the client might resend if the server is to slow to reset after sending
6335# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006336not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006337requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6338requires_config_enabled MBEDTLS_RSA_C
6339requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006340requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6341requires_config_enabled MBEDTLS_AES_C
6342requires_config_enabled MBEDTLS_GCM_C
6343run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006344 -p "$P_PXY mtu=512" \
6345 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6346 crt_file=data_files/server7_int-ca.crt \
6347 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006348 hs_timeout=10000-60000 \
6349 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006350 "$P_CLI dtls=1 debug_level=2 \
6351 crt_file=data_files/server8_int-ca2.crt \
6352 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006353 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6354 hs_timeout=10000-60000 \
6355 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006356 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006357 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006358 -s "found fragmented DTLS handshake message" \
6359 -c "found fragmented DTLS handshake message" \
6360 -C "error"
6361
Andrzej Kurek7311c782018-10-11 06:49:41 -04006362not_with_valgrind # spurious autoreduction due to timeout
6363requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6364requires_config_enabled MBEDTLS_RSA_C
6365requires_config_enabled MBEDTLS_ECDSA_C
6366run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006367 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006368 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6369 crt_file=data_files/server7_int-ca.crt \
6370 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006371 hs_timeout=10000-60000 \
6372 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006373 "$P_CLI dtls=1 debug_level=2 \
6374 crt_file=data_files/server8_int-ca2.crt \
6375 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006376 hs_timeout=10000-60000 \
6377 mtu=1024 nbio=2" \
6378 0 \
6379 -S "autoreduction" \
6380 -s "found fragmented DTLS handshake message" \
6381 -c "found fragmented DTLS handshake message" \
6382 -C "error"
6383
Andrzej Kurek77826052018-10-11 07:34:08 -04006384# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006385not_with_valgrind # spurious autoreduction due to timeout
6386requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6387requires_config_enabled MBEDTLS_RSA_C
6388requires_config_enabled MBEDTLS_ECDSA_C
6389requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6390requires_config_enabled MBEDTLS_AES_C
6391requires_config_enabled MBEDTLS_GCM_C
6392run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6393 -p "$P_PXY mtu=512" \
6394 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6395 crt_file=data_files/server7_int-ca.crt \
6396 key_file=data_files/server7.key \
6397 hs_timeout=10000-60000 \
6398 mtu=512 nbio=2" \
6399 "$P_CLI dtls=1 debug_level=2 \
6400 crt_file=data_files/server8_int-ca2.crt \
6401 key_file=data_files/server8.key \
6402 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6403 hs_timeout=10000-60000 \
6404 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006405 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006406 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006407 -s "found fragmented DTLS handshake message" \
6408 -c "found fragmented DTLS handshake message" \
6409 -C "error"
6410
Andrzej Kurek77826052018-10-11 07:34:08 -04006411# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006412# This ensures things still work after session_reset().
6413# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006414# Since we don't support reading fragmented ClientHello yet,
6415# up the MTU to 1450 (larger than ClientHello with session ticket,
6416# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006417# An autoreduction on the client-side might happen if the server is
6418# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006419# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006420# resumed listening, which would result in a spurious autoreduction.
6421not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006422requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6423requires_config_enabled MBEDTLS_RSA_C
6424requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006425requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6426requires_config_enabled MBEDTLS_AES_C
6427requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006428run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6429 -p "$P_PXY mtu=1450" \
6430 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6431 crt_file=data_files/server7_int-ca.crt \
6432 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006433 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006434 mtu=1450" \
6435 "$P_CLI dtls=1 debug_level=2 \
6436 crt_file=data_files/server8_int-ca2.crt \
6437 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006438 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006439 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006440 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006441 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006442 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006443 -s "found fragmented DTLS handshake message" \
6444 -c "found fragmented DTLS handshake message" \
6445 -C "error"
6446
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006447# An autoreduction on the client-side might happen if the server is
6448# slow to reset, therefore omitting '-C "autoreduction"' below.
6449not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006450requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6451requires_config_enabled MBEDTLS_RSA_C
6452requires_config_enabled MBEDTLS_ECDSA_C
6453requires_config_enabled MBEDTLS_SHA256_C
6454requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6455requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6456requires_config_enabled MBEDTLS_CHACHAPOLY_C
6457run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6458 -p "$P_PXY mtu=512" \
6459 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6460 crt_file=data_files/server7_int-ca.crt \
6461 key_file=data_files/server7.key \
6462 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006463 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006464 mtu=512" \
6465 "$P_CLI dtls=1 debug_level=2 \
6466 crt_file=data_files/server8_int-ca2.crt \
6467 key_file=data_files/server8.key \
6468 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006469 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006470 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006471 mtu=512" \
6472 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006473 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006474 -s "found fragmented DTLS handshake message" \
6475 -c "found fragmented DTLS handshake message" \
6476 -C "error"
6477
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006478# An autoreduction on the client-side might happen if the server is
6479# slow to reset, therefore omitting '-C "autoreduction"' below.
6480not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006481requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6482requires_config_enabled MBEDTLS_RSA_C
6483requires_config_enabled MBEDTLS_ECDSA_C
6484requires_config_enabled MBEDTLS_SHA256_C
6485requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6486requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6487requires_config_enabled MBEDTLS_AES_C
6488requires_config_enabled MBEDTLS_GCM_C
6489run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6490 -p "$P_PXY mtu=512" \
6491 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6492 crt_file=data_files/server7_int-ca.crt \
6493 key_file=data_files/server7.key \
6494 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006495 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006496 mtu=512" \
6497 "$P_CLI dtls=1 debug_level=2 \
6498 crt_file=data_files/server8_int-ca2.crt \
6499 key_file=data_files/server8.key \
6500 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006501 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006502 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006503 mtu=512" \
6504 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006505 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006506 -s "found fragmented DTLS handshake message" \
6507 -c "found fragmented DTLS handshake message" \
6508 -C "error"
6509
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006510# An autoreduction on the client-side might happen if the server is
6511# slow to reset, therefore omitting '-C "autoreduction"' below.
6512not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006513requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6514requires_config_enabled MBEDTLS_RSA_C
6515requires_config_enabled MBEDTLS_ECDSA_C
6516requires_config_enabled MBEDTLS_SHA256_C
6517requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6518requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6519requires_config_enabled MBEDTLS_AES_C
6520requires_config_enabled MBEDTLS_CCM_C
6521run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006522 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006523 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6524 crt_file=data_files/server7_int-ca.crt \
6525 key_file=data_files/server7.key \
6526 exchanges=2 renegotiation=1 \
6527 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006528 hs_timeout=10000-60000 \
6529 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006530 "$P_CLI dtls=1 debug_level=2 \
6531 crt_file=data_files/server8_int-ca2.crt \
6532 key_file=data_files/server8.key \
6533 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006534 hs_timeout=10000-60000 \
6535 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006536 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006537 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006538 -s "found fragmented DTLS handshake message" \
6539 -c "found fragmented DTLS handshake message" \
6540 -C "error"
6541
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006542# An autoreduction on the client-side might happen if the server is
6543# slow to reset, therefore omitting '-C "autoreduction"' below.
6544not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006545requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6546requires_config_enabled MBEDTLS_RSA_C
6547requires_config_enabled MBEDTLS_ECDSA_C
6548requires_config_enabled MBEDTLS_SHA256_C
6549requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6550requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6551requires_config_enabled MBEDTLS_AES_C
6552requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6553requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6554run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006555 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006556 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6557 crt_file=data_files/server7_int-ca.crt \
6558 key_file=data_files/server7.key \
6559 exchanges=2 renegotiation=1 \
6560 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006561 hs_timeout=10000-60000 \
6562 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006563 "$P_CLI dtls=1 debug_level=2 \
6564 crt_file=data_files/server8_int-ca2.crt \
6565 key_file=data_files/server8.key \
6566 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006567 hs_timeout=10000-60000 \
6568 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006569 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006570 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006571 -s "found fragmented DTLS handshake message" \
6572 -c "found fragmented DTLS handshake message" \
6573 -C "error"
6574
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006575# An autoreduction on the client-side might happen if the server is
6576# slow to reset, therefore omitting '-C "autoreduction"' below.
6577not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006578requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6579requires_config_enabled MBEDTLS_RSA_C
6580requires_config_enabled MBEDTLS_ECDSA_C
6581requires_config_enabled MBEDTLS_SHA256_C
6582requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6583requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6584requires_config_enabled MBEDTLS_AES_C
6585requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6586run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006587 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006588 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6589 crt_file=data_files/server7_int-ca.crt \
6590 key_file=data_files/server7.key \
6591 exchanges=2 renegotiation=1 \
6592 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006593 hs_timeout=10000-60000 \
6594 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006595 "$P_CLI dtls=1 debug_level=2 \
6596 crt_file=data_files/server8_int-ca2.crt \
6597 key_file=data_files/server8.key \
6598 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006599 hs_timeout=10000-60000 \
6600 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006601 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006602 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006603 -s "found fragmented DTLS handshake message" \
6604 -c "found fragmented DTLS handshake message" \
6605 -C "error"
6606
Andrzej Kurek77826052018-10-11 07:34:08 -04006607# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006608requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6609requires_config_enabled MBEDTLS_RSA_C
6610requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006611requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6612requires_config_enabled MBEDTLS_AES_C
6613requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006614client_needs_more_time 2
6615run_test "DTLS fragmenting: proxy MTU + 3d" \
6616 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006617 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006618 crt_file=data_files/server7_int-ca.crt \
6619 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006620 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006621 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006622 crt_file=data_files/server8_int-ca2.crt \
6623 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006624 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006625 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006626 0 \
6627 -s "found fragmented DTLS handshake message" \
6628 -c "found fragmented DTLS handshake message" \
6629 -C "error"
6630
Andrzej Kurek77826052018-10-11 07:34:08 -04006631# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006632requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6633requires_config_enabled MBEDTLS_RSA_C
6634requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006635requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6636requires_config_enabled MBEDTLS_AES_C
6637requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006638client_needs_more_time 2
6639run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6640 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6641 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6642 crt_file=data_files/server7_int-ca.crt \
6643 key_file=data_files/server7.key \
6644 hs_timeout=250-10000 mtu=512 nbio=2" \
6645 "$P_CLI dtls=1 debug_level=2 \
6646 crt_file=data_files/server8_int-ca2.crt \
6647 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006648 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006649 hs_timeout=250-10000 mtu=512 nbio=2" \
6650 0 \
6651 -s "found fragmented DTLS handshake message" \
6652 -c "found fragmented DTLS handshake message" \
6653 -C "error"
6654
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006655# interop tests for DTLS fragmentating with reliable connection
6656#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006657# here and below we just want to test that the we fragment in a way that
6658# pleases other implementations, so we don't need the peer to fragment
6659requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6660requires_config_enabled MBEDTLS_RSA_C
6661requires_config_enabled MBEDTLS_ECDSA_C
6662requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006663requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006664run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6665 "$G_SRV -u" \
6666 "$P_CLI dtls=1 debug_level=2 \
6667 crt_file=data_files/server8_int-ca2.crt \
6668 key_file=data_files/server8.key \
6669 mtu=512 force_version=dtls1_2" \
6670 0 \
6671 -c "fragmenting handshake message" \
6672 -C "error"
6673
6674requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6675requires_config_enabled MBEDTLS_RSA_C
6676requires_config_enabled MBEDTLS_ECDSA_C
6677requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006678requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006679run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6680 "$G_SRV -u" \
6681 "$P_CLI dtls=1 debug_level=2 \
6682 crt_file=data_files/server8_int-ca2.crt \
6683 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006684 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006685 0 \
6686 -c "fragmenting handshake message" \
6687 -C "error"
6688
Hanno Beckerb9a00862018-08-28 10:20:22 +01006689# We use --insecure for the GnuTLS client because it expects
6690# the hostname / IP it connects to to be the name used in the
6691# certificate obtained from the server. Here, however, it
6692# connects to 127.0.0.1 while our test certificates use 'localhost'
6693# as the server name in the certificate. This will make the
6694# certifiate validation fail, but passing --insecure makes
6695# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006696requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6697requires_config_enabled MBEDTLS_RSA_C
6698requires_config_enabled MBEDTLS_ECDSA_C
6699requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006700requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006701requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006702run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006703 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006704 crt_file=data_files/server7_int-ca.crt \
6705 key_file=data_files/server7.key \
6706 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006707 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006708 0 \
6709 -s "fragmenting handshake message"
6710
Hanno Beckerb9a00862018-08-28 10:20:22 +01006711# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006712requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6713requires_config_enabled MBEDTLS_RSA_C
6714requires_config_enabled MBEDTLS_ECDSA_C
6715requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006716requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006717requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006718run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006719 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006720 crt_file=data_files/server7_int-ca.crt \
6721 key_file=data_files/server7.key \
6722 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006723 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006724 0 \
6725 -s "fragmenting handshake message"
6726
6727requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6728requires_config_enabled MBEDTLS_RSA_C
6729requires_config_enabled MBEDTLS_ECDSA_C
6730requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6731run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6732 "$O_SRV -dtls1_2 -verify 10" \
6733 "$P_CLI dtls=1 debug_level=2 \
6734 crt_file=data_files/server8_int-ca2.crt \
6735 key_file=data_files/server8.key \
6736 mtu=512 force_version=dtls1_2" \
6737 0 \
6738 -c "fragmenting handshake message" \
6739 -C "error"
6740
6741requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6742requires_config_enabled MBEDTLS_RSA_C
6743requires_config_enabled MBEDTLS_ECDSA_C
6744requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6745run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6746 "$O_SRV -dtls1 -verify 10" \
6747 "$P_CLI dtls=1 debug_level=2 \
6748 crt_file=data_files/server8_int-ca2.crt \
6749 key_file=data_files/server8.key \
6750 mtu=512 force_version=dtls1" \
6751 0 \
6752 -c "fragmenting handshake message" \
6753 -C "error"
6754
6755requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6756requires_config_enabled MBEDTLS_RSA_C
6757requires_config_enabled MBEDTLS_ECDSA_C
6758requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6759run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6760 "$P_SRV dtls=1 debug_level=2 \
6761 crt_file=data_files/server7_int-ca.crt \
6762 key_file=data_files/server7.key \
6763 mtu=512 force_version=dtls1_2" \
6764 "$O_CLI -dtls1_2" \
6765 0 \
6766 -s "fragmenting handshake message"
6767
6768requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6769requires_config_enabled MBEDTLS_RSA_C
6770requires_config_enabled MBEDTLS_ECDSA_C
6771requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6772run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6773 "$P_SRV dtls=1 debug_level=2 \
6774 crt_file=data_files/server7_int-ca.crt \
6775 key_file=data_files/server7.key \
6776 mtu=512 force_version=dtls1" \
6777 "$O_CLI -dtls1" \
6778 0 \
6779 -s "fragmenting handshake message"
6780
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006781# interop tests for DTLS fragmentating with unreliable connection
6782#
6783# again we just want to test that the we fragment in a way that
6784# pleases other implementations, so we don't need the peer to fragment
6785requires_gnutls_next
6786requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6787requires_config_enabled MBEDTLS_RSA_C
6788requires_config_enabled MBEDTLS_ECDSA_C
6789requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006790client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006791run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6792 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6793 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006794 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006795 crt_file=data_files/server8_int-ca2.crt \
6796 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006797 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006798 0 \
6799 -c "fragmenting handshake message" \
6800 -C "error"
6801
6802requires_gnutls_next
6803requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6804requires_config_enabled MBEDTLS_RSA_C
6805requires_config_enabled MBEDTLS_ECDSA_C
6806requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006807client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006808run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6809 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6810 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006811 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006812 crt_file=data_files/server8_int-ca2.crt \
6813 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006814 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006815 0 \
6816 -c "fragmenting handshake message" \
6817 -C "error"
6818
k-stachowiakabb843e2019-02-18 16:14:03 +01006819requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006820requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6821requires_config_enabled MBEDTLS_RSA_C
6822requires_config_enabled MBEDTLS_ECDSA_C
6823requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6824client_needs_more_time 4
6825run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6826 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6827 "$P_SRV dtls=1 debug_level=2 \
6828 crt_file=data_files/server7_int-ca.crt \
6829 key_file=data_files/server7.key \
6830 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006831 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006832 0 \
6833 -s "fragmenting handshake message"
6834
k-stachowiakabb843e2019-02-18 16:14:03 +01006835requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006836requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6837requires_config_enabled MBEDTLS_RSA_C
6838requires_config_enabled MBEDTLS_ECDSA_C
6839requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6840client_needs_more_time 4
6841run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6842 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6843 "$P_SRV dtls=1 debug_level=2 \
6844 crt_file=data_files/server7_int-ca.crt \
6845 key_file=data_files/server7.key \
6846 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006847 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006848 0 \
6849 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006850
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006851## Interop test with OpenSSL might trigger a bug in recent versions (including
6852## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006853## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006854## They should be re-enabled once a fixed version of OpenSSL is available
6855## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006856skip_next_test
6857requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6858requires_config_enabled MBEDTLS_RSA_C
6859requires_config_enabled MBEDTLS_ECDSA_C
6860requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6861client_needs_more_time 4
6862run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6863 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6864 "$O_SRV -dtls1_2 -verify 10" \
6865 "$P_CLI dtls=1 debug_level=2 \
6866 crt_file=data_files/server8_int-ca2.crt \
6867 key_file=data_files/server8.key \
6868 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6869 0 \
6870 -c "fragmenting handshake message" \
6871 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006872
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006873skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006874requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6875requires_config_enabled MBEDTLS_RSA_C
6876requires_config_enabled MBEDTLS_ECDSA_C
6877requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006878client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006879run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6880 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006881 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006882 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006883 crt_file=data_files/server8_int-ca2.crt \
6884 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006885 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006886 0 \
6887 -c "fragmenting handshake message" \
6888 -C "error"
6889
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006890skip_next_test
6891requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6892requires_config_enabled MBEDTLS_RSA_C
6893requires_config_enabled MBEDTLS_ECDSA_C
6894requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6895client_needs_more_time 4
6896run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6897 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6898 "$P_SRV dtls=1 debug_level=2 \
6899 crt_file=data_files/server7_int-ca.crt \
6900 key_file=data_files/server7.key \
6901 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6902 "$O_CLI -dtls1_2" \
6903 0 \
6904 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006905
6906# -nbio is added to prevent s_client from blocking in case of duplicated
6907# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006908skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006909requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6910requires_config_enabled MBEDTLS_RSA_C
6911requires_config_enabled MBEDTLS_ECDSA_C
6912requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006913client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006914run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
6915 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006916 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006917 crt_file=data_files/server7_int-ca.crt \
6918 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006919 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006920 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006921 0 \
6922 -s "fragmenting handshake message"
6923
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006924# Tests for specific things with "unreliable" UDP connection
6925
6926not_with_valgrind # spurious resend due to timeout
6927run_test "DTLS proxy: reference" \
6928 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006929 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
6930 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006931 0 \
6932 -C "replayed record" \
6933 -S "replayed record" \
6934 -C "record from another epoch" \
6935 -S "record from another epoch" \
6936 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006937 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006938 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006939 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006940 -c "HTTP/1.0 200 OK"
6941
6942not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006943run_test "DTLS proxy: duplicate every packet" \
6944 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006945 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
6946 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006947 0 \
6948 -c "replayed record" \
6949 -s "replayed record" \
6950 -c "record from another epoch" \
6951 -s "record from another epoch" \
6952 -S "resend" \
6953 -s "Extra-header:" \
6954 -c "HTTP/1.0 200 OK"
6955
6956run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
6957 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006958 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
6959 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006960 0 \
6961 -c "replayed record" \
6962 -S "replayed record" \
6963 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006964 -s "record from another epoch" \
6965 -c "resend" \
6966 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006967 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006968 -c "HTTP/1.0 200 OK"
6969
6970run_test "DTLS proxy: multiple records in same datagram" \
6971 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006972 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6973 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006974 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006975 -c "next record in same datagram" \
6976 -s "next record in same datagram"
6977
6978run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
6979 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006980 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6981 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006982 0 \
6983 -c "next record in same datagram" \
6984 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006985
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006986run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
6987 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006988 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
6989 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006990 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006991 -c "discarding invalid record (mac)" \
6992 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006993 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006994 -c "HTTP/1.0 200 OK" \
6995 -S "too many records with bad MAC" \
6996 -S "Verification of the message MAC failed"
6997
6998run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
6999 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007000 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7001 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007002 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007003 -C "discarding invalid record (mac)" \
7004 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007005 -S "Extra-header:" \
7006 -C "HTTP/1.0 200 OK" \
7007 -s "too many records with bad MAC" \
7008 -s "Verification of the message MAC failed"
7009
7010run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7011 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007012 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7013 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007014 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007015 -c "discarding invalid record (mac)" \
7016 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007017 -s "Extra-header:" \
7018 -c "HTTP/1.0 200 OK" \
7019 -S "too many records with bad MAC" \
7020 -S "Verification of the message MAC failed"
7021
7022run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7023 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007024 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7025 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007026 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007027 -c "discarding invalid record (mac)" \
7028 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007029 -s "Extra-header:" \
7030 -c "HTTP/1.0 200 OK" \
7031 -s "too many records with bad MAC" \
7032 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007033
7034run_test "DTLS proxy: delay ChangeCipherSpec" \
7035 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007036 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7037 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007038 0 \
7039 -c "record from another epoch" \
7040 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007041 -s "Extra-header:" \
7042 -c "HTTP/1.0 200 OK"
7043
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007044# Tests for reordering support with DTLS
7045
Hanno Becker56cdfd12018-08-17 13:42:15 +01007046run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7047 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007048 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7049 hs_timeout=2500-60000" \
7050 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7051 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007052 0 \
7053 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007054 -c "Next handshake message has been buffered - load"\
7055 -S "Buffering HS message" \
7056 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007057 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007058 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007059 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007060 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007061
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007062run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7063 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007064 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7065 hs_timeout=2500-60000" \
7066 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7067 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007068 0 \
7069 -c "Buffering HS message" \
7070 -c "found fragmented DTLS handshake message"\
7071 -c "Next handshake message 1 not or only partially bufffered" \
7072 -c "Next handshake message has been buffered - load"\
7073 -S "Buffering HS message" \
7074 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007075 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007076 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007077 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007078 -S "Remember CCS message"
7079
Hanno Beckera1adcca2018-08-24 14:41:07 +01007080# The client buffers the ServerKeyExchange before receiving the fragmented
7081# Certificate message; at the time of writing, together these are aroudn 1200b
7082# in size, so that the bound below ensures that the certificate can be reassembled
7083# while keeping the ServerKeyExchange.
7084requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7085run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007086 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007087 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7088 hs_timeout=2500-60000" \
7089 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7090 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007091 0 \
7092 -c "Buffering HS message" \
7093 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007094 -C "attempt to make space by freeing buffered messages" \
7095 -S "Buffering HS message" \
7096 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007097 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007098 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007099 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007100 -S "Remember CCS message"
7101
7102# The size constraints ensure that the delayed certificate message can't
7103# be reassembled while keeping the ServerKeyExchange message, but it can
7104# when dropping it first.
7105requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7106requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7107run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7108 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007109 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7110 hs_timeout=2500-60000" \
7111 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7112 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007113 0 \
7114 -c "Buffering HS message" \
7115 -c "attempt to make space by freeing buffered future messages" \
7116 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007117 -S "Buffering HS message" \
7118 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007119 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007120 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007121 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007122 -S "Remember CCS message"
7123
Hanno Becker56cdfd12018-08-17 13:42:15 +01007124run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7125 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007126 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7127 hs_timeout=2500-60000" \
7128 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7129 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007130 0 \
7131 -C "Buffering HS message" \
7132 -C "Next handshake message has been buffered - load"\
7133 -s "Buffering HS message" \
7134 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007135 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007136 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007137 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007138 -S "Remember CCS message"
7139
7140run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7141 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007142 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7143 hs_timeout=2500-60000" \
7144 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7145 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007146 0 \
7147 -C "Buffering HS message" \
7148 -C "Next handshake message has been buffered - load"\
7149 -S "Buffering HS message" \
7150 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007151 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007152 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007153 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007154 -S "Remember CCS message"
7155
7156run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7157 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007158 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7159 hs_timeout=2500-60000" \
7160 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7161 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007162 0 \
7163 -C "Buffering HS message" \
7164 -C "Next handshake message has been buffered - load"\
7165 -S "Buffering HS message" \
7166 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007167 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007168 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007169 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007170 -s "Remember CCS message"
7171
Hanno Beckera1adcca2018-08-24 14:41:07 +01007172run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007173 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007174 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7175 hs_timeout=2500-60000" \
7176 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7177 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007178 0 \
7179 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007180 -s "Found buffered record from current epoch - load" \
7181 -c "Buffer record from epoch 1" \
7182 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007183
Hanno Beckera1adcca2018-08-24 14:41:07 +01007184# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7185# from the server are delayed, so that the encrypted Finished message
7186# is received and buffered. When the fragmented NewSessionTicket comes
7187# in afterwards, the encrypted Finished message must be freed in order
7188# to make space for the NewSessionTicket to be reassembled.
7189# This works only in very particular circumstances:
7190# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7191# of the NewSessionTicket, but small enough to also allow buffering of
7192# the encrypted Finished message.
7193# - The MTU setting on the server must be so small that the NewSessionTicket
7194# needs to be fragmented.
7195# - All messages sent by the server must be small enough to be either sent
7196# without fragmentation or be reassembled within the bounds of
7197# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7198# handshake, omitting CRTs.
7199requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7200requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7201run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7202 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7203 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7204 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7205 0 \
7206 -s "Buffer record from epoch 1" \
7207 -s "Found buffered record from current epoch - load" \
7208 -c "Buffer record from epoch 1" \
7209 -C "Found buffered record from current epoch - load" \
7210 -c "Enough space available after freeing future epoch record"
7211
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007212# Tests for "randomly unreliable connection": try a variety of flows and peers
7213
7214client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007215run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7216 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007217 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007218 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007219 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007220 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7221 0 \
7222 -s "Extra-header:" \
7223 -c "HTTP/1.0 200 OK"
7224
Janos Follath74537a62016-09-02 13:45:28 +01007225client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007226run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7227 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007228 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7229 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007230 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7231 0 \
7232 -s "Extra-header:" \
7233 -c "HTTP/1.0 200 OK"
7234
Janos Follath74537a62016-09-02 13:45:28 +01007235client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007236run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7237 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007238 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7239 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007240 0 \
7241 -s "Extra-header:" \
7242 -c "HTTP/1.0 200 OK"
7243
Janos Follath74537a62016-09-02 13:45:28 +01007244client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007245run_test "DTLS proxy: 3d, FS, client auth" \
7246 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007247 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7248 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007249 0 \
7250 -s "Extra-header:" \
7251 -c "HTTP/1.0 200 OK"
7252
Janos Follath74537a62016-09-02 13:45:28 +01007253client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007254run_test "DTLS proxy: 3d, FS, ticket" \
7255 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007256 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7257 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007258 0 \
7259 -s "Extra-header:" \
7260 -c "HTTP/1.0 200 OK"
7261
Janos Follath74537a62016-09-02 13:45:28 +01007262client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007263run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7264 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007265 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7266 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007267 0 \
7268 -s "Extra-header:" \
7269 -c "HTTP/1.0 200 OK"
7270
Janos Follath74537a62016-09-02 13:45:28 +01007271client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007272run_test "DTLS proxy: 3d, max handshake, nbio" \
7273 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007274 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007275 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007276 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007277 0 \
7278 -s "Extra-header:" \
7279 -c "HTTP/1.0 200 OK"
7280
Janos Follath74537a62016-09-02 13:45:28 +01007281client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007282run_test "DTLS proxy: 3d, min handshake, resumption" \
7283 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007284 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007285 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007286 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007287 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007288 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7289 0 \
7290 -s "a session has been resumed" \
7291 -c "a session has been resumed" \
7292 -s "Extra-header:" \
7293 -c "HTTP/1.0 200 OK"
7294
Janos Follath74537a62016-09-02 13:45:28 +01007295client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007296run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7297 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007298 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007299 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007300 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007301 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007302 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7303 0 \
7304 -s "a session has been resumed" \
7305 -c "a session has been resumed" \
7306 -s "Extra-header:" \
7307 -c "HTTP/1.0 200 OK"
7308
Janos Follath74537a62016-09-02 13:45:28 +01007309client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007310requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007311run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007312 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007313 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007314 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007315 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007316 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007317 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7318 0 \
7319 -c "=> renegotiate" \
7320 -s "=> renegotiate" \
7321 -s "Extra-header:" \
7322 -c "HTTP/1.0 200 OK"
7323
Janos Follath74537a62016-09-02 13:45:28 +01007324client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007325requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007326run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7327 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007328 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007329 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007330 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007331 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007332 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7333 0 \
7334 -c "=> renegotiate" \
7335 -s "=> renegotiate" \
7336 -s "Extra-header:" \
7337 -c "HTTP/1.0 200 OK"
7338
Janos Follath74537a62016-09-02 13:45:28 +01007339client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007340requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007341run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007342 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007343 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007344 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007345 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007346 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007347 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007348 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7349 0 \
7350 -c "=> renegotiate" \
7351 -s "=> renegotiate" \
7352 -s "Extra-header:" \
7353 -c "HTTP/1.0 200 OK"
7354
Janos Follath74537a62016-09-02 13:45:28 +01007355client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007356requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007357run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007358 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007359 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007360 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007361 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007362 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007363 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007364 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7365 0 \
7366 -c "=> renegotiate" \
7367 -s "=> renegotiate" \
7368 -s "Extra-header:" \
7369 -c "HTTP/1.0 200 OK"
7370
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007371## Interop tests with OpenSSL might trigger a bug in recent versions (including
7372## all versions installed on the CI machines), reported here:
7373## Bug report: https://github.com/openssl/openssl/issues/6902
7374## They should be re-enabled once a fixed version of OpenSSL is available
7375## (this should happen in some 1.1.1_ release according to the ticket).
7376skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007377client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007378not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007379run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007380 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7381 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007382 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007383 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007384 -c "HTTP/1.0 200 OK"
7385
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007386skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007387client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007388not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007389run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7390 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7391 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007392 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007393 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007394 -c "HTTP/1.0 200 OK"
7395
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007396skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007397client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007398not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007399run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7400 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7401 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007402 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007403 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007404 -c "HTTP/1.0 200 OK"
7405
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007406requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007407client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007408not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007409run_test "DTLS proxy: 3d, gnutls server" \
7410 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7411 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007412 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007413 0 \
7414 -s "Extra-header:" \
7415 -c "Extra-header:"
7416
k-stachowiakabb843e2019-02-18 16:14:03 +01007417requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007418client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007419not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007420run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7421 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007422 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007423 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007424 0 \
7425 -s "Extra-header:" \
7426 -c "Extra-header:"
7427
k-stachowiakabb843e2019-02-18 16:14:03 +01007428requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007429client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007430not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007431run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7432 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007433 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007434 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007435 0 \
7436 -s "Extra-header:" \
7437 -c "Extra-header:"
7438
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007439# Final report
7440
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007441echo "------------------------------------------------------------------------"
7442
7443if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007444 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007445else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007446 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007447fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007448PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007449echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007450
7451exit $FAILS