blob: 79ae325e3ac14479f33a89bb698d6ec95bb92805 [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 Peskineb7bb068b2020-08-26 22:35:46 +0200133 printf " -f|--filter\tOnly matching tests are executed (substring or BRE)\n"
134 printf " -e|--exclude\tMatching tests are excluded (substring or 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
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200187# Read boolean configuration options from config.h for easy and quick
188# testing. Skip non-boolean options (with something other than spaces
189# and a comment after "#define SYMBOL"). The variable contains a
190# space-separated list of symbols.
191CONFIGS_ENABLED=" $(<"$CONFIG_H" \
192 sed -n 's!^ *#define *\([A-Za-z][0-9A-Z_a-z]*\) *\(/*\)*!\1!p' |
193 tr '\n' ' ')"
194
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100195# Skip next test; use this macro to skip tests which are legitimate
196# in theory and expected to be re-introduced at some point, but
197# aren't expected to succeed at the moment due to problems outside
198# our control (such as bugs in other TLS implementations).
199skip_next_test() {
200 SKIP_NEXT="YES"
201}
202
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100203# skip next test if the flag is not enabled in config.h
204requires_config_enabled() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200205 case $CONFIGS_ENABLED in
206 *" $1 "*) :;;
207 *) SKIP_NEXT="YES";;
208 esac
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100209}
210
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200211# skip next test if the flag is enabled in config.h
212requires_config_disabled() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200213 case $CONFIGS_ENABLED in
214 *" $1 "*) SKIP_NEXT="YES";;
215 esac
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200216}
217
Hanno Becker7c48dd12018-08-28 16:09:22 +0100218get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100219 # This function uses the query_config command line option to query the
220 # required Mbed TLS compile time configuration from the ssl_server2
221 # program. The command will always return a success value if the
222 # configuration is defined and the value will be printed to stdout.
223 #
224 # Note that if the configuration is not defined or is defined to nothing,
225 # the output of this function will be an empty string.
226 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100227}
228
229requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100230 VAL="$( get_config_value_or_default "$1" )"
231 if [ -z "$VAL" ]; then
232 # Should never happen
233 echo "Mbed TLS configuration $1 is not defined"
234 exit 1
235 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100236 SKIP_NEXT="YES"
237 fi
238}
239
240requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100241 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100242 if [ -z "$VAL" ]; then
243 # Should never happen
244 echo "Mbed TLS configuration $1 is not defined"
245 exit 1
246 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100247 SKIP_NEXT="YES"
248 fi
249}
250
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200251# skip next test if OpenSSL doesn't support FALLBACK_SCSV
252requires_openssl_with_fallback_scsv() {
253 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
254 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
255 then
256 OPENSSL_HAS_FBSCSV="YES"
257 else
258 OPENSSL_HAS_FBSCSV="NO"
259 fi
260 fi
261 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
262 SKIP_NEXT="YES"
263 fi
264}
265
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200266# skip next test if GnuTLS isn't available
267requires_gnutls() {
268 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200269 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200270 GNUTLS_AVAILABLE="YES"
271 else
272 GNUTLS_AVAILABLE="NO"
273 fi
274 fi
275 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
276 SKIP_NEXT="YES"
277 fi
278}
279
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200280# skip next test if GnuTLS-next isn't available
281requires_gnutls_next() {
282 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
283 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
284 GNUTLS_NEXT_AVAILABLE="YES"
285 else
286 GNUTLS_NEXT_AVAILABLE="NO"
287 fi
288 fi
289 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
290 SKIP_NEXT="YES"
291 fi
292}
293
294# skip next test if OpenSSL-legacy isn't available
295requires_openssl_legacy() {
296 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
297 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
298 OPENSSL_LEGACY_AVAILABLE="YES"
299 else
300 OPENSSL_LEGACY_AVAILABLE="NO"
301 fi
302 fi
303 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
304 SKIP_NEXT="YES"
305 fi
306}
307
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200308# skip next test if IPv6 isn't available on this host
309requires_ipv6() {
310 if [ -z "${HAS_IPV6:-}" ]; then
311 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
312 SRV_PID=$!
313 sleep 1
314 kill $SRV_PID >/dev/null 2>&1
315 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
316 HAS_IPV6="NO"
317 else
318 HAS_IPV6="YES"
319 fi
320 rm -r $SRV_OUT
321 fi
322
323 if [ "$HAS_IPV6" = "NO" ]; then
324 SKIP_NEXT="YES"
325 fi
326}
327
Andrzej Kurekb4593462018-10-11 08:43:30 -0400328# skip next test if it's i686 or uname is not available
329requires_not_i686() {
330 if [ -z "${IS_I686:-}" ]; then
331 IS_I686="YES"
332 if which "uname" >/dev/null 2>&1; then
333 if [ -z "$(uname -a | grep i686)" ]; then
334 IS_I686="NO"
335 fi
336 fi
337 fi
338 if [ "$IS_I686" = "YES" ]; then
339 SKIP_NEXT="YES"
340 fi
341}
342
Angus Grattonc4dd0732018-04-11 16:28:39 +1000343# Calculate the input & output maximum content lengths set in the config
344MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
345MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
346MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
347
348if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
349 MAX_CONTENT_LEN="$MAX_IN_LEN"
350fi
351if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
352 MAX_CONTENT_LEN="$MAX_OUT_LEN"
353fi
354
355# skip the next test if the SSL output buffer is less than 16KB
356requires_full_size_output_buffer() {
357 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
358 SKIP_NEXT="YES"
359 fi
360}
361
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200362# skip the next test if valgrind is in use
363not_with_valgrind() {
364 if [ "$MEMCHECK" -gt 0 ]; then
365 SKIP_NEXT="YES"
366 fi
367}
368
Paul Bakker362689d2016-05-13 10:33:25 +0100369# skip the next test if valgrind is NOT in use
370only_with_valgrind() {
371 if [ "$MEMCHECK" -eq 0 ]; then
372 SKIP_NEXT="YES"
373 fi
374}
375
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200376# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100377client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200378 CLI_DELAY_FACTOR=$1
379}
380
Janos Follath74537a62016-09-02 13:45:28 +0100381# wait for the given seconds after the client finished in the next test
382server_needs_more_time() {
383 SRV_DELAY_SECONDS=$1
384}
385
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100386# print_name <name>
387print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100388 TESTS=$(( $TESTS + 1 ))
389 LINE=""
390
391 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
392 LINE="$TESTS "
393 fi
394
395 LINE="$LINE$1"
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200396 printf "%s " "$LINE"
Paul Bakkere20310a2016-05-10 11:18:17 +0100397 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100398 for i in `seq 1 $LEN`; do printf '.'; done
399 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100400
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100401}
402
403# fail <message>
404fail() {
405 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100406 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100407
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200408 mv $SRV_OUT o-srv-${TESTS}.log
409 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200410 if [ -n "$PXY_CMD" ]; then
411 mv $PXY_OUT o-pxy-${TESTS}.log
412 fi
413 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100414
Manuel Pégourié-Gonnarde63fc6d2020-06-08 11:49:05 +0200415 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200416 echo " ! server output:"
417 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200418 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200419 echo " ! client output:"
420 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200421 if [ -n "$PXY_CMD" ]; then
422 echo " ! ========================================================"
423 echo " ! proxy output:"
424 cat o-pxy-${TESTS}.log
425 fi
426 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200427 fi
428
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200429 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100430}
431
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100432# is_polar <cmd_line>
433is_polar() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200434 case "$1" in
435 *ssl_client2*) true;;
436 *ssl_server2*) true;;
437 *) false;;
438 esac
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100439}
440
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200441# openssl s_server doesn't have -www with DTLS
442check_osrv_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200443 case "$SRV_CMD" in
444 *s_server*-dtls*)
445 NEEDS_INPUT=1
446 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )";;
447 *) NEEDS_INPUT=0;;
448 esac
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200449}
450
451# provide input to commands that need it
452provide_input() {
453 if [ $NEEDS_INPUT -eq 0 ]; then
454 return
455 fi
456
457 while true; do
458 echo "HTTP/1.0 200 OK"
459 sleep 1
460 done
461}
462
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100463# has_mem_err <log_file_name>
464has_mem_err() {
465 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
466 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
467 then
468 return 1 # false: does not have errors
469 else
470 return 0 # true: has errors
471 fi
472}
473
Unknown43dc0d62019-09-02 10:42:57 -0400474# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100475if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400476 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100477 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200478 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100479 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200480 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100481 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200482 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100483 # Make a tight loop, server normally takes less than 1s to start.
484 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
485 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400486 echo "$3 START TIMEOUT"
487 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100488 break
489 fi
490 # Linux and *BSD support decimal arguments to sleep. On other
491 # OSes this may be a tight loop.
492 sleep 0.1 2>/dev/null || true
493 done
494 }
495else
Unknown43dc0d62019-09-02 10:42:57 -0400496 echo "Warning: lsof not available, wait_app_start = sleep"
497 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200498 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100499 }
500fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200501
Unknown43dc0d62019-09-02 10:42:57 -0400502# Wait for server process $2 to be listening on port $1.
503wait_server_start() {
504 wait_app_start $1 $2 "SERVER" $SRV_OUT
505}
506
507# Wait for proxy process $2 to be listening on port $1.
508wait_proxy_start() {
509 wait_app_start $1 $2 "PROXY" $PXY_OUT
510}
511
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100512# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100513# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100514# acceptable bounds
515check_server_hello_time() {
516 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100517 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100518 # Get the Unix timestamp for now
519 CUR_TIME=$(date +'%s')
520 THRESHOLD_IN_SECS=300
521
522 # Check if the ServerHello time was printed
523 if [ -z "$SERVER_HELLO_TIME" ]; then
524 return 1
525 fi
526
527 # Check the time in ServerHello is within acceptable bounds
528 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
529 # The time in ServerHello is at least 5 minutes before now
530 return 1
531 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100532 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100533 return 1
534 else
535 return 0
536 fi
537}
538
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200539# wait for client to terminate and set CLI_EXIT
540# must be called right after starting the client
541wait_client_done() {
542 CLI_PID=$!
543
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200544 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
545 CLI_DELAY_FACTOR=1
546
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200547 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200548 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200549
550 wait $CLI_PID
551 CLI_EXIT=$?
552
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200553 kill $DOG_PID >/dev/null 2>&1
554 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200555
556 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100557
558 sleep $SRV_DELAY_SECONDS
559 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200560}
561
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200562# check if the given command uses dtls and sets global variable DTLS
563detect_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200564 case "$1" in
565 *dtls=1*|-dtls|-u) DTLS=1;;
566 *) DTLS=0;;
567 esac
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200568}
569
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200570# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100571# Options: -s pattern pattern that must be present in server output
572# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100573# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100574# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100575# -S pattern pattern that must be absent in server output
576# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100577# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100578# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100579run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100580 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200581 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100582
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200583 if is_excluded "$NAME"; then
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200584 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100585 return
586 fi
587
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100588 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100589
Paul Bakkerb7584a52016-05-10 10:50:43 +0100590 # Do we only run numbered tests?
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200591 if [ -n "$RUN_TEST_NUMBER" ]; then
592 case ",$RUN_TEST_NUMBER," in
593 *",$TESTS,"*) :;;
594 *) SKIP_NEXT="YES";;
595 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100596 fi
597
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200598 # should we skip?
599 if [ "X$SKIP_NEXT" = "XYES" ]; then
600 SKIP_NEXT="NO"
601 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200602 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200603 return
604 fi
605
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200606 # does this test use a proxy?
607 if [ "X$1" = "X-p" ]; then
608 PXY_CMD="$2"
609 shift 2
610 else
611 PXY_CMD=""
612 fi
613
614 # get commands and client output
615 SRV_CMD="$1"
616 CLI_CMD="$2"
617 CLI_EXPECT="$3"
618 shift 3
619
Hanno Becker7a11e722019-05-10 14:38:42 +0100620 # Check if test uses files
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200621 case "$SRV_CMD $CLI_CMD" in
622 *data_files/*)
623 requires_config_enabled MBEDTLS_FS_IO;;
624 esac
Hanno Becker7a11e722019-05-10 14:38:42 +0100625
626 # should we skip?
627 if [ "X$SKIP_NEXT" = "XYES" ]; then
628 SKIP_NEXT="NO"
629 echo "SKIP"
630 SKIPS=$(( $SKIPS + 1 ))
631 return
632 fi
633
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200634 # update DTLS variable
635 detect_dtls "$SRV_CMD"
636
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200637 # if the test uses DTLS but no custom proxy, add a simple proxy
638 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200639 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200640 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200641 case " $SRV_CMD " in
642 *' server_addr=::1 '*)
643 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
644 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200645 fi
646
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200647 # fix client port
648 if [ -n "$PXY_CMD" ]; then
649 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
650 else
651 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
652 fi
653
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100654 # prepend valgrind to our commands if active
655 if [ "$MEMCHECK" -gt 0 ]; then
656 if is_polar "$SRV_CMD"; then
657 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
658 fi
659 if is_polar "$CLI_CMD"; then
660 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
661 fi
662 fi
663
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200664 TIMES_LEFT=2
665 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200666 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200667
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200668 # run the commands
669 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda1919ad2020-07-27 09:45:32 +0200670 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200671 $PXY_CMD >> $PXY_OUT 2>&1 &
672 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400673 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200674 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200675
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200676 check_osrv_dtls
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200677 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200678 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
679 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100680 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200681
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200682 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200683 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
684 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100685
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100686 sleep 0.05
687
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200688 # terminate the server (and the proxy)
689 kill $SRV_PID
690 wait $SRV_PID
Gilles Peskine634fe272021-02-02 23:29:03 +0100691 SRV_RET=$?
Hanno Beckerd82d8462017-05-29 21:37:46 +0100692
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200693 if [ -n "$PXY_CMD" ]; then
694 kill $PXY_PID >/dev/null 2>&1
695 wait $PXY_PID
696 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100697
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200698 # retry only on timeouts
699 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
700 printf "RETRY "
701 else
702 TIMES_LEFT=0
703 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200704 done
705
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100706 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200707 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100708 # expected client exit to incorrectly succeed in case of catastrophic
709 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100710 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200711 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100712 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100713 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100714 return
715 fi
716 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100717 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200718 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100719 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100720 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100721 return
722 fi
723 fi
724
Gilles Peskine2cf44b62021-02-09 21:01:33 +0100725 # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
726 # exit with status 0 when interrupted by a signal, and we don't really
727 # care anyway), in case e.g. the server reports a memory leak.
728 if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then
Gilles Peskine634fe272021-02-02 23:29:03 +0100729 fail "Server exited with status $SRV_RET"
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100730 return
731 fi
732
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100733 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100734 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
735 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100736 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200737 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100738 return
739 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100740
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100741 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200742 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100743 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100744 while [ $# -gt 0 ]
745 do
746 case $1 in
747 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100748 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 +0100749 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100750 return
751 fi
752 ;;
753
754 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100755 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 +0100756 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100757 return
758 fi
759 ;;
760
761 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100762 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 +0100763 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100764 return
765 fi
766 ;;
767
768 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100769 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 +0100770 fail "pattern '$2' MUST NOT be present in the Client output"
771 return
772 fi
773 ;;
774
775 # The filtering in the following two options (-u and -U) do the following
776 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100777 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100778 # - keep one of each non-unique line
779 # - count how many lines remain
780 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
781 # if there were no duplicates.
782 "-U")
783 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
784 fail "lines following pattern '$2' must be unique in Server output"
785 return
786 fi
787 ;;
788
789 "-u")
790 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
791 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100792 return
793 fi
794 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100795 "-F")
796 if ! $2 "$SRV_OUT"; then
797 fail "function call to '$2' failed on Server output"
798 return
799 fi
800 ;;
801 "-f")
802 if ! $2 "$CLI_OUT"; then
803 fail "function call to '$2' failed on Client output"
804 return
805 fi
806 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100807
808 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200809 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100810 exit 1
811 esac
812 shift 2
813 done
814
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100815 # check valgrind's results
816 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200817 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100818 fail "Server has memory errors"
819 return
820 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200821 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100822 fail "Client has memory errors"
823 return
824 fi
825 fi
826
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100827 # if we're here, everything is ok
828 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100829 if [ "$PRESERVE_LOGS" -gt 0 ]; then
830 mv $SRV_OUT o-srv-${TESTS}.log
831 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100832 if [ -n "$PXY_CMD" ]; then
833 mv $PXY_OUT o-pxy-${TESTS}.log
834 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100835 fi
836
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200837 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100838}
839
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100840cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200841 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200842 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
843 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
844 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
845 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100846 exit 1
847}
848
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100849#
850# MAIN
851#
852
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100853get_options "$@"
854
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200855# Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell
856# patterns rather than regular expressions, use a case statement instead
857# of calling grep. To keep the optimizer simple, it is incomplete and only
858# detects simple cases: plain substring, everything, nothing.
859#
860# As an exception, the character '.' is treated as an ordinary character
861# if it is the only special character in the string. This is because it's
862# rare to need "any one character", but needing a literal '.' is common
863# (e.g. '-f "DTLS 1.2"').
864need_grep=
865case "$FILTER" in
866 '^$') simple_filter=;;
867 '.*') simple_filter='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200868 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200869 need_grep=1;;
870 *) # No regexp or shell-pattern special character
871 simple_filter="*$FILTER*";;
872esac
873case "$EXCLUDE" in
874 '^$') simple_exclude=;;
875 '.*') simple_exclude='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200876 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200877 need_grep=1;;
878 *) # No regexp or shell-pattern special character
879 simple_exclude="*$EXCLUDE*";;
880esac
881if [ -n "$need_grep" ]; then
882 is_excluded () {
883 ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE"
884 }
885else
886 is_excluded () {
887 case "$1" in
888 $simple_exclude) true;;
889 $simple_filter) false;;
890 *) true;;
891 esac
892 }
893fi
894
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100895# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100896P_SRV_BIN="${P_SRV%%[ ]*}"
897P_CLI_BIN="${P_CLI%%[ ]*}"
898P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100899if [ ! -x "$P_SRV_BIN" ]; then
900 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100901 exit 1
902fi
Hanno Becker17c04932017-10-10 14:44:53 +0100903if [ ! -x "$P_CLI_BIN" ]; then
904 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100905 exit 1
906fi
Hanno Becker17c04932017-10-10 14:44:53 +0100907if [ ! -x "$P_PXY_BIN" ]; then
908 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200909 exit 1
910fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100911if [ "$MEMCHECK" -gt 0 ]; then
912 if which valgrind >/dev/null 2>&1; then :; else
913 echo "Memcheck not possible. Valgrind not found"
914 exit 1
915 fi
916fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100917if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
918 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100919 exit 1
920fi
921
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200922# used by watchdog
923MAIN_PID="$$"
924
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100925# We use somewhat arbitrary delays for tests:
926# - how long do we wait for the server to start (when lsof not available)?
927# - how long do we allow for the client to finish?
928# (not to check performance, just to avoid waiting indefinitely)
929# Things are slower with valgrind, so give extra time here.
930#
931# Note: without lsof, there is a trade-off between the running time of this
932# script and the risk of spurious errors because we didn't wait long enough.
933# The watchdog delay on the other hand doesn't affect normal running time of
934# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200935if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100936 START_DELAY=6
937 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200938else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100939 START_DELAY=2
940 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200941fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100942
943# some particular tests need more time:
944# - for the client, we multiply the usual watchdog limit by a factor
945# - for the server, we sleep for a number of seconds after the client exits
946# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200947CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100948SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200949
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200950# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000951# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200952P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
953P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100954P_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"}"
Gilles Peskine63a2b912021-04-01 14:00:11 +0200955O_SRV="$O_SRV -accept $SRV_PORT"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200956O_CLI="$O_CLI -connect localhost:+SRV_PORT"
957G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200958G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200959
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200960if [ -n "${OPENSSL_LEGACY:-}" ]; then
961 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
962 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
963fi
964
Hanno Becker58e9dc32018-08-17 15:53:21 +0100965if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200966 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
967fi
968
Hanno Becker58e9dc32018-08-17 15:53:21 +0100969if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200970 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200971fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100972
Gilles Peskine62469d92017-05-10 10:13:59 +0200973# Allow SHA-1, because many of our test certificates use it
974P_SRV="$P_SRV allow_sha1=1"
975P_CLI="$P_CLI allow_sha1=1"
976
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200977# Also pick a unique name for intermediate files
978SRV_OUT="srv_out.$$"
979CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200980PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200981SESSION="session.$$"
982
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200983SKIP_NEXT="NO"
984
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100985trap cleanup INT TERM HUP
986
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200987# Basic test
988
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200989# Checks that:
990# - things work with all ciphersuites active (used with config-full in all.sh)
991# - the expected (highest security) parameters are selected
992# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200993run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200994 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200995 "$P_CLI" \
996 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200997 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200998 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200999 -s "client hello v3, signature_algorithm ext: 6" \
1000 -s "ECDHE curve: secp521r1" \
1001 -S "error" \
1002 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001003
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001004run_test "Default, DTLS" \
1005 "$P_SRV dtls=1" \
1006 "$P_CLI dtls=1" \
1007 0 \
1008 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001009 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001010
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +01001011requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1012run_test "Default (compression enabled)" \
1013 "$P_SRV debug_level=3" \
1014 "$P_CLI debug_level=3" \
1015 0 \
1016 -s "Allocating compression buffer" \
1017 -c "Allocating compression buffer" \
1018 -s "Record expansion is unknown (compression)" \
1019 -c "Record expansion is unknown (compression)" \
1020 -S "error" \
1021 -C "error"
1022
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001023# Test current time in ServerHello
1024requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001025run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001026 "$P_SRV debug_level=3" \
1027 "$P_CLI debug_level=3" \
1028 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001029 -f "check_server_hello_time" \
1030 -F "check_server_hello_time"
1031
Simon Butcher8e004102016-10-14 00:48:33 +01001032# Test for uniqueness of IVs in AEAD ciphersuites
1033run_test "Unique IV in GCM" \
1034 "$P_SRV exchanges=20 debug_level=4" \
1035 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1036 0 \
1037 -u "IV used" \
1038 -U "IV used"
1039
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001040# Tests for rc4 option
1041
Simon Butchera410af52016-05-19 22:12:18 +01001042requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001043run_test "RC4: server disabled, client enabled" \
1044 "$P_SRV" \
1045 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1046 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001047 -s "SSL - The server has no ciphersuites in common"
1048
Simon Butchera410af52016-05-19 22:12:18 +01001049requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001050run_test "RC4: server half, client enabled" \
1051 "$P_SRV arc4=1" \
1052 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1053 1 \
1054 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001055
1056run_test "RC4: server enabled, client disabled" \
1057 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1058 "$P_CLI" \
1059 1 \
1060 -s "SSL - The server has no ciphersuites in common"
1061
1062run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001063 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001064 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1065 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001066 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001067 -S "SSL - The server has no ciphersuites in common"
1068
Hanno Beckerd26bb202018-08-17 09:54:10 +01001069# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1070
1071requires_gnutls
1072requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1073run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1074 "$G_SRV"\
1075 "$P_CLI force_version=tls1_1" \
1076 0
1077
1078requires_gnutls
1079requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1080run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1081 "$G_SRV"\
1082 "$P_CLI force_version=tls1" \
1083 0
1084
Gilles Peskinebc70a182017-05-09 15:59:24 +02001085# Tests for SHA-1 support
1086
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001087requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001088run_test "SHA-1 forbidden by default in server certificate" \
1089 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1090 "$P_CLI debug_level=2 allow_sha1=0" \
1091 1 \
1092 -c "The certificate is signed with an unacceptable hash"
1093
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001094requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1095run_test "SHA-1 forbidden by default in server certificate" \
1096 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1097 "$P_CLI debug_level=2 allow_sha1=0" \
1098 0
1099
Gilles Peskinebc70a182017-05-09 15:59:24 +02001100run_test "SHA-1 explicitly allowed in server certificate" \
1101 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1102 "$P_CLI allow_sha1=1" \
1103 0
1104
1105run_test "SHA-256 allowed by default in server certificate" \
1106 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1107 "$P_CLI allow_sha1=0" \
1108 0
1109
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001110requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001111run_test "SHA-1 forbidden by default in client certificate" \
1112 "$P_SRV auth_mode=required allow_sha1=0" \
1113 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1114 1 \
1115 -s "The certificate is signed with an unacceptable hash"
1116
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001117requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1118run_test "SHA-1 forbidden by default in client certificate" \
1119 "$P_SRV auth_mode=required allow_sha1=0" \
1120 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1121 0
1122
Gilles Peskinebc70a182017-05-09 15:59:24 +02001123run_test "SHA-1 explicitly allowed in client certificate" \
1124 "$P_SRV auth_mode=required allow_sha1=1" \
1125 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1126 0
1127
1128run_test "SHA-256 allowed by default in client certificate" \
1129 "$P_SRV auth_mode=required allow_sha1=0" \
1130 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1131 0
1132
Hanno Becker7ae8a762018-08-14 15:43:35 +01001133# Tests for datagram packing
1134run_test "DTLS: multiple records in same datagram, client and server" \
1135 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1136 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1137 0 \
1138 -c "next record in same datagram" \
1139 -s "next record in same datagram"
1140
1141run_test "DTLS: multiple records in same datagram, client only" \
1142 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1143 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1144 0 \
1145 -s "next record in same datagram" \
1146 -C "next record in same datagram"
1147
1148run_test "DTLS: multiple records in same datagram, server only" \
1149 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1150 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1151 0 \
1152 -S "next record in same datagram" \
1153 -c "next record in same datagram"
1154
1155run_test "DTLS: multiple records in same datagram, neither client nor server" \
1156 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1157 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1158 0 \
1159 -S "next record in same datagram" \
1160 -C "next record in same datagram"
1161
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001162# Tests for Truncated HMAC extension
1163
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001164run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001165 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001166 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001167 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001168 -s "dumping 'expected mac' (20 bytes)" \
1169 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001170
Hanno Becker32c55012017-11-10 08:42:54 +00001171requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001172run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001173 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001174 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001175 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001176 -s "dumping 'expected mac' (20 bytes)" \
1177 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001178
Hanno Becker32c55012017-11-10 08:42:54 +00001179requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001180run_test "Truncated HMAC: client enabled, server default" \
1181 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001182 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001183 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001184 -s "dumping 'expected mac' (20 bytes)" \
1185 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001186
Hanno Becker32c55012017-11-10 08:42:54 +00001187requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001188run_test "Truncated HMAC: client enabled, server disabled" \
1189 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001190 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001191 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001192 -s "dumping 'expected mac' (20 bytes)" \
1193 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001194
Hanno Becker32c55012017-11-10 08:42:54 +00001195requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001196run_test "Truncated HMAC: client disabled, server enabled" \
1197 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001198 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001199 0 \
1200 -s "dumping 'expected mac' (20 bytes)" \
1201 -S "dumping 'expected mac' (10 bytes)"
1202
1203requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001204run_test "Truncated HMAC: client enabled, server enabled" \
1205 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001206 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001207 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001208 -S "dumping 'expected mac' (20 bytes)" \
1209 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001210
Hanno Becker4c4f4102017-11-10 09:16:05 +00001211run_test "Truncated HMAC, DTLS: client default, server default" \
1212 "$P_SRV dtls=1 debug_level=4" \
1213 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1214 0 \
1215 -s "dumping 'expected mac' (20 bytes)" \
1216 -S "dumping 'expected mac' (10 bytes)"
1217
1218requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1219run_test "Truncated HMAC, DTLS: client disabled, server default" \
1220 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001221 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001222 0 \
1223 -s "dumping 'expected mac' (20 bytes)" \
1224 -S "dumping 'expected mac' (10 bytes)"
1225
1226requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1227run_test "Truncated HMAC, DTLS: client enabled, server default" \
1228 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001229 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001230 0 \
1231 -s "dumping 'expected mac' (20 bytes)" \
1232 -S "dumping 'expected mac' (10 bytes)"
1233
1234requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1235run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1236 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001237 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001238 0 \
1239 -s "dumping 'expected mac' (20 bytes)" \
1240 -S "dumping 'expected mac' (10 bytes)"
1241
1242requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1243run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1244 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001245 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001246 0 \
1247 -s "dumping 'expected mac' (20 bytes)" \
1248 -S "dumping 'expected mac' (10 bytes)"
1249
1250requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1251run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1252 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001253 "$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 +01001254 0 \
1255 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001256 -s "dumping 'expected mac' (10 bytes)"
1257
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001258# Tests for Encrypt-then-MAC extension
1259
1260run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001261 "$P_SRV debug_level=3 \
1262 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001263 "$P_CLI debug_level=3" \
1264 0 \
1265 -c "client hello, adding encrypt_then_mac extension" \
1266 -s "found encrypt then mac extension" \
1267 -s "server hello, adding encrypt then mac extension" \
1268 -c "found encrypt_then_mac extension" \
1269 -c "using encrypt then mac" \
1270 -s "using encrypt then mac"
1271
1272run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001273 "$P_SRV debug_level=3 etm=0 \
1274 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001275 "$P_CLI debug_level=3 etm=1" \
1276 0 \
1277 -c "client hello, adding encrypt_then_mac extension" \
1278 -s "found encrypt then mac extension" \
1279 -S "server hello, adding encrypt then mac extension" \
1280 -C "found encrypt_then_mac extension" \
1281 -C "using encrypt then mac" \
1282 -S "using encrypt then mac"
1283
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001284run_test "Encrypt then MAC: client enabled, aead cipher" \
1285 "$P_SRV debug_level=3 etm=1 \
1286 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1287 "$P_CLI debug_level=3 etm=1" \
1288 0 \
1289 -c "client hello, adding encrypt_then_mac extension" \
1290 -s "found encrypt then mac extension" \
1291 -S "server hello, adding encrypt then mac extension" \
1292 -C "found encrypt_then_mac extension" \
1293 -C "using encrypt then mac" \
1294 -S "using encrypt then mac"
1295
1296run_test "Encrypt then MAC: client enabled, stream cipher" \
1297 "$P_SRV debug_level=3 etm=1 \
1298 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001299 "$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 +01001300 0 \
1301 -c "client hello, adding encrypt_then_mac extension" \
1302 -s "found encrypt then mac extension" \
1303 -S "server hello, adding encrypt then mac extension" \
1304 -C "found encrypt_then_mac extension" \
1305 -C "using encrypt then mac" \
1306 -S "using encrypt then mac"
1307
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001308run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001309 "$P_SRV debug_level=3 etm=1 \
1310 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001311 "$P_CLI debug_level=3 etm=0" \
1312 0 \
1313 -C "client hello, adding encrypt_then_mac extension" \
1314 -S "found encrypt then mac extension" \
1315 -S "server hello, adding encrypt then mac extension" \
1316 -C "found encrypt_then_mac extension" \
1317 -C "using encrypt then mac" \
1318 -S "using encrypt then mac"
1319
Janos Follathe2681a42016-03-07 15:57:05 +00001320requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001321run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001322 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001323 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001324 "$P_CLI debug_level=3 force_version=ssl3" \
1325 0 \
1326 -C "client hello, adding encrypt_then_mac extension" \
1327 -S "found encrypt then mac extension" \
1328 -S "server hello, adding encrypt then mac extension" \
1329 -C "found encrypt_then_mac extension" \
1330 -C "using encrypt then mac" \
1331 -S "using encrypt then mac"
1332
Janos Follathe2681a42016-03-07 15:57:05 +00001333requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001334run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001335 "$P_SRV debug_level=3 force_version=ssl3 \
1336 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001337 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001338 0 \
1339 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001340 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001341 -S "server hello, adding encrypt then mac extension" \
1342 -C "found encrypt_then_mac extension" \
1343 -C "using encrypt then mac" \
1344 -S "using encrypt then mac"
1345
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001346# Tests for Extended Master Secret extension
1347
1348run_test "Extended Master Secret: default" \
1349 "$P_SRV debug_level=3" \
1350 "$P_CLI debug_level=3" \
1351 0 \
1352 -c "client hello, adding extended_master_secret extension" \
1353 -s "found extended master secret extension" \
1354 -s "server hello, adding extended master secret extension" \
1355 -c "found extended_master_secret extension" \
1356 -c "using extended master secret" \
1357 -s "using extended master secret"
1358
1359run_test "Extended Master Secret: client enabled, server disabled" \
1360 "$P_SRV debug_level=3 extended_ms=0" \
1361 "$P_CLI debug_level=3 extended_ms=1" \
1362 0 \
1363 -c "client hello, adding extended_master_secret extension" \
1364 -s "found extended master secret extension" \
1365 -S "server hello, adding extended master secret extension" \
1366 -C "found extended_master_secret extension" \
1367 -C "using extended master secret" \
1368 -S "using extended master secret"
1369
1370run_test "Extended Master Secret: client disabled, server enabled" \
1371 "$P_SRV debug_level=3 extended_ms=1" \
1372 "$P_CLI debug_level=3 extended_ms=0" \
1373 0 \
1374 -C "client hello, adding extended_master_secret extension" \
1375 -S "found extended master secret extension" \
1376 -S "server hello, adding extended master secret extension" \
1377 -C "found extended_master_secret extension" \
1378 -C "using extended master secret" \
1379 -S "using extended master secret"
1380
Janos Follathe2681a42016-03-07 15:57:05 +00001381requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001382run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001383 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001384 "$P_CLI debug_level=3 force_version=ssl3" \
1385 0 \
1386 -C "client hello, adding extended_master_secret extension" \
1387 -S "found extended master secret extension" \
1388 -S "server hello, adding extended master secret extension" \
1389 -C "found extended_master_secret extension" \
1390 -C "using extended master secret" \
1391 -S "using extended master secret"
1392
Janos Follathe2681a42016-03-07 15:57:05 +00001393requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001394run_test "Extended Master Secret: client enabled, server SSLv3" \
1395 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001396 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001397 0 \
1398 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001399 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001400 -S "server hello, adding extended master secret extension" \
1401 -C "found extended_master_secret extension" \
1402 -C "using extended master secret" \
1403 -S "using extended master secret"
1404
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001405# Tests for FALLBACK_SCSV
1406
1407run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001408 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001409 "$P_CLI debug_level=3 force_version=tls1_1" \
1410 0 \
1411 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001412 -S "received FALLBACK_SCSV" \
1413 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001414 -C "is a fatal alert message (msg 86)"
1415
1416run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001417 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001418 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1419 0 \
1420 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001421 -S "received FALLBACK_SCSV" \
1422 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001423 -C "is a fatal alert message (msg 86)"
1424
1425run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001426 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001427 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001428 1 \
1429 -c "adding FALLBACK_SCSV" \
1430 -s "received FALLBACK_SCSV" \
1431 -s "inapropriate fallback" \
1432 -c "is a fatal alert message (msg 86)"
1433
1434run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001435 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001436 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001437 0 \
1438 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001439 -s "received FALLBACK_SCSV" \
1440 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001441 -C "is a fatal alert message (msg 86)"
1442
1443requires_openssl_with_fallback_scsv
1444run_test "Fallback SCSV: default, openssl server" \
1445 "$O_SRV" \
1446 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1447 0 \
1448 -C "adding FALLBACK_SCSV" \
1449 -C "is a fatal alert message (msg 86)"
1450
1451requires_openssl_with_fallback_scsv
1452run_test "Fallback SCSV: enabled, openssl server" \
1453 "$O_SRV" \
1454 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1455 1 \
1456 -c "adding FALLBACK_SCSV" \
1457 -c "is a fatal alert message (msg 86)"
1458
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001459requires_openssl_with_fallback_scsv
1460run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001461 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001462 "$O_CLI -tls1_1" \
1463 0 \
1464 -S "received FALLBACK_SCSV" \
1465 -S "inapropriate fallback"
1466
1467requires_openssl_with_fallback_scsv
1468run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001469 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001470 "$O_CLI -tls1_1 -fallback_scsv" \
1471 1 \
1472 -s "received FALLBACK_SCSV" \
1473 -s "inapropriate fallback"
1474
1475requires_openssl_with_fallback_scsv
1476run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001477 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001478 "$O_CLI -fallback_scsv" \
1479 0 \
1480 -s "received FALLBACK_SCSV" \
1481 -S "inapropriate fallback"
1482
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001483# Test sending and receiving empty application data records
1484
1485run_test "Encrypt then MAC: empty application data record" \
1486 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1487 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1488 0 \
1489 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1490 -s "dumping 'input payload after decrypt' (0 bytes)" \
1491 -c "0 bytes written in 1 fragments"
1492
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001493run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001494 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1495 "$P_CLI auth_mode=none etm=0 request_size=0" \
1496 0 \
1497 -s "dumping 'input payload after decrypt' (0 bytes)" \
1498 -c "0 bytes written in 1 fragments"
1499
1500run_test "Encrypt then MAC, DTLS: empty application data record" \
1501 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1502 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1503 0 \
1504 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1505 -s "dumping 'input payload after decrypt' (0 bytes)" \
1506 -c "0 bytes written in 1 fragments"
1507
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001508run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001509 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1510 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1511 0 \
1512 -s "dumping 'input payload after decrypt' (0 bytes)" \
1513 -c "0 bytes written in 1 fragments"
1514
Gilles Peskined50177f2017-05-16 17:53:03 +02001515## ClientHello generated with
1516## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1517## then manually twiddling the ciphersuite list.
1518## The ClientHello content is spelled out below as a hex string as
1519## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1520## The expected response is an inappropriate_fallback alert.
1521requires_openssl_with_fallback_scsv
1522run_test "Fallback SCSV: beginning of list" \
1523 "$P_SRV debug_level=2" \
1524 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1525 0 \
1526 -s "received FALLBACK_SCSV" \
1527 -s "inapropriate fallback"
1528
1529requires_openssl_with_fallback_scsv
1530run_test "Fallback SCSV: end of list" \
1531 "$P_SRV debug_level=2" \
1532 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1533 0 \
1534 -s "received FALLBACK_SCSV" \
1535 -s "inapropriate fallback"
1536
1537## Here the expected response is a valid ServerHello prefix, up to the random.
1538requires_openssl_with_fallback_scsv
1539run_test "Fallback SCSV: not in list" \
1540 "$P_SRV debug_level=2" \
1541 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1542 0 \
1543 -S "received FALLBACK_SCSV" \
1544 -S "inapropriate fallback"
1545
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001546# Tests for CBC 1/n-1 record splitting
1547
1548run_test "CBC Record splitting: TLS 1.2, no splitting" \
1549 "$P_SRV" \
1550 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1551 request_size=123 force_version=tls1_2" \
1552 0 \
1553 -s "Read from client: 123 bytes read" \
1554 -S "Read from client: 1 bytes read" \
1555 -S "122 bytes read"
1556
1557run_test "CBC Record splitting: TLS 1.1, no splitting" \
1558 "$P_SRV" \
1559 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1560 request_size=123 force_version=tls1_1" \
1561 0 \
1562 -s "Read from client: 123 bytes read" \
1563 -S "Read from client: 1 bytes read" \
1564 -S "122 bytes read"
1565
1566run_test "CBC Record splitting: TLS 1.0, splitting" \
1567 "$P_SRV" \
1568 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1569 request_size=123 force_version=tls1" \
1570 0 \
1571 -S "Read from client: 123 bytes read" \
1572 -s "Read from client: 1 bytes read" \
1573 -s "122 bytes read"
1574
Janos Follathe2681a42016-03-07 15:57:05 +00001575requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001576run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001577 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001578 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1579 request_size=123 force_version=ssl3" \
1580 0 \
1581 -S "Read from client: 123 bytes read" \
1582 -s "Read from client: 1 bytes read" \
1583 -s "122 bytes read"
1584
1585run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001586 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001587 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1588 request_size=123 force_version=tls1" \
1589 0 \
1590 -s "Read from client: 123 bytes read" \
1591 -S "Read from client: 1 bytes read" \
1592 -S "122 bytes read"
1593
1594run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1595 "$P_SRV" \
1596 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1597 request_size=123 force_version=tls1 recsplit=0" \
1598 0 \
1599 -s "Read from client: 123 bytes read" \
1600 -S "Read from client: 1 bytes read" \
1601 -S "122 bytes read"
1602
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001603run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1604 "$P_SRV nbio=2" \
1605 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1606 request_size=123 force_version=tls1" \
1607 0 \
1608 -S "Read from client: 123 bytes read" \
1609 -s "Read from client: 1 bytes read" \
1610 -s "122 bytes read"
1611
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001612# Tests for Session Tickets
1613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001614run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001615 "$P_SRV debug_level=3 tickets=1" \
1616 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001617 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001618 -c "client hello, adding session ticket extension" \
1619 -s "found session ticket extension" \
1620 -s "server hello, adding session ticket extension" \
1621 -c "found session_ticket extension" \
1622 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001623 -S "session successfully restored from cache" \
1624 -s "session successfully restored from ticket" \
1625 -s "a session has been resumed" \
1626 -c "a session has been resumed"
1627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001628run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001629 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1630 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001631 0 \
1632 -c "client hello, adding session ticket extension" \
1633 -s "found session ticket extension" \
1634 -s "server hello, adding session ticket extension" \
1635 -c "found session_ticket extension" \
1636 -c "parse new session ticket" \
1637 -S "session successfully restored from cache" \
1638 -s "session successfully restored from ticket" \
1639 -s "a session has been resumed" \
1640 -c "a session has been resumed"
1641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001642run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001643 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1644 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001645 0 \
1646 -c "client hello, adding session ticket extension" \
1647 -s "found session ticket extension" \
1648 -s "server hello, adding session ticket extension" \
1649 -c "found session_ticket extension" \
1650 -c "parse new session ticket" \
1651 -S "session successfully restored from cache" \
1652 -S "session successfully restored from ticket" \
1653 -S "a session has been resumed" \
1654 -C "a session has been resumed"
1655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001656run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001657 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001658 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001659 0 \
1660 -c "client hello, adding session ticket extension" \
1661 -c "found session_ticket extension" \
1662 -c "parse new session ticket" \
1663 -c "a session has been resumed"
1664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001665run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001666 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001667 "( $O_CLI -sess_out $SESSION; \
1668 $O_CLI -sess_in $SESSION; \
1669 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001670 0 \
1671 -s "found session ticket extension" \
1672 -s "server hello, adding session ticket extension" \
1673 -S "session successfully restored from cache" \
1674 -s "session successfully restored from ticket" \
1675 -s "a session has been resumed"
1676
Hanno Becker1d739932018-08-21 13:55:22 +01001677# Tests for Session Tickets with DTLS
1678
1679run_test "Session resume using tickets, DTLS: basic" \
1680 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001681 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001682 0 \
1683 -c "client hello, adding session ticket extension" \
1684 -s "found session ticket extension" \
1685 -s "server hello, adding session ticket extension" \
1686 -c "found session_ticket extension" \
1687 -c "parse new session ticket" \
1688 -S "session successfully restored from cache" \
1689 -s "session successfully restored from ticket" \
1690 -s "a session has been resumed" \
1691 -c "a session has been resumed"
1692
1693run_test "Session resume using tickets, DTLS: cache disabled" \
1694 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001695 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001696 0 \
1697 -c "client hello, adding session ticket extension" \
1698 -s "found session ticket extension" \
1699 -s "server hello, adding session ticket extension" \
1700 -c "found session_ticket extension" \
1701 -c "parse new session ticket" \
1702 -S "session successfully restored from cache" \
1703 -s "session successfully restored from ticket" \
1704 -s "a session has been resumed" \
1705 -c "a session has been resumed"
1706
1707run_test "Session resume using tickets, DTLS: timeout" \
1708 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001709 "$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 +01001710 0 \
1711 -c "client hello, adding session ticket extension" \
1712 -s "found session ticket extension" \
1713 -s "server hello, adding session ticket extension" \
1714 -c "found session_ticket extension" \
1715 -c "parse new session ticket" \
1716 -S "session successfully restored from cache" \
1717 -S "session successfully restored from ticket" \
1718 -S "a session has been resumed" \
1719 -C "a session has been resumed"
1720
1721run_test "Session resume using tickets, DTLS: openssl server" \
1722 "$O_SRV -dtls1" \
1723 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1724 0 \
1725 -c "client hello, adding session ticket extension" \
1726 -c "found session_ticket extension" \
1727 -c "parse new session ticket" \
1728 -c "a session has been resumed"
1729
1730run_test "Session resume using tickets, DTLS: openssl client" \
1731 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1732 "( $O_CLI -dtls1 -sess_out $SESSION; \
1733 $O_CLI -dtls1 -sess_in $SESSION; \
1734 rm -f $SESSION )" \
1735 0 \
1736 -s "found session ticket extension" \
1737 -s "server hello, adding session ticket extension" \
1738 -S "session successfully restored from cache" \
1739 -s "session successfully restored from ticket" \
1740 -s "a session has been resumed"
1741
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001742# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001744run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001745 "$P_SRV debug_level=3 tickets=0" \
1746 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001747 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001748 -c "client hello, adding session ticket extension" \
1749 -s "found session ticket extension" \
1750 -S "server hello, adding session ticket extension" \
1751 -C "found session_ticket extension" \
1752 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001753 -s "session successfully restored from cache" \
1754 -S "session successfully restored from ticket" \
1755 -s "a session has been resumed" \
1756 -c "a session has been resumed"
1757
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001758run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001759 "$P_SRV debug_level=3 tickets=1" \
1760 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001761 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001762 -C "client hello, adding session ticket extension" \
1763 -S "found session ticket extension" \
1764 -S "server hello, adding session ticket extension" \
1765 -C "found session_ticket extension" \
1766 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001767 -s "session successfully restored from cache" \
1768 -S "session successfully restored from ticket" \
1769 -s "a session has been resumed" \
1770 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001772run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001773 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1774 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001775 0 \
1776 -S "session successfully restored from cache" \
1777 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001778 -S "a session has been resumed" \
1779 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001781run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001782 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1783 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001784 0 \
1785 -s "session successfully restored from cache" \
1786 -S "session successfully restored from ticket" \
1787 -s "a session has been resumed" \
1788 -c "a session has been resumed"
1789
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001790run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001791 "$P_SRV debug_level=3 tickets=0" \
1792 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001793 0 \
1794 -s "session successfully restored from cache" \
1795 -S "session successfully restored from ticket" \
1796 -s "a session has been resumed" \
1797 -c "a session has been resumed"
1798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001799run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001800 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1801 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001802 0 \
1803 -S "session successfully restored from cache" \
1804 -S "session successfully restored from ticket" \
1805 -S "a session has been resumed" \
1806 -C "a session has been resumed"
1807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001808run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001809 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1810 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001811 0 \
1812 -s "session successfully restored from cache" \
1813 -S "session successfully restored from ticket" \
1814 -s "a session has been resumed" \
1815 -c "a session has been resumed"
1816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001817run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001818 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001819 "( $O_CLI -sess_out $SESSION; \
1820 $O_CLI -sess_in $SESSION; \
1821 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001822 0 \
1823 -s "found session ticket extension" \
1824 -S "server hello, adding session ticket extension" \
1825 -s "session successfully restored from cache" \
1826 -S "session successfully restored from ticket" \
1827 -s "a session has been resumed"
1828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001829run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001830 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001831 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001832 0 \
1833 -C "found session_ticket extension" \
1834 -C "parse new session ticket" \
1835 -c "a session has been resumed"
1836
Hanno Becker1d739932018-08-21 13:55:22 +01001837# Tests for Session Resume based on session-ID and cache, DTLS
1838
1839run_test "Session resume using cache, DTLS: tickets enabled on client" \
1840 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001841 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001842 0 \
1843 -c "client hello, adding session ticket extension" \
1844 -s "found session ticket extension" \
1845 -S "server hello, adding session ticket extension" \
1846 -C "found session_ticket extension" \
1847 -C "parse new session ticket" \
1848 -s "session successfully restored from cache" \
1849 -S "session successfully restored from ticket" \
1850 -s "a session has been resumed" \
1851 -c "a session has been resumed"
1852
1853run_test "Session resume using cache, DTLS: tickets enabled on server" \
1854 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001855 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001856 0 \
1857 -C "client hello, adding session ticket extension" \
1858 -S "found session ticket extension" \
1859 -S "server hello, adding session ticket extension" \
1860 -C "found session_ticket extension" \
1861 -C "parse new session ticket" \
1862 -s "session successfully restored from cache" \
1863 -S "session successfully restored from ticket" \
1864 -s "a session has been resumed" \
1865 -c "a session has been resumed"
1866
1867run_test "Session resume using cache, DTLS: cache_max=0" \
1868 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001869 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001870 0 \
1871 -S "session successfully restored from cache" \
1872 -S "session successfully restored from ticket" \
1873 -S "a session has been resumed" \
1874 -C "a session has been resumed"
1875
1876run_test "Session resume using cache, DTLS: cache_max=1" \
1877 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001878 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001879 0 \
1880 -s "session successfully restored from cache" \
1881 -S "session successfully restored from ticket" \
1882 -s "a session has been resumed" \
1883 -c "a session has been resumed"
1884
1885run_test "Session resume using cache, DTLS: timeout > delay" \
1886 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001887 "$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 +01001888 0 \
1889 -s "session successfully restored from cache" \
1890 -S "session successfully restored from ticket" \
1891 -s "a session has been resumed" \
1892 -c "a session has been resumed"
1893
1894run_test "Session resume using cache, DTLS: timeout < delay" \
1895 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001896 "$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 +01001897 0 \
1898 -S "session successfully restored from cache" \
1899 -S "session successfully restored from ticket" \
1900 -S "a session has been resumed" \
1901 -C "a session has been resumed"
1902
1903run_test "Session resume using cache, DTLS: no timeout" \
1904 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001905 "$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 +01001906 0 \
1907 -s "session successfully restored from cache" \
1908 -S "session successfully restored from ticket" \
1909 -s "a session has been resumed" \
1910 -c "a session has been resumed"
1911
1912run_test "Session resume using cache, DTLS: openssl client" \
1913 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1914 "( $O_CLI -dtls1 -sess_out $SESSION; \
1915 $O_CLI -dtls1 -sess_in $SESSION; \
1916 rm -f $SESSION )" \
1917 0 \
1918 -s "found session ticket extension" \
1919 -S "server hello, adding session ticket extension" \
1920 -s "session successfully restored from cache" \
1921 -S "session successfully restored from ticket" \
1922 -s "a session has been resumed"
1923
1924run_test "Session resume using cache, DTLS: openssl server" \
1925 "$O_SRV -dtls1" \
1926 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1927 0 \
1928 -C "found session_ticket extension" \
1929 -C "parse new session ticket" \
1930 -c "a session has been resumed"
1931
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001932# Tests for Max Fragment Length extension
1933
Angus Grattonc4dd0732018-04-11 16:28:39 +10001934if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02001935 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 +01001936 exit 1
1937fi
1938
Angus Grattonc4dd0732018-04-11 16:28:39 +10001939if [ $MAX_CONTENT_LEN -ne 16384 ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02001940 echo "Using non-default maximum content length $MAX_CONTENT_LEN"
Angus Grattonc4dd0732018-04-11 16:28:39 +10001941fi
1942
Hanno Becker4aed27e2017-09-18 15:00:34 +01001943requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001944run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001945 "$P_SRV debug_level=3" \
1946 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001947 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001948 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1949 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001950 -C "client hello, adding max_fragment_length extension" \
1951 -S "found max fragment length extension" \
1952 -S "server hello, max_fragment_length extension" \
1953 -C "found max_fragment_length extension"
1954
Hanno Becker4aed27e2017-09-18 15:00:34 +01001955requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001956run_test "Max fragment length: enabled, default, larger message" \
1957 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001958 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001959 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001960 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1961 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +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" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001966 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1967 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001968 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001969
1970requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1971run_test "Max fragment length, DTLS: enabled, default, larger message" \
1972 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001973 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001974 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001975 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1976 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001977 -C "client hello, adding max_fragment_length extension" \
1978 -S "found max fragment length extension" \
1979 -S "server hello, max_fragment_length extension" \
1980 -C "found max_fragment_length extension" \
1981 -c "fragment larger than.*maximum "
1982
Angus Grattonc4dd0732018-04-11 16:28:39 +10001983# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1984# (session fragment length will be 16384 regardless of mbedtls
1985# content length configuration.)
1986
Hanno Beckerc5266962017-09-18 15:01:50 +01001987requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1988run_test "Max fragment length: disabled, larger message" \
1989 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001990 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001991 0 \
1992 -C "Maximum fragment length is 16384" \
1993 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001994 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1995 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001996 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001997
1998requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1999run_test "Max fragment length DTLS: disabled, larger message" \
2000 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002001 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002002 1 \
2003 -C "Maximum fragment length is 16384" \
2004 -S "Maximum fragment length is 16384" \
2005 -c "fragment larger than.*maximum "
2006
2007requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002008run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002009 "$P_SRV debug_level=3" \
2010 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002011 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002012 -c "Maximum fragment length is 4096" \
2013 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002014 -c "client hello, adding max_fragment_length extension" \
2015 -s "found max fragment length extension" \
2016 -s "server hello, max_fragment_length extension" \
2017 -c "found max_fragment_length extension"
2018
Hanno Becker4aed27e2017-09-18 15:00:34 +01002019requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002020run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002021 "$P_SRV debug_level=3 max_frag_len=4096" \
2022 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002023 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002024 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002025 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002026 -C "client hello, adding max_fragment_length extension" \
2027 -S "found max fragment length extension" \
2028 -S "server hello, max_fragment_length extension" \
2029 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002030
Hanno Becker4aed27e2017-09-18 15:00:34 +01002031requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002032requires_gnutls
2033run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002034 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002035 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002036 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002037 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002038 -c "client hello, adding max_fragment_length extension" \
2039 -c "found max_fragment_length extension"
2040
Hanno Becker4aed27e2017-09-18 15:00:34 +01002041requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002042run_test "Max fragment length: client, message just fits" \
2043 "$P_SRV debug_level=3" \
2044 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
2045 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002046 -c "Maximum fragment length is 2048" \
2047 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002048 -c "client hello, adding max_fragment_length extension" \
2049 -s "found max fragment length extension" \
2050 -s "server hello, max_fragment_length extension" \
2051 -c "found max_fragment_length extension" \
2052 -c "2048 bytes written in 1 fragments" \
2053 -s "2048 bytes read"
2054
Hanno Becker4aed27e2017-09-18 15:00:34 +01002055requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002056run_test "Max fragment length: client, larger message" \
2057 "$P_SRV debug_level=3" \
2058 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2059 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002060 -c "Maximum fragment length is 2048" \
2061 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002062 -c "client hello, adding max_fragment_length extension" \
2063 -s "found max fragment length extension" \
2064 -s "server hello, max_fragment_length extension" \
2065 -c "found max_fragment_length extension" \
2066 -c "2345 bytes written in 2 fragments" \
2067 -s "2048 bytes read" \
2068 -s "297 bytes read"
2069
Hanno Becker4aed27e2017-09-18 15:00:34 +01002070requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002071run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002072 "$P_SRV debug_level=3 dtls=1" \
2073 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2074 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002075 -c "Maximum fragment length is 2048" \
2076 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002077 -c "client hello, adding max_fragment_length extension" \
2078 -s "found max fragment length extension" \
2079 -s "server hello, max_fragment_length extension" \
2080 -c "found max_fragment_length extension" \
2081 -c "fragment larger than.*maximum"
2082
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002083# Tests for renegotiation
2084
Hanno Becker6a243642017-10-12 15:18:45 +01002085# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002086run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002087 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002088 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002089 0 \
2090 -C "client hello, adding renegotiation extension" \
2091 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2092 -S "found renegotiation extension" \
2093 -s "server hello, secure renegotiation extension" \
2094 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002095 -C "=> renegotiate" \
2096 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002097 -S "write hello request"
2098
Hanno Becker6a243642017-10-12 15:18:45 +01002099requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002100run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002101 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002102 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002103 0 \
2104 -c "client hello, adding renegotiation extension" \
2105 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2106 -s "found renegotiation extension" \
2107 -s "server hello, secure renegotiation extension" \
2108 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002109 -c "=> renegotiate" \
2110 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002111 -S "write hello request"
2112
Hanno Becker6a243642017-10-12 15:18:45 +01002113requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002114run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002115 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002116 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002117 0 \
2118 -c "client hello, adding renegotiation extension" \
2119 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2120 -s "found renegotiation extension" \
2121 -s "server hello, secure renegotiation extension" \
2122 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002123 -c "=> renegotiate" \
2124 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002125 -s "write hello request"
2126
Janos Follathb0f148c2017-10-05 12:29:42 +01002127# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2128# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2129# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002130requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002131run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2132 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2133 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2134 0 \
2135 -c "client hello, adding renegotiation extension" \
2136 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2137 -s "found renegotiation extension" \
2138 -s "server hello, secure renegotiation extension" \
2139 -c "found renegotiation extension" \
2140 -c "=> renegotiate" \
2141 -s "=> renegotiate" \
2142 -S "write hello request" \
2143 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2144
2145# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2146# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2147# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002148requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002149run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2150 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2151 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2152 0 \
2153 -c "client hello, adding renegotiation extension" \
2154 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2155 -s "found renegotiation extension" \
2156 -s "server hello, secure renegotiation extension" \
2157 -c "found renegotiation extension" \
2158 -c "=> renegotiate" \
2159 -s "=> renegotiate" \
2160 -s "write hello request" \
2161 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2162
Hanno Becker6a243642017-10-12 15:18:45 +01002163requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002164run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002165 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002166 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002167 0 \
2168 -c "client hello, adding renegotiation extension" \
2169 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2170 -s "found renegotiation extension" \
2171 -s "server hello, secure renegotiation extension" \
2172 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002173 -c "=> renegotiate" \
2174 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002175 -s "write hello request"
2176
Hanno Becker6a243642017-10-12 15:18:45 +01002177requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002178run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002179 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002180 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002181 1 \
2182 -c "client hello, adding renegotiation extension" \
2183 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2184 -S "found renegotiation extension" \
2185 -s "server hello, secure renegotiation extension" \
2186 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002187 -c "=> renegotiate" \
2188 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002189 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002190 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002191 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002192
Hanno Becker6a243642017-10-12 15:18:45 +01002193requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002194run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002195 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 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é-Gonnard780d6712014-02-20 17:19:59 +01002197 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" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002203 -C "=> renegotiate" \
2204 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002205 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002206 -S "SSL - An unexpected message was received from our peer" \
2207 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002208
Hanno Becker6a243642017-10-12 15:18:45 +01002209requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002210run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002211 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002212 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002213 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002214 0 \
2215 -C "client hello, adding renegotiation extension" \
2216 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2217 -S "found renegotiation extension" \
2218 -s "server hello, secure renegotiation extension" \
2219 -c "found renegotiation extension" \
2220 -C "=> renegotiate" \
2221 -S "=> renegotiate" \
2222 -s "write hello request" \
2223 -S "SSL - An unexpected message was received from our peer" \
2224 -S "failed"
2225
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002226# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002227requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002228run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002229 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002230 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002231 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002232 0 \
2233 -C "client hello, adding renegotiation extension" \
2234 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2235 -S "found renegotiation extension" \
2236 -s "server hello, secure renegotiation extension" \
2237 -c "found renegotiation extension" \
2238 -C "=> renegotiate" \
2239 -S "=> renegotiate" \
2240 -s "write hello request" \
2241 -S "SSL - An unexpected message was received from our peer" \
2242 -S "failed"
2243
Hanno Becker6a243642017-10-12 15:18:45 +01002244requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002245run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002246 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002247 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002248 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002249 0 \
2250 -C "client hello, adding renegotiation extension" \
2251 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2252 -S "found renegotiation extension" \
2253 -s "server hello, secure renegotiation extension" \
2254 -c "found renegotiation extension" \
2255 -C "=> renegotiate" \
2256 -S "=> renegotiate" \
2257 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002258 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002259
Hanno Becker6a243642017-10-12 15:18:45 +01002260requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002261run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002262 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002263 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002264 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002265 0 \
2266 -c "client hello, adding renegotiation extension" \
2267 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2268 -s "found renegotiation extension" \
2269 -s "server hello, secure renegotiation extension" \
2270 -c "found renegotiation extension" \
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, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002279 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002280 "$P_CLI debug_level=3 exchanges=2 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
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002294# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002295requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002296run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002297 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002298 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002299 0 \
2300 -c "client hello, adding renegotiation extension" \
2301 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2302 -s "found renegotiation extension" \
2303 -s "server hello, secure renegotiation extension" \
2304 -c "found renegotiation extension" \
2305 -s "record counter limit reached: renegotiate" \
2306 -c "=> renegotiate" \
2307 -s "=> renegotiate" \
2308 -s "write hello request" \
2309 -S "SSL - An unexpected message was received from our peer" \
2310 -S "failed"
2311
Hanno Becker6a243642017-10-12 15:18:45 +01002312requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002313run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002314 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002315 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002316 0 \
2317 -c "client hello, adding renegotiation extension" \
2318 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2319 -s "found renegotiation extension" \
2320 -s "server hello, secure renegotiation extension" \
2321 -c "found renegotiation extension" \
2322 -s "record counter limit reached: renegotiate" \
2323 -c "=> renegotiate" \
2324 -s "=> renegotiate" \
2325 -s "write hello request" \
2326 -S "SSL - An unexpected message was received from our peer" \
2327 -S "failed"
2328
Hanno Becker6a243642017-10-12 15:18:45 +01002329requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002330run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002331 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002332 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2333 0 \
2334 -C "client hello, adding renegotiation extension" \
2335 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2336 -S "found renegotiation extension" \
2337 -s "server hello, secure renegotiation extension" \
2338 -c "found renegotiation extension" \
2339 -S "record counter limit reached: renegotiate" \
2340 -C "=> renegotiate" \
2341 -S "=> renegotiate" \
2342 -S "write hello request" \
2343 -S "SSL - An unexpected message was received from our peer" \
2344 -S "failed"
2345
Hanno Becker6a243642017-10-12 15:18:45 +01002346requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002347run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002348 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002349 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002350 0 \
2351 -c "client hello, adding renegotiation extension" \
2352 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2353 -s "found renegotiation extension" \
2354 -s "server hello, secure renegotiation extension" \
2355 -c "found renegotiation extension" \
2356 -c "=> renegotiate" \
2357 -s "=> renegotiate" \
2358 -S "write hello request"
2359
Hanno Becker6a243642017-10-12 15:18:45 +01002360requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002361run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002362 "$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 +02002363 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002364 0 \
2365 -c "client hello, adding renegotiation extension" \
2366 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2367 -s "found renegotiation extension" \
2368 -s "server hello, secure renegotiation extension" \
2369 -c "found renegotiation extension" \
2370 -c "=> renegotiate" \
2371 -s "=> renegotiate" \
2372 -s "write hello request"
2373
Hanno Becker6a243642017-10-12 15:18:45 +01002374requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002375run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002376 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002377 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002378 0 \
2379 -c "client hello, adding renegotiation extension" \
2380 -c "found renegotiation extension" \
2381 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002382 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002383 -C "error" \
2384 -c "HTTP/1.0 200 [Oo][Kk]"
2385
Paul Bakker539d9722015-02-08 16:18:35 +01002386requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002387requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002388run_test "Renegotiation: gnutls server strict, client-initiated" \
2389 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002390 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002391 0 \
2392 -c "client hello, adding renegotiation extension" \
2393 -c "found renegotiation extension" \
2394 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002395 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002396 -C "error" \
2397 -c "HTTP/1.0 200 [Oo][Kk]"
2398
Paul Bakker539d9722015-02-08 16:18:35 +01002399requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002400requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002401run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2402 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2403 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2404 1 \
2405 -c "client hello, adding renegotiation extension" \
2406 -C "found renegotiation extension" \
2407 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002408 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002409 -c "error" \
2410 -C "HTTP/1.0 200 [Oo][Kk]"
2411
Paul Bakker539d9722015-02-08 16:18:35 +01002412requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002413requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002414run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2415 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2416 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2417 allow_legacy=0" \
2418 1 \
2419 -c "client hello, adding renegotiation extension" \
2420 -C "found renegotiation extension" \
2421 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002422 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002423 -c "error" \
2424 -C "HTTP/1.0 200 [Oo][Kk]"
2425
Paul Bakker539d9722015-02-08 16:18:35 +01002426requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002427requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002428run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2429 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2430 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2431 allow_legacy=1" \
2432 0 \
2433 -c "client hello, adding renegotiation extension" \
2434 -C "found renegotiation extension" \
2435 -c "=> renegotiate" \
2436 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002437 -C "error" \
2438 -c "HTTP/1.0 200 [Oo][Kk]"
2439
Hanno Becker6a243642017-10-12 15:18:45 +01002440requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002441run_test "Renegotiation: DTLS, client-initiated" \
2442 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2443 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2444 0 \
2445 -c "client hello, adding renegotiation extension" \
2446 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2447 -s "found renegotiation extension" \
2448 -s "server hello, secure renegotiation extension" \
2449 -c "found renegotiation extension" \
2450 -c "=> renegotiate" \
2451 -s "=> renegotiate" \
2452 -S "write hello request"
2453
Hanno Becker6a243642017-10-12 15:18:45 +01002454requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002455run_test "Renegotiation: DTLS, server-initiated" \
2456 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002457 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2458 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002459 0 \
2460 -c "client hello, adding renegotiation extension" \
2461 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2462 -s "found renegotiation extension" \
2463 -s "server hello, secure renegotiation extension" \
2464 -c "found renegotiation extension" \
2465 -c "=> renegotiate" \
2466 -s "=> renegotiate" \
2467 -s "write hello request"
2468
Hanno Becker6a243642017-10-12 15:18:45 +01002469requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002470run_test "Renegotiation: DTLS, renego_period overflow" \
2471 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2472 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2473 0 \
2474 -c "client hello, adding renegotiation extension" \
2475 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2476 -s "found renegotiation extension" \
2477 -s "server hello, secure renegotiation extension" \
2478 -s "record counter limit reached: renegotiate" \
2479 -c "=> renegotiate" \
2480 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002481 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002482
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002483requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002484requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002485run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2486 "$G_SRV -u --mtu 4096" \
2487 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2488 0 \
2489 -c "client hello, adding renegotiation extension" \
2490 -c "found renegotiation extension" \
2491 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002492 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002493 -C "error" \
2494 -s "Extra-header:"
2495
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002496# Test for the "secure renegotation" extension only (no actual renegotiation)
2497
Paul Bakker539d9722015-02-08 16:18:35 +01002498requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002499run_test "Renego ext: gnutls server strict, client default" \
2500 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2501 "$P_CLI debug_level=3" \
2502 0 \
2503 -c "found renegotiation extension" \
2504 -C "error" \
2505 -c "HTTP/1.0 200 [Oo][Kk]"
2506
Paul Bakker539d9722015-02-08 16:18:35 +01002507requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002508run_test "Renego ext: gnutls server unsafe, client default" \
2509 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2510 "$P_CLI debug_level=3" \
2511 0 \
2512 -C "found renegotiation extension" \
2513 -C "error" \
2514 -c "HTTP/1.0 200 [Oo][Kk]"
2515
Paul Bakker539d9722015-02-08 16:18:35 +01002516requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002517run_test "Renego ext: gnutls server unsafe, client break legacy" \
2518 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2519 "$P_CLI debug_level=3 allow_legacy=-1" \
2520 1 \
2521 -C "found renegotiation extension" \
2522 -c "error" \
2523 -C "HTTP/1.0 200 [Oo][Kk]"
2524
Paul Bakker539d9722015-02-08 16:18:35 +01002525requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002526run_test "Renego ext: gnutls client strict, server default" \
2527 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002528 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002529 0 \
2530 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2531 -s "server hello, secure renegotiation extension"
2532
Paul Bakker539d9722015-02-08 16:18:35 +01002533requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002534run_test "Renego ext: gnutls client unsafe, server default" \
2535 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002536 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002537 0 \
2538 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2539 -S "server hello, secure renegotiation extension"
2540
Paul Bakker539d9722015-02-08 16:18:35 +01002541requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002542run_test "Renego ext: gnutls client unsafe, server break legacy" \
2543 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002544 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002545 1 \
2546 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2547 -S "server hello, secure renegotiation extension"
2548
Janos Follath0b242342016-02-17 10:11:21 +00002549# Tests for silently dropping trailing extra bytes in .der certificates
2550
2551requires_gnutls
2552run_test "DER format: no trailing bytes" \
2553 "$P_SRV crt_file=data_files/server5-der0.crt \
2554 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002555 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002556 0 \
2557 -c "Handshake was completed" \
2558
2559requires_gnutls
2560run_test "DER format: with a trailing zero byte" \
2561 "$P_SRV crt_file=data_files/server5-der1a.crt \
2562 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002563 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002564 0 \
2565 -c "Handshake was completed" \
2566
2567requires_gnutls
2568run_test "DER format: with a trailing random byte" \
2569 "$P_SRV crt_file=data_files/server5-der1b.crt \
2570 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002571 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002572 0 \
2573 -c "Handshake was completed" \
2574
2575requires_gnutls
2576run_test "DER format: with 2 trailing random bytes" \
2577 "$P_SRV crt_file=data_files/server5-der2.crt \
2578 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002579 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002580 0 \
2581 -c "Handshake was completed" \
2582
2583requires_gnutls
2584run_test "DER format: with 4 trailing random bytes" \
2585 "$P_SRV crt_file=data_files/server5-der4.crt \
2586 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002587 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002588 0 \
2589 -c "Handshake was completed" \
2590
2591requires_gnutls
2592run_test "DER format: with 8 trailing random bytes" \
2593 "$P_SRV crt_file=data_files/server5-der8.crt \
2594 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002595 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002596 0 \
2597 -c "Handshake was completed" \
2598
2599requires_gnutls
2600run_test "DER format: with 9 trailing random bytes" \
2601 "$P_SRV crt_file=data_files/server5-der9.crt \
2602 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002603 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002604 0 \
2605 -c "Handshake was completed" \
2606
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002607# Tests for auth_mode
2608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002609run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002610 "$P_SRV crt_file=data_files/server5-badsign.crt \
2611 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002612 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002613 1 \
2614 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002615 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002616 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002617 -c "X509 - Certificate verification failed"
2618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002619run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002620 "$P_SRV crt_file=data_files/server5-badsign.crt \
2621 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002622 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002623 0 \
2624 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002625 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002626 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002627 -C "X509 - Certificate verification failed"
2628
Hanno Beckere6706e62017-05-15 16:05:15 +01002629run_test "Authentication: server goodcert, client optional, no trusted CA" \
2630 "$P_SRV" \
2631 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2632 0 \
2633 -c "x509_verify_cert() returned" \
2634 -c "! The certificate is not correctly signed by the trusted CA" \
2635 -c "! Certificate verification flags"\
2636 -C "! mbedtls_ssl_handshake returned" \
2637 -C "X509 - Certificate verification failed" \
2638 -C "SSL - No CA Chain is set, but required to operate"
2639
2640run_test "Authentication: server goodcert, client required, no trusted CA" \
2641 "$P_SRV" \
2642 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2643 1 \
2644 -c "x509_verify_cert() returned" \
2645 -c "! The certificate is not correctly signed by the trusted CA" \
2646 -c "! Certificate verification flags"\
2647 -c "! mbedtls_ssl_handshake returned" \
2648 -c "SSL - No CA Chain is set, but required to operate"
2649
2650# The purpose of the next two tests is to test the client's behaviour when receiving a server
2651# certificate with an unsupported elliptic curve. This should usually not happen because
2652# the client informs the server about the supported curves - it does, though, in the
2653# corner case of a static ECDH suite, because the server doesn't check the curve on that
2654# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2655# different means to have the server ignoring the client's supported curve list.
2656
2657requires_config_enabled MBEDTLS_ECP_C
2658run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2659 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2660 crt_file=data_files/server5.ku-ka.crt" \
2661 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2662 1 \
2663 -c "bad certificate (EC key curve)"\
2664 -c "! Certificate verification flags"\
2665 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2666
2667requires_config_enabled MBEDTLS_ECP_C
2668run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2669 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2670 crt_file=data_files/server5.ku-ka.crt" \
2671 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2672 1 \
2673 -c "bad certificate (EC key curve)"\
2674 -c "! Certificate verification flags"\
2675 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002677run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002678 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002679 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002680 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002681 0 \
2682 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002683 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002684 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002685 -C "X509 - Certificate verification failed"
2686
Simon Butcher99000142016-10-13 17:21:01 +01002687run_test "Authentication: client SHA256, server required" \
2688 "$P_SRV auth_mode=required" \
2689 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2690 key_file=data_files/server6.key \
2691 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2692 0 \
2693 -c "Supported Signature Algorithm found: 4," \
2694 -c "Supported Signature Algorithm found: 5,"
2695
2696run_test "Authentication: client SHA384, server required" \
2697 "$P_SRV auth_mode=required" \
2698 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2699 key_file=data_files/server6.key \
2700 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2701 0 \
2702 -c "Supported Signature Algorithm found: 4," \
2703 -c "Supported Signature Algorithm found: 5,"
2704
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002705requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2706run_test "Authentication: client has no cert, server required (SSLv3)" \
2707 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2708 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
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 "got no certificate to send" \
2715 -S "x509_verify_cert() returned" \
2716 -s "client has no certificate" \
2717 -s "! mbedtls_ssl_handshake returned" \
2718 -c "! mbedtls_ssl_handshake returned" \
2719 -s "No client certification received from the client, but required by the authentication mode"
2720
2721run_test "Authentication: client has no cert, server required (TLS)" \
2722 "$P_SRV debug_level=3 auth_mode=required" \
2723 "$P_CLI debug_level=3 crt_file=none \
2724 key_file=data_files/server5.key" \
2725 1 \
2726 -S "skip write certificate request" \
2727 -C "skip parse certificate request" \
2728 -c "got a certificate request" \
2729 -c "= write certificate$" \
2730 -C "skip write certificate$" \
2731 -S "x509_verify_cert() returned" \
2732 -s "client has no certificate" \
2733 -s "! mbedtls_ssl_handshake returned" \
2734 -c "! mbedtls_ssl_handshake returned" \
2735 -s "No client certification received from the client, but required by the authentication mode"
2736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002737run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002738 "$P_SRV debug_level=3 auth_mode=required" \
2739 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002740 key_file=data_files/server5.key" \
2741 1 \
2742 -S "skip write certificate request" \
2743 -C "skip parse certificate request" \
2744 -c "got a certificate request" \
2745 -C "skip write certificate" \
2746 -C "skip write certificate verify" \
2747 -S "skip parse certificate verify" \
2748 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002749 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002750 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002751 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002752 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002753 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002754# We don't check that the client receives the alert because it might
2755# detect that its write end of the connection is closed and abort
2756# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002757
Janos Follath89baba22017-04-10 14:34:35 +01002758run_test "Authentication: client cert not trusted, server required" \
2759 "$P_SRV debug_level=3 auth_mode=required" \
2760 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2761 key_file=data_files/server5.key" \
2762 1 \
2763 -S "skip write certificate request" \
2764 -C "skip parse certificate request" \
2765 -c "got a certificate request" \
2766 -C "skip write certificate" \
2767 -C "skip write certificate verify" \
2768 -S "skip parse certificate verify" \
2769 -s "x509_verify_cert() returned" \
2770 -s "! The certificate is not correctly signed by the trusted CA" \
2771 -s "! mbedtls_ssl_handshake returned" \
2772 -c "! mbedtls_ssl_handshake returned" \
2773 -s "X509 - Certificate verification failed"
2774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002775run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002776 "$P_SRV debug_level=3 auth_mode=optional" \
2777 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002778 key_file=data_files/server5.key" \
2779 0 \
2780 -S "skip write certificate request" \
2781 -C "skip parse certificate request" \
2782 -c "got a certificate request" \
2783 -C "skip write certificate" \
2784 -C "skip write certificate verify" \
2785 -S "skip parse certificate verify" \
2786 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002787 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002788 -S "! mbedtls_ssl_handshake returned" \
2789 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002790 -S "X509 - Certificate verification failed"
2791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002792run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002793 "$P_SRV debug_level=3 auth_mode=none" \
2794 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002795 key_file=data_files/server5.key" \
2796 0 \
2797 -s "skip write certificate request" \
2798 -C "skip parse certificate request" \
2799 -c "got no certificate request" \
2800 -c "skip write certificate" \
2801 -c "skip write certificate verify" \
2802 -s "skip parse certificate verify" \
2803 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002804 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002805 -S "! mbedtls_ssl_handshake returned" \
2806 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002807 -S "X509 - Certificate verification failed"
2808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002809run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002810 "$P_SRV debug_level=3 auth_mode=optional" \
2811 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002812 0 \
2813 -S "skip write certificate request" \
2814 -C "skip parse certificate request" \
2815 -c "got a certificate request" \
2816 -C "skip write certificate$" \
2817 -C "got no certificate to send" \
2818 -S "SSLv3 client has no certificate" \
2819 -c "skip write certificate verify" \
2820 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002821 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002822 -S "! mbedtls_ssl_handshake returned" \
2823 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002824 -S "X509 - Certificate verification failed"
2825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002826run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002827 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002828 "$O_CLI" \
2829 0 \
2830 -S "skip write certificate request" \
2831 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002832 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002833 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002834 -S "X509 - Certificate verification failed"
2835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002836run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002837 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002838 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002839 0 \
2840 -C "skip parse certificate request" \
2841 -c "got a certificate request" \
2842 -C "skip write certificate$" \
2843 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002844 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002845
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002846run_test "Authentication: client no cert, openssl server required" \
2847 "$O_SRV -Verify 10" \
2848 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2849 1 \
2850 -C "skip parse certificate request" \
2851 -c "got a certificate request" \
2852 -C "skip write certificate$" \
2853 -c "skip write certificate verify" \
2854 -c "! mbedtls_ssl_handshake returned"
2855
Janos Follathe2681a42016-03-07 15:57:05 +00002856requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002857run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002858 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002859 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002860 0 \
2861 -S "skip write certificate request" \
2862 -C "skip parse certificate request" \
2863 -c "got a certificate request" \
2864 -C "skip write certificate$" \
2865 -c "skip write certificate verify" \
2866 -c "got no certificate to send" \
2867 -s "SSLv3 client has no certificate" \
2868 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002869 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002870 -S "! mbedtls_ssl_handshake returned" \
2871 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002872 -S "X509 - Certificate verification failed"
2873
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002874# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2875# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002876
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002877MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002878MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002879
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002880if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002881 cat <<EOF
2882${CONFIG_H} contains a value for the configuration of
2883MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script's
2884test value of ${MAX_IM_CA}.
Simon Butcher06b78632017-07-28 01:00:17 +01002885
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002886The tests assume this value and if it changes, the tests in this
2887script should also be adjusted.
2888EOF
Simon Butcher06b78632017-07-28 01:00:17 +01002889 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002890fi
2891
Angus Grattonc4dd0732018-04-11 16:28:39 +10002892requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002893run_test "Authentication: server max_int chain, client default" \
2894 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2895 key_file=data_files/dir-maxpath/09.key" \
2896 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2897 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002898 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002899
Angus Grattonc4dd0732018-04-11 16:28:39 +10002900requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002901run_test "Authentication: server max_int+1 chain, client default" \
2902 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2903 key_file=data_files/dir-maxpath/10.key" \
2904 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2905 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002906 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002907
Angus Grattonc4dd0732018-04-11 16:28:39 +10002908requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002909run_test "Authentication: server max_int+1 chain, client optional" \
2910 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2911 key_file=data_files/dir-maxpath/10.key" \
2912 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2913 auth_mode=optional" \
2914 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002915 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002916
Angus Grattonc4dd0732018-04-11 16:28:39 +10002917requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002918run_test "Authentication: server max_int+1 chain, client none" \
2919 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2920 key_file=data_files/dir-maxpath/10.key" \
2921 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2922 auth_mode=none" \
2923 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002924 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002925
Angus Grattonc4dd0732018-04-11 16:28:39 +10002926requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002927run_test "Authentication: client max_int+1 chain, server default" \
2928 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2929 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2930 key_file=data_files/dir-maxpath/10.key" \
2931 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002932 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002933
Angus Grattonc4dd0732018-04-11 16:28:39 +10002934requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002935run_test "Authentication: client max_int+1 chain, server optional" \
2936 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2937 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2938 key_file=data_files/dir-maxpath/10.key" \
2939 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002940 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002941
Angus Grattonc4dd0732018-04-11 16:28:39 +10002942requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002943run_test "Authentication: client max_int+1 chain, server required" \
2944 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2945 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2946 key_file=data_files/dir-maxpath/10.key" \
2947 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002948 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002949
Angus Grattonc4dd0732018-04-11 16:28:39 +10002950requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002951run_test "Authentication: client max_int chain, server required" \
2952 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2953 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2954 key_file=data_files/dir-maxpath/09.key" \
2955 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002956 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002957
Janos Follath89baba22017-04-10 14:34:35 +01002958# Tests for CA list in CertificateRequest messages
2959
2960run_test "Authentication: send CA list in CertificateRequest (default)" \
2961 "$P_SRV debug_level=3 auth_mode=required" \
2962 "$P_CLI crt_file=data_files/server6.crt \
2963 key_file=data_files/server6.key" \
2964 0 \
2965 -s "requested DN"
2966
2967run_test "Authentication: do not send CA list in CertificateRequest" \
2968 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2969 "$P_CLI crt_file=data_files/server6.crt \
2970 key_file=data_files/server6.key" \
2971 0 \
2972 -S "requested DN"
2973
2974run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2975 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2976 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2977 key_file=data_files/server5.key" \
2978 1 \
2979 -S "requested DN" \
2980 -s "x509_verify_cert() returned" \
2981 -s "! The certificate is not correctly signed by the trusted CA" \
2982 -s "! mbedtls_ssl_handshake returned" \
2983 -c "! mbedtls_ssl_handshake returned" \
2984 -s "X509 - Certificate verification failed"
2985
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002986# Tests for certificate selection based on SHA verson
2987
2988run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2989 "$P_SRV crt_file=data_files/server5.crt \
2990 key_file=data_files/server5.key \
2991 crt_file2=data_files/server5-sha1.crt \
2992 key_file2=data_files/server5.key" \
2993 "$P_CLI force_version=tls1_2" \
2994 0 \
2995 -c "signed using.*ECDSA with SHA256" \
2996 -C "signed using.*ECDSA with SHA1"
2997
2998run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2999 "$P_SRV crt_file=data_files/server5.crt \
3000 key_file=data_files/server5.key \
3001 crt_file2=data_files/server5-sha1.crt \
3002 key_file2=data_files/server5.key" \
3003 "$P_CLI force_version=tls1_1" \
3004 0 \
3005 -C "signed using.*ECDSA with SHA256" \
3006 -c "signed using.*ECDSA with SHA1"
3007
3008run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
3009 "$P_SRV crt_file=data_files/server5.crt \
3010 key_file=data_files/server5.key \
3011 crt_file2=data_files/server5-sha1.crt \
3012 key_file2=data_files/server5.key" \
3013 "$P_CLI force_version=tls1" \
3014 0 \
3015 -C "signed using.*ECDSA with SHA256" \
3016 -c "signed using.*ECDSA with SHA1"
3017
3018run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
3019 "$P_SRV crt_file=data_files/server5.crt \
3020 key_file=data_files/server5.key \
3021 crt_file2=data_files/server6.crt \
3022 key_file2=data_files/server6.key" \
3023 "$P_CLI force_version=tls1_1" \
3024 0 \
3025 -c "serial number.*09" \
3026 -c "signed using.*ECDSA with SHA256" \
3027 -C "signed using.*ECDSA with SHA1"
3028
3029run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
3030 "$P_SRV crt_file=data_files/server6.crt \
3031 key_file=data_files/server6.key \
3032 crt_file2=data_files/server5.crt \
3033 key_file2=data_files/server5.key" \
3034 "$P_CLI force_version=tls1_1" \
3035 0 \
3036 -c "serial number.*0A" \
3037 -c "signed using.*ECDSA with SHA256" \
3038 -C "signed using.*ECDSA with SHA1"
3039
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003040# tests for SNI
3041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003042run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003043 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003044 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003045 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003046 0 \
3047 -S "parse ServerName extension" \
3048 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3049 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003051run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003052 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003053 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003054 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 +02003055 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003056 0 \
3057 -s "parse ServerName extension" \
3058 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3059 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003061run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003062 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003063 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003064 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 +02003065 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003066 0 \
3067 -s "parse ServerName extension" \
3068 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3069 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003071run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003072 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003073 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003074 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 +02003075 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003076 1 \
3077 -s "parse ServerName extension" \
3078 -s "ssl_sni_wrapper() returned" \
3079 -s "mbedtls_ssl_handshake returned" \
3080 -c "mbedtls_ssl_handshake returned" \
3081 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003082
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003083run_test "SNI: client auth no override: optional" \
3084 "$P_SRV debug_level=3 auth_mode=optional \
3085 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3086 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3087 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003088 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003089 -S "skip write certificate request" \
3090 -C "skip parse certificate request" \
3091 -c "got a certificate request" \
3092 -C "skip write certificate" \
3093 -C "skip write certificate verify" \
3094 -S "skip parse certificate verify"
3095
3096run_test "SNI: client auth override: none -> optional" \
3097 "$P_SRV debug_level=3 auth_mode=none \
3098 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3099 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3100 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003101 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003102 -S "skip write certificate request" \
3103 -C "skip parse certificate request" \
3104 -c "got a certificate request" \
3105 -C "skip write certificate" \
3106 -C "skip write certificate verify" \
3107 -S "skip parse certificate verify"
3108
3109run_test "SNI: client auth override: optional -> none" \
3110 "$P_SRV debug_level=3 auth_mode=optional \
3111 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3112 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3113 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003114 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003115 -s "skip write certificate request" \
3116 -C "skip parse certificate request" \
3117 -c "got no certificate request" \
3118 -c "skip write certificate" \
3119 -c "skip write certificate verify" \
3120 -s "skip parse certificate verify"
3121
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003122run_test "SNI: CA no override" \
3123 "$P_SRV debug_level=3 auth_mode=optional \
3124 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3125 ca_file=data_files/test-ca.crt \
3126 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3127 "$P_CLI debug_level=3 server_name=localhost \
3128 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3129 1 \
3130 -S "skip write certificate request" \
3131 -C "skip parse certificate request" \
3132 -c "got a certificate request" \
3133 -C "skip write certificate" \
3134 -C "skip write certificate verify" \
3135 -S "skip parse certificate verify" \
3136 -s "x509_verify_cert() returned" \
3137 -s "! The certificate is not correctly signed by the trusted CA" \
3138 -S "The certificate has been revoked (is on a CRL)"
3139
3140run_test "SNI: CA override" \
3141 "$P_SRV debug_level=3 auth_mode=optional \
3142 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3143 ca_file=data_files/test-ca.crt \
3144 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3145 "$P_CLI debug_level=3 server_name=localhost \
3146 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3147 0 \
3148 -S "skip write certificate request" \
3149 -C "skip parse certificate request" \
3150 -c "got a certificate request" \
3151 -C "skip write certificate" \
3152 -C "skip write certificate verify" \
3153 -S "skip parse certificate verify" \
3154 -S "x509_verify_cert() returned" \
3155 -S "! The certificate is not correctly signed by the trusted CA" \
3156 -S "The certificate has been revoked (is on a CRL)"
3157
3158run_test "SNI: CA override with CRL" \
3159 "$P_SRV debug_level=3 auth_mode=optional \
3160 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3161 ca_file=data_files/test-ca.crt \
3162 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3163 "$P_CLI debug_level=3 server_name=localhost \
3164 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3165 1 \
3166 -S "skip write certificate request" \
3167 -C "skip parse certificate request" \
3168 -c "got a certificate request" \
3169 -C "skip write certificate" \
3170 -C "skip write certificate verify" \
3171 -S "skip parse certificate verify" \
3172 -s "x509_verify_cert() returned" \
3173 -S "! The certificate is not correctly signed by the trusted CA" \
3174 -s "The certificate has been revoked (is on a CRL)"
3175
Andres AG1a834452016-12-07 10:01:30 +00003176# Tests for SNI and DTLS
3177
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003178run_test "SNI: DTLS, no SNI callback" \
3179 "$P_SRV debug_level=3 dtls=1 \
3180 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3181 "$P_CLI server_name=localhost dtls=1" \
3182 0 \
3183 -S "parse ServerName extension" \
3184 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3185 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3186
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003187run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003188 "$P_SRV debug_level=3 dtls=1 \
3189 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3190 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3191 "$P_CLI server_name=localhost dtls=1" \
3192 0 \
3193 -s "parse ServerName extension" \
3194 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3195 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3196
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003197run_test "SNI: DTLS, matching cert 2" \
3198 "$P_SRV debug_level=3 dtls=1 \
3199 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3200 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3201 "$P_CLI server_name=polarssl.example dtls=1" \
3202 0 \
3203 -s "parse ServerName extension" \
3204 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3205 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3206
3207run_test "SNI: DTLS, no matching cert" \
3208 "$P_SRV debug_level=3 dtls=1 \
3209 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3210 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3211 "$P_CLI server_name=nonesuch.example dtls=1" \
3212 1 \
3213 -s "parse ServerName extension" \
3214 -s "ssl_sni_wrapper() returned" \
3215 -s "mbedtls_ssl_handshake returned" \
3216 -c "mbedtls_ssl_handshake returned" \
3217 -c "SSL - A fatal alert message was received from our peer"
3218
3219run_test "SNI: DTLS, client auth no override: optional" \
3220 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3221 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3222 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3223 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3224 0 \
3225 -S "skip write certificate request" \
3226 -C "skip parse certificate request" \
3227 -c "got a certificate request" \
3228 -C "skip write certificate" \
3229 -C "skip write certificate verify" \
3230 -S "skip parse certificate verify"
3231
3232run_test "SNI: DTLS, client auth override: none -> optional" \
3233 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3234 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3235 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3236 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3237 0 \
3238 -S "skip write certificate request" \
3239 -C "skip parse certificate request" \
3240 -c "got a certificate request" \
3241 -C "skip write certificate" \
3242 -C "skip write certificate verify" \
3243 -S "skip parse certificate verify"
3244
3245run_test "SNI: DTLS, client auth override: optional -> none" \
3246 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3247 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3248 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3249 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3250 0 \
3251 -s "skip write certificate request" \
3252 -C "skip parse certificate request" \
3253 -c "got no certificate request" \
3254 -c "skip write certificate" \
3255 -c "skip write certificate verify" \
3256 -s "skip parse certificate verify"
3257
3258run_test "SNI: DTLS, CA no override" \
3259 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3260 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3261 ca_file=data_files/test-ca.crt \
3262 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3263 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3264 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3265 1 \
3266 -S "skip write certificate request" \
3267 -C "skip parse certificate request" \
3268 -c "got a certificate request" \
3269 -C "skip write certificate" \
3270 -C "skip write certificate verify" \
3271 -S "skip parse certificate verify" \
3272 -s "x509_verify_cert() returned" \
3273 -s "! The certificate is not correctly signed by the trusted CA" \
3274 -S "The certificate has been revoked (is on a CRL)"
3275
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003276run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003277 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3278 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3279 ca_file=data_files/test-ca.crt \
3280 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3281 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3282 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3283 0 \
3284 -S "skip write certificate request" \
3285 -C "skip parse certificate request" \
3286 -c "got a certificate request" \
3287 -C "skip write certificate" \
3288 -C "skip write certificate verify" \
3289 -S "skip parse certificate verify" \
3290 -S "x509_verify_cert() returned" \
3291 -S "! The certificate is not correctly signed by the trusted CA" \
3292 -S "The certificate has been revoked (is on a CRL)"
3293
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003294run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003295 "$P_SRV debug_level=3 auth_mode=optional \
3296 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3297 ca_file=data_files/test-ca.crt \
3298 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3299 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3300 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3301 1 \
3302 -S "skip write certificate request" \
3303 -C "skip parse certificate request" \
3304 -c "got a certificate request" \
3305 -C "skip write certificate" \
3306 -C "skip write certificate verify" \
3307 -S "skip parse certificate verify" \
3308 -s "x509_verify_cert() returned" \
3309 -S "! The certificate is not correctly signed by the trusted CA" \
3310 -s "The certificate has been revoked (is on a CRL)"
3311
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003312# Tests for non-blocking I/O: exercise a variety of handshake flows
3313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003314run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003315 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3316 "$P_CLI nbio=2 tickets=0" \
3317 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003318 -S "mbedtls_ssl_handshake returned" \
3319 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003320 -c "Read from server: .* bytes read"
3321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003322run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003323 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3324 "$P_CLI nbio=2 tickets=0" \
3325 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003326 -S "mbedtls_ssl_handshake returned" \
3327 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003328 -c "Read from server: .* bytes read"
3329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003330run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003331 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3332 "$P_CLI nbio=2 tickets=1" \
3333 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003334 -S "mbedtls_ssl_handshake returned" \
3335 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003336 -c "Read from server: .* bytes read"
3337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003338run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003339 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3340 "$P_CLI nbio=2 tickets=1" \
3341 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003342 -S "mbedtls_ssl_handshake returned" \
3343 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003344 -c "Read from server: .* bytes read"
3345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003346run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003347 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3348 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3349 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003350 -S "mbedtls_ssl_handshake returned" \
3351 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003352 -c "Read from server: .* bytes read"
3353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003354run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003355 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3356 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3357 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003358 -S "mbedtls_ssl_handshake returned" \
3359 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003360 -c "Read from server: .* bytes read"
3361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003362run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003363 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3364 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3365 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003366 -S "mbedtls_ssl_handshake returned" \
3367 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003368 -c "Read from server: .* bytes read"
3369
Hanno Becker00076712017-11-15 16:39:08 +00003370# Tests for event-driven I/O: exercise a variety of handshake flows
3371
3372run_test "Event-driven I/O: basic handshake" \
3373 "$P_SRV event=1 tickets=0 auth_mode=none" \
3374 "$P_CLI event=1 tickets=0" \
3375 0 \
3376 -S "mbedtls_ssl_handshake returned" \
3377 -C "mbedtls_ssl_handshake returned" \
3378 -c "Read from server: .* bytes read"
3379
3380run_test "Event-driven I/O: client auth" \
3381 "$P_SRV event=1 tickets=0 auth_mode=required" \
3382 "$P_CLI event=1 tickets=0" \
3383 0 \
3384 -S "mbedtls_ssl_handshake returned" \
3385 -C "mbedtls_ssl_handshake returned" \
3386 -c "Read from server: .* bytes read"
3387
3388run_test "Event-driven I/O: ticket" \
3389 "$P_SRV event=1 tickets=1 auth_mode=none" \
3390 "$P_CLI event=1 tickets=1" \
3391 0 \
3392 -S "mbedtls_ssl_handshake returned" \
3393 -C "mbedtls_ssl_handshake returned" \
3394 -c "Read from server: .* bytes read"
3395
3396run_test "Event-driven I/O: ticket + client auth" \
3397 "$P_SRV event=1 tickets=1 auth_mode=required" \
3398 "$P_CLI event=1 tickets=1" \
3399 0 \
3400 -S "mbedtls_ssl_handshake returned" \
3401 -C "mbedtls_ssl_handshake returned" \
3402 -c "Read from server: .* bytes read"
3403
3404run_test "Event-driven I/O: ticket + client auth + resume" \
3405 "$P_SRV event=1 tickets=1 auth_mode=required" \
3406 "$P_CLI event=1 tickets=1 reconnect=1" \
3407 0 \
3408 -S "mbedtls_ssl_handshake returned" \
3409 -C "mbedtls_ssl_handshake returned" \
3410 -c "Read from server: .* bytes read"
3411
3412run_test "Event-driven I/O: ticket + resume" \
3413 "$P_SRV event=1 tickets=1 auth_mode=none" \
3414 "$P_CLI event=1 tickets=1 reconnect=1" \
3415 0 \
3416 -S "mbedtls_ssl_handshake returned" \
3417 -C "mbedtls_ssl_handshake returned" \
3418 -c "Read from server: .* bytes read"
3419
3420run_test "Event-driven I/O: session-id resume" \
3421 "$P_SRV event=1 tickets=0 auth_mode=none" \
3422 "$P_CLI event=1 tickets=0 reconnect=1" \
3423 0 \
3424 -S "mbedtls_ssl_handshake returned" \
3425 -C "mbedtls_ssl_handshake returned" \
3426 -c "Read from server: .* bytes read"
3427
Hanno Becker6a33f592018-03-13 11:38:46 +00003428run_test "Event-driven I/O, DTLS: basic handshake" \
3429 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3430 "$P_CLI dtls=1 event=1 tickets=0" \
3431 0 \
3432 -c "Read from server: .* bytes read"
3433
3434run_test "Event-driven I/O, DTLS: client auth" \
3435 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3436 "$P_CLI dtls=1 event=1 tickets=0" \
3437 0 \
3438 -c "Read from server: .* bytes read"
3439
3440run_test "Event-driven I/O, DTLS: ticket" \
3441 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3442 "$P_CLI dtls=1 event=1 tickets=1" \
3443 0 \
3444 -c "Read from server: .* bytes read"
3445
3446run_test "Event-driven I/O, DTLS: ticket + client auth" \
3447 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3448 "$P_CLI dtls=1 event=1 tickets=1" \
3449 0 \
3450 -c "Read from server: .* bytes read"
3451
3452run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3453 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003454 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003455 0 \
3456 -c "Read from server: .* bytes read"
3457
3458run_test "Event-driven I/O, DTLS: ticket + resume" \
3459 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003460 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003461 0 \
3462 -c "Read from server: .* bytes read"
3463
3464run_test "Event-driven I/O, DTLS: session-id resume" \
3465 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003466 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003467 0 \
3468 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003469
3470# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3471# During session resumption, the client will send its ApplicationData record
3472# within the same datagram as the Finished messages. In this situation, the
3473# server MUST NOT idle on the underlying transport after handshake completion,
3474# because the ApplicationData request has already been queued internally.
3475run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003476 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003477 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003478 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003479 0 \
3480 -c "Read from server: .* bytes read"
3481
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003482# Tests for version negotiation
3483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003484run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003485 "$P_SRV" \
3486 "$P_CLI" \
3487 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003488 -S "mbedtls_ssl_handshake returned" \
3489 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003490 -s "Protocol is TLSv1.2" \
3491 -c "Protocol is TLSv1.2"
3492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003493run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003494 "$P_SRV" \
3495 "$P_CLI max_version=tls1_1" \
3496 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003497 -S "mbedtls_ssl_handshake returned" \
3498 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003499 -s "Protocol is TLSv1.1" \
3500 -c "Protocol is TLSv1.1"
3501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003502run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003503 "$P_SRV max_version=tls1_1" \
3504 "$P_CLI" \
3505 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003506 -S "mbedtls_ssl_handshake returned" \
3507 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003508 -s "Protocol is TLSv1.1" \
3509 -c "Protocol is TLSv1.1"
3510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003511run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003512 "$P_SRV max_version=tls1_1" \
3513 "$P_CLI max_version=tls1_1" \
3514 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003515 -S "mbedtls_ssl_handshake returned" \
3516 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003517 -s "Protocol is TLSv1.1" \
3518 -c "Protocol is TLSv1.1"
3519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003520run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003521 "$P_SRV min_version=tls1_1" \
3522 "$P_CLI max_version=tls1_1" \
3523 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003524 -S "mbedtls_ssl_handshake returned" \
3525 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003526 -s "Protocol is TLSv1.1" \
3527 -c "Protocol is TLSv1.1"
3528
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003529run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003530 "$P_SRV max_version=tls1_1" \
3531 "$P_CLI min_version=tls1_1" \
3532 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003533 -S "mbedtls_ssl_handshake returned" \
3534 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003535 -s "Protocol is TLSv1.1" \
3536 -c "Protocol is TLSv1.1"
3537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003538run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003539 "$P_SRV max_version=tls1_1" \
3540 "$P_CLI min_version=tls1_2" \
3541 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003542 -s "mbedtls_ssl_handshake returned" \
3543 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003544 -c "SSL - Handshake protocol not within min/max boundaries"
3545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003546run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003547 "$P_SRV min_version=tls1_2" \
3548 "$P_CLI max_version=tls1_1" \
3549 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003550 -s "mbedtls_ssl_handshake returned" \
3551 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003552 -s "SSL - Handshake protocol not within min/max boundaries"
3553
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003554# Tests for ALPN extension
3555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003556run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003557 "$P_SRV debug_level=3" \
3558 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003559 0 \
3560 -C "client hello, adding alpn extension" \
3561 -S "found alpn extension" \
3562 -C "got an alert message, type: \\[2:120]" \
3563 -S "server hello, adding alpn extension" \
3564 -C "found alpn extension " \
3565 -C "Application Layer Protocol is" \
3566 -S "Application Layer Protocol is"
3567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003568run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003569 "$P_SRV debug_level=3" \
3570 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003571 0 \
3572 -c "client hello, adding alpn extension" \
3573 -s "found alpn extension" \
3574 -C "got an alert message, type: \\[2:120]" \
3575 -S "server hello, adding alpn extension" \
3576 -C "found alpn extension " \
3577 -c "Application Layer Protocol is (none)" \
3578 -S "Application Layer Protocol is"
3579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003580run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003581 "$P_SRV debug_level=3 alpn=abc,1234" \
3582 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003583 0 \
3584 -C "client hello, adding alpn extension" \
3585 -S "found alpn extension" \
3586 -C "got an alert message, type: \\[2:120]" \
3587 -S "server hello, adding alpn extension" \
3588 -C "found alpn extension " \
3589 -C "Application Layer Protocol is" \
3590 -s "Application Layer Protocol is (none)"
3591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003592run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003593 "$P_SRV debug_level=3 alpn=abc,1234" \
3594 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003595 0 \
3596 -c "client hello, adding alpn extension" \
3597 -s "found alpn extension" \
3598 -C "got an alert message, type: \\[2:120]" \
3599 -s "server hello, adding alpn extension" \
3600 -c "found alpn extension" \
3601 -c "Application Layer Protocol is abc" \
3602 -s "Application Layer Protocol is abc"
3603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003604run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003605 "$P_SRV debug_level=3 alpn=abc,1234" \
3606 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003607 0 \
3608 -c "client hello, adding alpn extension" \
3609 -s "found alpn extension" \
3610 -C "got an alert message, type: \\[2:120]" \
3611 -s "server hello, adding alpn extension" \
3612 -c "found alpn extension" \
3613 -c "Application Layer Protocol is abc" \
3614 -s "Application Layer Protocol is abc"
3615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003616run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003617 "$P_SRV debug_level=3 alpn=abc,1234" \
3618 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003619 0 \
3620 -c "client hello, adding alpn extension" \
3621 -s "found alpn extension" \
3622 -C "got an alert message, type: \\[2:120]" \
3623 -s "server hello, adding alpn extension" \
3624 -c "found alpn extension" \
3625 -c "Application Layer Protocol is 1234" \
3626 -s "Application Layer Protocol is 1234"
3627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003628run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003629 "$P_SRV debug_level=3 alpn=abc,123" \
3630 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003631 1 \
3632 -c "client hello, adding alpn extension" \
3633 -s "found alpn extension" \
3634 -c "got an alert message, type: \\[2:120]" \
3635 -S "server hello, adding alpn extension" \
3636 -C "found alpn extension" \
3637 -C "Application Layer Protocol is 1234" \
3638 -S "Application Layer Protocol is 1234"
3639
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003640
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003641# Tests for keyUsage in leaf certificates, part 1:
3642# server-side certificate/suite selection
3643
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003644run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003645 "$P_SRV key_file=data_files/server2.key \
3646 crt_file=data_files/server2.ku-ds.crt" \
3647 "$P_CLI" \
3648 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003649 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003650
3651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003652run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003653 "$P_SRV key_file=data_files/server2.key \
3654 crt_file=data_files/server2.ku-ke.crt" \
3655 "$P_CLI" \
3656 0 \
3657 -c "Ciphersuite is TLS-RSA-WITH-"
3658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003659run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003660 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003661 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003662 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003663 1 \
3664 -C "Ciphersuite is "
3665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003666run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003667 "$P_SRV key_file=data_files/server5.key \
3668 crt_file=data_files/server5.ku-ds.crt" \
3669 "$P_CLI" \
3670 0 \
3671 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3672
3673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003674run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003675 "$P_SRV key_file=data_files/server5.key \
3676 crt_file=data_files/server5.ku-ka.crt" \
3677 "$P_CLI" \
3678 0 \
3679 -c "Ciphersuite is TLS-ECDH-"
3680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003681run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003682 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003683 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003684 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003685 1 \
3686 -C "Ciphersuite is "
3687
3688# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003689# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003691run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003692 "$O_SRV -key data_files/server2.key \
3693 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003694 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003695 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3696 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003697 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003698 -C "Processing of the Certificate handshake message failed" \
3699 -c "Ciphersuite is TLS-"
3700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003701run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003702 "$O_SRV -key data_files/server2.key \
3703 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003704 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003705 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3706 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003707 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003708 -C "Processing of the Certificate handshake message failed" \
3709 -c "Ciphersuite is TLS-"
3710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003711run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003712 "$O_SRV -key data_files/server2.key \
3713 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003714 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003715 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3716 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003717 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003718 -C "Processing of the Certificate handshake message failed" \
3719 -c "Ciphersuite is TLS-"
3720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003721run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003722 "$O_SRV -key data_files/server2.key \
3723 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003724 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003725 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3726 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003727 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003728 -c "Processing of the Certificate handshake message failed" \
3729 -C "Ciphersuite is TLS-"
3730
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003731run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3732 "$O_SRV -key data_files/server2.key \
3733 -cert data_files/server2.ku-ke.crt" \
3734 "$P_CLI debug_level=1 auth_mode=optional \
3735 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3736 0 \
3737 -c "bad certificate (usage extensions)" \
3738 -C "Processing of the Certificate handshake message failed" \
3739 -c "Ciphersuite is TLS-" \
3740 -c "! Usage does not match the keyUsage extension"
3741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003742run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003743 "$O_SRV -key data_files/server2.key \
3744 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003745 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003746 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3747 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003748 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003749 -C "Processing of the Certificate handshake message failed" \
3750 -c "Ciphersuite is TLS-"
3751
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003752run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003753 "$O_SRV -key data_files/server2.key \
3754 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003755 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003756 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3757 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003758 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003759 -c "Processing of the Certificate handshake message failed" \
3760 -C "Ciphersuite is TLS-"
3761
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003762run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3763 "$O_SRV -key data_files/server2.key \
3764 -cert data_files/server2.ku-ds.crt" \
3765 "$P_CLI debug_level=1 auth_mode=optional \
3766 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3767 0 \
3768 -c "bad certificate (usage extensions)" \
3769 -C "Processing of the Certificate handshake message failed" \
3770 -c "Ciphersuite is TLS-" \
3771 -c "! Usage does not match the keyUsage extension"
3772
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003773# Tests for keyUsage in leaf certificates, part 3:
3774# server-side checking of client cert
3775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003776run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003777 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003778 "$O_CLI -key data_files/server2.key \
3779 -cert data_files/server2.ku-ds.crt" \
3780 0 \
3781 -S "bad certificate (usage extensions)" \
3782 -S "Processing of the Certificate handshake message failed"
3783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003784run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003785 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003786 "$O_CLI -key data_files/server2.key \
3787 -cert data_files/server2.ku-ke.crt" \
3788 0 \
3789 -s "bad certificate (usage extensions)" \
3790 -S "Processing of the Certificate handshake message failed"
3791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003792run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003793 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003794 "$O_CLI -key data_files/server2.key \
3795 -cert data_files/server2.ku-ke.crt" \
3796 1 \
3797 -s "bad certificate (usage extensions)" \
3798 -s "Processing of the Certificate handshake message failed"
3799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003800run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003801 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003802 "$O_CLI -key data_files/server5.key \
3803 -cert data_files/server5.ku-ds.crt" \
3804 0 \
3805 -S "bad certificate (usage extensions)" \
3806 -S "Processing of the Certificate handshake message failed"
3807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003808run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003809 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003810 "$O_CLI -key data_files/server5.key \
3811 -cert data_files/server5.ku-ka.crt" \
3812 0 \
3813 -s "bad certificate (usage extensions)" \
3814 -S "Processing of the Certificate handshake message failed"
3815
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003816# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003818run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003819 "$P_SRV key_file=data_files/server5.key \
3820 crt_file=data_files/server5.eku-srv.crt" \
3821 "$P_CLI" \
3822 0
3823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003824run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003825 "$P_SRV key_file=data_files/server5.key \
3826 crt_file=data_files/server5.eku-srv.crt" \
3827 "$P_CLI" \
3828 0
3829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003830run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003831 "$P_SRV key_file=data_files/server5.key \
3832 crt_file=data_files/server5.eku-cs_any.crt" \
3833 "$P_CLI" \
3834 0
3835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003836run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003837 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003838 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003839 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003840 1
3841
3842# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003844run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003845 "$O_SRV -key data_files/server5.key \
3846 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003847 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003848 0 \
3849 -C "bad certificate (usage extensions)" \
3850 -C "Processing of the Certificate handshake message failed" \
3851 -c "Ciphersuite is TLS-"
3852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003853run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003854 "$O_SRV -key data_files/server5.key \
3855 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003856 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003857 0 \
3858 -C "bad certificate (usage extensions)" \
3859 -C "Processing of the Certificate handshake message failed" \
3860 -c "Ciphersuite is TLS-"
3861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003862run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003863 "$O_SRV -key data_files/server5.key \
3864 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003865 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003866 0 \
3867 -C "bad certificate (usage extensions)" \
3868 -C "Processing of the Certificate handshake message failed" \
3869 -c "Ciphersuite is TLS-"
3870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003871run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003872 "$O_SRV -key data_files/server5.key \
3873 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003874 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003875 1 \
3876 -c "bad certificate (usage extensions)" \
3877 -c "Processing of the Certificate handshake message failed" \
3878 -C "Ciphersuite is TLS-"
3879
3880# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003882run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003883 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003884 "$O_CLI -key data_files/server5.key \
3885 -cert data_files/server5.eku-cli.crt" \
3886 0 \
3887 -S "bad certificate (usage extensions)" \
3888 -S "Processing of the Certificate handshake message failed"
3889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003890run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003891 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003892 "$O_CLI -key data_files/server5.key \
3893 -cert data_files/server5.eku-srv_cli.crt" \
3894 0 \
3895 -S "bad certificate (usage extensions)" \
3896 -S "Processing of the Certificate handshake message failed"
3897
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003898run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003899 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003900 "$O_CLI -key data_files/server5.key \
3901 -cert data_files/server5.eku-cs_any.crt" \
3902 0 \
3903 -S "bad certificate (usage extensions)" \
3904 -S "Processing of the Certificate handshake message failed"
3905
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003906run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003907 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003908 "$O_CLI -key data_files/server5.key \
3909 -cert data_files/server5.eku-cs.crt" \
3910 0 \
3911 -s "bad certificate (usage extensions)" \
3912 -S "Processing of the Certificate handshake message failed"
3913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003914run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003915 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003916 "$O_CLI -key data_files/server5.key \
3917 -cert data_files/server5.eku-cs.crt" \
3918 1 \
3919 -s "bad certificate (usage extensions)" \
3920 -s "Processing of the Certificate handshake message failed"
3921
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003922# Tests for DHM parameters loading
3923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003924run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003925 "$P_SRV" \
3926 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3927 debug_level=3" \
3928 0 \
3929 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003930 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003931
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003932run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003933 "$P_SRV dhm_file=data_files/dhparams.pem" \
3934 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3935 debug_level=3" \
3936 0 \
3937 -c "value of 'DHM: P ' (1024 bits)" \
3938 -c "value of 'DHM: G ' (2 bits)"
3939
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003940# Tests for DHM client-side size checking
3941
3942run_test "DHM size: server default, client default, OK" \
3943 "$P_SRV" \
3944 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3945 debug_level=1" \
3946 0 \
3947 -C "DHM prime too short:"
3948
3949run_test "DHM size: server default, client 2048, OK" \
3950 "$P_SRV" \
3951 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3952 debug_level=1 dhmlen=2048" \
3953 0 \
3954 -C "DHM prime too short:"
3955
3956run_test "DHM size: server 1024, client default, OK" \
3957 "$P_SRV dhm_file=data_files/dhparams.pem" \
3958 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3959 debug_level=1" \
3960 0 \
3961 -C "DHM prime too short:"
3962
3963run_test "DHM size: server 1000, client default, rejected" \
3964 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3965 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3966 debug_level=1" \
3967 1 \
3968 -c "DHM prime too short:"
3969
3970run_test "DHM size: server default, client 2049, rejected" \
3971 "$P_SRV" \
3972 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3973 debug_level=1 dhmlen=2049" \
3974 1 \
3975 -c "DHM prime too short:"
3976
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003977# Tests for PSK callback
3978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003979run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003980 "$P_SRV psk=abc123 psk_identity=foo" \
3981 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3982 psk_identity=foo psk=abc123" \
3983 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003984 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003985 -S "SSL - Unknown identity received" \
3986 -S "SSL - Verification of the message MAC failed"
3987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003988run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003989 "$P_SRV" \
3990 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3991 psk_identity=foo psk=abc123" \
3992 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003993 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003994 -S "SSL - Unknown identity received" \
3995 -S "SSL - Verification of the message MAC failed"
3996
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003997run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003998 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3999 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4000 psk_identity=foo psk=abc123" \
4001 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004002 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004003 -s "SSL - Unknown identity received" \
4004 -S "SSL - Verification of the message MAC failed"
4005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004006run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004007 "$P_SRV psk_list=abc,dead,def,beef" \
4008 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4009 psk_identity=abc psk=dead" \
4010 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004011 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004012 -S "SSL - Unknown identity received" \
4013 -S "SSL - Verification of the message MAC failed"
4014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004015run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004016 "$P_SRV psk_list=abc,dead,def,beef" \
4017 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4018 psk_identity=def psk=beef" \
4019 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004020 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004021 -S "SSL - Unknown identity received" \
4022 -S "SSL - Verification of the message MAC failed"
4023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004024run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004025 "$P_SRV psk_list=abc,dead,def,beef" \
4026 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4027 psk_identity=ghi psk=beef" \
4028 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004029 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004030 -s "SSL - Unknown identity received" \
4031 -S "SSL - Verification of the message MAC failed"
4032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004033run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004034 "$P_SRV psk_list=abc,dead,def,beef" \
4035 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4036 psk_identity=abc psk=beef" \
4037 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004038 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004039 -S "SSL - Unknown identity received" \
4040 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004041
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004042# Tests for EC J-PAKE
4043
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004044requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004045run_test "ECJPAKE: client not configured" \
4046 "$P_SRV debug_level=3" \
4047 "$P_CLI debug_level=3" \
4048 0 \
4049 -C "add ciphersuite: c0ff" \
4050 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004051 -S "found ecjpake kkpp extension" \
4052 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004053 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004054 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004055 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004056 -S "None of the common ciphersuites is usable"
4057
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004058requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004059run_test "ECJPAKE: server not configured" \
4060 "$P_SRV debug_level=3" \
4061 "$P_CLI debug_level=3 ecjpake_pw=bla \
4062 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4063 1 \
4064 -c "add ciphersuite: c0ff" \
4065 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004066 -s "found ecjpake kkpp extension" \
4067 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004068 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004069 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004070 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004071 -s "None of the common ciphersuites is usable"
4072
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004073requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004074run_test "ECJPAKE: working, TLS" \
4075 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4076 "$P_CLI debug_level=3 ecjpake_pw=bla \
4077 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004078 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004079 -c "add ciphersuite: c0ff" \
4080 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004081 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004082 -s "found ecjpake kkpp extension" \
4083 -S "skip ecjpake kkpp extension" \
4084 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004085 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004086 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004087 -S "None of the common ciphersuites is usable" \
4088 -S "SSL - Verification of the message MAC failed"
4089
Janos Follath74537a62016-09-02 13:45:28 +01004090server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004091requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004092run_test "ECJPAKE: password mismatch, TLS" \
4093 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4094 "$P_CLI debug_level=3 ecjpake_pw=bad \
4095 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4096 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004097 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004098 -s "SSL - Verification of the message MAC failed"
4099
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004100requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004101run_test "ECJPAKE: working, DTLS" \
4102 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4103 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4104 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4105 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004106 -c "re-using cached ecjpake parameters" \
4107 -S "SSL - Verification of the message MAC failed"
4108
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004109requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004110run_test "ECJPAKE: working, DTLS, no cookie" \
4111 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4112 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4113 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4114 0 \
4115 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004116 -S "SSL - Verification of the message MAC failed"
4117
Janos Follath74537a62016-09-02 13:45:28 +01004118server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004119requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004120run_test "ECJPAKE: password mismatch, DTLS" \
4121 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4122 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4123 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4124 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004125 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004126 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004127
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004128# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004129requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004130run_test "ECJPAKE: working, DTLS, nolog" \
4131 "$P_SRV dtls=1 ecjpake_pw=bla" \
4132 "$P_CLI dtls=1 ecjpake_pw=bla \
4133 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4134 0
4135
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004136# Tests for ciphersuites per version
4137
Janos Follathe2681a42016-03-07 15:57:05 +00004138requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004139requires_config_enabled MBEDTLS_CAMELLIA_C
4140requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004141run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004142 "$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 +02004143 "$P_CLI force_version=ssl3" \
4144 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004145 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004146
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004147requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4148requires_config_enabled MBEDTLS_CAMELLIA_C
4149requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004150run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004151 "$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 +01004152 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004153 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004154 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004155
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004156requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4157requires_config_enabled MBEDTLS_CAMELLIA_C
4158requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004159run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004160 "$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 +02004161 "$P_CLI force_version=tls1_1" \
4162 0 \
4163 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4164
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004165requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4166requires_config_enabled MBEDTLS_CAMELLIA_C
4167requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004168run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004169 "$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 +02004170 "$P_CLI force_version=tls1_2" \
4171 0 \
4172 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4173
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004174# Test for ClientHello without extensions
4175
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004176requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004177run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004178 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004179 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004180 0 \
4181 -s "dumping 'client hello extensions' (0 bytes)"
4182
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004183# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004184
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004185run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004186 "$P_SRV" \
4187 "$P_CLI request_size=100" \
4188 0 \
4189 -s "Read from client: 100 bytes read$"
4190
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004191run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004192 "$P_SRV" \
4193 "$P_CLI request_size=500" \
4194 0 \
4195 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004196
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004197# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004198
Janos Follathe2681a42016-03-07 15:57:05 +00004199requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004200run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004201 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004202 "$P_CLI request_size=1 force_version=ssl3 \
4203 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4204 0 \
4205 -s "Read from client: 1 bytes read"
4206
Janos Follathe2681a42016-03-07 15:57:05 +00004207requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004208run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004209 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004210 "$P_CLI request_size=1 force_version=ssl3 \
4211 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4212 0 \
4213 -s "Read from client: 1 bytes read"
4214
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004215run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004216 "$P_SRV" \
4217 "$P_CLI request_size=1 force_version=tls1 \
4218 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4219 0 \
4220 -s "Read from client: 1 bytes read"
4221
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004222run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004223 "$P_SRV" \
4224 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4225 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4226 0 \
4227 -s "Read from client: 1 bytes read"
4228
Hanno Becker32c55012017-11-10 08:42:54 +00004229requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004230run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004231 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004232 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004233 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004234 0 \
4235 -s "Read from client: 1 bytes read"
4236
Hanno Becker32c55012017-11-10 08:42:54 +00004237requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004238run_test "Small client packet TLS 1.0 BlockCipher, without EtM, 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 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004241 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004242 0 \
4243 -s "Read from client: 1 bytes read"
4244
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004245run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004246 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004247 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004248 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4249 0 \
4250 -s "Read from client: 1 bytes read"
4251
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004252run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004253 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4254 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004255 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004256 0 \
4257 -s "Read from client: 1 bytes read"
4258
4259requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004260run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004261 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004262 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004263 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
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.0 StreamCipher, without EtM, 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" \
4270 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4271 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004272 0 \
4273 -s "Read from client: 1 bytes read"
4274
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004275run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004276 "$P_SRV" \
4277 "$P_CLI request_size=1 force_version=tls1_1 \
4278 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4279 0 \
4280 -s "Read from client: 1 bytes read"
4281
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004282run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004283 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004284 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004285 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004286 0 \
4287 -s "Read from client: 1 bytes read"
4288
4289requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004290run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004291 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004292 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004293 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004294 0 \
4295 -s "Read from client: 1 bytes read"
4296
4297requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004298run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004299 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004300 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004301 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004302 0 \
4303 -s "Read from client: 1 bytes read"
4304
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004305run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004306 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004307 "$P_CLI request_size=1 force_version=tls1_1 \
4308 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4309 0 \
4310 -s "Read from client: 1 bytes read"
4311
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004312run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004313 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004314 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004315 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004316 0 \
4317 -s "Read from client: 1 bytes read"
4318
Hanno Becker8501f982017-11-10 08:59:04 +00004319requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004320run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004321 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004322 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004323 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004324 0 \
4325 -s "Read from client: 1 bytes read"
4326
Hanno Becker32c55012017-11-10 08:42:54 +00004327requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004328run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004329 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004330 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004331 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004332 0 \
4333 -s "Read from client: 1 bytes read"
4334
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004335run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004336 "$P_SRV" \
4337 "$P_CLI request_size=1 force_version=tls1_2 \
4338 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4339 0 \
4340 -s "Read from client: 1 bytes read"
4341
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004342run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004343 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004344 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004345 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004346 0 \
4347 -s "Read from client: 1 bytes read"
4348
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004349run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004350 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004351 "$P_CLI request_size=1 force_version=tls1_2 \
4352 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004353 0 \
4354 -s "Read from client: 1 bytes read"
4355
Hanno Becker32c55012017-11-10 08:42:54 +00004356requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004357run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004358 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004359 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004360 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004361 0 \
4362 -s "Read from client: 1 bytes read"
4363
Hanno Becker8501f982017-11-10 08:59:04 +00004364requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004365run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004366 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004367 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004368 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004369 0 \
4370 -s "Read from client: 1 bytes read"
4371
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004372run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004373 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004374 "$P_CLI request_size=1 force_version=tls1_2 \
4375 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4376 0 \
4377 -s "Read from client: 1 bytes read"
4378
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004379run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004380 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004381 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004382 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004383 0 \
4384 -s "Read from client: 1 bytes read"
4385
Hanno Becker32c55012017-11-10 08:42:54 +00004386requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004387run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004388 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004389 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004390 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004391 0 \
4392 -s "Read from client: 1 bytes read"
4393
Hanno Becker8501f982017-11-10 08:59:04 +00004394requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004395run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004396 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004397 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004398 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004399 0 \
4400 -s "Read from client: 1 bytes read"
4401
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004402run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004403 "$P_SRV" \
4404 "$P_CLI request_size=1 force_version=tls1_2 \
4405 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4406 0 \
4407 -s "Read from client: 1 bytes read"
4408
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004409run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004410 "$P_SRV" \
4411 "$P_CLI request_size=1 force_version=tls1_2 \
4412 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4413 0 \
4414 -s "Read from client: 1 bytes read"
4415
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004416# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004417
4418requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004419run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004420 "$P_SRV dtls=1 force_version=dtls1" \
4421 "$P_CLI dtls=1 request_size=1 \
4422 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4423 0 \
4424 -s "Read from client: 1 bytes read"
4425
4426requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004427run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004428 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4429 "$P_CLI dtls=1 request_size=1 \
4430 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4431 0 \
4432 -s "Read from client: 1 bytes read"
4433
4434requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4435requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004436run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004437 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4438 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004439 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4440 0 \
4441 -s "Read from client: 1 bytes read"
4442
4443requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4444requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004445run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004446 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004447 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004448 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004449 0 \
4450 -s "Read from client: 1 bytes read"
4451
4452requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004453run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004454 "$P_SRV dtls=1 force_version=dtls1_2" \
4455 "$P_CLI dtls=1 request_size=1 \
4456 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4457 0 \
4458 -s "Read from client: 1 bytes read"
4459
4460requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004461run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004462 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004463 "$P_CLI dtls=1 request_size=1 \
4464 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4465 0 \
4466 -s "Read from client: 1 bytes read"
4467
4468requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4469requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004470run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004471 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004472 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004473 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004474 0 \
4475 -s "Read from client: 1 bytes read"
4476
4477requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4478requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004479run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004480 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004481 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004482 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004483 0 \
4484 -s "Read from client: 1 bytes read"
4485
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004486# Tests for small server packets
4487
4488requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4489run_test "Small server packet SSLv3 BlockCipher" \
4490 "$P_SRV response_size=1 min_version=ssl3" \
4491 "$P_CLI force_version=ssl3 \
4492 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4493 0 \
4494 -c "Read from server: 1 bytes read"
4495
4496requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4497run_test "Small server packet SSLv3 StreamCipher" \
4498 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4499 "$P_CLI force_version=ssl3 \
4500 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4501 0 \
4502 -c "Read from server: 1 bytes read"
4503
4504run_test "Small server packet TLS 1.0 BlockCipher" \
4505 "$P_SRV response_size=1" \
4506 "$P_CLI force_version=tls1 \
4507 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4508 0 \
4509 -c "Read from server: 1 bytes read"
4510
4511run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4512 "$P_SRV response_size=1" \
4513 "$P_CLI force_version=tls1 etm=0 \
4514 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4515 0 \
4516 -c "Read from server: 1 bytes read"
4517
4518requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4519run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4520 "$P_SRV response_size=1 trunc_hmac=1" \
4521 "$P_CLI force_version=tls1 \
4522 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
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.0 BlockCipher, without EtM, truncated MAC" \
4528 "$P_SRV response_size=1 trunc_hmac=1" \
4529 "$P_CLI force_version=tls1 \
4530 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4531 0 \
4532 -c "Read from server: 1 bytes read"
4533
4534run_test "Small server packet TLS 1.0 StreamCipher" \
4535 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4536 "$P_CLI force_version=tls1 \
4537 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4538 0 \
4539 -c "Read from server: 1 bytes read"
4540
4541run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4542 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4543 "$P_CLI force_version=tls1 \
4544 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4545 0 \
4546 -c "Read from server: 1 bytes read"
4547
4548requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4549run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4550 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4551 "$P_CLI force_version=tls1 \
4552 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
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.0 StreamCipher, without EtM, 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 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4560 trunc_hmac=1 etm=0" \
4561 0 \
4562 -c "Read from server: 1 bytes read"
4563
4564run_test "Small server packet TLS 1.1 BlockCipher" \
4565 "$P_SRV response_size=1" \
4566 "$P_CLI force_version=tls1_1 \
4567 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4568 0 \
4569 -c "Read from server: 1 bytes read"
4570
4571run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4572 "$P_SRV response_size=1" \
4573 "$P_CLI force_version=tls1_1 \
4574 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4575 0 \
4576 -c "Read from server: 1 bytes read"
4577
4578requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4579run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4580 "$P_SRV response_size=1 trunc_hmac=1" \
4581 "$P_CLI force_version=tls1_1 \
4582 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4583 0 \
4584 -c "Read from server: 1 bytes read"
4585
4586requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4587run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4588 "$P_SRV response_size=1 trunc_hmac=1" \
4589 "$P_CLI force_version=tls1_1 \
4590 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4591 0 \
4592 -c "Read from server: 1 bytes read"
4593
4594run_test "Small server packet TLS 1.1 StreamCipher" \
4595 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4596 "$P_CLI force_version=tls1_1 \
4597 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4598 0 \
4599 -c "Read from server: 1 bytes read"
4600
4601run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4602 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4603 "$P_CLI force_version=tls1_1 \
4604 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4605 0 \
4606 -c "Read from server: 1 bytes read"
4607
4608requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4609run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4610 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4611 "$P_CLI force_version=tls1_1 \
4612 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4613 0 \
4614 -c "Read from server: 1 bytes read"
4615
4616requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4617run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4618 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4619 "$P_CLI force_version=tls1_1 \
4620 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4621 0 \
4622 -c "Read from server: 1 bytes read"
4623
4624run_test "Small server packet TLS 1.2 BlockCipher" \
4625 "$P_SRV response_size=1" \
4626 "$P_CLI force_version=tls1_2 \
4627 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4628 0 \
4629 -c "Read from server: 1 bytes read"
4630
4631run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4632 "$P_SRV response_size=1" \
4633 "$P_CLI force_version=tls1_2 \
4634 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4635 0 \
4636 -c "Read from server: 1 bytes read"
4637
4638run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4639 "$P_SRV response_size=1" \
4640 "$P_CLI force_version=tls1_2 \
4641 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4642 0 \
4643 -c "Read from server: 1 bytes read"
4644
4645requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4646run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4647 "$P_SRV response_size=1 trunc_hmac=1" \
4648 "$P_CLI force_version=tls1_2 \
4649 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4650 0 \
4651 -c "Read from server: 1 bytes read"
4652
4653requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4654run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4655 "$P_SRV response_size=1 trunc_hmac=1" \
4656 "$P_CLI force_version=tls1_2 \
4657 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4658 0 \
4659 -c "Read from server: 1 bytes read"
4660
4661run_test "Small server packet TLS 1.2 StreamCipher" \
4662 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4663 "$P_CLI force_version=tls1_2 \
4664 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4665 0 \
4666 -c "Read from server: 1 bytes read"
4667
4668run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4669 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4670 "$P_CLI force_version=tls1_2 \
4671 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4672 0 \
4673 -c "Read from server: 1 bytes read"
4674
4675requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4676run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4677 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4678 "$P_CLI force_version=tls1_2 \
4679 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4680 0 \
4681 -c "Read from server: 1 bytes read"
4682
4683requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4684run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4685 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4686 "$P_CLI force_version=tls1_2 \
4687 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4688 0 \
4689 -c "Read from server: 1 bytes read"
4690
4691run_test "Small server packet TLS 1.2 AEAD" \
4692 "$P_SRV response_size=1" \
4693 "$P_CLI force_version=tls1_2 \
4694 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4695 0 \
4696 -c "Read from server: 1 bytes read"
4697
4698run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4699 "$P_SRV response_size=1" \
4700 "$P_CLI force_version=tls1_2 \
4701 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4702 0 \
4703 -c "Read from server: 1 bytes read"
4704
4705# Tests for small server packets in DTLS
4706
4707requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4708run_test "Small server packet DTLS 1.0" \
4709 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4710 "$P_CLI dtls=1 \
4711 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4712 0 \
4713 -c "Read from server: 1 bytes read"
4714
4715requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4716run_test "Small server packet DTLS 1.0, without EtM" \
4717 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4718 "$P_CLI dtls=1 \
4719 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4720 0 \
4721 -c "Read from server: 1 bytes read"
4722
4723requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4724requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4725run_test "Small server packet DTLS 1.0, truncated hmac" \
4726 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4727 "$P_CLI dtls=1 trunc_hmac=1 \
4728 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4729 0 \
4730 -c "Read from server: 1 bytes read"
4731
4732requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4733requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4734run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4735 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4736 "$P_CLI dtls=1 \
4737 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4738 0 \
4739 -c "Read from server: 1 bytes read"
4740
4741requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4742run_test "Small server packet DTLS 1.2" \
4743 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4744 "$P_CLI dtls=1 \
4745 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4746 0 \
4747 -c "Read from server: 1 bytes read"
4748
4749requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4750run_test "Small server packet DTLS 1.2, without EtM" \
4751 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4752 "$P_CLI dtls=1 \
4753 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4754 0 \
4755 -c "Read from server: 1 bytes read"
4756
4757requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4758requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4759run_test "Small server packet DTLS 1.2, truncated hmac" \
4760 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4761 "$P_CLI dtls=1 \
4762 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4763 0 \
4764 -c "Read from server: 1 bytes read"
4765
4766requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4767requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4768run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4769 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4770 "$P_CLI dtls=1 \
4771 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4772 0 \
4773 -c "Read from server: 1 bytes read"
4774
Janos Follath00efff72016-05-06 13:48:23 +01004775# A test for extensions in SSLv3
4776
4777requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4778run_test "SSLv3 with extensions, server side" \
4779 "$P_SRV min_version=ssl3 debug_level=3" \
4780 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4781 0 \
4782 -S "dumping 'client hello extensions'" \
4783 -S "server hello, total extension length:"
4784
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004785# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004786
Angus Grattonc4dd0732018-04-11 16:28:39 +10004787# How many fragments do we expect to write $1 bytes?
4788fragments_for_write() {
4789 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4790}
4791
Janos Follathe2681a42016-03-07 15:57:05 +00004792requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004793run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004794 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004795 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004796 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4797 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004798 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4799 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004800
Janos Follathe2681a42016-03-07 15:57:05 +00004801requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004802run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004803 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004804 "$P_CLI request_size=16384 force_version=ssl3 \
4805 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4806 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004807 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4808 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004809
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004810run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004811 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004812 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004813 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4814 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004815 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4816 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004817
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004818run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004819 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004820 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4821 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4822 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004823 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004824
Hanno Becker32c55012017-11-10 08:42:54 +00004825requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004826run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004827 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004828 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004829 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004830 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004831 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4832 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004833
Hanno Becker32c55012017-11-10 08:42:54 +00004834requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004835run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004836 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004837 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004838 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004839 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004840 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004841
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004842run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004843 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004844 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004845 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4846 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004847 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004848
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004849run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004850 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4851 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004852 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004853 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004854 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004855
4856requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004857run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004858 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004859 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004860 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004861 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004862 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004863
Hanno Becker278fc7a2017-11-10 09:16:28 +00004864requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004865run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004866 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004867 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004868 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004869 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004870 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4871 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004872
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004873run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004874 "$P_SRV" \
4875 "$P_CLI request_size=16384 force_version=tls1_1 \
4876 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4877 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004878 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4879 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004880
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004881run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004882 "$P_SRV" \
4883 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4884 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004885 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004886 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004887
Hanno Becker32c55012017-11-10 08:42:54 +00004888requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004889run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004890 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004891 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004892 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004893 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004894 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004895
Hanno Becker32c55012017-11-10 08:42:54 +00004896requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004897run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004898 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004899 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004900 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004901 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004902 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004903
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004904run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004905 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4906 "$P_CLI request_size=16384 force_version=tls1_1 \
4907 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4908 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004909 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4910 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004911
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004912run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004913 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004914 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004915 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004916 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004917 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4918 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004919
Hanno Becker278fc7a2017-11-10 09:16:28 +00004920requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004921run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004922 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004923 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004924 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004925 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004926 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004927
Hanno Becker278fc7a2017-11-10 09:16:28 +00004928requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004929run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004930 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004931 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004932 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004933 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004934 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4935 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004936
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004937run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004938 "$P_SRV" \
4939 "$P_CLI request_size=16384 force_version=tls1_2 \
4940 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4941 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004942 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4943 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004944
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004945run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004946 "$P_SRV" \
4947 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4948 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4949 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004950 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004951
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004952run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004953 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004954 "$P_CLI request_size=16384 force_version=tls1_2 \
4955 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004956 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004957 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4958 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004959
Hanno Becker32c55012017-11-10 08:42:54 +00004960requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004961run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004962 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004963 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004964 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004965 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004966 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004967
Hanno Becker278fc7a2017-11-10 09:16:28 +00004968requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004969run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004970 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004971 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004972 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004973 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004974 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4975 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004976
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004977run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004978 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004979 "$P_CLI request_size=16384 force_version=tls1_2 \
4980 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4981 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004982 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4983 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004984
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004985run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004986 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004987 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004988 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4989 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004990 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004991
Hanno Becker32c55012017-11-10 08:42:54 +00004992requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004993run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004994 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004995 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004996 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004997 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004998 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004999
Hanno Becker278fc7a2017-11-10 09:16:28 +00005000requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005001run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005002 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005003 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005004 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005005 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005006 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5007 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005008
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005009run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005010 "$P_SRV" \
5011 "$P_CLI request_size=16384 force_version=tls1_2 \
5012 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5013 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005014 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5015 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005016
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005017run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005018 "$P_SRV" \
5019 "$P_CLI request_size=16384 force_version=tls1_2 \
5020 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5021 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005022 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5023 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005024
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005025# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005026requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5027run_test "Large server packet SSLv3 StreamCipher" \
5028 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5029 "$P_CLI force_version=ssl3 \
5030 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5031 0 \
5032 -c "Read from server: 16384 bytes read"
5033
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04005034# Checking next 4 tests logs for 1n-1 split against BEAST too
5035requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5036run_test "Large server packet SSLv3 BlockCipher" \
5037 "$P_SRV response_size=16384 min_version=ssl3" \
5038 "$P_CLI force_version=ssl3 recsplit=0 \
5039 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5040 0 \
5041 -c "Read from server: 1 bytes read"\
5042 -c "16383 bytes read"\
5043 -C "Read from server: 16384 bytes read"
5044
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005045run_test "Large server packet TLS 1.0 BlockCipher" \
5046 "$P_SRV response_size=16384" \
5047 "$P_CLI force_version=tls1 recsplit=0 \
5048 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5049 0 \
5050 -c "Read from server: 1 bytes read"\
5051 -c "16383 bytes read"\
5052 -C "Read from server: 16384 bytes read"
5053
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005054run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5055 "$P_SRV response_size=16384" \
5056 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5057 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5058 0 \
5059 -c "Read from server: 1 bytes read"\
5060 -c "16383 bytes read"\
5061 -C "Read from server: 16384 bytes read"
5062
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005063requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5064run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5065 "$P_SRV response_size=16384" \
5066 "$P_CLI force_version=tls1 recsplit=0 \
5067 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5068 trunc_hmac=1" \
5069 0 \
5070 -c "Read from server: 1 bytes read"\
5071 -c "16383 bytes read"\
5072 -C "Read from server: 16384 bytes read"
5073
5074requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5075run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5076 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5077 "$P_CLI force_version=tls1 \
5078 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5079 trunc_hmac=1" \
5080 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005081 -s "16384 bytes written in 1 fragments" \
5082 -c "Read from server: 16384 bytes read"
5083
5084run_test "Large server packet TLS 1.0 StreamCipher" \
5085 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5086 "$P_CLI force_version=tls1 \
5087 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5088 0 \
5089 -s "16384 bytes written in 1 fragments" \
5090 -c "Read from server: 16384 bytes read"
5091
5092run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5093 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5094 "$P_CLI force_version=tls1 \
5095 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5096 0 \
5097 -s "16384 bytes written in 1 fragments" \
5098 -c "Read from server: 16384 bytes read"
5099
5100requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5101run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5102 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5103 "$P_CLI force_version=tls1 \
5104 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5105 0 \
5106 -s "16384 bytes written in 1 fragments" \
5107 -c "Read from server: 16384 bytes read"
5108
5109requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5110run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5111 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5112 "$P_CLI force_version=tls1 \
5113 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5114 0 \
5115 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005116 -c "Read from server: 16384 bytes read"
5117
5118run_test "Large server packet TLS 1.1 BlockCipher" \
5119 "$P_SRV response_size=16384" \
5120 "$P_CLI force_version=tls1_1 \
5121 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5122 0 \
5123 -c "Read from server: 16384 bytes read"
5124
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005125run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5126 "$P_SRV response_size=16384" \
5127 "$P_CLI force_version=tls1_1 etm=0 \
5128 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005129 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005130 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005131 -c "Read from server: 16384 bytes read"
5132
5133requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5134run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5135 "$P_SRV response_size=16384" \
5136 "$P_CLI force_version=tls1_1 \
5137 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5138 trunc_hmac=1" \
5139 0 \
5140 -c "Read from server: 16384 bytes read"
5141
5142requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005143run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5144 "$P_SRV response_size=16384 trunc_hmac=1" \
5145 "$P_CLI force_version=tls1_1 \
5146 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5147 0 \
5148 -s "16384 bytes written in 1 fragments" \
5149 -c "Read from server: 16384 bytes read"
5150
5151run_test "Large server packet TLS 1.1 StreamCipher" \
5152 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5153 "$P_CLI force_version=tls1_1 \
5154 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5155 0 \
5156 -c "Read from server: 16384 bytes read"
5157
5158run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5159 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5160 "$P_CLI force_version=tls1_1 \
5161 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5162 0 \
5163 -s "16384 bytes written in 1 fragments" \
5164 -c "Read from server: 16384 bytes read"
5165
5166requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005167run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5168 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5169 "$P_CLI force_version=tls1_1 \
5170 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5171 trunc_hmac=1" \
5172 0 \
5173 -c "Read from server: 16384 bytes read"
5174
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005175run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5176 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5177 "$P_CLI force_version=tls1_1 \
5178 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5179 0 \
5180 -s "16384 bytes written in 1 fragments" \
5181 -c "Read from server: 16384 bytes read"
5182
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005183run_test "Large server packet TLS 1.2 BlockCipher" \
5184 "$P_SRV response_size=16384" \
5185 "$P_CLI force_version=tls1_2 \
5186 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5187 0 \
5188 -c "Read from server: 16384 bytes read"
5189
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005190run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5191 "$P_SRV response_size=16384" \
5192 "$P_CLI force_version=tls1_2 etm=0 \
5193 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5194 0 \
5195 -s "16384 bytes written in 1 fragments" \
5196 -c "Read from server: 16384 bytes read"
5197
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005198run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5199 "$P_SRV response_size=16384" \
5200 "$P_CLI force_version=tls1_2 \
5201 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5202 0 \
5203 -c "Read from server: 16384 bytes read"
5204
5205requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5206run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5207 "$P_SRV response_size=16384" \
5208 "$P_CLI force_version=tls1_2 \
5209 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5210 trunc_hmac=1" \
5211 0 \
5212 -c "Read from server: 16384 bytes read"
5213
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005214run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5215 "$P_SRV response_size=16384 trunc_hmac=1" \
5216 "$P_CLI force_version=tls1_2 \
5217 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5218 0 \
5219 -s "16384 bytes written in 1 fragments" \
5220 -c "Read from server: 16384 bytes read"
5221
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005222run_test "Large server packet TLS 1.2 StreamCipher" \
5223 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5224 "$P_CLI force_version=tls1_2 \
5225 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5226 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005227 -s "16384 bytes written in 1 fragments" \
5228 -c "Read from server: 16384 bytes read"
5229
5230run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5231 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5232 "$P_CLI force_version=tls1_2 \
5233 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5234 0 \
5235 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005236 -c "Read from server: 16384 bytes read"
5237
5238requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5239run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5240 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5241 "$P_CLI force_version=tls1_2 \
5242 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5243 trunc_hmac=1" \
5244 0 \
5245 -c "Read from server: 16384 bytes read"
5246
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005247requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5248run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5249 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5250 "$P_CLI force_version=tls1_2 \
5251 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5252 0 \
5253 -s "16384 bytes written in 1 fragments" \
5254 -c "Read from server: 16384 bytes read"
5255
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005256run_test "Large server packet TLS 1.2 AEAD" \
5257 "$P_SRV response_size=16384" \
5258 "$P_CLI force_version=tls1_2 \
5259 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5260 0 \
5261 -c "Read from server: 16384 bytes read"
5262
5263run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5264 "$P_SRV response_size=16384" \
5265 "$P_CLI force_version=tls1_2 \
5266 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5267 0 \
5268 -c "Read from server: 16384 bytes read"
5269
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005270# Tests for restartable ECC
5271
5272requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5273run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005274 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005275 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005276 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005277 debug_level=1" \
5278 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005279 -C "x509_verify_cert.*4b00" \
5280 -C "mbedtls_pk_verify.*4b00" \
5281 -C "mbedtls_ecdh_make_public.*4b00" \
5282 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005283
5284requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5285run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005286 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005287 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005288 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005289 debug_level=1 ec_max_ops=0" \
5290 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005291 -C "x509_verify_cert.*4b00" \
5292 -C "mbedtls_pk_verify.*4b00" \
5293 -C "mbedtls_ecdh_make_public.*4b00" \
5294 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005295
5296requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5297run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005298 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005299 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005300 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005301 debug_level=1 ec_max_ops=65535" \
5302 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005303 -C "x509_verify_cert.*4b00" \
5304 -C "mbedtls_pk_verify.*4b00" \
5305 -C "mbedtls_ecdh_make_public.*4b00" \
5306 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005307
5308requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5309run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005310 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005311 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005312 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005313 debug_level=1 ec_max_ops=1000" \
5314 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005315 -c "x509_verify_cert.*4b00" \
5316 -c "mbedtls_pk_verify.*4b00" \
5317 -c "mbedtls_ecdh_make_public.*4b00" \
5318 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005319
5320requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005321run_test "EC restart: TLS, max_ops=1000, badsign" \
5322 "$P_SRV auth_mode=required \
5323 crt_file=data_files/server5-badsign.crt \
5324 key_file=data_files/server5.key" \
5325 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5326 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5327 debug_level=1 ec_max_ops=1000" \
5328 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005329 -c "x509_verify_cert.*4b00" \
5330 -C "mbedtls_pk_verify.*4b00" \
5331 -C "mbedtls_ecdh_make_public.*4b00" \
5332 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005333 -c "! The certificate is not correctly signed by the trusted CA" \
5334 -c "! mbedtls_ssl_handshake returned" \
5335 -c "X509 - Certificate verification failed"
5336
5337requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5338run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5339 "$P_SRV auth_mode=required \
5340 crt_file=data_files/server5-badsign.crt \
5341 key_file=data_files/server5.key" \
5342 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5343 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5344 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5345 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005346 -c "x509_verify_cert.*4b00" \
5347 -c "mbedtls_pk_verify.*4b00" \
5348 -c "mbedtls_ecdh_make_public.*4b00" \
5349 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005350 -c "! The certificate is not correctly signed by the trusted CA" \
5351 -C "! mbedtls_ssl_handshake returned" \
5352 -C "X509 - Certificate verification failed"
5353
5354requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5355run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5356 "$P_SRV auth_mode=required \
5357 crt_file=data_files/server5-badsign.crt \
5358 key_file=data_files/server5.key" \
5359 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5360 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5361 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5362 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005363 -C "x509_verify_cert.*4b00" \
5364 -c "mbedtls_pk_verify.*4b00" \
5365 -c "mbedtls_ecdh_make_public.*4b00" \
5366 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005367 -C "! The certificate is not correctly signed by the trusted CA" \
5368 -C "! mbedtls_ssl_handshake returned" \
5369 -C "X509 - Certificate verification failed"
5370
5371requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005372run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005373 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005374 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005375 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005376 dtls=1 debug_level=1 ec_max_ops=1000" \
5377 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005378 -c "x509_verify_cert.*4b00" \
5379 -c "mbedtls_pk_verify.*4b00" \
5380 -c "mbedtls_ecdh_make_public.*4b00" \
5381 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005382
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005383requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5384run_test "EC restart: TLS, max_ops=1000 no client auth" \
5385 "$P_SRV" \
5386 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5387 debug_level=1 ec_max_ops=1000" \
5388 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005389 -c "x509_verify_cert.*4b00" \
5390 -c "mbedtls_pk_verify.*4b00" \
5391 -c "mbedtls_ecdh_make_public.*4b00" \
5392 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005393
5394requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5395run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5396 "$P_SRV psk=abc123" \
5397 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5398 psk=abc123 debug_level=1 ec_max_ops=1000" \
5399 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005400 -C "x509_verify_cert.*4b00" \
5401 -C "mbedtls_pk_verify.*4b00" \
5402 -C "mbedtls_ecdh_make_public.*4b00" \
5403 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005404
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005405# Tests of asynchronous private key support in SSL
5406
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005407requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005408run_test "SSL async private: sign, delay=0" \
5409 "$P_SRV \
5410 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005411 "$P_CLI" \
5412 0 \
5413 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005414 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005415
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005416requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005417run_test "SSL async private: sign, delay=1" \
5418 "$P_SRV \
5419 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005420 "$P_CLI" \
5421 0 \
5422 -s "Async sign callback: using key slot " \
5423 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005424 -s "Async resume (slot [0-9]): sign done, status=0"
5425
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005426requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5427run_test "SSL async private: sign, delay=2" \
5428 "$P_SRV \
5429 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5430 "$P_CLI" \
5431 0 \
5432 -s "Async sign callback: using key slot " \
5433 -U "Async sign callback: using key slot " \
5434 -s "Async resume (slot [0-9]): call 1 more times." \
5435 -s "Async resume (slot [0-9]): call 0 more times." \
5436 -s "Async resume (slot [0-9]): sign done, status=0"
5437
Gilles Peskined3268832018-04-26 06:23:59 +02005438# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5439# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5440requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5441requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5442run_test "SSL async private: sign, RSA, TLS 1.1" \
5443 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5444 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5445 "$P_CLI force_version=tls1_1" \
5446 0 \
5447 -s "Async sign callback: using key slot " \
5448 -s "Async resume (slot [0-9]): sign done, status=0"
5449
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005450requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005451run_test "SSL async private: sign, SNI" \
5452 "$P_SRV debug_level=3 \
5453 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5454 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5455 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5456 "$P_CLI server_name=polarssl.example" \
5457 0 \
5458 -s "Async sign callback: using key slot " \
5459 -s "Async resume (slot [0-9]): sign done, status=0" \
5460 -s "parse ServerName extension" \
5461 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5462 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5463
5464requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005465run_test "SSL async private: decrypt, delay=0" \
5466 "$P_SRV \
5467 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5468 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5469 0 \
5470 -s "Async decrypt callback: using key slot " \
5471 -s "Async resume (slot [0-9]): decrypt done, status=0"
5472
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005473requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005474run_test "SSL async private: decrypt, delay=1" \
5475 "$P_SRV \
5476 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5477 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5478 0 \
5479 -s "Async decrypt callback: using key slot " \
5480 -s "Async resume (slot [0-9]): call 0 more times." \
5481 -s "Async resume (slot [0-9]): decrypt done, status=0"
5482
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005483requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005484run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5485 "$P_SRV psk=abc123 \
5486 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5487 "$P_CLI psk=abc123 \
5488 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5489 0 \
5490 -s "Async decrypt callback: using key slot " \
5491 -s "Async resume (slot [0-9]): decrypt done, status=0"
5492
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005493requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005494run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5495 "$P_SRV psk=abc123 \
5496 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5497 "$P_CLI psk=abc123 \
5498 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5499 0 \
5500 -s "Async decrypt callback: using key slot " \
5501 -s "Async resume (slot [0-9]): call 0 more times." \
5502 -s "Async resume (slot [0-9]): decrypt done, status=0"
5503
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005504requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005505run_test "SSL async private: sign callback not present" \
5506 "$P_SRV \
5507 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5508 "$P_CLI; [ \$? -eq 1 ] &&
5509 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5510 0 \
5511 -S "Async sign callback" \
5512 -s "! mbedtls_ssl_handshake returned" \
5513 -s "The own private key or pre-shared key is not set, but needed" \
5514 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5515 -s "Successful connection"
5516
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005517requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005518run_test "SSL async private: decrypt callback not present" \
5519 "$P_SRV debug_level=1 \
5520 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5521 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5522 [ \$? -eq 1 ] && $P_CLI" \
5523 0 \
5524 -S "Async decrypt callback" \
5525 -s "! mbedtls_ssl_handshake returned" \
5526 -s "got no RSA private key" \
5527 -s "Async resume (slot [0-9]): sign done, status=0" \
5528 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005529
5530# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005531requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005532run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005533 "$P_SRV \
5534 async_operations=s async_private_delay1=1 \
5535 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5536 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005537 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5538 0 \
5539 -s "Async sign callback: using key slot 0," \
5540 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005541 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005542
5543# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005544requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005545run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005546 "$P_SRV \
5547 async_operations=s async_private_delay2=1 \
5548 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5549 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005550 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5551 0 \
5552 -s "Async sign callback: using key slot 0," \
5553 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005554 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005555
5556# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005557requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005558run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005559 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005560 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005561 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5562 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005563 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5564 0 \
5565 -s "Async sign callback: using key slot 1," \
5566 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005567 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005568
5569# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005570requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005571run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005572 "$P_SRV \
5573 async_operations=s async_private_delay1=1 \
5574 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5575 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005576 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5577 0 \
5578 -s "Async sign callback: no key matches this certificate."
5579
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005580requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005581run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005582 "$P_SRV \
5583 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5584 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005585 "$P_CLI" \
5586 1 \
5587 -s "Async sign callback: injected error" \
5588 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005589 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005590 -s "! mbedtls_ssl_handshake returned"
5591
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005592requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005593run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005594 "$P_SRV \
5595 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5596 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005597 "$P_CLI" \
5598 1 \
5599 -s "Async sign callback: using key slot " \
5600 -S "Async resume" \
5601 -s "Async cancel"
5602
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005603requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005604run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005605 "$P_SRV \
5606 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5607 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005608 "$P_CLI" \
5609 1 \
5610 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005611 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005612 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005613 -s "! mbedtls_ssl_handshake returned"
5614
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005615requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005616run_test "SSL async private: decrypt, error in start" \
5617 "$P_SRV \
5618 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5619 async_private_error=1" \
5620 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5621 1 \
5622 -s "Async decrypt callback: injected error" \
5623 -S "Async resume" \
5624 -S "Async cancel" \
5625 -s "! mbedtls_ssl_handshake returned"
5626
5627requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5628run_test "SSL async private: decrypt, cancel after start" \
5629 "$P_SRV \
5630 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5631 async_private_error=2" \
5632 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5633 1 \
5634 -s "Async decrypt callback: using key slot " \
5635 -S "Async resume" \
5636 -s "Async cancel"
5637
5638requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5639run_test "SSL async private: decrypt, error in resume" \
5640 "$P_SRV \
5641 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5642 async_private_error=3" \
5643 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5644 1 \
5645 -s "Async decrypt callback: using key slot " \
5646 -s "Async resume callback: decrypt done but injected error" \
5647 -S "Async cancel" \
5648 -s "! mbedtls_ssl_handshake returned"
5649
5650requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005651run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005652 "$P_SRV \
5653 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5654 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005655 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5656 0 \
5657 -s "Async cancel" \
5658 -s "! mbedtls_ssl_handshake returned" \
5659 -s "Async resume" \
5660 -s "Successful connection"
5661
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005662requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005663run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005664 "$P_SRV \
5665 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5666 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005667 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5668 0 \
5669 -s "! mbedtls_ssl_handshake returned" \
5670 -s "Async resume" \
5671 -s "Successful connection"
5672
5673# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005674requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005675run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005676 "$P_SRV \
5677 async_operations=s async_private_delay1=1 async_private_error=-2 \
5678 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5679 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005680 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5681 [ \$? -eq 1 ] &&
5682 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5683 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005684 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005685 -S "Async resume" \
5686 -s "Async cancel" \
5687 -s "! mbedtls_ssl_handshake returned" \
5688 -s "Async sign callback: no key matches this certificate." \
5689 -s "Successful connection"
5690
5691# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005692requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005693run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005694 "$P_SRV \
5695 async_operations=s async_private_delay1=1 async_private_error=-3 \
5696 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5697 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005698 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5699 [ \$? -eq 1 ] &&
5700 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5701 0 \
5702 -s "Async resume" \
5703 -s "! mbedtls_ssl_handshake returned" \
5704 -s "Async sign callback: no key matches this certificate." \
5705 -s "Successful connection"
5706
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005707requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005708requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005709run_test "SSL async private: renegotiation: client-initiated; sign" \
5710 "$P_SRV \
5711 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005712 exchanges=2 renegotiation=1" \
5713 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5714 0 \
5715 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005716 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005717
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005718requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005719requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005720run_test "SSL async private: renegotiation: server-initiated; sign" \
5721 "$P_SRV \
5722 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005723 exchanges=2 renegotiation=1 renegotiate=1" \
5724 "$P_CLI exchanges=2 renegotiation=1" \
5725 0 \
5726 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005727 -s "Async resume (slot [0-9]): sign done, status=0"
5728
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005729requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005730requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5731run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5732 "$P_SRV \
5733 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5734 exchanges=2 renegotiation=1" \
5735 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5736 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5737 0 \
5738 -s "Async decrypt callback: using key slot " \
5739 -s "Async resume (slot [0-9]): decrypt done, status=0"
5740
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005741requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005742requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5743run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5744 "$P_SRV \
5745 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5746 exchanges=2 renegotiation=1 renegotiate=1" \
5747 "$P_CLI exchanges=2 renegotiation=1 \
5748 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5749 0 \
5750 -s "Async decrypt callback: using key slot " \
5751 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005752
Ron Eldor58093c82018-06-28 13:22:05 +03005753# Tests for ECC extensions (rfc 4492)
5754
Ron Eldor643df7c2018-06-28 16:17:00 +03005755requires_config_enabled MBEDTLS_AES_C
5756requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5757requires_config_enabled MBEDTLS_SHA256_C
5758requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005759run_test "Force a non ECC ciphersuite in the client side" \
5760 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005761 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005762 0 \
5763 -C "client hello, adding supported_elliptic_curves extension" \
5764 -C "client hello, adding supported_point_formats extension" \
5765 -S "found supported elliptic curves extension" \
5766 -S "found supported point formats extension"
5767
Ron Eldor643df7c2018-06-28 16:17:00 +03005768requires_config_enabled MBEDTLS_AES_C
5769requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5770requires_config_enabled MBEDTLS_SHA256_C
5771requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005772run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005773 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005774 "$P_CLI debug_level=3" \
5775 0 \
5776 -C "found supported_point_formats extension" \
5777 -S "server hello, supported_point_formats extension"
5778
Ron Eldor643df7c2018-06-28 16:17:00 +03005779requires_config_enabled MBEDTLS_AES_C
5780requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5781requires_config_enabled MBEDTLS_SHA256_C
5782requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005783run_test "Force an ECC ciphersuite in the client side" \
5784 "$P_SRV debug_level=3" \
5785 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5786 0 \
5787 -c "client hello, adding supported_elliptic_curves extension" \
5788 -c "client hello, adding supported_point_formats extension" \
5789 -s "found supported elliptic curves extension" \
5790 -s "found supported point formats extension"
5791
Ron Eldor643df7c2018-06-28 16:17:00 +03005792requires_config_enabled MBEDTLS_AES_C
5793requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5794requires_config_enabled MBEDTLS_SHA256_C
5795requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005796run_test "Force an ECC ciphersuite in the server side" \
5797 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5798 "$P_CLI debug_level=3" \
5799 0 \
5800 -c "found supported_point_formats extension" \
5801 -s "server hello, supported_point_formats extension"
5802
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005803# Tests for DTLS HelloVerifyRequest
5804
5805run_test "DTLS cookie: enabled" \
5806 "$P_SRV dtls=1 debug_level=2" \
5807 "$P_CLI dtls=1 debug_level=2" \
5808 0 \
5809 -s "cookie verification failed" \
5810 -s "cookie verification passed" \
5811 -S "cookie verification skipped" \
5812 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005813 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005814 -S "SSL - The requested feature is not available"
5815
5816run_test "DTLS cookie: disabled" \
5817 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5818 "$P_CLI dtls=1 debug_level=2" \
5819 0 \
5820 -S "cookie verification failed" \
5821 -S "cookie verification passed" \
5822 -s "cookie verification skipped" \
5823 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005824 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005825 -S "SSL - The requested feature is not available"
5826
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005827run_test "DTLS cookie: default (failing)" \
5828 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5829 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5830 1 \
5831 -s "cookie verification failed" \
5832 -S "cookie verification passed" \
5833 -S "cookie verification skipped" \
5834 -C "received hello verify request" \
5835 -S "hello verification requested" \
5836 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005837
5838requires_ipv6
5839run_test "DTLS cookie: enabled, IPv6" \
5840 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5841 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5842 0 \
5843 -s "cookie verification failed" \
5844 -s "cookie verification passed" \
5845 -S "cookie verification skipped" \
5846 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005847 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005848 -S "SSL - The requested feature is not available"
5849
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005850run_test "DTLS cookie: enabled, nbio" \
5851 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5852 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5853 0 \
5854 -s "cookie verification failed" \
5855 -s "cookie verification passed" \
5856 -S "cookie verification skipped" \
5857 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005858 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005859 -S "SSL - The requested feature is not available"
5860
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005861# Tests for client reconnecting from the same port with DTLS
5862
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005863not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005864run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005865 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5866 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005867 0 \
5868 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005869 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005870 -S "Client initiated reconnection from same port"
5871
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005872not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005873run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005874 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5875 "$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 +02005876 0 \
5877 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005878 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005879 -s "Client initiated reconnection from same port"
5880
Paul Bakker362689d2016-05-13 10:33:25 +01005881not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5882run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005883 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5884 "$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 +02005885 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005886 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005887 -s "Client initiated reconnection from same port"
5888
Paul Bakker362689d2016-05-13 10:33:25 +01005889only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5890run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5891 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5892 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5893 0 \
5894 -S "The operation timed out" \
5895 -s "Client initiated reconnection from same port"
5896
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005897run_test "DTLS client reconnect from same port: no cookies" \
5898 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005899 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5900 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005901 -s "The operation timed out" \
5902 -S "Client initiated reconnection from same port"
5903
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005904run_test "DTLS client reconnect from same port: attacker-injected" \
5905 -p "$P_PXY inject_clihlo=1" \
5906 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5907 "$P_CLI dtls=1 exchanges=2" \
5908 0 \
5909 -s "possible client reconnect from the same port" \
5910 -S "Client initiated reconnection from same port"
5911
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005912# Tests for various cases of client authentication with DTLS
5913# (focused on handshake flows and message parsing)
5914
5915run_test "DTLS client auth: required" \
5916 "$P_SRV dtls=1 auth_mode=required" \
5917 "$P_CLI dtls=1" \
5918 0 \
5919 -s "Verifying peer X.509 certificate... ok"
5920
5921run_test "DTLS client auth: optional, client has no cert" \
5922 "$P_SRV dtls=1 auth_mode=optional" \
5923 "$P_CLI dtls=1 crt_file=none key_file=none" \
5924 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005925 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005926
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005927run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005928 "$P_SRV dtls=1 auth_mode=none" \
5929 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5930 0 \
5931 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005932 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005933
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005934run_test "DTLS wrong PSK: badmac alert" \
5935 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5936 "$P_CLI dtls=1 psk=abc124" \
5937 1 \
5938 -s "SSL - Verification of the message MAC failed" \
5939 -c "SSL - A fatal alert message was received from our peer"
5940
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005941# Tests for receiving fragmented handshake messages with DTLS
5942
5943requires_gnutls
5944run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5945 "$G_SRV -u --mtu 2048 -a" \
5946 "$P_CLI dtls=1 debug_level=2" \
5947 0 \
5948 -C "found fragmented DTLS handshake message" \
5949 -C "error"
5950
5951requires_gnutls
5952run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5953 "$G_SRV -u --mtu 512" \
5954 "$P_CLI dtls=1 debug_level=2" \
5955 0 \
5956 -c "found fragmented DTLS handshake message" \
5957 -C "error"
5958
5959requires_gnutls
5960run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5961 "$G_SRV -u --mtu 128" \
5962 "$P_CLI dtls=1 debug_level=2" \
5963 0 \
5964 -c "found fragmented DTLS handshake message" \
5965 -C "error"
5966
5967requires_gnutls
5968run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5969 "$G_SRV -u --mtu 128" \
5970 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5971 0 \
5972 -c "found fragmented DTLS handshake message" \
5973 -C "error"
5974
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005975requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005976requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005977run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5978 "$G_SRV -u --mtu 256" \
5979 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5980 0 \
5981 -c "found fragmented DTLS handshake message" \
5982 -c "client hello, adding renegotiation extension" \
5983 -c "found renegotiation extension" \
5984 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005985 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005986 -C "error" \
5987 -s "Extra-header:"
5988
5989requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005990requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005991run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5992 "$G_SRV -u --mtu 256" \
5993 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5994 0 \
5995 -c "found fragmented DTLS handshake message" \
5996 -c "client hello, adding renegotiation extension" \
5997 -c "found renegotiation extension" \
5998 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005999 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006000 -C "error" \
6001 -s "Extra-header:"
6002
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006003run_test "DTLS reassembly: no fragmentation (openssl server)" \
6004 "$O_SRV -dtls1 -mtu 2048" \
6005 "$P_CLI dtls=1 debug_level=2" \
6006 0 \
6007 -C "found fragmented DTLS handshake message" \
6008 -C "error"
6009
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006010run_test "DTLS reassembly: some fragmentation (openssl server)" \
6011 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006012 "$P_CLI dtls=1 debug_level=2" \
6013 0 \
6014 -c "found fragmented DTLS handshake message" \
6015 -C "error"
6016
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006017run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006018 "$O_SRV -dtls1 -mtu 256" \
6019 "$P_CLI dtls=1 debug_level=2" \
6020 0 \
6021 -c "found fragmented DTLS handshake message" \
6022 -C "error"
6023
6024run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6025 "$O_SRV -dtls1 -mtu 256" \
6026 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6027 0 \
6028 -c "found fragmented DTLS handshake message" \
6029 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006030
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006031# Tests for sending fragmented handshake messages with DTLS
6032#
6033# Use client auth when we need the client to send large messages,
6034# and use large cert chains on both sides too (the long chains we have all use
6035# both RSA and ECDSA, but ideally we should have long chains with either).
6036# Sizes reached (UDP payload):
6037# - 2037B for server certificate
6038# - 1542B for client certificate
6039# - 1013B for newsessionticket
6040# - all others below 512B
6041# All those tests assume MAX_CONTENT_LEN is at least 2048
6042
6043requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6044requires_config_enabled MBEDTLS_RSA_C
6045requires_config_enabled MBEDTLS_ECDSA_C
6046requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6047run_test "DTLS fragmenting: none (for reference)" \
6048 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6049 crt_file=data_files/server7_int-ca.crt \
6050 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006051 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006052 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006053 "$P_CLI dtls=1 debug_level=2 \
6054 crt_file=data_files/server8_int-ca2.crt \
6055 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006056 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006057 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006058 0 \
6059 -S "found fragmented DTLS handshake message" \
6060 -C "found fragmented DTLS handshake message" \
6061 -C "error"
6062
6063requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6064requires_config_enabled MBEDTLS_RSA_C
6065requires_config_enabled MBEDTLS_ECDSA_C
6066requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006067run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006068 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6069 crt_file=data_files/server7_int-ca.crt \
6070 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006071 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006072 max_frag_len=1024" \
6073 "$P_CLI dtls=1 debug_level=2 \
6074 crt_file=data_files/server8_int-ca2.crt \
6075 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006076 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006077 max_frag_len=2048" \
6078 0 \
6079 -S "found fragmented DTLS handshake message" \
6080 -c "found fragmented DTLS handshake message" \
6081 -C "error"
6082
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006083# With the MFL extension, the server has no way of forcing
6084# the client to not exceed a certain MTU; hence, the following
6085# test can't be replicated with an MTU proxy such as the one
6086# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006087requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6088requires_config_enabled MBEDTLS_RSA_C
6089requires_config_enabled MBEDTLS_ECDSA_C
6090requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006091run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006092 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6093 crt_file=data_files/server7_int-ca.crt \
6094 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006095 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006096 max_frag_len=512" \
6097 "$P_CLI dtls=1 debug_level=2 \
6098 crt_file=data_files/server8_int-ca2.crt \
6099 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006100 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006101 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006102 0 \
6103 -S "found fragmented DTLS handshake message" \
6104 -c "found fragmented DTLS handshake message" \
6105 -C "error"
6106
6107requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6108requires_config_enabled MBEDTLS_RSA_C
6109requires_config_enabled MBEDTLS_ECDSA_C
6110requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006111run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006112 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6113 crt_file=data_files/server7_int-ca.crt \
6114 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006115 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006116 max_frag_len=2048" \
6117 "$P_CLI dtls=1 debug_level=2 \
6118 crt_file=data_files/server8_int-ca2.crt \
6119 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006120 hs_timeout=2500-60000 \
6121 max_frag_len=1024" \
6122 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006123 -S "found fragmented DTLS handshake message" \
6124 -c "found fragmented DTLS handshake message" \
6125 -C "error"
6126
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006127# While not required by the standard defining the MFL extension
6128# (according to which it only applies to records, not to datagrams),
6129# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6130# as otherwise there wouldn't be any means to communicate MTU restrictions
6131# to the peer.
6132# The next test checks that no datagrams significantly larger than the
6133# negotiated MFL are sent.
6134requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6135requires_config_enabled MBEDTLS_RSA_C
6136requires_config_enabled MBEDTLS_ECDSA_C
6137requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6138run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006139 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006140 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6141 crt_file=data_files/server7_int-ca.crt \
6142 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006143 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006144 max_frag_len=2048" \
6145 "$P_CLI dtls=1 debug_level=2 \
6146 crt_file=data_files/server8_int-ca2.crt \
6147 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006148 hs_timeout=2500-60000 \
6149 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006150 0 \
6151 -S "found fragmented DTLS handshake message" \
6152 -c "found fragmented DTLS handshake message" \
6153 -C "error"
6154
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006155requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6156requires_config_enabled MBEDTLS_RSA_C
6157requires_config_enabled MBEDTLS_ECDSA_C
6158requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006159run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006160 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6161 crt_file=data_files/server7_int-ca.crt \
6162 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006163 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006164 max_frag_len=2048" \
6165 "$P_CLI dtls=1 debug_level=2 \
6166 crt_file=data_files/server8_int-ca2.crt \
6167 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006168 hs_timeout=2500-60000 \
6169 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006170 0 \
6171 -s "found fragmented DTLS handshake message" \
6172 -c "found fragmented DTLS handshake message" \
6173 -C "error"
6174
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006175# While not required by the standard defining the MFL extension
6176# (according to which it only applies to records, not to datagrams),
6177# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6178# as otherwise there wouldn't be any means to communicate MTU restrictions
6179# to the peer.
6180# The next test checks that no datagrams significantly larger than the
6181# negotiated MFL are sent.
6182requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6183requires_config_enabled MBEDTLS_RSA_C
6184requires_config_enabled MBEDTLS_ECDSA_C
6185requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6186run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006187 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006188 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6189 crt_file=data_files/server7_int-ca.crt \
6190 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006191 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006192 max_frag_len=2048" \
6193 "$P_CLI dtls=1 debug_level=2 \
6194 crt_file=data_files/server8_int-ca2.crt \
6195 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006196 hs_timeout=2500-60000 \
6197 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006198 0 \
6199 -s "found fragmented DTLS handshake message" \
6200 -c "found fragmented DTLS handshake message" \
6201 -C "error"
6202
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006203requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6204requires_config_enabled MBEDTLS_RSA_C
6205requires_config_enabled MBEDTLS_ECDSA_C
6206run_test "DTLS fragmenting: none (for reference) (MTU)" \
6207 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6208 crt_file=data_files/server7_int-ca.crt \
6209 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006210 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006211 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006212 "$P_CLI dtls=1 debug_level=2 \
6213 crt_file=data_files/server8_int-ca2.crt \
6214 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006215 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006216 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006217 0 \
6218 -S "found fragmented DTLS handshake message" \
6219 -C "found fragmented DTLS handshake message" \
6220 -C "error"
6221
6222requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6223requires_config_enabled MBEDTLS_RSA_C
6224requires_config_enabled MBEDTLS_ECDSA_C
6225run_test "DTLS fragmenting: client (MTU)" \
6226 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6227 crt_file=data_files/server7_int-ca.crt \
6228 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006229 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006230 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006231 "$P_CLI dtls=1 debug_level=2 \
6232 crt_file=data_files/server8_int-ca2.crt \
6233 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006234 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006235 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006236 0 \
6237 -s "found fragmented DTLS handshake message" \
6238 -C "found fragmented DTLS handshake message" \
6239 -C "error"
6240
6241requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6242requires_config_enabled MBEDTLS_RSA_C
6243requires_config_enabled MBEDTLS_ECDSA_C
6244run_test "DTLS fragmenting: server (MTU)" \
6245 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6246 crt_file=data_files/server7_int-ca.crt \
6247 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006248 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006249 mtu=512" \
6250 "$P_CLI dtls=1 debug_level=2 \
6251 crt_file=data_files/server8_int-ca2.crt \
6252 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006253 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006254 mtu=2048" \
6255 0 \
6256 -S "found fragmented DTLS handshake message" \
6257 -c "found fragmented DTLS handshake message" \
6258 -C "error"
6259
6260requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6261requires_config_enabled MBEDTLS_RSA_C
6262requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006263run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006264 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006265 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6266 crt_file=data_files/server7_int-ca.crt \
6267 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006268 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006269 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006270 "$P_CLI dtls=1 debug_level=2 \
6271 crt_file=data_files/server8_int-ca2.crt \
6272 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006273 hs_timeout=2500-60000 \
6274 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006275 0 \
6276 -s "found fragmented DTLS handshake message" \
6277 -c "found fragmented DTLS handshake message" \
6278 -C "error"
6279
Andrzej Kurek77826052018-10-11 07:34:08 -04006280# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006281requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6282requires_config_enabled MBEDTLS_RSA_C
6283requires_config_enabled MBEDTLS_ECDSA_C
6284requires_config_enabled MBEDTLS_SHA256_C
6285requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6286requires_config_enabled MBEDTLS_AES_C
6287requires_config_enabled MBEDTLS_GCM_C
6288run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006289 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006290 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6291 crt_file=data_files/server7_int-ca.crt \
6292 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006293 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006294 mtu=512" \
6295 "$P_CLI dtls=1 debug_level=2 \
6296 crt_file=data_files/server8_int-ca2.crt \
6297 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006298 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6299 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006300 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006301 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006302 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006303 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006304 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006305
Andrzej Kurek7311c782018-10-11 06:49:41 -04006306# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006307# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006308# The ratio of max/min timeout should ideally equal 4 to accept two
6309# retransmissions, but in some cases (like both the server and client using
6310# fragmentation and auto-reduction) an extra retransmission might occur,
6311# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006312not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006313requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6314requires_config_enabled MBEDTLS_RSA_C
6315requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006316requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6317requires_config_enabled MBEDTLS_AES_C
6318requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006319run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6320 -p "$P_PXY mtu=508" \
6321 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6322 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006323 key_file=data_files/server7.key \
6324 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006325 "$P_CLI dtls=1 debug_level=2 \
6326 crt_file=data_files/server8_int-ca2.crt \
6327 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006328 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6329 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006330 0 \
6331 -s "found fragmented DTLS handshake message" \
6332 -c "found fragmented DTLS handshake message" \
6333 -C "error"
6334
Andrzej Kurek77826052018-10-11 07:34:08 -04006335# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006336only_with_valgrind
6337requires_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
Hanno Becker108992e2018-08-29 17:04:18 +01006343run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6344 -p "$P_PXY mtu=508" \
6345 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6346 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006347 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006348 hs_timeout=250-10000" \
6349 "$P_CLI dtls=1 debug_level=2 \
6350 crt_file=data_files/server8_int-ca2.crt \
6351 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006352 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006353 hs_timeout=250-10000" \
6354 0 \
6355 -s "found fragmented DTLS handshake message" \
6356 -c "found fragmented DTLS handshake message" \
6357 -C "error"
6358
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006359# 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 +02006360# OTOH the client might resend if the server is to slow to reset after sending
6361# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006362not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006363requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6364requires_config_enabled MBEDTLS_RSA_C
6365requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006366run_test "DTLS fragmenting: proxy MTU, simple handshake (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 Kurek52f84912018-10-05 07:53:40 -04006371 hs_timeout=10000-60000 \
6372 mtu=1024" \
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 Kurek52f84912018-10-05 07:53:40 -04006376 hs_timeout=10000-60000 \
6377 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006378 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006379 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006380 -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 -04006385# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6386# OTOH the client might resend if the server is to slow to reset after sending
6387# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006388not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006389requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6390requires_config_enabled MBEDTLS_RSA_C
6391requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006392requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6393requires_config_enabled MBEDTLS_AES_C
6394requires_config_enabled MBEDTLS_GCM_C
6395run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006396 -p "$P_PXY mtu=512" \
6397 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6398 crt_file=data_files/server7_int-ca.crt \
6399 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006400 hs_timeout=10000-60000 \
6401 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006402 "$P_CLI dtls=1 debug_level=2 \
6403 crt_file=data_files/server8_int-ca2.crt \
6404 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006405 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6406 hs_timeout=10000-60000 \
6407 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006408 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006409 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006410 -s "found fragmented DTLS handshake message" \
6411 -c "found fragmented DTLS handshake message" \
6412 -C "error"
6413
Andrzej Kurek7311c782018-10-11 06:49:41 -04006414not_with_valgrind # spurious autoreduction due to timeout
6415requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6416requires_config_enabled MBEDTLS_RSA_C
6417requires_config_enabled MBEDTLS_ECDSA_C
6418run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006419 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006420 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6421 crt_file=data_files/server7_int-ca.crt \
6422 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006423 hs_timeout=10000-60000 \
6424 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006425 "$P_CLI dtls=1 debug_level=2 \
6426 crt_file=data_files/server8_int-ca2.crt \
6427 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006428 hs_timeout=10000-60000 \
6429 mtu=1024 nbio=2" \
6430 0 \
6431 -S "autoreduction" \
6432 -s "found fragmented DTLS handshake message" \
6433 -c "found fragmented DTLS handshake message" \
6434 -C "error"
6435
Andrzej Kurek77826052018-10-11 07:34:08 -04006436# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006437not_with_valgrind # spurious autoreduction due to timeout
6438requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6439requires_config_enabled MBEDTLS_RSA_C
6440requires_config_enabled MBEDTLS_ECDSA_C
6441requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6442requires_config_enabled MBEDTLS_AES_C
6443requires_config_enabled MBEDTLS_GCM_C
6444run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6445 -p "$P_PXY mtu=512" \
6446 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6447 crt_file=data_files/server7_int-ca.crt \
6448 key_file=data_files/server7.key \
6449 hs_timeout=10000-60000 \
6450 mtu=512 nbio=2" \
6451 "$P_CLI dtls=1 debug_level=2 \
6452 crt_file=data_files/server8_int-ca2.crt \
6453 key_file=data_files/server8.key \
6454 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6455 hs_timeout=10000-60000 \
6456 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006457 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006458 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006459 -s "found fragmented DTLS handshake message" \
6460 -c "found fragmented DTLS handshake message" \
6461 -C "error"
6462
Andrzej Kurek77826052018-10-11 07:34:08 -04006463# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006464# This ensures things still work after session_reset().
6465# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006466# Since we don't support reading fragmented ClientHello yet,
6467# up the MTU to 1450 (larger than ClientHello with session ticket,
6468# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006469# An autoreduction on the client-side might happen if the server is
6470# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006471# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006472# resumed listening, which would result in a spurious autoreduction.
6473not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006474requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6475requires_config_enabled MBEDTLS_RSA_C
6476requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006477requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6478requires_config_enabled MBEDTLS_AES_C
6479requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006480run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6481 -p "$P_PXY mtu=1450" \
6482 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6483 crt_file=data_files/server7_int-ca.crt \
6484 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006485 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006486 mtu=1450" \
6487 "$P_CLI dtls=1 debug_level=2 \
6488 crt_file=data_files/server8_int-ca2.crt \
6489 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006490 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006491 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006492 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006493 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006494 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006495 -s "found fragmented DTLS handshake message" \
6496 -c "found fragmented DTLS handshake message" \
6497 -C "error"
6498
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006499# An autoreduction on the client-side might happen if the server is
6500# slow to reset, therefore omitting '-C "autoreduction"' below.
6501not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006502requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6503requires_config_enabled MBEDTLS_RSA_C
6504requires_config_enabled MBEDTLS_ECDSA_C
6505requires_config_enabled MBEDTLS_SHA256_C
6506requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6507requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6508requires_config_enabled MBEDTLS_CHACHAPOLY_C
6509run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6510 -p "$P_PXY mtu=512" \
6511 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6512 crt_file=data_files/server7_int-ca.crt \
6513 key_file=data_files/server7.key \
6514 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006515 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006516 mtu=512" \
6517 "$P_CLI dtls=1 debug_level=2 \
6518 crt_file=data_files/server8_int-ca2.crt \
6519 key_file=data_files/server8.key \
6520 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006521 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006522 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006523 mtu=512" \
6524 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006525 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006526 -s "found fragmented DTLS handshake message" \
6527 -c "found fragmented DTLS handshake message" \
6528 -C "error"
6529
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006530# An autoreduction on the client-side might happen if the server is
6531# slow to reset, therefore omitting '-C "autoreduction"' below.
6532not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006533requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6534requires_config_enabled MBEDTLS_RSA_C
6535requires_config_enabled MBEDTLS_ECDSA_C
6536requires_config_enabled MBEDTLS_SHA256_C
6537requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6538requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6539requires_config_enabled MBEDTLS_AES_C
6540requires_config_enabled MBEDTLS_GCM_C
6541run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6542 -p "$P_PXY mtu=512" \
6543 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6544 crt_file=data_files/server7_int-ca.crt \
6545 key_file=data_files/server7.key \
6546 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006547 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006548 mtu=512" \
6549 "$P_CLI dtls=1 debug_level=2 \
6550 crt_file=data_files/server8_int-ca2.crt \
6551 key_file=data_files/server8.key \
6552 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006553 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006554 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006555 mtu=512" \
6556 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006557 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006558 -s "found fragmented DTLS handshake message" \
6559 -c "found fragmented DTLS handshake message" \
6560 -C "error"
6561
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006562# An autoreduction on the client-side might happen if the server is
6563# slow to reset, therefore omitting '-C "autoreduction"' below.
6564not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006565requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6566requires_config_enabled MBEDTLS_RSA_C
6567requires_config_enabled MBEDTLS_ECDSA_C
6568requires_config_enabled MBEDTLS_SHA256_C
6569requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6570requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6571requires_config_enabled MBEDTLS_AES_C
6572requires_config_enabled MBEDTLS_CCM_C
6573run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006574 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006575 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6576 crt_file=data_files/server7_int-ca.crt \
6577 key_file=data_files/server7.key \
6578 exchanges=2 renegotiation=1 \
6579 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006580 hs_timeout=10000-60000 \
6581 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006582 "$P_CLI dtls=1 debug_level=2 \
6583 crt_file=data_files/server8_int-ca2.crt \
6584 key_file=data_files/server8.key \
6585 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006586 hs_timeout=10000-60000 \
6587 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006588 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006589 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006590 -s "found fragmented DTLS handshake message" \
6591 -c "found fragmented DTLS handshake message" \
6592 -C "error"
6593
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006594# An autoreduction on the client-side might happen if the server is
6595# slow to reset, therefore omitting '-C "autoreduction"' below.
6596not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006597requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6598requires_config_enabled MBEDTLS_RSA_C
6599requires_config_enabled MBEDTLS_ECDSA_C
6600requires_config_enabled MBEDTLS_SHA256_C
6601requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6602requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6603requires_config_enabled MBEDTLS_AES_C
6604requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6605requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6606run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006607 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006608 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6609 crt_file=data_files/server7_int-ca.crt \
6610 key_file=data_files/server7.key \
6611 exchanges=2 renegotiation=1 \
6612 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006613 hs_timeout=10000-60000 \
6614 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006615 "$P_CLI dtls=1 debug_level=2 \
6616 crt_file=data_files/server8_int-ca2.crt \
6617 key_file=data_files/server8.key \
6618 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006619 hs_timeout=10000-60000 \
6620 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006621 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006622 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006623 -s "found fragmented DTLS handshake message" \
6624 -c "found fragmented DTLS handshake message" \
6625 -C "error"
6626
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006627# An autoreduction on the client-side might happen if the server is
6628# slow to reset, therefore omitting '-C "autoreduction"' below.
6629not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006630requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6631requires_config_enabled MBEDTLS_RSA_C
6632requires_config_enabled MBEDTLS_ECDSA_C
6633requires_config_enabled MBEDTLS_SHA256_C
6634requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6635requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6636requires_config_enabled MBEDTLS_AES_C
6637requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6638run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006639 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006640 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6641 crt_file=data_files/server7_int-ca.crt \
6642 key_file=data_files/server7.key \
6643 exchanges=2 renegotiation=1 \
6644 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006645 hs_timeout=10000-60000 \
6646 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006647 "$P_CLI dtls=1 debug_level=2 \
6648 crt_file=data_files/server8_int-ca2.crt \
6649 key_file=data_files/server8.key \
6650 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006651 hs_timeout=10000-60000 \
6652 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006653 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006654 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006655 -s "found fragmented DTLS handshake message" \
6656 -c "found fragmented DTLS handshake message" \
6657 -C "error"
6658
Andrzej Kurek77826052018-10-11 07:34:08 -04006659# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006660requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6661requires_config_enabled MBEDTLS_RSA_C
6662requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006663requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6664requires_config_enabled MBEDTLS_AES_C
6665requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006666client_needs_more_time 2
6667run_test "DTLS fragmenting: proxy MTU + 3d" \
6668 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006669 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006670 crt_file=data_files/server7_int-ca.crt \
6671 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006672 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006673 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006674 crt_file=data_files/server8_int-ca2.crt \
6675 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006676 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006677 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006678 0 \
6679 -s "found fragmented DTLS handshake message" \
6680 -c "found fragmented DTLS handshake message" \
6681 -C "error"
6682
Andrzej Kurek77826052018-10-11 07:34:08 -04006683# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006684requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6685requires_config_enabled MBEDTLS_RSA_C
6686requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006687requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6688requires_config_enabled MBEDTLS_AES_C
6689requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006690client_needs_more_time 2
6691run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6692 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6693 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6694 crt_file=data_files/server7_int-ca.crt \
6695 key_file=data_files/server7.key \
6696 hs_timeout=250-10000 mtu=512 nbio=2" \
6697 "$P_CLI dtls=1 debug_level=2 \
6698 crt_file=data_files/server8_int-ca2.crt \
6699 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006700 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006701 hs_timeout=250-10000 mtu=512 nbio=2" \
6702 0 \
6703 -s "found fragmented DTLS handshake message" \
6704 -c "found fragmented DTLS handshake message" \
6705 -C "error"
6706
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006707# interop tests for DTLS fragmentating with reliable connection
6708#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006709# here and below we just want to test that the we fragment in a way that
6710# pleases other implementations, so we don't need the peer to fragment
6711requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6712requires_config_enabled MBEDTLS_RSA_C
6713requires_config_enabled MBEDTLS_ECDSA_C
6714requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006715requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006716run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6717 "$G_SRV -u" \
6718 "$P_CLI dtls=1 debug_level=2 \
6719 crt_file=data_files/server8_int-ca2.crt \
6720 key_file=data_files/server8.key \
6721 mtu=512 force_version=dtls1_2" \
6722 0 \
6723 -c "fragmenting handshake message" \
6724 -C "error"
6725
6726requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6727requires_config_enabled MBEDTLS_RSA_C
6728requires_config_enabled MBEDTLS_ECDSA_C
6729requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006730requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006731run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6732 "$G_SRV -u" \
6733 "$P_CLI dtls=1 debug_level=2 \
6734 crt_file=data_files/server8_int-ca2.crt \
6735 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006736 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006737 0 \
6738 -c "fragmenting handshake message" \
6739 -C "error"
6740
Hanno Beckerb9a00862018-08-28 10:20:22 +01006741# We use --insecure for the GnuTLS client because it expects
6742# the hostname / IP it connects to to be the name used in the
6743# certificate obtained from the server. Here, however, it
6744# connects to 127.0.0.1 while our test certificates use 'localhost'
6745# as the server name in the certificate. This will make the
6746# certifiate validation fail, but passing --insecure makes
6747# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006748requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6749requires_config_enabled MBEDTLS_RSA_C
6750requires_config_enabled MBEDTLS_ECDSA_C
6751requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006752requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006753requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006754run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006755 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006756 crt_file=data_files/server7_int-ca.crt \
6757 key_file=data_files/server7.key \
6758 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006759 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006760 0 \
6761 -s "fragmenting handshake message"
6762
Hanno Beckerb9a00862018-08-28 10:20:22 +01006763# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006764requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6765requires_config_enabled MBEDTLS_RSA_C
6766requires_config_enabled MBEDTLS_ECDSA_C
6767requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006768requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006769requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006770run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006771 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006772 crt_file=data_files/server7_int-ca.crt \
6773 key_file=data_files/server7.key \
6774 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006775 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006776 0 \
6777 -s "fragmenting handshake message"
6778
6779requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6780requires_config_enabled MBEDTLS_RSA_C
6781requires_config_enabled MBEDTLS_ECDSA_C
6782requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6783run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6784 "$O_SRV -dtls1_2 -verify 10" \
6785 "$P_CLI dtls=1 debug_level=2 \
6786 crt_file=data_files/server8_int-ca2.crt \
6787 key_file=data_files/server8.key \
6788 mtu=512 force_version=dtls1_2" \
6789 0 \
6790 -c "fragmenting handshake message" \
6791 -C "error"
6792
6793requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6794requires_config_enabled MBEDTLS_RSA_C
6795requires_config_enabled MBEDTLS_ECDSA_C
6796requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6797run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6798 "$O_SRV -dtls1 -verify 10" \
6799 "$P_CLI dtls=1 debug_level=2 \
6800 crt_file=data_files/server8_int-ca2.crt \
6801 key_file=data_files/server8.key \
6802 mtu=512 force_version=dtls1" \
6803 0 \
6804 -c "fragmenting handshake message" \
6805 -C "error"
6806
6807requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6808requires_config_enabled MBEDTLS_RSA_C
6809requires_config_enabled MBEDTLS_ECDSA_C
6810requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6811run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6812 "$P_SRV dtls=1 debug_level=2 \
6813 crt_file=data_files/server7_int-ca.crt \
6814 key_file=data_files/server7.key \
6815 mtu=512 force_version=dtls1_2" \
6816 "$O_CLI -dtls1_2" \
6817 0 \
6818 -s "fragmenting handshake message"
6819
6820requires_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_1
6824run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6825 "$P_SRV dtls=1 debug_level=2 \
6826 crt_file=data_files/server7_int-ca.crt \
6827 key_file=data_files/server7.key \
6828 mtu=512 force_version=dtls1" \
6829 "$O_CLI -dtls1" \
6830 0 \
6831 -s "fragmenting handshake message"
6832
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006833# interop tests for DTLS fragmentating with unreliable connection
6834#
6835# again we just want to test that the we fragment in a way that
6836# pleases other implementations, so we don't need the peer to fragment
6837requires_gnutls_next
6838requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6839requires_config_enabled MBEDTLS_RSA_C
6840requires_config_enabled MBEDTLS_ECDSA_C
6841requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006842client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006843run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6844 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6845 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006846 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006847 crt_file=data_files/server8_int-ca2.crt \
6848 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006849 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006850 0 \
6851 -c "fragmenting handshake message" \
6852 -C "error"
6853
6854requires_gnutls_next
6855requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6856requires_config_enabled MBEDTLS_RSA_C
6857requires_config_enabled MBEDTLS_ECDSA_C
6858requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006859client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006860run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6861 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6862 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006863 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006864 crt_file=data_files/server8_int-ca2.crt \
6865 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006866 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006867 0 \
6868 -c "fragmenting handshake message" \
6869 -C "error"
6870
k-stachowiakabb843e2019-02-18 16:14:03 +01006871requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006872requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6873requires_config_enabled MBEDTLS_RSA_C
6874requires_config_enabled MBEDTLS_ECDSA_C
6875requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6876client_needs_more_time 4
6877run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6878 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6879 "$P_SRV dtls=1 debug_level=2 \
6880 crt_file=data_files/server7_int-ca.crt \
6881 key_file=data_files/server7.key \
6882 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006883 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006884 0 \
6885 -s "fragmenting handshake message"
6886
k-stachowiakabb843e2019-02-18 16:14:03 +01006887requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006888requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6889requires_config_enabled MBEDTLS_RSA_C
6890requires_config_enabled MBEDTLS_ECDSA_C
6891requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6892client_needs_more_time 4
6893run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6894 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6895 "$P_SRV dtls=1 debug_level=2 \
6896 crt_file=data_files/server7_int-ca.crt \
6897 key_file=data_files/server7.key \
6898 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006899 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006900 0 \
6901 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006903## Interop test with OpenSSL might trigger a bug in recent versions (including
6904## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006905## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006906## They should be re-enabled once a fixed version of OpenSSL is available
6907## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006908skip_next_test
6909requires_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_2
6913client_needs_more_time 4
6914run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6915 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6916 "$O_SRV -dtls1_2 -verify 10" \
6917 "$P_CLI dtls=1 debug_level=2 \
6918 crt_file=data_files/server8_int-ca2.crt \
6919 key_file=data_files/server8.key \
6920 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6921 0 \
6922 -c "fragmenting handshake message" \
6923 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006924
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006925skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006926requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6927requires_config_enabled MBEDTLS_RSA_C
6928requires_config_enabled MBEDTLS_ECDSA_C
6929requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006930client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006931run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6932 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006933 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006934 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006935 crt_file=data_files/server8_int-ca2.crt \
6936 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006937 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006938 0 \
6939 -c "fragmenting handshake message" \
6940 -C "error"
6941
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006942skip_next_test
6943requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6944requires_config_enabled MBEDTLS_RSA_C
6945requires_config_enabled MBEDTLS_ECDSA_C
6946requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6947client_needs_more_time 4
6948run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6949 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6950 "$P_SRV dtls=1 debug_level=2 \
6951 crt_file=data_files/server7_int-ca.crt \
6952 key_file=data_files/server7.key \
6953 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6954 "$O_CLI -dtls1_2" \
6955 0 \
6956 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006957
6958# -nbio is added to prevent s_client from blocking in case of duplicated
6959# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006960skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006961requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6962requires_config_enabled MBEDTLS_RSA_C
6963requires_config_enabled MBEDTLS_ECDSA_C
6964requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006965client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006966run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
6967 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006968 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006969 crt_file=data_files/server7_int-ca.crt \
6970 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006971 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006972 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006973 0 \
6974 -s "fragmenting handshake message"
6975
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006976# Tests for specific things with "unreliable" UDP connection
6977
6978not_with_valgrind # spurious resend due to timeout
6979run_test "DTLS proxy: reference" \
6980 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006981 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
6982 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006983 0 \
6984 -C "replayed record" \
6985 -S "replayed record" \
6986 -C "record from another epoch" \
6987 -S "record from another epoch" \
6988 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006989 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006990 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006991 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006992 -c "HTTP/1.0 200 OK"
6993
6994not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006995run_test "DTLS proxy: duplicate every packet" \
6996 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006997 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
6998 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006999 0 \
7000 -c "replayed record" \
7001 -s "replayed record" \
7002 -c "record from another epoch" \
7003 -s "record from another epoch" \
7004 -S "resend" \
7005 -s "Extra-header:" \
7006 -c "HTTP/1.0 200 OK"
7007
7008run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7009 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007010 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7011 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007012 0 \
7013 -c "replayed record" \
7014 -S "replayed record" \
7015 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007016 -s "record from another epoch" \
7017 -c "resend" \
7018 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007019 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007020 -c "HTTP/1.0 200 OK"
7021
7022run_test "DTLS proxy: multiple records in same datagram" \
7023 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007024 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7025 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007026 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007027 -c "next record in same datagram" \
7028 -s "next record in same datagram"
7029
7030run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7031 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007032 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7033 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007034 0 \
7035 -c "next record in same datagram" \
7036 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007037
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007038run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7039 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007040 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7041 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007042 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007043 -c "discarding invalid record (mac)" \
7044 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007045 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007046 -c "HTTP/1.0 200 OK" \
7047 -S "too many records with bad MAC" \
7048 -S "Verification of the message MAC failed"
7049
7050run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
7051 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007052 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7053 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007054 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007055 -C "discarding invalid record (mac)" \
7056 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007057 -S "Extra-header:" \
7058 -C "HTTP/1.0 200 OK" \
7059 -s "too many records with bad MAC" \
7060 -s "Verification of the message MAC failed"
7061
7062run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7063 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007064 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7065 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007066 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007067 -c "discarding invalid record (mac)" \
7068 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007069 -s "Extra-header:" \
7070 -c "HTTP/1.0 200 OK" \
7071 -S "too many records with bad MAC" \
7072 -S "Verification of the message MAC failed"
7073
7074run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7075 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007076 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7077 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007078 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007079 -c "discarding invalid record (mac)" \
7080 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007081 -s "Extra-header:" \
7082 -c "HTTP/1.0 200 OK" \
7083 -s "too many records with bad MAC" \
7084 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007085
7086run_test "DTLS proxy: delay ChangeCipherSpec" \
7087 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007088 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7089 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007090 0 \
7091 -c "record from another epoch" \
7092 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007093 -s "Extra-header:" \
7094 -c "HTTP/1.0 200 OK"
7095
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007096# Tests for reordering support with DTLS
7097
Hanno Becker56cdfd12018-08-17 13:42:15 +01007098run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7099 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007100 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7101 hs_timeout=2500-60000" \
7102 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7103 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007104 0 \
7105 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007106 -c "Next handshake message has been buffered - load"\
7107 -S "Buffering HS message" \
7108 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007109 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007110 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007111 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007112 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007113
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007114run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7115 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007116 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7117 hs_timeout=2500-60000" \
7118 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7119 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007120 0 \
7121 -c "Buffering HS message" \
7122 -c "found fragmented DTLS handshake message"\
7123 -c "Next handshake message 1 not or only partially bufffered" \
7124 -c "Next handshake message has been buffered - load"\
7125 -S "Buffering HS message" \
7126 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007127 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007128 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007129 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007130 -S "Remember CCS message"
7131
Hanno Beckera1adcca2018-08-24 14:41:07 +01007132# The client buffers the ServerKeyExchange before receiving the fragmented
7133# Certificate message; at the time of writing, together these are aroudn 1200b
7134# in size, so that the bound below ensures that the certificate can be reassembled
7135# while keeping the ServerKeyExchange.
7136requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7137run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007138 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007139 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7140 hs_timeout=2500-60000" \
7141 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7142 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007143 0 \
7144 -c "Buffering HS message" \
7145 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007146 -C "attempt to make space by freeing buffered messages" \
7147 -S "Buffering HS message" \
7148 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007149 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007150 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007151 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007152 -S "Remember CCS message"
7153
7154# The size constraints ensure that the delayed certificate message can't
7155# be reassembled while keeping the ServerKeyExchange message, but it can
7156# when dropping it first.
7157requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7158requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7159run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7160 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007161 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7162 hs_timeout=2500-60000" \
7163 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7164 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007165 0 \
7166 -c "Buffering HS message" \
7167 -c "attempt to make space by freeing buffered future messages" \
7168 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007169 -S "Buffering HS message" \
7170 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007171 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007172 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007173 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007174 -S "Remember CCS message"
7175
Hanno Becker56cdfd12018-08-17 13:42:15 +01007176run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7177 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007178 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7179 hs_timeout=2500-60000" \
7180 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7181 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007182 0 \
7183 -C "Buffering HS message" \
7184 -C "Next handshake message has been buffered - load"\
7185 -s "Buffering HS message" \
7186 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007187 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007188 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007189 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007190 -S "Remember CCS message"
7191
7192run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7193 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007194 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7195 hs_timeout=2500-60000" \
7196 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7197 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007198 0 \
7199 -C "Buffering HS message" \
7200 -C "Next handshake message has been buffered - load"\
7201 -S "Buffering HS message" \
7202 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007203 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007204 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007205 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007206 -S "Remember CCS message"
7207
7208run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7209 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007210 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7211 hs_timeout=2500-60000" \
7212 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7213 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007214 0 \
7215 -C "Buffering HS message" \
7216 -C "Next handshake message has been buffered - load"\
7217 -S "Buffering HS message" \
7218 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007219 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007220 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007221 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007222 -s "Remember CCS message"
7223
Hanno Beckera1adcca2018-08-24 14:41:07 +01007224run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007225 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007226 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7227 hs_timeout=2500-60000" \
7228 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7229 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007230 0 \
7231 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007232 -s "Found buffered record from current epoch - load" \
7233 -c "Buffer record from epoch 1" \
7234 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007235
Hanno Beckera1adcca2018-08-24 14:41:07 +01007236# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7237# from the server are delayed, so that the encrypted Finished message
7238# is received and buffered. When the fragmented NewSessionTicket comes
7239# in afterwards, the encrypted Finished message must be freed in order
7240# to make space for the NewSessionTicket to be reassembled.
7241# This works only in very particular circumstances:
7242# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7243# of the NewSessionTicket, but small enough to also allow buffering of
7244# the encrypted Finished message.
7245# - The MTU setting on the server must be so small that the NewSessionTicket
7246# needs to be fragmented.
7247# - All messages sent by the server must be small enough to be either sent
7248# without fragmentation or be reassembled within the bounds of
7249# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7250# handshake, omitting CRTs.
7251requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7252requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7253run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7254 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7255 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7256 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7257 0 \
7258 -s "Buffer record from epoch 1" \
7259 -s "Found buffered record from current epoch - load" \
7260 -c "Buffer record from epoch 1" \
7261 -C "Found buffered record from current epoch - load" \
7262 -c "Enough space available after freeing future epoch record"
7263
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007264# Tests for "randomly unreliable connection": try a variety of flows and peers
7265
7266client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007267run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7268 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007269 "$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 +02007270 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007271 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007272 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7273 0 \
7274 -s "Extra-header:" \
7275 -c "HTTP/1.0 200 OK"
7276
Janos Follath74537a62016-09-02 13:45:28 +01007277client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007278run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7279 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007280 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7281 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007282 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7283 0 \
7284 -s "Extra-header:" \
7285 -c "HTTP/1.0 200 OK"
7286
Janos Follath74537a62016-09-02 13:45:28 +01007287client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007288run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7289 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007290 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7291 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007292 0 \
7293 -s "Extra-header:" \
7294 -c "HTTP/1.0 200 OK"
7295
Janos Follath74537a62016-09-02 13:45:28 +01007296client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007297run_test "DTLS proxy: 3d, FS, client auth" \
7298 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007299 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7300 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007301 0 \
7302 -s "Extra-header:" \
7303 -c "HTTP/1.0 200 OK"
7304
Janos Follath74537a62016-09-02 13:45:28 +01007305client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007306run_test "DTLS proxy: 3d, FS, ticket" \
7307 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007308 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7309 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007310 0 \
7311 -s "Extra-header:" \
7312 -c "HTTP/1.0 200 OK"
7313
Janos Follath74537a62016-09-02 13:45:28 +01007314client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007315run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7316 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007317 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7318 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007319 0 \
7320 -s "Extra-header:" \
7321 -c "HTTP/1.0 200 OK"
7322
Janos Follath74537a62016-09-02 13:45:28 +01007323client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007324run_test "DTLS proxy: 3d, max handshake, nbio" \
7325 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007326 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007327 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007328 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007329 0 \
7330 -s "Extra-header:" \
7331 -c "HTTP/1.0 200 OK"
7332
Janos Follath74537a62016-09-02 13:45:28 +01007333client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007334run_test "DTLS proxy: 3d, min handshake, resumption" \
7335 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007336 "$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 +02007337 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007338 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007339 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007340 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7341 0 \
7342 -s "a session has been resumed" \
7343 -c "a session has been resumed" \
7344 -s "Extra-header:" \
7345 -c "HTTP/1.0 200 OK"
7346
Janos Follath74537a62016-09-02 13:45:28 +01007347client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007348run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7349 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007350 "$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 +02007351 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007352 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007353 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007354 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7355 0 \
7356 -s "a session has been resumed" \
7357 -c "a session has been resumed" \
7358 -s "Extra-header:" \
7359 -c "HTTP/1.0 200 OK"
7360
Janos Follath74537a62016-09-02 13:45:28 +01007361client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007362requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007363run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007364 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007365 "$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 +02007366 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007367 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007368 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007369 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7370 0 \
7371 -c "=> renegotiate" \
7372 -s "=> renegotiate" \
7373 -s "Extra-header:" \
7374 -c "HTTP/1.0 200 OK"
7375
Janos Follath74537a62016-09-02 13:45:28 +01007376client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007377requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007378run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7379 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007380 "$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 +02007381 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007382 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007383 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007384 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7385 0 \
7386 -c "=> renegotiate" \
7387 -s "=> renegotiate" \
7388 -s "Extra-header:" \
7389 -c "HTTP/1.0 200 OK"
7390
Janos Follath74537a62016-09-02 13:45:28 +01007391client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007392requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007393run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007394 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007395 "$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 +02007396 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007397 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007398 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007399 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007400 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7401 0 \
7402 -c "=> renegotiate" \
7403 -s "=> renegotiate" \
7404 -s "Extra-header:" \
7405 -c "HTTP/1.0 200 OK"
7406
Janos Follath74537a62016-09-02 13:45:28 +01007407client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007408requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007409run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007410 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007411 "$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 +02007412 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007413 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007414 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007415 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007416 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7417 0 \
7418 -c "=> renegotiate" \
7419 -s "=> renegotiate" \
7420 -s "Extra-header:" \
7421 -c "HTTP/1.0 200 OK"
7422
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007423## Interop tests with OpenSSL might trigger a bug in recent versions (including
7424## all versions installed on the CI machines), reported here:
7425## Bug report: https://github.com/openssl/openssl/issues/6902
7426## They should be re-enabled once a fixed version of OpenSSL is available
7427## (this should happen in some 1.1.1_ release according to the ticket).
7428skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007429client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007430not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007431run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007432 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7433 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007434 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007435 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007436 -c "HTTP/1.0 200 OK"
7437
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007438skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007439client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007440not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007441run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7442 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7443 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007444 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007445 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007446 -c "HTTP/1.0 200 OK"
7447
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007448skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007449client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007450not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007451run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7452 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7453 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007454 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007455 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007456 -c "HTTP/1.0 200 OK"
7457
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007458requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007459client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007460not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007461run_test "DTLS proxy: 3d, gnutls server" \
7462 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7463 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007464 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007465 0 \
7466 -s "Extra-header:" \
7467 -c "Extra-header:"
7468
k-stachowiakabb843e2019-02-18 16:14:03 +01007469requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007470client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007471not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007472run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7473 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007474 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007475 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007476 0 \
7477 -s "Extra-header:" \
7478 -c "Extra-header:"
7479
k-stachowiakabb843e2019-02-18 16:14:03 +01007480requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007481client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007482not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007483run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7484 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007485 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007486 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007487 0 \
7488 -s "Extra-header:" \
7489 -c "Extra-header:"
7490
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007491# Final report
7492
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007493echo "------------------------------------------------------------------------"
7494
7495if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007496 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007497else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007498 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007499fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007500PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007501echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007502
7503exit $FAILS