blob: e40c3150f0130d31b29243aa816b688645ec479a [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Bence Szépkútia2947ac2020-08-19 16:37:36 +02005# Copyright The Mbed TLS Contributors
Bence Szépkútif744bd72020-06-05 13:02:18 +02006# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7#
8# This file is provided under the Apache License 2.0, or the
9# GNU General Public License v2.0 or later.
10#
11# **********
12# Apache License 2.0:
Bence Szépkúti51b41d52020-05-26 01:54:15 +020013#
14# Licensed under the Apache License, Version 2.0 (the "License"); you may
15# not use this file except in compliance with the License.
16# You may obtain a copy of the License at
17#
18# http://www.apache.org/licenses/LICENSE-2.0
19#
20# Unless required by applicable law or agreed to in writing, software
21# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23# See the License for the specific language governing permissions and
24# limitations under the License.
25#
Bence Szépkútif744bd72020-06-05 13:02:18 +020026# **********
27#
28# **********
29# GNU General Public License v2.0 or later:
30#
31# This program is free software; you can redistribute it and/or modify
32# it under the terms of the GNU General Public License as published by
33# the Free Software Foundation; either version 2 of the License, or
34# (at your option) any later version.
35#
36# This program is distributed in the hope that it will be useful,
37# but WITHOUT ANY WARRANTY; without even the implied warranty of
38# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39# GNU General Public License for more details.
40#
41# You should have received a copy of the GNU General Public License along
42# with this program; if not, write to the Free Software Foundation, Inc.,
43# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
44#
45# **********
46#
Simon Butcher58eddef2016-05-19 23:43:11 +010047# Purpose
48#
49# Executes tests to prove various TLS/SSL options and extensions.
50#
51# The goal is not to cover every ciphersuite/version, but instead to cover
52# specific options (max fragment length, truncated hmac, etc) or procedures
53# (session resumption from cache or ticket, renego, etc).
54#
55# The tests assume a build with default options, with exceptions expressed
56# with a dependency. The tests focus on functionality and do not consider
57# performance.
58#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010059
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010060set -u
61
Jaeden Ameroa258ccd2019-07-03 13:51:04 +010062# Limit the size of each log to 10 GiB, in case of failures with this script
63# where it may output seemingly unlimited length error logs.
64ulimit -f 20971520
65
Angus Grattonc4dd0732018-04-11 16:28:39 +100066if cd $( dirname $0 ); then :; else
67 echo "cd $( dirname $0 ) failed" >&2
68 exit 1
69fi
70
Antonin Décimod5f47592019-01-23 15:24:37 +010071# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010072: ${P_SRV:=../programs/ssl/ssl_server2}
73: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020074: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010075: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020076: ${GNUTLS_CLI:=gnutls-cli}
77: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020078: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010079
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020080O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010081O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020082G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010083G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020084TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010085
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020086# alternative versions of OpenSSL and GnuTLS (no default path)
87
88if [ -n "${OPENSSL_LEGACY:-}" ]; then
89 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
90 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
91else
92 O_LEGACY_SRV=false
93 O_LEGACY_CLI=false
94fi
95
Hanno Becker58e9dc32018-08-17 15:53:21 +010096if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020097 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
98else
99 G_NEXT_SRV=false
100fi
101
Hanno Becker58e9dc32018-08-17 15:53:21 +0100102if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200103 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
104else
105 G_NEXT_CLI=false
106fi
107
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100108TESTS=0
109FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200110SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100111
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000112CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +0200113
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100114MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100115FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200116EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100117
Paul Bakkere20310a2016-05-10 11:18:17 +0100118SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +0100119RUN_TEST_NUMBER=''
120
Paul Bakkeracaac852016-05-10 11:47:13 +0100121PRESERVE_LOGS=0
122
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200123# Pick a "unique" server port in the range 10000-19999, and a proxy
124# port which is this plus 10000. Each port number may be independently
125# overridden by a command line option.
126SRV_PORT=$(($$ % 10000 + 10000))
127PXY_PORT=$((SRV_PORT + 10000))
128
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100129print_usage() {
130 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100131 printf " -h|--help\tPrint this help.\n"
132 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskine663d0992020-08-26 22:50:38 +0200133 printf " -f|--filter\tOnly matching tests are executed (BRE)\n"
134 printf " -e|--exclude\tMatching tests are excluded (BRE)\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100135 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100136 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100137 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200138 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
139 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100140 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100141}
142
143get_options() {
144 while [ $# -gt 0 ]; do
145 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100146 -f|--filter)
147 shift; FILTER=$1
148 ;;
149 -e|--exclude)
150 shift; EXCLUDE=$1
151 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100152 -m|--memcheck)
153 MEMCHECK=1
154 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100155 -n|--number)
156 shift; RUN_TEST_NUMBER=$1
157 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100158 -s|--show-numbers)
159 SHOW_TEST_NUMBER=1
160 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100161 -p|--preserve-logs)
162 PRESERVE_LOGS=1
163 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200164 --port)
165 shift; SRV_PORT=$1
166 ;;
167 --proxy-port)
168 shift; PXY_PORT=$1
169 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100170 --seed)
171 shift; SEED="$1"
172 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100173 -h|--help)
174 print_usage
175 exit 0
176 ;;
177 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200178 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100179 print_usage
180 exit 1
181 ;;
182 esac
183 shift
184 done
185}
186
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
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100583 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
584 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200585 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100586 return
587 fi
588
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100589 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100590
Paul Bakkerb7584a52016-05-10 10:50:43 +0100591 # Do we only run numbered tests?
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200592 if [ -n "$RUN_TEST_NUMBER" ]; then
593 case ",$RUN_TEST_NUMBER," in
594 *",$TESTS,"*) :;;
595 *) SKIP_NEXT="YES";;
596 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100597 fi
598
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200599 # should we skip?
600 if [ "X$SKIP_NEXT" = "XYES" ]; then
601 SKIP_NEXT="NO"
602 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200603 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200604 return
605 fi
606
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200607 # does this test use a proxy?
608 if [ "X$1" = "X-p" ]; then
609 PXY_CMD="$2"
610 shift 2
611 else
612 PXY_CMD=""
613 fi
614
615 # get commands and client output
616 SRV_CMD="$1"
617 CLI_CMD="$2"
618 CLI_EXPECT="$3"
619 shift 3
620
Hanno Becker7a11e722019-05-10 14:38:42 +0100621 # Check if test uses files
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200622 case "$SRV_CMD $CLI_CMD" in
623 *data_files/*)
624 requires_config_enabled MBEDTLS_FS_IO;;
625 esac
Hanno Becker7a11e722019-05-10 14:38:42 +0100626
627 # should we skip?
628 if [ "X$SKIP_NEXT" = "XYES" ]; then
629 SKIP_NEXT="NO"
630 echo "SKIP"
631 SKIPS=$(( $SKIPS + 1 ))
632 return
633 fi
634
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200635 # update DTLS variable
636 detect_dtls "$SRV_CMD"
637
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200638 # if the test uses DTLS but no custom proxy, add a simple proxy
639 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200640 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200641 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200642 case " $SRV_CMD " in
643 *' server_addr=::1 '*)
644 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
645 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200646 fi
647
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200648 # fix client port
649 if [ -n "$PXY_CMD" ]; then
650 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
651 else
652 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
653 fi
654
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100655 # prepend valgrind to our commands if active
656 if [ "$MEMCHECK" -gt 0 ]; then
657 if is_polar "$SRV_CMD"; then
658 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
659 fi
660 if is_polar "$CLI_CMD"; then
661 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
662 fi
663 fi
664
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200665 TIMES_LEFT=2
666 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200667 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200668
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200669 # run the commands
670 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda1919ad2020-07-27 09:45:32 +0200671 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200672 $PXY_CMD >> $PXY_OUT 2>&1 &
673 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400674 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200675 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200676
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200677 check_osrv_dtls
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200678 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200679 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
680 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100681 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200682
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200683 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200684 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
685 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100686
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100687 sleep 0.05
688
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200689 # terminate the server (and the proxy)
690 kill $SRV_PID
691 wait $SRV_PID
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
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100725 # check server exit code
726 if [ $? != 0 ]; then
727 fail "server fail"
728 return
729 fi
730
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100731 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100732 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
733 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100734 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200735 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100736 return
737 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100738
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100739 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200740 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100741 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100742 while [ $# -gt 0 ]
743 do
744 case $1 in
745 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100746 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 +0100747 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100748 return
749 fi
750 ;;
751
752 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100753 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 +0100754 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100755 return
756 fi
757 ;;
758
759 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100760 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 +0100761 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100762 return
763 fi
764 ;;
765
766 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100767 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 +0100768 fail "pattern '$2' MUST NOT be present in the Client output"
769 return
770 fi
771 ;;
772
773 # The filtering in the following two options (-u and -U) do the following
774 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100775 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100776 # - keep one of each non-unique line
777 # - count how many lines remain
778 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
779 # if there were no duplicates.
780 "-U")
781 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
782 fail "lines following pattern '$2' must be unique in Server output"
783 return
784 fi
785 ;;
786
787 "-u")
788 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
789 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100790 return
791 fi
792 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100793 "-F")
794 if ! $2 "$SRV_OUT"; then
795 fail "function call to '$2' failed on Server output"
796 return
797 fi
798 ;;
799 "-f")
800 if ! $2 "$CLI_OUT"; then
801 fail "function call to '$2' failed on Client output"
802 return
803 fi
804 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100805
806 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200807 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100808 exit 1
809 esac
810 shift 2
811 done
812
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100813 # check valgrind's results
814 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200815 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100816 fail "Server has memory errors"
817 return
818 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200819 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100820 fail "Client has memory errors"
821 return
822 fi
823 fi
824
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100825 # if we're here, everything is ok
826 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100827 if [ "$PRESERVE_LOGS" -gt 0 ]; then
828 mv $SRV_OUT o-srv-${TESTS}.log
829 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100830 if [ -n "$PXY_CMD" ]; then
831 mv $PXY_OUT o-pxy-${TESTS}.log
832 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100833 fi
834
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200835 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100836}
837
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100838cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200839 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200840 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
841 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
842 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
843 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100844 exit 1
845}
846
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100847#
848# MAIN
849#
850
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100851get_options "$@"
852
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100853# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100854P_SRV_BIN="${P_SRV%%[ ]*}"
855P_CLI_BIN="${P_CLI%%[ ]*}"
856P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100857if [ ! -x "$P_SRV_BIN" ]; then
858 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100859 exit 1
860fi
Hanno Becker17c04932017-10-10 14:44:53 +0100861if [ ! -x "$P_CLI_BIN" ]; then
862 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100863 exit 1
864fi
Hanno Becker17c04932017-10-10 14:44:53 +0100865if [ ! -x "$P_PXY_BIN" ]; then
866 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200867 exit 1
868fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100869if [ "$MEMCHECK" -gt 0 ]; then
870 if which valgrind >/dev/null 2>&1; then :; else
871 echo "Memcheck not possible. Valgrind not found"
872 exit 1
873 fi
874fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100875if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
876 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100877 exit 1
878fi
879
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200880# used by watchdog
881MAIN_PID="$$"
882
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100883# We use somewhat arbitrary delays for tests:
884# - how long do we wait for the server to start (when lsof not available)?
885# - how long do we allow for the client to finish?
886# (not to check performance, just to avoid waiting indefinitely)
887# Things are slower with valgrind, so give extra time here.
888#
889# Note: without lsof, there is a trade-off between the running time of this
890# script and the risk of spurious errors because we didn't wait long enough.
891# The watchdog delay on the other hand doesn't affect normal running time of
892# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200893if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100894 START_DELAY=6
895 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200896else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100897 START_DELAY=2
898 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200899fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100900
901# some particular tests need more time:
902# - for the client, we multiply the usual watchdog limit by a factor
903# - for the server, we sleep for a number of seconds after the client exits
904# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200905CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100906SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200907
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200908# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000909# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200910P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
911P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100912P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200913O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200914O_CLI="$O_CLI -connect localhost:+SRV_PORT"
915G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200916G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200917
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200918if [ -n "${OPENSSL_LEGACY:-}" ]; then
919 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
920 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
921fi
922
Hanno Becker58e9dc32018-08-17 15:53:21 +0100923if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200924 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
925fi
926
Hanno Becker58e9dc32018-08-17 15:53:21 +0100927if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200928 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200929fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100930
Gilles Peskine62469d92017-05-10 10:13:59 +0200931# Allow SHA-1, because many of our test certificates use it
932P_SRV="$P_SRV allow_sha1=1"
933P_CLI="$P_CLI allow_sha1=1"
934
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200935# Also pick a unique name for intermediate files
936SRV_OUT="srv_out.$$"
937CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200938PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200939SESSION="session.$$"
940
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200941SKIP_NEXT="NO"
942
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100943trap cleanup INT TERM HUP
944
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200945# Basic test
946
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200947# Checks that:
948# - things work with all ciphersuites active (used with config-full in all.sh)
949# - the expected (highest security) parameters are selected
950# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200951run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200952 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200953 "$P_CLI" \
954 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200955 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200956 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200957 -s "client hello v3, signature_algorithm ext: 6" \
958 -s "ECDHE curve: secp521r1" \
959 -S "error" \
960 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200961
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000962run_test "Default, DTLS" \
963 "$P_SRV dtls=1" \
964 "$P_CLI dtls=1" \
965 0 \
966 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200967 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000968
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +0100969requires_config_enabled MBEDTLS_ZLIB_SUPPORT
970run_test "Default (compression enabled)" \
971 "$P_SRV debug_level=3" \
972 "$P_CLI debug_level=3" \
973 0 \
974 -s "Allocating compression buffer" \
975 -c "Allocating compression buffer" \
976 -s "Record expansion is unknown (compression)" \
977 -c "Record expansion is unknown (compression)" \
978 -S "error" \
979 -C "error"
980
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100981# Test current time in ServerHello
982requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200983run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100984 "$P_SRV debug_level=3" \
985 "$P_CLI debug_level=3" \
986 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100987 -f "check_server_hello_time" \
988 -F "check_server_hello_time"
989
Simon Butcher8e004102016-10-14 00:48:33 +0100990# Test for uniqueness of IVs in AEAD ciphersuites
991run_test "Unique IV in GCM" \
992 "$P_SRV exchanges=20 debug_level=4" \
993 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
994 0 \
995 -u "IV used" \
996 -U "IV used"
997
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100998# Tests for rc4 option
999
Simon Butchera410af52016-05-19 22:12:18 +01001000requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001001run_test "RC4: server disabled, client enabled" \
1002 "$P_SRV" \
1003 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1004 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001005 -s "SSL - The server has no ciphersuites in common"
1006
Simon Butchera410af52016-05-19 22:12:18 +01001007requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001008run_test "RC4: server half, client enabled" \
1009 "$P_SRV arc4=1" \
1010 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1011 1 \
1012 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001013
1014run_test "RC4: server enabled, client disabled" \
1015 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1016 "$P_CLI" \
1017 1 \
1018 -s "SSL - The server has no ciphersuites in common"
1019
1020run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001021 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001022 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1023 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001024 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001025 -S "SSL - The server has no ciphersuites in common"
1026
Hanno Beckerd26bb202018-08-17 09:54:10 +01001027# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1028
1029requires_gnutls
1030requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1031run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1032 "$G_SRV"\
1033 "$P_CLI force_version=tls1_1" \
1034 0
1035
1036requires_gnutls
1037requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1038run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1039 "$G_SRV"\
1040 "$P_CLI force_version=tls1" \
1041 0
1042
Gilles Peskinebc70a182017-05-09 15:59:24 +02001043# Tests for SHA-1 support
1044
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001045requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001046run_test "SHA-1 forbidden by default in server certificate" \
1047 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1048 "$P_CLI debug_level=2 allow_sha1=0" \
1049 1 \
1050 -c "The certificate is signed with an unacceptable hash"
1051
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001052requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1053run_test "SHA-1 forbidden by default in server certificate" \
1054 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1055 "$P_CLI debug_level=2 allow_sha1=0" \
1056 0
1057
Gilles Peskinebc70a182017-05-09 15:59:24 +02001058run_test "SHA-1 explicitly allowed in server certificate" \
1059 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1060 "$P_CLI allow_sha1=1" \
1061 0
1062
1063run_test "SHA-256 allowed by default in server certificate" \
1064 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1065 "$P_CLI allow_sha1=0" \
1066 0
1067
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001068requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001069run_test "SHA-1 forbidden by default in client certificate" \
1070 "$P_SRV auth_mode=required allow_sha1=0" \
1071 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1072 1 \
1073 -s "The certificate is signed with an unacceptable hash"
1074
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001075requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1076run_test "SHA-1 forbidden by default in client certificate" \
1077 "$P_SRV auth_mode=required allow_sha1=0" \
1078 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1079 0
1080
Gilles Peskinebc70a182017-05-09 15:59:24 +02001081run_test "SHA-1 explicitly allowed in client certificate" \
1082 "$P_SRV auth_mode=required allow_sha1=1" \
1083 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1084 0
1085
1086run_test "SHA-256 allowed by default in client certificate" \
1087 "$P_SRV auth_mode=required allow_sha1=0" \
1088 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1089 0
1090
Hanno Becker7ae8a762018-08-14 15:43:35 +01001091# Tests for datagram packing
1092run_test "DTLS: multiple records in same datagram, client and server" \
1093 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1094 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1095 0 \
1096 -c "next record in same datagram" \
1097 -s "next record in same datagram"
1098
1099run_test "DTLS: multiple records in same datagram, client only" \
1100 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1101 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1102 0 \
1103 -s "next record in same datagram" \
1104 -C "next record in same datagram"
1105
1106run_test "DTLS: multiple records in same datagram, server only" \
1107 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1108 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1109 0 \
1110 -S "next record in same datagram" \
1111 -c "next record in same datagram"
1112
1113run_test "DTLS: multiple records in same datagram, neither client nor server" \
1114 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1115 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1116 0 \
1117 -S "next record in same datagram" \
1118 -C "next record in same datagram"
1119
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001120# Tests for Truncated HMAC extension
1121
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001122run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001123 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001124 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001125 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001126 -s "dumping 'expected mac' (20 bytes)" \
1127 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001128
Hanno Becker32c55012017-11-10 08:42:54 +00001129requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001130run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001131 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001132 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001133 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001134 -s "dumping 'expected mac' (20 bytes)" \
1135 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001136
Hanno Becker32c55012017-11-10 08:42:54 +00001137requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001138run_test "Truncated HMAC: client enabled, server default" \
1139 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001140 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001141 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001142 -s "dumping 'expected mac' (20 bytes)" \
1143 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001144
Hanno Becker32c55012017-11-10 08:42:54 +00001145requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001146run_test "Truncated HMAC: client enabled, server disabled" \
1147 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001148 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001149 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001150 -s "dumping 'expected mac' (20 bytes)" \
1151 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001152
Hanno Becker32c55012017-11-10 08:42:54 +00001153requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001154run_test "Truncated HMAC: client disabled, server enabled" \
1155 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001156 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001157 0 \
1158 -s "dumping 'expected mac' (20 bytes)" \
1159 -S "dumping 'expected mac' (10 bytes)"
1160
1161requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001162run_test "Truncated HMAC: client enabled, server enabled" \
1163 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001164 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001165 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001166 -S "dumping 'expected mac' (20 bytes)" \
1167 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001168
Hanno Becker4c4f4102017-11-10 09:16:05 +00001169run_test "Truncated HMAC, DTLS: client default, server default" \
1170 "$P_SRV dtls=1 debug_level=4" \
1171 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1172 0 \
1173 -s "dumping 'expected mac' (20 bytes)" \
1174 -S "dumping 'expected mac' (10 bytes)"
1175
1176requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1177run_test "Truncated HMAC, DTLS: client disabled, server default" \
1178 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001179 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001180 0 \
1181 -s "dumping 'expected mac' (20 bytes)" \
1182 -S "dumping 'expected mac' (10 bytes)"
1183
1184requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1185run_test "Truncated HMAC, DTLS: client enabled, server default" \
1186 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001187 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001188 0 \
1189 -s "dumping 'expected mac' (20 bytes)" \
1190 -S "dumping 'expected mac' (10 bytes)"
1191
1192requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1193run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1194 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001195 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001196 0 \
1197 -s "dumping 'expected mac' (20 bytes)" \
1198 -S "dumping 'expected mac' (10 bytes)"
1199
1200requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1201run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1202 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001203 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001204 0 \
1205 -s "dumping 'expected mac' (20 bytes)" \
1206 -S "dumping 'expected mac' (10 bytes)"
1207
1208requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1209run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1210 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001211 "$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 +01001212 0 \
1213 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001214 -s "dumping 'expected mac' (10 bytes)"
1215
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001216# Tests for Encrypt-then-MAC extension
1217
1218run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001219 "$P_SRV debug_level=3 \
1220 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001221 "$P_CLI debug_level=3" \
1222 0 \
1223 -c "client hello, adding encrypt_then_mac extension" \
1224 -s "found encrypt then mac extension" \
1225 -s "server hello, adding encrypt then mac extension" \
1226 -c "found encrypt_then_mac extension" \
1227 -c "using encrypt then mac" \
1228 -s "using encrypt then mac"
1229
1230run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001231 "$P_SRV debug_level=3 etm=0 \
1232 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001233 "$P_CLI debug_level=3 etm=1" \
1234 0 \
1235 -c "client hello, adding encrypt_then_mac extension" \
1236 -s "found encrypt then mac extension" \
1237 -S "server hello, adding encrypt then mac extension" \
1238 -C "found encrypt_then_mac extension" \
1239 -C "using encrypt then mac" \
1240 -S "using encrypt then mac"
1241
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001242run_test "Encrypt then MAC: client enabled, aead cipher" \
1243 "$P_SRV debug_level=3 etm=1 \
1244 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1245 "$P_CLI debug_level=3 etm=1" \
1246 0 \
1247 -c "client hello, adding encrypt_then_mac extension" \
1248 -s "found encrypt then mac extension" \
1249 -S "server hello, adding encrypt then mac extension" \
1250 -C "found encrypt_then_mac extension" \
1251 -C "using encrypt then mac" \
1252 -S "using encrypt then mac"
1253
1254run_test "Encrypt then MAC: client enabled, stream cipher" \
1255 "$P_SRV debug_level=3 etm=1 \
1256 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001257 "$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 +01001258 0 \
1259 -c "client hello, adding encrypt_then_mac extension" \
1260 -s "found encrypt then mac extension" \
1261 -S "server hello, adding encrypt then mac extension" \
1262 -C "found encrypt_then_mac extension" \
1263 -C "using encrypt then mac" \
1264 -S "using encrypt then mac"
1265
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001266run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001267 "$P_SRV debug_level=3 etm=1 \
1268 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001269 "$P_CLI debug_level=3 etm=0" \
1270 0 \
1271 -C "client hello, adding encrypt_then_mac extension" \
1272 -S "found encrypt then mac extension" \
1273 -S "server hello, adding encrypt then mac extension" \
1274 -C "found encrypt_then_mac extension" \
1275 -C "using encrypt then mac" \
1276 -S "using encrypt then mac"
1277
Janos Follathe2681a42016-03-07 15:57:05 +00001278requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001279run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001280 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001281 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001282 "$P_CLI debug_level=3 force_version=ssl3" \
1283 0 \
1284 -C "client hello, adding encrypt_then_mac extension" \
1285 -S "found encrypt then mac extension" \
1286 -S "server hello, adding encrypt then mac extension" \
1287 -C "found encrypt_then_mac extension" \
1288 -C "using encrypt then mac" \
1289 -S "using encrypt then mac"
1290
Janos Follathe2681a42016-03-07 15:57:05 +00001291requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001292run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001293 "$P_SRV debug_level=3 force_version=ssl3 \
1294 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001295 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001296 0 \
1297 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001298 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001299 -S "server hello, adding encrypt then mac extension" \
1300 -C "found encrypt_then_mac extension" \
1301 -C "using encrypt then mac" \
1302 -S "using encrypt then mac"
1303
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001304# Tests for Extended Master Secret extension
1305
1306run_test "Extended Master Secret: default" \
1307 "$P_SRV debug_level=3" \
1308 "$P_CLI debug_level=3" \
1309 0 \
1310 -c "client hello, adding extended_master_secret extension" \
1311 -s "found extended master secret extension" \
1312 -s "server hello, adding extended master secret extension" \
1313 -c "found extended_master_secret extension" \
1314 -c "using extended master secret" \
1315 -s "using extended master secret"
1316
1317run_test "Extended Master Secret: client enabled, server disabled" \
1318 "$P_SRV debug_level=3 extended_ms=0" \
1319 "$P_CLI debug_level=3 extended_ms=1" \
1320 0 \
1321 -c "client hello, adding extended_master_secret extension" \
1322 -s "found extended master secret extension" \
1323 -S "server hello, adding extended master secret extension" \
1324 -C "found extended_master_secret extension" \
1325 -C "using extended master secret" \
1326 -S "using extended master secret"
1327
1328run_test "Extended Master Secret: client disabled, server enabled" \
1329 "$P_SRV debug_level=3 extended_ms=1" \
1330 "$P_CLI debug_level=3 extended_ms=0" \
1331 0 \
1332 -C "client hello, adding extended_master_secret extension" \
1333 -S "found extended master secret extension" \
1334 -S "server hello, adding extended master secret extension" \
1335 -C "found extended_master_secret extension" \
1336 -C "using extended master secret" \
1337 -S "using extended master secret"
1338
Janos Follathe2681a42016-03-07 15:57:05 +00001339requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001340run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001341 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001342 "$P_CLI debug_level=3 force_version=ssl3" \
1343 0 \
1344 -C "client hello, adding extended_master_secret extension" \
1345 -S "found extended master secret extension" \
1346 -S "server hello, adding extended master secret extension" \
1347 -C "found extended_master_secret extension" \
1348 -C "using extended master secret" \
1349 -S "using extended master secret"
1350
Janos Follathe2681a42016-03-07 15:57:05 +00001351requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001352run_test "Extended Master Secret: client enabled, server SSLv3" \
1353 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001354 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001355 0 \
1356 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001357 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001358 -S "server hello, adding extended master secret extension" \
1359 -C "found extended_master_secret extension" \
1360 -C "using extended master secret" \
1361 -S "using extended master secret"
1362
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001363# Tests for FALLBACK_SCSV
1364
1365run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001366 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001367 "$P_CLI debug_level=3 force_version=tls1_1" \
1368 0 \
1369 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001370 -S "received FALLBACK_SCSV" \
1371 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001372 -C "is a fatal alert message (msg 86)"
1373
1374run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001375 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001376 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1377 0 \
1378 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001379 -S "received FALLBACK_SCSV" \
1380 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001381 -C "is a fatal alert message (msg 86)"
1382
1383run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001384 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001385 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001386 1 \
1387 -c "adding FALLBACK_SCSV" \
1388 -s "received FALLBACK_SCSV" \
1389 -s "inapropriate fallback" \
1390 -c "is a fatal alert message (msg 86)"
1391
1392run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001393 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001394 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001395 0 \
1396 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001397 -s "received FALLBACK_SCSV" \
1398 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001399 -C "is a fatal alert message (msg 86)"
1400
1401requires_openssl_with_fallback_scsv
1402run_test "Fallback SCSV: default, openssl server" \
1403 "$O_SRV" \
1404 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1405 0 \
1406 -C "adding FALLBACK_SCSV" \
1407 -C "is a fatal alert message (msg 86)"
1408
1409requires_openssl_with_fallback_scsv
1410run_test "Fallback SCSV: enabled, openssl server" \
1411 "$O_SRV" \
1412 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1413 1 \
1414 -c "adding FALLBACK_SCSV" \
1415 -c "is a fatal alert message (msg 86)"
1416
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001417requires_openssl_with_fallback_scsv
1418run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001419 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001420 "$O_CLI -tls1_1" \
1421 0 \
1422 -S "received FALLBACK_SCSV" \
1423 -S "inapropriate fallback"
1424
1425requires_openssl_with_fallback_scsv
1426run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001427 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001428 "$O_CLI -tls1_1 -fallback_scsv" \
1429 1 \
1430 -s "received FALLBACK_SCSV" \
1431 -s "inapropriate fallback"
1432
1433requires_openssl_with_fallback_scsv
1434run_test "Fallback SCSV: enabled, max version, openssl client" \
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 "$O_CLI -fallback_scsv" \
1437 0 \
1438 -s "received FALLBACK_SCSV" \
1439 -S "inapropriate fallback"
1440
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001441# Test sending and receiving empty application data records
1442
1443run_test "Encrypt then MAC: empty application data record" \
1444 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1445 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1446 0 \
1447 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1448 -s "dumping 'input payload after decrypt' (0 bytes)" \
1449 -c "0 bytes written in 1 fragments"
1450
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001451run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001452 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1453 "$P_CLI auth_mode=none etm=0 request_size=0" \
1454 0 \
1455 -s "dumping 'input payload after decrypt' (0 bytes)" \
1456 -c "0 bytes written in 1 fragments"
1457
1458run_test "Encrypt then MAC, DTLS: empty application data record" \
1459 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1460 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1461 0 \
1462 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1463 -s "dumping 'input payload after decrypt' (0 bytes)" \
1464 -c "0 bytes written in 1 fragments"
1465
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001466run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001467 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1468 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1469 0 \
1470 -s "dumping 'input payload after decrypt' (0 bytes)" \
1471 -c "0 bytes written in 1 fragments"
1472
Gilles Peskined50177f2017-05-16 17:53:03 +02001473## ClientHello generated with
1474## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1475## then manually twiddling the ciphersuite list.
1476## The ClientHello content is spelled out below as a hex string as
1477## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1478## The expected response is an inappropriate_fallback alert.
1479requires_openssl_with_fallback_scsv
1480run_test "Fallback SCSV: beginning of list" \
1481 "$P_SRV debug_level=2" \
1482 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1483 0 \
1484 -s "received FALLBACK_SCSV" \
1485 -s "inapropriate fallback"
1486
1487requires_openssl_with_fallback_scsv
1488run_test "Fallback SCSV: end of list" \
1489 "$P_SRV debug_level=2" \
1490 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1491 0 \
1492 -s "received FALLBACK_SCSV" \
1493 -s "inapropriate fallback"
1494
1495## Here the expected response is a valid ServerHello prefix, up to the random.
1496requires_openssl_with_fallback_scsv
1497run_test "Fallback SCSV: not in list" \
1498 "$P_SRV debug_level=2" \
1499 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1500 0 \
1501 -S "received FALLBACK_SCSV" \
1502 -S "inapropriate fallback"
1503
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001504# Tests for CBC 1/n-1 record splitting
1505
1506run_test "CBC Record splitting: TLS 1.2, no splitting" \
1507 "$P_SRV" \
1508 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1509 request_size=123 force_version=tls1_2" \
1510 0 \
1511 -s "Read from client: 123 bytes read" \
1512 -S "Read from client: 1 bytes read" \
1513 -S "122 bytes read"
1514
1515run_test "CBC Record splitting: TLS 1.1, no splitting" \
1516 "$P_SRV" \
1517 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1518 request_size=123 force_version=tls1_1" \
1519 0 \
1520 -s "Read from client: 123 bytes read" \
1521 -S "Read from client: 1 bytes read" \
1522 -S "122 bytes read"
1523
1524run_test "CBC Record splitting: TLS 1.0, splitting" \
1525 "$P_SRV" \
1526 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1527 request_size=123 force_version=tls1" \
1528 0 \
1529 -S "Read from client: 123 bytes read" \
1530 -s "Read from client: 1 bytes read" \
1531 -s "122 bytes read"
1532
Janos Follathe2681a42016-03-07 15:57:05 +00001533requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001534run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001535 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001536 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1537 request_size=123 force_version=ssl3" \
1538 0 \
1539 -S "Read from client: 123 bytes read" \
1540 -s "Read from client: 1 bytes read" \
1541 -s "122 bytes read"
1542
1543run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001544 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001545 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1546 request_size=123 force_version=tls1" \
1547 0 \
1548 -s "Read from client: 123 bytes read" \
1549 -S "Read from client: 1 bytes read" \
1550 -S "122 bytes read"
1551
1552run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1553 "$P_SRV" \
1554 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1555 request_size=123 force_version=tls1 recsplit=0" \
1556 0 \
1557 -s "Read from client: 123 bytes read" \
1558 -S "Read from client: 1 bytes read" \
1559 -S "122 bytes read"
1560
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001561run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1562 "$P_SRV nbio=2" \
1563 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1564 request_size=123 force_version=tls1" \
1565 0 \
1566 -S "Read from client: 123 bytes read" \
1567 -s "Read from client: 1 bytes read" \
1568 -s "122 bytes read"
1569
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001570# Tests for Session Tickets
1571
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001572run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001573 "$P_SRV debug_level=3 tickets=1" \
1574 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001575 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001576 -c "client hello, adding session ticket extension" \
1577 -s "found session ticket extension" \
1578 -s "server hello, adding session ticket extension" \
1579 -c "found session_ticket extension" \
1580 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001581 -S "session successfully restored from cache" \
1582 -s "session successfully restored from ticket" \
1583 -s "a session has been resumed" \
1584 -c "a session has been resumed"
1585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001586run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001587 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1588 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001589 0 \
1590 -c "client hello, adding session ticket extension" \
1591 -s "found session ticket extension" \
1592 -s "server hello, adding session ticket extension" \
1593 -c "found session_ticket extension" \
1594 -c "parse new session ticket" \
1595 -S "session successfully restored from cache" \
1596 -s "session successfully restored from ticket" \
1597 -s "a session has been resumed" \
1598 -c "a session has been resumed"
1599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001600run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001601 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1602 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001603 0 \
1604 -c "client hello, adding session ticket extension" \
1605 -s "found session ticket extension" \
1606 -s "server hello, adding session ticket extension" \
1607 -c "found session_ticket extension" \
1608 -c "parse new session ticket" \
1609 -S "session successfully restored from cache" \
1610 -S "session successfully restored from ticket" \
1611 -S "a session has been resumed" \
1612 -C "a session has been resumed"
1613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001614run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001615 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001616 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001617 0 \
1618 -c "client hello, adding session ticket extension" \
1619 -c "found session_ticket extension" \
1620 -c "parse new session ticket" \
1621 -c "a session has been resumed"
1622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001623run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001624 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001625 "( $O_CLI -sess_out $SESSION; \
1626 $O_CLI -sess_in $SESSION; \
1627 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001628 0 \
1629 -s "found session ticket extension" \
1630 -s "server hello, adding session ticket extension" \
1631 -S "session successfully restored from cache" \
1632 -s "session successfully restored from ticket" \
1633 -s "a session has been resumed"
1634
Hanno Becker1d739932018-08-21 13:55:22 +01001635# Tests for Session Tickets with DTLS
1636
1637run_test "Session resume using tickets, DTLS: basic" \
1638 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001639 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001640 0 \
1641 -c "client hello, adding session ticket extension" \
1642 -s "found session ticket extension" \
1643 -s "server hello, adding session ticket extension" \
1644 -c "found session_ticket extension" \
1645 -c "parse new session ticket" \
1646 -S "session successfully restored from cache" \
1647 -s "session successfully restored from ticket" \
1648 -s "a session has been resumed" \
1649 -c "a session has been resumed"
1650
1651run_test "Session resume using tickets, DTLS: cache disabled" \
1652 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001653 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001654 0 \
1655 -c "client hello, adding session ticket extension" \
1656 -s "found session ticket extension" \
1657 -s "server hello, adding session ticket extension" \
1658 -c "found session_ticket extension" \
1659 -c "parse new session ticket" \
1660 -S "session successfully restored from cache" \
1661 -s "session successfully restored from ticket" \
1662 -s "a session has been resumed" \
1663 -c "a session has been resumed"
1664
1665run_test "Session resume using tickets, DTLS: timeout" \
1666 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001667 "$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 +01001668 0 \
1669 -c "client hello, adding session ticket extension" \
1670 -s "found session ticket extension" \
1671 -s "server hello, adding session ticket extension" \
1672 -c "found session_ticket extension" \
1673 -c "parse new session ticket" \
1674 -S "session successfully restored from cache" \
1675 -S "session successfully restored from ticket" \
1676 -S "a session has been resumed" \
1677 -C "a session has been resumed"
1678
1679run_test "Session resume using tickets, DTLS: openssl server" \
1680 "$O_SRV -dtls1" \
1681 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1682 0 \
1683 -c "client hello, adding session ticket extension" \
1684 -c "found session_ticket extension" \
1685 -c "parse new session ticket" \
1686 -c "a session has been resumed"
1687
1688run_test "Session resume using tickets, DTLS: openssl client" \
1689 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1690 "( $O_CLI -dtls1 -sess_out $SESSION; \
1691 $O_CLI -dtls1 -sess_in $SESSION; \
1692 rm -f $SESSION )" \
1693 0 \
1694 -s "found session ticket extension" \
1695 -s "server hello, adding session ticket extension" \
1696 -S "session successfully restored from cache" \
1697 -s "session successfully restored from ticket" \
1698 -s "a session has been resumed"
1699
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001700# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001701
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001702run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001703 "$P_SRV debug_level=3 tickets=0" \
1704 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001705 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001706 -c "client hello, adding session ticket extension" \
1707 -s "found session ticket extension" \
1708 -S "server hello, adding session ticket extension" \
1709 -C "found session_ticket extension" \
1710 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001711 -s "session successfully restored from cache" \
1712 -S "session successfully restored from ticket" \
1713 -s "a session has been resumed" \
1714 -c "a session has been resumed"
1715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001716run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001717 "$P_SRV debug_level=3 tickets=1" \
1718 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001719 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001720 -C "client hello, adding session ticket extension" \
1721 -S "found session ticket extension" \
1722 -S "server hello, adding session ticket extension" \
1723 -C "found session_ticket extension" \
1724 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001725 -s "session successfully restored from cache" \
1726 -S "session successfully restored from ticket" \
1727 -s "a session has been resumed" \
1728 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001730run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001731 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1732 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001733 0 \
1734 -S "session successfully restored from cache" \
1735 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001736 -S "a session has been resumed" \
1737 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001739run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001740 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1741 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001742 0 \
1743 -s "session successfully restored from cache" \
1744 -S "session successfully restored from ticket" \
1745 -s "a session has been resumed" \
1746 -c "a session has been resumed"
1747
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001748run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001749 "$P_SRV debug_level=3 tickets=0" \
1750 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001751 0 \
1752 -s "session successfully restored from cache" \
1753 -S "session successfully restored from ticket" \
1754 -s "a session has been resumed" \
1755 -c "a session has been resumed"
1756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001757run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001758 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1759 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001760 0 \
1761 -S "session successfully restored from cache" \
1762 -S "session successfully restored from ticket" \
1763 -S "a session has been resumed" \
1764 -C "a session has been resumed"
1765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001766run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001767 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1768 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001769 0 \
1770 -s "session successfully restored from cache" \
1771 -S "session successfully restored from ticket" \
1772 -s "a session has been resumed" \
1773 -c "a session has been resumed"
1774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001775run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001776 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001777 "( $O_CLI -sess_out $SESSION; \
1778 $O_CLI -sess_in $SESSION; \
1779 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001780 0 \
1781 -s "found session ticket extension" \
1782 -S "server hello, adding session ticket extension" \
1783 -s "session successfully restored from cache" \
1784 -S "session successfully restored from ticket" \
1785 -s "a session has been resumed"
1786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001787run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001788 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001789 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001790 0 \
1791 -C "found session_ticket extension" \
1792 -C "parse new session ticket" \
1793 -c "a session has been resumed"
1794
Hanno Becker1d739932018-08-21 13:55:22 +01001795# Tests for Session Resume based on session-ID and cache, DTLS
1796
1797run_test "Session resume using cache, DTLS: tickets enabled on client" \
1798 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001799 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001800 0 \
1801 -c "client hello, adding session ticket extension" \
1802 -s "found session ticket extension" \
1803 -S "server hello, adding session ticket extension" \
1804 -C "found session_ticket extension" \
1805 -C "parse new session ticket" \
1806 -s "session successfully restored from cache" \
1807 -S "session successfully restored from ticket" \
1808 -s "a session has been resumed" \
1809 -c "a session has been resumed"
1810
1811run_test "Session resume using cache, DTLS: tickets enabled on server" \
1812 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001813 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001814 0 \
1815 -C "client hello, adding session ticket extension" \
1816 -S "found session ticket extension" \
1817 -S "server hello, adding session ticket extension" \
1818 -C "found session_ticket extension" \
1819 -C "parse new session ticket" \
1820 -s "session successfully restored from cache" \
1821 -S "session successfully restored from ticket" \
1822 -s "a session has been resumed" \
1823 -c "a session has been resumed"
1824
1825run_test "Session resume using cache, DTLS: cache_max=0" \
1826 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001827 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001828 0 \
1829 -S "session successfully restored from cache" \
1830 -S "session successfully restored from ticket" \
1831 -S "a session has been resumed" \
1832 -C "a session has been resumed"
1833
1834run_test "Session resume using cache, DTLS: cache_max=1" \
1835 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001836 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001837 0 \
1838 -s "session successfully restored from cache" \
1839 -S "session successfully restored from ticket" \
1840 -s "a session has been resumed" \
1841 -c "a session has been resumed"
1842
1843run_test "Session resume using cache, DTLS: timeout > delay" \
1844 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001845 "$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 +01001846 0 \
1847 -s "session successfully restored from cache" \
1848 -S "session successfully restored from ticket" \
1849 -s "a session has been resumed" \
1850 -c "a session has been resumed"
1851
1852run_test "Session resume using cache, DTLS: timeout < delay" \
1853 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001854 "$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 +01001855 0 \
1856 -S "session successfully restored from cache" \
1857 -S "session successfully restored from ticket" \
1858 -S "a session has been resumed" \
1859 -C "a session has been resumed"
1860
1861run_test "Session resume using cache, DTLS: no timeout" \
1862 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001863 "$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 +01001864 0 \
1865 -s "session successfully restored from cache" \
1866 -S "session successfully restored from ticket" \
1867 -s "a session has been resumed" \
1868 -c "a session has been resumed"
1869
1870run_test "Session resume using cache, DTLS: openssl client" \
1871 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1872 "( $O_CLI -dtls1 -sess_out $SESSION; \
1873 $O_CLI -dtls1 -sess_in $SESSION; \
1874 rm -f $SESSION )" \
1875 0 \
1876 -s "found session ticket extension" \
1877 -S "server hello, adding session ticket extension" \
1878 -s "session successfully restored from cache" \
1879 -S "session successfully restored from ticket" \
1880 -s "a session has been resumed"
1881
1882run_test "Session resume using cache, DTLS: openssl server" \
1883 "$O_SRV -dtls1" \
1884 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1885 0 \
1886 -C "found session_ticket extension" \
1887 -C "parse new session ticket" \
1888 -c "a session has been resumed"
1889
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001890# Tests for Max Fragment Length extension
1891
Angus Grattonc4dd0732018-04-11 16:28:39 +10001892if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02001893 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 +01001894 exit 1
1895fi
1896
Angus Grattonc4dd0732018-04-11 16:28:39 +10001897if [ $MAX_CONTENT_LEN -ne 16384 ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02001898 echo "Using non-default maximum content length $MAX_CONTENT_LEN"
Angus Grattonc4dd0732018-04-11 16:28:39 +10001899fi
1900
Hanno Becker4aed27e2017-09-18 15:00:34 +01001901requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001902run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001903 "$P_SRV debug_level=3" \
1904 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001905 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001906 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1907 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001908 -C "client hello, adding max_fragment_length extension" \
1909 -S "found max fragment length extension" \
1910 -S "server hello, max_fragment_length extension" \
1911 -C "found max_fragment_length extension"
1912
Hanno Becker4aed27e2017-09-18 15:00:34 +01001913requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001914run_test "Max fragment length: enabled, default, larger message" \
1915 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001916 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001917 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001918 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1919 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001920 -C "client hello, adding max_fragment_length extension" \
1921 -S "found max fragment length extension" \
1922 -S "server hello, max_fragment_length extension" \
1923 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001924 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1925 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001926 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001927
1928requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1929run_test "Max fragment length, DTLS: enabled, default, larger message" \
1930 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001931 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001932 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001933 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1934 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001935 -C "client hello, adding max_fragment_length extension" \
1936 -S "found max fragment length extension" \
1937 -S "server hello, max_fragment_length extension" \
1938 -C "found max_fragment_length extension" \
1939 -c "fragment larger than.*maximum "
1940
Angus Grattonc4dd0732018-04-11 16:28:39 +10001941# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1942# (session fragment length will be 16384 regardless of mbedtls
1943# content length configuration.)
1944
Hanno Beckerc5266962017-09-18 15:01:50 +01001945requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1946run_test "Max fragment length: disabled, larger message" \
1947 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001948 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001949 0 \
1950 -C "Maximum fragment length is 16384" \
1951 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001952 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1953 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001954 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001955
1956requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1957run_test "Max fragment length DTLS: disabled, larger message" \
1958 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001959 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001960 1 \
1961 -C "Maximum fragment length is 16384" \
1962 -S "Maximum fragment length is 16384" \
1963 -c "fragment larger than.*maximum "
1964
1965requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001966run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001967 "$P_SRV debug_level=3" \
1968 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001969 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001970 -c "Maximum fragment length is 4096" \
1971 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001972 -c "client hello, adding max_fragment_length extension" \
1973 -s "found max fragment length extension" \
1974 -s "server hello, max_fragment_length extension" \
1975 -c "found max_fragment_length extension"
1976
Hanno Becker4aed27e2017-09-18 15:00:34 +01001977requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001978run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001979 "$P_SRV debug_level=3 max_frag_len=4096" \
1980 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001981 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001982 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001983 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001984 -C "client hello, adding max_fragment_length extension" \
1985 -S "found max fragment length extension" \
1986 -S "server hello, max_fragment_length extension" \
1987 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001988
Hanno Becker4aed27e2017-09-18 15:00:34 +01001989requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001990requires_gnutls
1991run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001992 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001993 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001994 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001995 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001996 -c "client hello, adding max_fragment_length extension" \
1997 -c "found max_fragment_length extension"
1998
Hanno Becker4aed27e2017-09-18 15:00:34 +01001999requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002000run_test "Max fragment length: client, message just fits" \
2001 "$P_SRV debug_level=3" \
2002 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
2003 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002004 -c "Maximum fragment length is 2048" \
2005 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002006 -c "client hello, adding max_fragment_length extension" \
2007 -s "found max fragment length extension" \
2008 -s "server hello, max_fragment_length extension" \
2009 -c "found max_fragment_length extension" \
2010 -c "2048 bytes written in 1 fragments" \
2011 -s "2048 bytes read"
2012
Hanno Becker4aed27e2017-09-18 15:00:34 +01002013requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002014run_test "Max fragment length: client, larger message" \
2015 "$P_SRV debug_level=3" \
2016 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2017 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002018 -c "Maximum fragment length is 2048" \
2019 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002020 -c "client hello, adding max_fragment_length extension" \
2021 -s "found max fragment length extension" \
2022 -s "server hello, max_fragment_length extension" \
2023 -c "found max_fragment_length extension" \
2024 -c "2345 bytes written in 2 fragments" \
2025 -s "2048 bytes read" \
2026 -s "297 bytes read"
2027
Hanno Becker4aed27e2017-09-18 15:00:34 +01002028requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002029run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002030 "$P_SRV debug_level=3 dtls=1" \
2031 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2032 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002033 -c "Maximum fragment length is 2048" \
2034 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002035 -c "client hello, adding max_fragment_length extension" \
2036 -s "found max fragment length extension" \
2037 -s "server hello, max_fragment_length extension" \
2038 -c "found max_fragment_length extension" \
2039 -c "fragment larger than.*maximum"
2040
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002041# Tests for renegotiation
2042
Hanno Becker6a243642017-10-12 15:18:45 +01002043# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002044run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002045 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002046 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002047 0 \
2048 -C "client hello, adding renegotiation extension" \
2049 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2050 -S "found renegotiation extension" \
2051 -s "server hello, secure renegotiation extension" \
2052 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002053 -C "=> renegotiate" \
2054 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002055 -S "write hello request"
2056
Hanno Becker6a243642017-10-12 15:18:45 +01002057requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002058run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002059 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002060 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002061 0 \
2062 -c "client hello, adding renegotiation extension" \
2063 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2064 -s "found renegotiation extension" \
2065 -s "server hello, secure renegotiation extension" \
2066 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002067 -c "=> renegotiate" \
2068 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002069 -S "write hello request"
2070
Hanno Becker6a243642017-10-12 15:18:45 +01002071requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002072run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002073 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002074 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002075 0 \
2076 -c "client hello, adding renegotiation extension" \
2077 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2078 -s "found renegotiation extension" \
2079 -s "server hello, secure renegotiation extension" \
2080 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002081 -c "=> renegotiate" \
2082 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002083 -s "write hello request"
2084
Janos Follathb0f148c2017-10-05 12:29:42 +01002085# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2086# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2087# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002088requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002089run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2090 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2091 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2092 0 \
2093 -c "client hello, adding renegotiation extension" \
2094 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2095 -s "found renegotiation extension" \
2096 -s "server hello, secure renegotiation extension" \
2097 -c "found renegotiation extension" \
2098 -c "=> renegotiate" \
2099 -s "=> renegotiate" \
2100 -S "write hello request" \
2101 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2102
2103# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2104# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2105# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002106requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002107run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2108 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2109 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2110 0 \
2111 -c "client hello, adding renegotiation extension" \
2112 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2113 -s "found renegotiation extension" \
2114 -s "server hello, secure renegotiation extension" \
2115 -c "found renegotiation extension" \
2116 -c "=> renegotiate" \
2117 -s "=> renegotiate" \
2118 -s "write hello request" \
2119 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2120
Hanno Becker6a243642017-10-12 15:18:45 +01002121requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002122run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002123 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002124 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002125 0 \
2126 -c "client hello, adding renegotiation extension" \
2127 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2128 -s "found renegotiation extension" \
2129 -s "server hello, secure renegotiation extension" \
2130 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002131 -c "=> renegotiate" \
2132 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002133 -s "write hello request"
2134
Hanno Becker6a243642017-10-12 15:18:45 +01002135requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002136run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002137 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002138 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002139 1 \
2140 -c "client hello, adding renegotiation extension" \
2141 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2142 -S "found renegotiation extension" \
2143 -s "server hello, secure renegotiation extension" \
2144 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002145 -c "=> renegotiate" \
2146 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002147 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002148 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002149 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002150
Hanno Becker6a243642017-10-12 15:18:45 +01002151requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002152run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002153 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002154 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002155 0 \
2156 -C "client hello, adding renegotiation extension" \
2157 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2158 -S "found renegotiation extension" \
2159 -s "server hello, secure renegotiation extension" \
2160 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002161 -C "=> renegotiate" \
2162 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002163 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002164 -S "SSL - An unexpected message was received from our peer" \
2165 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002166
Hanno Becker6a243642017-10-12 15:18:45 +01002167requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002168run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002169 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002170 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002171 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002172 0 \
2173 -C "client hello, adding renegotiation extension" \
2174 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2175 -S "found renegotiation extension" \
2176 -s "server hello, secure renegotiation extension" \
2177 -c "found renegotiation extension" \
2178 -C "=> renegotiate" \
2179 -S "=> renegotiate" \
2180 -s "write hello request" \
2181 -S "SSL - An unexpected message was received from our peer" \
2182 -S "failed"
2183
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002184# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002185requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002186run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002187 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002188 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002189 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002190 0 \
2191 -C "client hello, adding renegotiation extension" \
2192 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2193 -S "found renegotiation extension" \
2194 -s "server hello, secure renegotiation extension" \
2195 -c "found renegotiation extension" \
2196 -C "=> renegotiate" \
2197 -S "=> renegotiate" \
2198 -s "write hello request" \
2199 -S "SSL - An unexpected message was received from our peer" \
2200 -S "failed"
2201
Hanno Becker6a243642017-10-12 15:18:45 +01002202requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002203run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002204 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002205 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002206 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002207 0 \
2208 -C "client hello, adding renegotiation extension" \
2209 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2210 -S "found renegotiation extension" \
2211 -s "server hello, secure renegotiation extension" \
2212 -c "found renegotiation extension" \
2213 -C "=> renegotiate" \
2214 -S "=> renegotiate" \
2215 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002216 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002217
Hanno Becker6a243642017-10-12 15:18:45 +01002218requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002219run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002220 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002221 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002222 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002223 0 \
2224 -c "client hello, adding renegotiation extension" \
2225 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2226 -s "found renegotiation extension" \
2227 -s "server hello, secure renegotiation extension" \
2228 -c "found renegotiation extension" \
2229 -c "=> renegotiate" \
2230 -s "=> renegotiate" \
2231 -s "write hello request" \
2232 -S "SSL - An unexpected message was received from our peer" \
2233 -S "failed"
2234
Hanno Becker6a243642017-10-12 15:18:45 +01002235requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002236run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002237 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002238 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2239 0 \
2240 -C "client hello, adding renegotiation extension" \
2241 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2242 -S "found renegotiation extension" \
2243 -s "server hello, secure renegotiation extension" \
2244 -c "found renegotiation extension" \
2245 -S "record counter limit reached: renegotiate" \
2246 -C "=> renegotiate" \
2247 -S "=> renegotiate" \
2248 -S "write hello request" \
2249 -S "SSL - An unexpected message was received from our peer" \
2250 -S "failed"
2251
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002252# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002253requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002254run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002255 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002256 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002257 0 \
2258 -c "client hello, adding renegotiation extension" \
2259 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2260 -s "found renegotiation extension" \
2261 -s "server hello, secure renegotiation extension" \
2262 -c "found renegotiation extension" \
2263 -s "record counter limit reached: renegotiate" \
2264 -c "=> renegotiate" \
2265 -s "=> renegotiate" \
2266 -s "write hello request" \
2267 -S "SSL - An unexpected message was received from our peer" \
2268 -S "failed"
2269
Hanno Becker6a243642017-10-12 15:18:45 +01002270requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002271run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002272 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002273 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002274 0 \
2275 -c "client hello, adding renegotiation extension" \
2276 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2277 -s "found renegotiation extension" \
2278 -s "server hello, secure renegotiation extension" \
2279 -c "found renegotiation extension" \
2280 -s "record counter limit reached: renegotiate" \
2281 -c "=> renegotiate" \
2282 -s "=> renegotiate" \
2283 -s "write hello request" \
2284 -S "SSL - An unexpected message was received from our peer" \
2285 -S "failed"
2286
Hanno Becker6a243642017-10-12 15:18:45 +01002287requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002288run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002289 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002290 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2291 0 \
2292 -C "client hello, adding renegotiation extension" \
2293 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2294 -S "found renegotiation extension" \
2295 -s "server hello, secure renegotiation extension" \
2296 -c "found renegotiation extension" \
2297 -S "record counter limit reached: renegotiate" \
2298 -C "=> renegotiate" \
2299 -S "=> renegotiate" \
2300 -S "write hello request" \
2301 -S "SSL - An unexpected message was received from our peer" \
2302 -S "failed"
2303
Hanno Becker6a243642017-10-12 15:18:45 +01002304requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002305run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002306 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002307 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002308 0 \
2309 -c "client hello, adding renegotiation extension" \
2310 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2311 -s "found renegotiation extension" \
2312 -s "server hello, secure renegotiation extension" \
2313 -c "found renegotiation extension" \
2314 -c "=> renegotiate" \
2315 -s "=> renegotiate" \
2316 -S "write hello request"
2317
Hanno Becker6a243642017-10-12 15:18:45 +01002318requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002319run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002320 "$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 +02002321 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002322 0 \
2323 -c "client hello, adding renegotiation extension" \
2324 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2325 -s "found renegotiation extension" \
2326 -s "server hello, secure renegotiation extension" \
2327 -c "found renegotiation extension" \
2328 -c "=> renegotiate" \
2329 -s "=> renegotiate" \
2330 -s "write hello request"
2331
Hanno Becker6a243642017-10-12 15:18:45 +01002332requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002333run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002334 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002335 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002336 0 \
2337 -c "client hello, adding renegotiation extension" \
2338 -c "found renegotiation extension" \
2339 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002340 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002341 -C "error" \
2342 -c "HTTP/1.0 200 [Oo][Kk]"
2343
Paul Bakker539d9722015-02-08 16:18:35 +01002344requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002345requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002346run_test "Renegotiation: gnutls server strict, client-initiated" \
2347 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002348 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002349 0 \
2350 -c "client hello, adding renegotiation extension" \
2351 -c "found renegotiation extension" \
2352 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002353 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002354 -C "error" \
2355 -c "HTTP/1.0 200 [Oo][Kk]"
2356
Paul Bakker539d9722015-02-08 16:18:35 +01002357requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002358requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002359run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2360 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2361 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2362 1 \
2363 -c "client hello, adding renegotiation extension" \
2364 -C "found renegotiation extension" \
2365 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002366 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002367 -c "error" \
2368 -C "HTTP/1.0 200 [Oo][Kk]"
2369
Paul Bakker539d9722015-02-08 16:18:35 +01002370requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002371requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002372run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2373 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2374 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2375 allow_legacy=0" \
2376 1 \
2377 -c "client hello, adding renegotiation extension" \
2378 -C "found renegotiation extension" \
2379 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002380 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002381 -c "error" \
2382 -C "HTTP/1.0 200 [Oo][Kk]"
2383
Paul Bakker539d9722015-02-08 16:18:35 +01002384requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002385requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002386run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2387 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2388 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2389 allow_legacy=1" \
2390 0 \
2391 -c "client hello, adding renegotiation extension" \
2392 -C "found renegotiation extension" \
2393 -c "=> renegotiate" \
2394 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002395 -C "error" \
2396 -c "HTTP/1.0 200 [Oo][Kk]"
2397
Hanno Becker6a243642017-10-12 15:18:45 +01002398requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002399run_test "Renegotiation: DTLS, client-initiated" \
2400 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2401 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2402 0 \
2403 -c "client hello, adding renegotiation extension" \
2404 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2405 -s "found renegotiation extension" \
2406 -s "server hello, secure renegotiation extension" \
2407 -c "found renegotiation extension" \
2408 -c "=> renegotiate" \
2409 -s "=> renegotiate" \
2410 -S "write hello request"
2411
Hanno Becker6a243642017-10-12 15:18:45 +01002412requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002413run_test "Renegotiation: DTLS, server-initiated" \
2414 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002415 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2416 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002417 0 \
2418 -c "client hello, adding renegotiation extension" \
2419 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2420 -s "found renegotiation extension" \
2421 -s "server hello, secure renegotiation extension" \
2422 -c "found renegotiation extension" \
2423 -c "=> renegotiate" \
2424 -s "=> renegotiate" \
2425 -s "write hello request"
2426
Hanno Becker6a243642017-10-12 15:18:45 +01002427requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002428run_test "Renegotiation: DTLS, renego_period overflow" \
2429 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2430 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2431 0 \
2432 -c "client hello, adding renegotiation extension" \
2433 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2434 -s "found renegotiation extension" \
2435 -s "server hello, secure renegotiation extension" \
2436 -s "record counter limit reached: renegotiate" \
2437 -c "=> renegotiate" \
2438 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002439 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002440
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002441requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002442requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002443run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2444 "$G_SRV -u --mtu 4096" \
2445 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2446 0 \
2447 -c "client hello, adding renegotiation extension" \
2448 -c "found renegotiation extension" \
2449 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002450 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002451 -C "error" \
2452 -s "Extra-header:"
2453
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002454# Test for the "secure renegotation" extension only (no actual renegotiation)
2455
Paul Bakker539d9722015-02-08 16:18:35 +01002456requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002457run_test "Renego ext: gnutls server strict, client default" \
2458 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2459 "$P_CLI debug_level=3" \
2460 0 \
2461 -c "found renegotiation extension" \
2462 -C "error" \
2463 -c "HTTP/1.0 200 [Oo][Kk]"
2464
Paul Bakker539d9722015-02-08 16:18:35 +01002465requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002466run_test "Renego ext: gnutls server unsafe, client default" \
2467 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2468 "$P_CLI debug_level=3" \
2469 0 \
2470 -C "found renegotiation extension" \
2471 -C "error" \
2472 -c "HTTP/1.0 200 [Oo][Kk]"
2473
Paul Bakker539d9722015-02-08 16:18:35 +01002474requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002475run_test "Renego ext: gnutls server unsafe, client break legacy" \
2476 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2477 "$P_CLI debug_level=3 allow_legacy=-1" \
2478 1 \
2479 -C "found renegotiation extension" \
2480 -c "error" \
2481 -C "HTTP/1.0 200 [Oo][Kk]"
2482
Paul Bakker539d9722015-02-08 16:18:35 +01002483requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002484run_test "Renego ext: gnutls client strict, server default" \
2485 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002486 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002487 0 \
2488 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2489 -s "server hello, secure renegotiation extension"
2490
Paul Bakker539d9722015-02-08 16:18:35 +01002491requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002492run_test "Renego ext: gnutls client unsafe, server default" \
2493 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002494 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002495 0 \
2496 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2497 -S "server hello, secure renegotiation extension"
2498
Paul Bakker539d9722015-02-08 16:18:35 +01002499requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002500run_test "Renego ext: gnutls client unsafe, server break legacy" \
2501 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002502 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002503 1 \
2504 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2505 -S "server hello, secure renegotiation extension"
2506
Janos Follath0b242342016-02-17 10:11:21 +00002507# Tests for silently dropping trailing extra bytes in .der certificates
2508
2509requires_gnutls
2510run_test "DER format: no trailing bytes" \
2511 "$P_SRV crt_file=data_files/server5-der0.crt \
2512 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002513 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002514 0 \
2515 -c "Handshake was completed" \
2516
2517requires_gnutls
2518run_test "DER format: with a trailing zero byte" \
2519 "$P_SRV crt_file=data_files/server5-der1a.crt \
2520 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002521 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002522 0 \
2523 -c "Handshake was completed" \
2524
2525requires_gnutls
2526run_test "DER format: with a trailing random byte" \
2527 "$P_SRV crt_file=data_files/server5-der1b.crt \
2528 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002529 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002530 0 \
2531 -c "Handshake was completed" \
2532
2533requires_gnutls
2534run_test "DER format: with 2 trailing random bytes" \
2535 "$P_SRV crt_file=data_files/server5-der2.crt \
2536 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002537 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002538 0 \
2539 -c "Handshake was completed" \
2540
2541requires_gnutls
2542run_test "DER format: with 4 trailing random bytes" \
2543 "$P_SRV crt_file=data_files/server5-der4.crt \
2544 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002545 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002546 0 \
2547 -c "Handshake was completed" \
2548
2549requires_gnutls
2550run_test "DER format: with 8 trailing random bytes" \
2551 "$P_SRV crt_file=data_files/server5-der8.crt \
2552 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002553 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002554 0 \
2555 -c "Handshake was completed" \
2556
2557requires_gnutls
2558run_test "DER format: with 9 trailing random bytes" \
2559 "$P_SRV crt_file=data_files/server5-der9.crt \
2560 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002561 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002562 0 \
2563 -c "Handshake was completed" \
2564
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002565# Tests for auth_mode
2566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002567run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002568 "$P_SRV crt_file=data_files/server5-badsign.crt \
2569 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002570 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002571 1 \
2572 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002573 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002574 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002575 -c "X509 - Certificate verification failed"
2576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002577run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002578 "$P_SRV crt_file=data_files/server5-badsign.crt \
2579 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002580 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002581 0 \
2582 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002583 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002584 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002585 -C "X509 - Certificate verification failed"
2586
Hanno Beckere6706e62017-05-15 16:05:15 +01002587run_test "Authentication: server goodcert, client optional, no trusted CA" \
2588 "$P_SRV" \
2589 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2590 0 \
2591 -c "x509_verify_cert() returned" \
2592 -c "! The certificate is not correctly signed by the trusted CA" \
2593 -c "! Certificate verification flags"\
2594 -C "! mbedtls_ssl_handshake returned" \
2595 -C "X509 - Certificate verification failed" \
2596 -C "SSL - No CA Chain is set, but required to operate"
2597
2598run_test "Authentication: server goodcert, client required, no trusted CA" \
2599 "$P_SRV" \
2600 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2601 1 \
2602 -c "x509_verify_cert() returned" \
2603 -c "! The certificate is not correctly signed by the trusted CA" \
2604 -c "! Certificate verification flags"\
2605 -c "! mbedtls_ssl_handshake returned" \
2606 -c "SSL - No CA Chain is set, but required to operate"
2607
2608# The purpose of the next two tests is to test the client's behaviour when receiving a server
2609# certificate with an unsupported elliptic curve. This should usually not happen because
2610# the client informs the server about the supported curves - it does, though, in the
2611# corner case of a static ECDH suite, because the server doesn't check the curve on that
2612# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2613# different means to have the server ignoring the client's supported curve list.
2614
2615requires_config_enabled MBEDTLS_ECP_C
2616run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2617 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2618 crt_file=data_files/server5.ku-ka.crt" \
2619 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2620 1 \
2621 -c "bad certificate (EC key curve)"\
2622 -c "! Certificate verification flags"\
2623 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2624
2625requires_config_enabled MBEDTLS_ECP_C
2626run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2627 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2628 crt_file=data_files/server5.ku-ka.crt" \
2629 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2630 1 \
2631 -c "bad certificate (EC key curve)"\
2632 -c "! Certificate verification flags"\
2633 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002635run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002636 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002637 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002638 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002639 0 \
2640 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002641 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002642 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002643 -C "X509 - Certificate verification failed"
2644
Simon Butcher99000142016-10-13 17:21:01 +01002645run_test "Authentication: client SHA256, server required" \
2646 "$P_SRV auth_mode=required" \
2647 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2648 key_file=data_files/server6.key \
2649 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2650 0 \
2651 -c "Supported Signature Algorithm found: 4," \
2652 -c "Supported Signature Algorithm found: 5,"
2653
2654run_test "Authentication: client SHA384, server required" \
2655 "$P_SRV auth_mode=required" \
2656 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2657 key_file=data_files/server6.key \
2658 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2659 0 \
2660 -c "Supported Signature Algorithm found: 4," \
2661 -c "Supported Signature Algorithm found: 5,"
2662
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002663requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2664run_test "Authentication: client has no cert, server required (SSLv3)" \
2665 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2666 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2667 key_file=data_files/server5.key" \
2668 1 \
2669 -S "skip write certificate request" \
2670 -C "skip parse certificate request" \
2671 -c "got a certificate request" \
2672 -c "got no certificate to send" \
2673 -S "x509_verify_cert() returned" \
2674 -s "client has no certificate" \
2675 -s "! mbedtls_ssl_handshake returned" \
2676 -c "! mbedtls_ssl_handshake returned" \
2677 -s "No client certification received from the client, but required by the authentication mode"
2678
2679run_test "Authentication: client has no cert, server required (TLS)" \
2680 "$P_SRV debug_level=3 auth_mode=required" \
2681 "$P_CLI debug_level=3 crt_file=none \
2682 key_file=data_files/server5.key" \
2683 1 \
2684 -S "skip write certificate request" \
2685 -C "skip parse certificate request" \
2686 -c "got a certificate request" \
2687 -c "= write certificate$" \
2688 -C "skip write certificate$" \
2689 -S "x509_verify_cert() returned" \
2690 -s "client has no certificate" \
2691 -s "! mbedtls_ssl_handshake returned" \
2692 -c "! mbedtls_ssl_handshake returned" \
2693 -s "No client certification received from the client, but required by the authentication mode"
2694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002695run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002696 "$P_SRV debug_level=3 auth_mode=required" \
2697 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002698 key_file=data_files/server5.key" \
2699 1 \
2700 -S "skip write certificate request" \
2701 -C "skip parse certificate request" \
2702 -c "got a certificate request" \
2703 -C "skip write certificate" \
2704 -C "skip write certificate verify" \
2705 -S "skip parse certificate verify" \
2706 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002707 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002708 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002709 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002710 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002711 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002712# We don't check that the client receives the alert because it might
2713# detect that its write end of the connection is closed and abort
2714# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002715
Janos Follath89baba22017-04-10 14:34:35 +01002716run_test "Authentication: client cert not trusted, server required" \
2717 "$P_SRV debug_level=3 auth_mode=required" \
2718 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2719 key_file=data_files/server5.key" \
2720 1 \
2721 -S "skip write certificate request" \
2722 -C "skip parse certificate request" \
2723 -c "got a certificate request" \
2724 -C "skip write certificate" \
2725 -C "skip write certificate verify" \
2726 -S "skip parse certificate verify" \
2727 -s "x509_verify_cert() returned" \
2728 -s "! The certificate is not correctly signed by the trusted CA" \
2729 -s "! mbedtls_ssl_handshake returned" \
2730 -c "! mbedtls_ssl_handshake returned" \
2731 -s "X509 - Certificate verification failed"
2732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002733run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002734 "$P_SRV debug_level=3 auth_mode=optional" \
2735 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002736 key_file=data_files/server5.key" \
2737 0 \
2738 -S "skip write certificate request" \
2739 -C "skip parse certificate request" \
2740 -c "got a certificate request" \
2741 -C "skip write certificate" \
2742 -C "skip write certificate verify" \
2743 -S "skip parse certificate verify" \
2744 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002745 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002746 -S "! mbedtls_ssl_handshake returned" \
2747 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002748 -S "X509 - Certificate verification failed"
2749
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002750run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002751 "$P_SRV debug_level=3 auth_mode=none" \
2752 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002753 key_file=data_files/server5.key" \
2754 0 \
2755 -s "skip write certificate request" \
2756 -C "skip parse certificate request" \
2757 -c "got no certificate request" \
2758 -c "skip write certificate" \
2759 -c "skip write certificate verify" \
2760 -s "skip parse certificate verify" \
2761 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002762 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002763 -S "! mbedtls_ssl_handshake returned" \
2764 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002765 -S "X509 - Certificate verification failed"
2766
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002767run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002768 "$P_SRV debug_level=3 auth_mode=optional" \
2769 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002770 0 \
2771 -S "skip write certificate request" \
2772 -C "skip parse certificate request" \
2773 -c "got a certificate request" \
2774 -C "skip write certificate$" \
2775 -C "got no certificate to send" \
2776 -S "SSLv3 client has no certificate" \
2777 -c "skip write certificate verify" \
2778 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002779 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002780 -S "! mbedtls_ssl_handshake returned" \
2781 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002782 -S "X509 - Certificate verification failed"
2783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002784run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002785 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002786 "$O_CLI" \
2787 0 \
2788 -S "skip write certificate request" \
2789 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002790 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002791 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002792 -S "X509 - Certificate verification failed"
2793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002794run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002795 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002796 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002797 0 \
2798 -C "skip parse certificate request" \
2799 -c "got a certificate request" \
2800 -C "skip write certificate$" \
2801 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002802 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002803
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002804run_test "Authentication: client no cert, openssl server required" \
2805 "$O_SRV -Verify 10" \
2806 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2807 1 \
2808 -C "skip parse certificate request" \
2809 -c "got a certificate request" \
2810 -C "skip write certificate$" \
2811 -c "skip write certificate verify" \
2812 -c "! mbedtls_ssl_handshake returned"
2813
Janos Follathe2681a42016-03-07 15:57:05 +00002814requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002815run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002816 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002817 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002818 0 \
2819 -S "skip write certificate request" \
2820 -C "skip parse certificate request" \
2821 -c "got a certificate request" \
2822 -C "skip write certificate$" \
2823 -c "skip write certificate verify" \
2824 -c "got no certificate to send" \
2825 -s "SSLv3 client has no certificate" \
2826 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002827 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002828 -S "! mbedtls_ssl_handshake returned" \
2829 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002830 -S "X509 - Certificate verification failed"
2831
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002832# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2833# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002834
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002835MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002836MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002837
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002838if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002839 cat <<EOF
2840${CONFIG_H} contains a value for the configuration of
2841MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script's
2842test value of ${MAX_IM_CA}.
Simon Butcher06b78632017-07-28 01:00:17 +01002843
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002844The tests assume this value and if it changes, the tests in this
2845script should also be adjusted.
2846EOF
Simon Butcher06b78632017-07-28 01:00:17 +01002847 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002848fi
2849
Angus Grattonc4dd0732018-04-11 16:28:39 +10002850requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002851run_test "Authentication: server max_int chain, client default" \
2852 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2853 key_file=data_files/dir-maxpath/09.key" \
2854 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2855 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002856 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002857
Angus Grattonc4dd0732018-04-11 16:28:39 +10002858requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002859run_test "Authentication: server max_int+1 chain, client default" \
2860 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2861 key_file=data_files/dir-maxpath/10.key" \
2862 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2863 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002864 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002865
Angus Grattonc4dd0732018-04-11 16:28:39 +10002866requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002867run_test "Authentication: server max_int+1 chain, client optional" \
2868 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2869 key_file=data_files/dir-maxpath/10.key" \
2870 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2871 auth_mode=optional" \
2872 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002873 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002874
Angus Grattonc4dd0732018-04-11 16:28:39 +10002875requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002876run_test "Authentication: server max_int+1 chain, client none" \
2877 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2878 key_file=data_files/dir-maxpath/10.key" \
2879 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2880 auth_mode=none" \
2881 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002882 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002883
Angus Grattonc4dd0732018-04-11 16:28:39 +10002884requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002885run_test "Authentication: client max_int+1 chain, server default" \
2886 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2887 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2888 key_file=data_files/dir-maxpath/10.key" \
2889 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002890 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002891
Angus Grattonc4dd0732018-04-11 16:28:39 +10002892requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002893run_test "Authentication: client max_int+1 chain, server optional" \
2894 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2895 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2896 key_file=data_files/dir-maxpath/10.key" \
2897 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002898 -s "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: client max_int+1 chain, server required" \
2902 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2903 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2904 key_file=data_files/dir-maxpath/10.key" \
2905 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002906 -s "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: client max_int chain, server required" \
2910 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2911 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2912 key_file=data_files/dir-maxpath/09.key" \
2913 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002914 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002915
Janos Follath89baba22017-04-10 14:34:35 +01002916# Tests for CA list in CertificateRequest messages
2917
2918run_test "Authentication: send CA list in CertificateRequest (default)" \
2919 "$P_SRV debug_level=3 auth_mode=required" \
2920 "$P_CLI crt_file=data_files/server6.crt \
2921 key_file=data_files/server6.key" \
2922 0 \
2923 -s "requested DN"
2924
2925run_test "Authentication: do not send CA list in CertificateRequest" \
2926 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2927 "$P_CLI crt_file=data_files/server6.crt \
2928 key_file=data_files/server6.key" \
2929 0 \
2930 -S "requested DN"
2931
2932run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2933 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2934 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2935 key_file=data_files/server5.key" \
2936 1 \
2937 -S "requested DN" \
2938 -s "x509_verify_cert() returned" \
2939 -s "! The certificate is not correctly signed by the trusted CA" \
2940 -s "! mbedtls_ssl_handshake returned" \
2941 -c "! mbedtls_ssl_handshake returned" \
2942 -s "X509 - Certificate verification failed"
2943
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002944# Tests for certificate selection based on SHA verson
2945
2946run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2947 "$P_SRV crt_file=data_files/server5.crt \
2948 key_file=data_files/server5.key \
2949 crt_file2=data_files/server5-sha1.crt \
2950 key_file2=data_files/server5.key" \
2951 "$P_CLI force_version=tls1_2" \
2952 0 \
2953 -c "signed using.*ECDSA with SHA256" \
2954 -C "signed using.*ECDSA with SHA1"
2955
2956run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2957 "$P_SRV crt_file=data_files/server5.crt \
2958 key_file=data_files/server5.key \
2959 crt_file2=data_files/server5-sha1.crt \
2960 key_file2=data_files/server5.key" \
2961 "$P_CLI force_version=tls1_1" \
2962 0 \
2963 -C "signed using.*ECDSA with SHA256" \
2964 -c "signed using.*ECDSA with SHA1"
2965
2966run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2967 "$P_SRV crt_file=data_files/server5.crt \
2968 key_file=data_files/server5.key \
2969 crt_file2=data_files/server5-sha1.crt \
2970 key_file2=data_files/server5.key" \
2971 "$P_CLI force_version=tls1" \
2972 0 \
2973 -C "signed using.*ECDSA with SHA256" \
2974 -c "signed using.*ECDSA with SHA1"
2975
2976run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2977 "$P_SRV crt_file=data_files/server5.crt \
2978 key_file=data_files/server5.key \
2979 crt_file2=data_files/server6.crt \
2980 key_file2=data_files/server6.key" \
2981 "$P_CLI force_version=tls1_1" \
2982 0 \
2983 -c "serial number.*09" \
2984 -c "signed using.*ECDSA with SHA256" \
2985 -C "signed using.*ECDSA with SHA1"
2986
2987run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2988 "$P_SRV crt_file=data_files/server6.crt \
2989 key_file=data_files/server6.key \
2990 crt_file2=data_files/server5.crt \
2991 key_file2=data_files/server5.key" \
2992 "$P_CLI force_version=tls1_1" \
2993 0 \
2994 -c "serial number.*0A" \
2995 -c "signed using.*ECDSA with SHA256" \
2996 -C "signed using.*ECDSA with SHA1"
2997
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002998# tests for SNI
2999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003000run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003001 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003002 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003003 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003004 0 \
3005 -S "parse ServerName extension" \
3006 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3007 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003008
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003009run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003010 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003011 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003012 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003013 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003014 0 \
3015 -s "parse ServerName extension" \
3016 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3017 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003019run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003020 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003021 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003022 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003023 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003024 0 \
3025 -s "parse ServerName extension" \
3026 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3027 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003029run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003030 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003031 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003032 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 +02003033 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003034 1 \
3035 -s "parse ServerName extension" \
3036 -s "ssl_sni_wrapper() returned" \
3037 -s "mbedtls_ssl_handshake returned" \
3038 -c "mbedtls_ssl_handshake returned" \
3039 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003040
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003041run_test "SNI: client auth no override: optional" \
3042 "$P_SRV debug_level=3 auth_mode=optional \
3043 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3044 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3045 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003046 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003047 -S "skip write certificate request" \
3048 -C "skip parse certificate request" \
3049 -c "got a certificate request" \
3050 -C "skip write certificate" \
3051 -C "skip write certificate verify" \
3052 -S "skip parse certificate verify"
3053
3054run_test "SNI: client auth override: none -> optional" \
3055 "$P_SRV debug_level=3 auth_mode=none \
3056 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3057 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3058 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003059 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003060 -S "skip write certificate request" \
3061 -C "skip parse certificate request" \
3062 -c "got a certificate request" \
3063 -C "skip write certificate" \
3064 -C "skip write certificate verify" \
3065 -S "skip parse certificate verify"
3066
3067run_test "SNI: client auth override: optional -> none" \
3068 "$P_SRV debug_level=3 auth_mode=optional \
3069 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3070 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3071 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003072 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003073 -s "skip write certificate request" \
3074 -C "skip parse certificate request" \
3075 -c "got no certificate request" \
3076 -c "skip write certificate" \
3077 -c "skip write certificate verify" \
3078 -s "skip parse certificate verify"
3079
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003080run_test "SNI: CA no override" \
3081 "$P_SRV debug_level=3 auth_mode=optional \
3082 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3083 ca_file=data_files/test-ca.crt \
3084 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3085 "$P_CLI debug_level=3 server_name=localhost \
3086 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3087 1 \
3088 -S "skip write certificate request" \
3089 -C "skip parse certificate request" \
3090 -c "got a certificate request" \
3091 -C "skip write certificate" \
3092 -C "skip write certificate verify" \
3093 -S "skip parse certificate verify" \
3094 -s "x509_verify_cert() returned" \
3095 -s "! The certificate is not correctly signed by the trusted CA" \
3096 -S "The certificate has been revoked (is on a CRL)"
3097
3098run_test "SNI: CA override" \
3099 "$P_SRV debug_level=3 auth_mode=optional \
3100 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3101 ca_file=data_files/test-ca.crt \
3102 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3103 "$P_CLI debug_level=3 server_name=localhost \
3104 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3105 0 \
3106 -S "skip write certificate request" \
3107 -C "skip parse certificate request" \
3108 -c "got a certificate request" \
3109 -C "skip write certificate" \
3110 -C "skip write certificate verify" \
3111 -S "skip parse certificate verify" \
3112 -S "x509_verify_cert() returned" \
3113 -S "! The certificate is not correctly signed by the trusted CA" \
3114 -S "The certificate has been revoked (is on a CRL)"
3115
3116run_test "SNI: CA override with CRL" \
3117 "$P_SRV debug_level=3 auth_mode=optional \
3118 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3119 ca_file=data_files/test-ca.crt \
3120 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3121 "$P_CLI debug_level=3 server_name=localhost \
3122 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3123 1 \
3124 -S "skip write certificate request" \
3125 -C "skip parse certificate request" \
3126 -c "got a certificate request" \
3127 -C "skip write certificate" \
3128 -C "skip write certificate verify" \
3129 -S "skip parse certificate verify" \
3130 -s "x509_verify_cert() returned" \
3131 -S "! The certificate is not correctly signed by the trusted CA" \
3132 -s "The certificate has been revoked (is on a CRL)"
3133
Andres AG1a834452016-12-07 10:01:30 +00003134# Tests for SNI and DTLS
3135
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003136run_test "SNI: DTLS, no SNI callback" \
3137 "$P_SRV debug_level=3 dtls=1 \
3138 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3139 "$P_CLI server_name=localhost dtls=1" \
3140 0 \
3141 -S "parse ServerName extension" \
3142 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3143 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3144
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003145run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003146 "$P_SRV debug_level=3 dtls=1 \
3147 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3148 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3149 "$P_CLI server_name=localhost dtls=1" \
3150 0 \
3151 -s "parse ServerName extension" \
3152 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3153 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3154
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003155run_test "SNI: DTLS, matching cert 2" \
3156 "$P_SRV debug_level=3 dtls=1 \
3157 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3158 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3159 "$P_CLI server_name=polarssl.example dtls=1" \
3160 0 \
3161 -s "parse ServerName extension" \
3162 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3163 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3164
3165run_test "SNI: DTLS, no matching cert" \
3166 "$P_SRV debug_level=3 dtls=1 \
3167 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3168 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3169 "$P_CLI server_name=nonesuch.example dtls=1" \
3170 1 \
3171 -s "parse ServerName extension" \
3172 -s "ssl_sni_wrapper() returned" \
3173 -s "mbedtls_ssl_handshake returned" \
3174 -c "mbedtls_ssl_handshake returned" \
3175 -c "SSL - A fatal alert message was received from our peer"
3176
3177run_test "SNI: DTLS, client auth no override: optional" \
3178 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3179 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3180 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3181 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3182 0 \
3183 -S "skip write certificate request" \
3184 -C "skip parse certificate request" \
3185 -c "got a certificate request" \
3186 -C "skip write certificate" \
3187 -C "skip write certificate verify" \
3188 -S "skip parse certificate verify"
3189
3190run_test "SNI: DTLS, client auth override: none -> optional" \
3191 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3192 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3193 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3194 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3195 0 \
3196 -S "skip write certificate request" \
3197 -C "skip parse certificate request" \
3198 -c "got a certificate request" \
3199 -C "skip write certificate" \
3200 -C "skip write certificate verify" \
3201 -S "skip parse certificate verify"
3202
3203run_test "SNI: DTLS, client auth override: optional -> none" \
3204 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3205 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3206 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3207 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3208 0 \
3209 -s "skip write certificate request" \
3210 -C "skip parse certificate request" \
3211 -c "got no certificate request" \
3212 -c "skip write certificate" \
3213 -c "skip write certificate verify" \
3214 -s "skip parse certificate verify"
3215
3216run_test "SNI: DTLS, CA no override" \
3217 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3218 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3219 ca_file=data_files/test-ca.crt \
3220 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3221 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3222 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3223 1 \
3224 -S "skip write certificate request" \
3225 -C "skip parse certificate request" \
3226 -c "got a certificate request" \
3227 -C "skip write certificate" \
3228 -C "skip write certificate verify" \
3229 -S "skip parse certificate verify" \
3230 -s "x509_verify_cert() returned" \
3231 -s "! The certificate is not correctly signed by the trusted CA" \
3232 -S "The certificate has been revoked (is on a CRL)"
3233
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003234run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003235 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3236 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3237 ca_file=data_files/test-ca.crt \
3238 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3239 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3240 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3241 0 \
3242 -S "skip write certificate request" \
3243 -C "skip parse certificate request" \
3244 -c "got a certificate request" \
3245 -C "skip write certificate" \
3246 -C "skip write certificate verify" \
3247 -S "skip parse certificate verify" \
3248 -S "x509_verify_cert() returned" \
3249 -S "! The certificate is not correctly signed by the trusted CA" \
3250 -S "The certificate has been revoked (is on a CRL)"
3251
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003252run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003253 "$P_SRV debug_level=3 auth_mode=optional \
3254 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3255 ca_file=data_files/test-ca.crt \
3256 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3257 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3258 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3259 1 \
3260 -S "skip write certificate request" \
3261 -C "skip parse certificate request" \
3262 -c "got a certificate request" \
3263 -C "skip write certificate" \
3264 -C "skip write certificate verify" \
3265 -S "skip parse certificate verify" \
3266 -s "x509_verify_cert() returned" \
3267 -S "! The certificate is not correctly signed by the trusted CA" \
3268 -s "The certificate has been revoked (is on a CRL)"
3269
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003270# Tests for non-blocking I/O: exercise a variety of handshake flows
3271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003272run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003273 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3274 "$P_CLI nbio=2 tickets=0" \
3275 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003276 -S "mbedtls_ssl_handshake returned" \
3277 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003278 -c "Read from server: .* bytes read"
3279
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003280run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003281 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3282 "$P_CLI nbio=2 tickets=0" \
3283 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003284 -S "mbedtls_ssl_handshake returned" \
3285 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003286 -c "Read from server: .* bytes read"
3287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003288run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003289 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3290 "$P_CLI nbio=2 tickets=1" \
3291 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003292 -S "mbedtls_ssl_handshake returned" \
3293 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003294 -c "Read from server: .* bytes read"
3295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003296run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003297 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3298 "$P_CLI nbio=2 tickets=1" \
3299 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003300 -S "mbedtls_ssl_handshake returned" \
3301 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003302 -c "Read from server: .* bytes read"
3303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003304run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003305 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3306 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3307 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003308 -S "mbedtls_ssl_handshake returned" \
3309 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003310 -c "Read from server: .* bytes read"
3311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003312run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003313 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3314 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3315 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003316 -S "mbedtls_ssl_handshake returned" \
3317 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003318 -c "Read from server: .* bytes read"
3319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003320run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003321 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3322 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3323 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003324 -S "mbedtls_ssl_handshake returned" \
3325 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003326 -c "Read from server: .* bytes read"
3327
Hanno Becker00076712017-11-15 16:39:08 +00003328# Tests for event-driven I/O: exercise a variety of handshake flows
3329
3330run_test "Event-driven I/O: basic handshake" \
3331 "$P_SRV event=1 tickets=0 auth_mode=none" \
3332 "$P_CLI event=1 tickets=0" \
3333 0 \
3334 -S "mbedtls_ssl_handshake returned" \
3335 -C "mbedtls_ssl_handshake returned" \
3336 -c "Read from server: .* bytes read"
3337
3338run_test "Event-driven I/O: client auth" \
3339 "$P_SRV event=1 tickets=0 auth_mode=required" \
3340 "$P_CLI event=1 tickets=0" \
3341 0 \
3342 -S "mbedtls_ssl_handshake returned" \
3343 -C "mbedtls_ssl_handshake returned" \
3344 -c "Read from server: .* bytes read"
3345
3346run_test "Event-driven I/O: ticket" \
3347 "$P_SRV event=1 tickets=1 auth_mode=none" \
3348 "$P_CLI event=1 tickets=1" \
3349 0 \
3350 -S "mbedtls_ssl_handshake returned" \
3351 -C "mbedtls_ssl_handshake returned" \
3352 -c "Read from server: .* bytes read"
3353
3354run_test "Event-driven I/O: ticket + client auth" \
3355 "$P_SRV event=1 tickets=1 auth_mode=required" \
3356 "$P_CLI event=1 tickets=1" \
3357 0 \
3358 -S "mbedtls_ssl_handshake returned" \
3359 -C "mbedtls_ssl_handshake returned" \
3360 -c "Read from server: .* bytes read"
3361
3362run_test "Event-driven I/O: ticket + client auth + resume" \
3363 "$P_SRV event=1 tickets=1 auth_mode=required" \
3364 "$P_CLI event=1 tickets=1 reconnect=1" \
3365 0 \
3366 -S "mbedtls_ssl_handshake returned" \
3367 -C "mbedtls_ssl_handshake returned" \
3368 -c "Read from server: .* bytes read"
3369
3370run_test "Event-driven I/O: ticket + resume" \
3371 "$P_SRV event=1 tickets=1 auth_mode=none" \
3372 "$P_CLI event=1 tickets=1 reconnect=1" \
3373 0 \
3374 -S "mbedtls_ssl_handshake returned" \
3375 -C "mbedtls_ssl_handshake returned" \
3376 -c "Read from server: .* bytes read"
3377
3378run_test "Event-driven I/O: session-id resume" \
3379 "$P_SRV event=1 tickets=0 auth_mode=none" \
3380 "$P_CLI event=1 tickets=0 reconnect=1" \
3381 0 \
3382 -S "mbedtls_ssl_handshake returned" \
3383 -C "mbedtls_ssl_handshake returned" \
3384 -c "Read from server: .* bytes read"
3385
Hanno Becker6a33f592018-03-13 11:38:46 +00003386run_test "Event-driven I/O, DTLS: basic handshake" \
3387 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3388 "$P_CLI dtls=1 event=1 tickets=0" \
3389 0 \
3390 -c "Read from server: .* bytes read"
3391
3392run_test "Event-driven I/O, DTLS: client auth" \
3393 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3394 "$P_CLI dtls=1 event=1 tickets=0" \
3395 0 \
3396 -c "Read from server: .* bytes read"
3397
3398run_test "Event-driven I/O, DTLS: ticket" \
3399 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3400 "$P_CLI dtls=1 event=1 tickets=1" \
3401 0 \
3402 -c "Read from server: .* bytes read"
3403
3404run_test "Event-driven I/O, DTLS: ticket + client auth" \
3405 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3406 "$P_CLI dtls=1 event=1 tickets=1" \
3407 0 \
3408 -c "Read from server: .* bytes read"
3409
3410run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3411 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003412 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003413 0 \
3414 -c "Read from server: .* bytes read"
3415
3416run_test "Event-driven I/O, DTLS: ticket + resume" \
3417 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003418 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003419 0 \
3420 -c "Read from server: .* bytes read"
3421
3422run_test "Event-driven I/O, DTLS: session-id resume" \
3423 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003424 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003425 0 \
3426 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003427
3428# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3429# During session resumption, the client will send its ApplicationData record
3430# within the same datagram as the Finished messages. In this situation, the
3431# server MUST NOT idle on the underlying transport after handshake completion,
3432# because the ApplicationData request has already been queued internally.
3433run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003434 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003435 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003436 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003437 0 \
3438 -c "Read from server: .* bytes read"
3439
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003440# Tests for version negotiation
3441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003442run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003443 "$P_SRV" \
3444 "$P_CLI" \
3445 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003446 -S "mbedtls_ssl_handshake returned" \
3447 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003448 -s "Protocol is TLSv1.2" \
3449 -c "Protocol is TLSv1.2"
3450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003451run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003452 "$P_SRV" \
3453 "$P_CLI max_version=tls1_1" \
3454 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003455 -S "mbedtls_ssl_handshake returned" \
3456 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003457 -s "Protocol is TLSv1.1" \
3458 -c "Protocol is TLSv1.1"
3459
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003460run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003461 "$P_SRV max_version=tls1_1" \
3462 "$P_CLI" \
3463 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003464 -S "mbedtls_ssl_handshake returned" \
3465 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003466 -s "Protocol is TLSv1.1" \
3467 -c "Protocol is TLSv1.1"
3468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003469run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003470 "$P_SRV max_version=tls1_1" \
3471 "$P_CLI max_version=tls1_1" \
3472 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003473 -S "mbedtls_ssl_handshake returned" \
3474 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003475 -s "Protocol is TLSv1.1" \
3476 -c "Protocol is TLSv1.1"
3477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003478run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003479 "$P_SRV min_version=tls1_1" \
3480 "$P_CLI max_version=tls1_1" \
3481 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003482 -S "mbedtls_ssl_handshake returned" \
3483 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003484 -s "Protocol is TLSv1.1" \
3485 -c "Protocol is TLSv1.1"
3486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003487run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003488 "$P_SRV max_version=tls1_1" \
3489 "$P_CLI min_version=tls1_1" \
3490 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003491 -S "mbedtls_ssl_handshake returned" \
3492 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003493 -s "Protocol is TLSv1.1" \
3494 -c "Protocol is TLSv1.1"
3495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003496run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003497 "$P_SRV max_version=tls1_1" \
3498 "$P_CLI min_version=tls1_2" \
3499 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003500 -s "mbedtls_ssl_handshake returned" \
3501 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003502 -c "SSL - Handshake protocol not within min/max boundaries"
3503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003504run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003505 "$P_SRV min_version=tls1_2" \
3506 "$P_CLI max_version=tls1_1" \
3507 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003508 -s "mbedtls_ssl_handshake returned" \
3509 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003510 -s "SSL - Handshake protocol not within min/max boundaries"
3511
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003512# Tests for ALPN extension
3513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003514run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003515 "$P_SRV debug_level=3" \
3516 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003517 0 \
3518 -C "client hello, adding alpn extension" \
3519 -S "found alpn extension" \
3520 -C "got an alert message, type: \\[2:120]" \
3521 -S "server hello, adding alpn extension" \
3522 -C "found alpn extension " \
3523 -C "Application Layer Protocol is" \
3524 -S "Application Layer Protocol is"
3525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003526run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003527 "$P_SRV debug_level=3" \
3528 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003529 0 \
3530 -c "client hello, adding alpn extension" \
3531 -s "found alpn extension" \
3532 -C "got an alert message, type: \\[2:120]" \
3533 -S "server hello, adding alpn extension" \
3534 -C "found alpn extension " \
3535 -c "Application Layer Protocol is (none)" \
3536 -S "Application Layer Protocol is"
3537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003538run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003539 "$P_SRV debug_level=3 alpn=abc,1234" \
3540 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003541 0 \
3542 -C "client hello, adding alpn extension" \
3543 -S "found alpn extension" \
3544 -C "got an alert message, type: \\[2:120]" \
3545 -S "server hello, adding alpn extension" \
3546 -C "found alpn extension " \
3547 -C "Application Layer Protocol is" \
3548 -s "Application Layer Protocol is (none)"
3549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003550run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003551 "$P_SRV debug_level=3 alpn=abc,1234" \
3552 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003553 0 \
3554 -c "client hello, adding alpn extension" \
3555 -s "found alpn extension" \
3556 -C "got an alert message, type: \\[2:120]" \
3557 -s "server hello, adding alpn extension" \
3558 -c "found alpn extension" \
3559 -c "Application Layer Protocol is abc" \
3560 -s "Application Layer Protocol is abc"
3561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003562run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003563 "$P_SRV debug_level=3 alpn=abc,1234" \
3564 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003565 0 \
3566 -c "client hello, adding alpn extension" \
3567 -s "found alpn extension" \
3568 -C "got an alert message, type: \\[2:120]" \
3569 -s "server hello, adding alpn extension" \
3570 -c "found alpn extension" \
3571 -c "Application Layer Protocol is abc" \
3572 -s "Application Layer Protocol is abc"
3573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003574run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003575 "$P_SRV debug_level=3 alpn=abc,1234" \
3576 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003577 0 \
3578 -c "client hello, adding alpn extension" \
3579 -s "found alpn extension" \
3580 -C "got an alert message, type: \\[2:120]" \
3581 -s "server hello, adding alpn extension" \
3582 -c "found alpn extension" \
3583 -c "Application Layer Protocol is 1234" \
3584 -s "Application Layer Protocol is 1234"
3585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003586run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003587 "$P_SRV debug_level=3 alpn=abc,123" \
3588 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003589 1 \
3590 -c "client hello, adding alpn extension" \
3591 -s "found alpn extension" \
3592 -c "got an alert message, type: \\[2:120]" \
3593 -S "server hello, adding alpn extension" \
3594 -C "found alpn extension" \
3595 -C "Application Layer Protocol is 1234" \
3596 -S "Application Layer Protocol is 1234"
3597
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003598
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003599# Tests for keyUsage in leaf certificates, part 1:
3600# server-side certificate/suite selection
3601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003602run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003603 "$P_SRV key_file=data_files/server2.key \
3604 crt_file=data_files/server2.ku-ds.crt" \
3605 "$P_CLI" \
3606 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003607 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003608
3609
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003610run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003611 "$P_SRV key_file=data_files/server2.key \
3612 crt_file=data_files/server2.ku-ke.crt" \
3613 "$P_CLI" \
3614 0 \
3615 -c "Ciphersuite is TLS-RSA-WITH-"
3616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003617run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003618 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003619 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003620 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003621 1 \
3622 -C "Ciphersuite is "
3623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003624run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003625 "$P_SRV key_file=data_files/server5.key \
3626 crt_file=data_files/server5.ku-ds.crt" \
3627 "$P_CLI" \
3628 0 \
3629 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3630
3631
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003632run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003633 "$P_SRV key_file=data_files/server5.key \
3634 crt_file=data_files/server5.ku-ka.crt" \
3635 "$P_CLI" \
3636 0 \
3637 -c "Ciphersuite is TLS-ECDH-"
3638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003639run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003640 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003641 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003642 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003643 1 \
3644 -C "Ciphersuite is "
3645
3646# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003647# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003649run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003650 "$O_SRV -key data_files/server2.key \
3651 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003652 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003653 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3654 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003655 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003656 -C "Processing of the Certificate handshake message failed" \
3657 -c "Ciphersuite is TLS-"
3658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003659run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003660 "$O_SRV -key data_files/server2.key \
3661 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003662 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003663 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3664 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003665 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003666 -C "Processing of the Certificate handshake message failed" \
3667 -c "Ciphersuite is TLS-"
3668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003669run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003670 "$O_SRV -key data_files/server2.key \
3671 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003672 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003673 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3674 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003675 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003676 -C "Processing of the Certificate handshake message failed" \
3677 -c "Ciphersuite is TLS-"
3678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003679run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003680 "$O_SRV -key data_files/server2.key \
3681 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003682 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003683 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3684 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003685 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003686 -c "Processing of the Certificate handshake message failed" \
3687 -C "Ciphersuite is TLS-"
3688
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003689run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3690 "$O_SRV -key data_files/server2.key \
3691 -cert data_files/server2.ku-ke.crt" \
3692 "$P_CLI debug_level=1 auth_mode=optional \
3693 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3694 0 \
3695 -c "bad certificate (usage extensions)" \
3696 -C "Processing of the Certificate handshake message failed" \
3697 -c "Ciphersuite is TLS-" \
3698 -c "! Usage does not match the keyUsage extension"
3699
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003700run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003701 "$O_SRV -key data_files/server2.key \
3702 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003703 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003704 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3705 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003706 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003707 -C "Processing of the Certificate handshake message failed" \
3708 -c "Ciphersuite is TLS-"
3709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003710run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003711 "$O_SRV -key data_files/server2.key \
3712 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003713 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003714 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3715 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003716 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003717 -c "Processing of the Certificate handshake message failed" \
3718 -C "Ciphersuite is TLS-"
3719
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003720run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3721 "$O_SRV -key data_files/server2.key \
3722 -cert data_files/server2.ku-ds.crt" \
3723 "$P_CLI debug_level=1 auth_mode=optional \
3724 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3725 0 \
3726 -c "bad certificate (usage extensions)" \
3727 -C "Processing of the Certificate handshake message failed" \
3728 -c "Ciphersuite is TLS-" \
3729 -c "! Usage does not match the keyUsage extension"
3730
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003731# Tests for keyUsage in leaf certificates, part 3:
3732# server-side checking of client cert
3733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003734run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003735 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003736 "$O_CLI -key data_files/server2.key \
3737 -cert data_files/server2.ku-ds.crt" \
3738 0 \
3739 -S "bad certificate (usage extensions)" \
3740 -S "Processing of the Certificate handshake message failed"
3741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003742run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003743 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003744 "$O_CLI -key data_files/server2.key \
3745 -cert data_files/server2.ku-ke.crt" \
3746 0 \
3747 -s "bad certificate (usage extensions)" \
3748 -S "Processing of the Certificate handshake message failed"
3749
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003750run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003751 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003752 "$O_CLI -key data_files/server2.key \
3753 -cert data_files/server2.ku-ke.crt" \
3754 1 \
3755 -s "bad certificate (usage extensions)" \
3756 -s "Processing of the Certificate handshake message failed"
3757
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003758run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003759 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003760 "$O_CLI -key data_files/server5.key \
3761 -cert data_files/server5.ku-ds.crt" \
3762 0 \
3763 -S "bad certificate (usage extensions)" \
3764 -S "Processing of the Certificate handshake message failed"
3765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003766run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003767 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003768 "$O_CLI -key data_files/server5.key \
3769 -cert data_files/server5.ku-ka.crt" \
3770 0 \
3771 -s "bad certificate (usage extensions)" \
3772 -S "Processing of the Certificate handshake message failed"
3773
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003774# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003776run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003777 "$P_SRV key_file=data_files/server5.key \
3778 crt_file=data_files/server5.eku-srv.crt" \
3779 "$P_CLI" \
3780 0
3781
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003782run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003783 "$P_SRV key_file=data_files/server5.key \
3784 crt_file=data_files/server5.eku-srv.crt" \
3785 "$P_CLI" \
3786 0
3787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003788run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003789 "$P_SRV key_file=data_files/server5.key \
3790 crt_file=data_files/server5.eku-cs_any.crt" \
3791 "$P_CLI" \
3792 0
3793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003794run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003795 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003796 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003797 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003798 1
3799
3800# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003802run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003803 "$O_SRV -key data_files/server5.key \
3804 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003805 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003806 0 \
3807 -C "bad certificate (usage extensions)" \
3808 -C "Processing of the Certificate handshake message failed" \
3809 -c "Ciphersuite is TLS-"
3810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003811run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003812 "$O_SRV -key data_files/server5.key \
3813 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003814 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003815 0 \
3816 -C "bad certificate (usage extensions)" \
3817 -C "Processing of the Certificate handshake message failed" \
3818 -c "Ciphersuite is TLS-"
3819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003820run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003821 "$O_SRV -key data_files/server5.key \
3822 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003823 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003824 0 \
3825 -C "bad certificate (usage extensions)" \
3826 -C "Processing of the Certificate handshake message failed" \
3827 -c "Ciphersuite is TLS-"
3828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003829run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003830 "$O_SRV -key data_files/server5.key \
3831 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003832 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003833 1 \
3834 -c "bad certificate (usage extensions)" \
3835 -c "Processing of the Certificate handshake message failed" \
3836 -C "Ciphersuite is TLS-"
3837
3838# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003840run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003841 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003842 "$O_CLI -key data_files/server5.key \
3843 -cert data_files/server5.eku-cli.crt" \
3844 0 \
3845 -S "bad certificate (usage extensions)" \
3846 -S "Processing of the Certificate handshake message failed"
3847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003848run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003849 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003850 "$O_CLI -key data_files/server5.key \
3851 -cert data_files/server5.eku-srv_cli.crt" \
3852 0 \
3853 -S "bad certificate (usage extensions)" \
3854 -S "Processing of the Certificate handshake message failed"
3855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003856run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003857 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003858 "$O_CLI -key data_files/server5.key \
3859 -cert data_files/server5.eku-cs_any.crt" \
3860 0 \
3861 -S "bad certificate (usage extensions)" \
3862 -S "Processing of the Certificate handshake message failed"
3863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003864run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003865 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003866 "$O_CLI -key data_files/server5.key \
3867 -cert data_files/server5.eku-cs.crt" \
3868 0 \
3869 -s "bad certificate (usage extensions)" \
3870 -S "Processing of the Certificate handshake message failed"
3871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003872run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003873 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003874 "$O_CLI -key data_files/server5.key \
3875 -cert data_files/server5.eku-cs.crt" \
3876 1 \
3877 -s "bad certificate (usage extensions)" \
3878 -s "Processing of the Certificate handshake message failed"
3879
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003880# Tests for DHM parameters loading
3881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003882run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003883 "$P_SRV" \
3884 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3885 debug_level=3" \
3886 0 \
3887 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003888 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003890run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003891 "$P_SRV dhm_file=data_files/dhparams.pem" \
3892 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3893 debug_level=3" \
3894 0 \
3895 -c "value of 'DHM: P ' (1024 bits)" \
3896 -c "value of 'DHM: G ' (2 bits)"
3897
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003898# Tests for DHM client-side size checking
3899
3900run_test "DHM size: server default, client default, OK" \
3901 "$P_SRV" \
3902 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3903 debug_level=1" \
3904 0 \
3905 -C "DHM prime too short:"
3906
3907run_test "DHM size: server default, client 2048, OK" \
3908 "$P_SRV" \
3909 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3910 debug_level=1 dhmlen=2048" \
3911 0 \
3912 -C "DHM prime too short:"
3913
3914run_test "DHM size: server 1024, client default, OK" \
3915 "$P_SRV dhm_file=data_files/dhparams.pem" \
3916 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3917 debug_level=1" \
3918 0 \
3919 -C "DHM prime too short:"
3920
3921run_test "DHM size: server 1000, client default, rejected" \
3922 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3923 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3924 debug_level=1" \
3925 1 \
3926 -c "DHM prime too short:"
3927
3928run_test "DHM size: server default, client 2049, rejected" \
3929 "$P_SRV" \
3930 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3931 debug_level=1 dhmlen=2049" \
3932 1 \
3933 -c "DHM prime too short:"
3934
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003935# Tests for PSK callback
3936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003937run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003938 "$P_SRV psk=abc123 psk_identity=foo" \
3939 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3940 psk_identity=foo psk=abc123" \
3941 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003942 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003943 -S "SSL - Unknown identity received" \
3944 -S "SSL - Verification of the message MAC failed"
3945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003946run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003947 "$P_SRV" \
3948 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3949 psk_identity=foo psk=abc123" \
3950 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003951 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003952 -S "SSL - Unknown identity received" \
3953 -S "SSL - Verification of the message MAC failed"
3954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003955run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003956 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3957 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3958 psk_identity=foo psk=abc123" \
3959 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003960 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003961 -s "SSL - Unknown identity received" \
3962 -S "SSL - Verification of the message MAC failed"
3963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003964run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003965 "$P_SRV psk_list=abc,dead,def,beef" \
3966 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3967 psk_identity=abc psk=dead" \
3968 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003969 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003970 -S "SSL - Unknown identity received" \
3971 -S "SSL - Verification of the message MAC failed"
3972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003973run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003974 "$P_SRV psk_list=abc,dead,def,beef" \
3975 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3976 psk_identity=def psk=beef" \
3977 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003978 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003979 -S "SSL - Unknown identity received" \
3980 -S "SSL - Verification of the message MAC failed"
3981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003982run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003983 "$P_SRV psk_list=abc,dead,def,beef" \
3984 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3985 psk_identity=ghi psk=beef" \
3986 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003987 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003988 -s "SSL - Unknown identity received" \
3989 -S "SSL - Verification of the message MAC failed"
3990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003991run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003992 "$P_SRV psk_list=abc,dead,def,beef" \
3993 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3994 psk_identity=abc psk=beef" \
3995 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003996 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003997 -S "SSL - Unknown identity received" \
3998 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003999
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004000# Tests for EC J-PAKE
4001
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004002requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004003run_test "ECJPAKE: client not configured" \
4004 "$P_SRV debug_level=3" \
4005 "$P_CLI debug_level=3" \
4006 0 \
4007 -C "add ciphersuite: c0ff" \
4008 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004009 -S "found ecjpake kkpp extension" \
4010 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004011 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004012 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004013 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004014 -S "None of the common ciphersuites is usable"
4015
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004016requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004017run_test "ECJPAKE: server not configured" \
4018 "$P_SRV debug_level=3" \
4019 "$P_CLI debug_level=3 ecjpake_pw=bla \
4020 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4021 1 \
4022 -c "add ciphersuite: c0ff" \
4023 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004024 -s "found ecjpake kkpp extension" \
4025 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004026 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004027 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004028 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004029 -s "None of the common ciphersuites is usable"
4030
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004031requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004032run_test "ECJPAKE: working, TLS" \
4033 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4034 "$P_CLI debug_level=3 ecjpake_pw=bla \
4035 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004036 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004037 -c "add ciphersuite: c0ff" \
4038 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004039 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004040 -s "found ecjpake kkpp extension" \
4041 -S "skip ecjpake kkpp extension" \
4042 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004043 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004044 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004045 -S "None of the common ciphersuites is usable" \
4046 -S "SSL - Verification of the message MAC failed"
4047
Janos Follath74537a62016-09-02 13:45:28 +01004048server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004049requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004050run_test "ECJPAKE: password mismatch, TLS" \
4051 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4052 "$P_CLI debug_level=3 ecjpake_pw=bad \
4053 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4054 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004055 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004056 -s "SSL - Verification of the message MAC failed"
4057
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004058requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004059run_test "ECJPAKE: working, DTLS" \
4060 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4061 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4062 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4063 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004064 -c "re-using cached ecjpake parameters" \
4065 -S "SSL - Verification of the message MAC failed"
4066
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004067requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004068run_test "ECJPAKE: working, DTLS, no cookie" \
4069 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4070 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4071 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4072 0 \
4073 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004074 -S "SSL - Verification of the message MAC failed"
4075
Janos Follath74537a62016-09-02 13:45:28 +01004076server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004077requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004078run_test "ECJPAKE: password mismatch, DTLS" \
4079 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4080 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4081 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4082 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004083 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004084 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004085
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004086# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004087requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004088run_test "ECJPAKE: working, DTLS, nolog" \
4089 "$P_SRV dtls=1 ecjpake_pw=bla" \
4090 "$P_CLI dtls=1 ecjpake_pw=bla \
4091 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4092 0
4093
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004094# Tests for ciphersuites per version
4095
Janos Follathe2681a42016-03-07 15:57:05 +00004096requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004097requires_config_enabled MBEDTLS_CAMELLIA_C
4098requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004099run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004100 "$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 +02004101 "$P_CLI force_version=ssl3" \
4102 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004103 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004104
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004105requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4106requires_config_enabled MBEDTLS_CAMELLIA_C
4107requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004108run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004109 "$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 +01004110 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004111 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004112 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004113
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004114requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4115requires_config_enabled MBEDTLS_CAMELLIA_C
4116requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004117run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004118 "$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 +02004119 "$P_CLI force_version=tls1_1" \
4120 0 \
4121 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4122
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004123requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4124requires_config_enabled MBEDTLS_CAMELLIA_C
4125requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004126run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004127 "$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 +02004128 "$P_CLI force_version=tls1_2" \
4129 0 \
4130 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4131
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004132# Test for ClientHello without extensions
4133
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004134requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004135run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004136 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004137 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004138 0 \
4139 -s "dumping 'client hello extensions' (0 bytes)"
4140
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004141# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004142
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004143run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004144 "$P_SRV" \
4145 "$P_CLI request_size=100" \
4146 0 \
4147 -s "Read from client: 100 bytes read$"
4148
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004149run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004150 "$P_SRV" \
4151 "$P_CLI request_size=500" \
4152 0 \
4153 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004154
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004155# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004156
Janos Follathe2681a42016-03-07 15:57:05 +00004157requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004158run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004159 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004160 "$P_CLI request_size=1 force_version=ssl3 \
4161 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4162 0 \
4163 -s "Read from client: 1 bytes read"
4164
Janos Follathe2681a42016-03-07 15:57:05 +00004165requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004166run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004167 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004168 "$P_CLI request_size=1 force_version=ssl3 \
4169 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4170 0 \
4171 -s "Read from client: 1 bytes read"
4172
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004173run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004174 "$P_SRV" \
4175 "$P_CLI request_size=1 force_version=tls1 \
4176 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4177 0 \
4178 -s "Read from client: 1 bytes read"
4179
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004180run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004181 "$P_SRV" \
4182 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4183 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4184 0 \
4185 -s "Read from client: 1 bytes read"
4186
Hanno Becker32c55012017-11-10 08:42:54 +00004187requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004188run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004189 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004190 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004191 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004192 0 \
4193 -s "Read from client: 1 bytes read"
4194
Hanno Becker32c55012017-11-10 08:42:54 +00004195requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004196run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004197 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004198 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004199 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004200 0 \
4201 -s "Read from client: 1 bytes read"
4202
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004203run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004204 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004205 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004206 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4207 0 \
4208 -s "Read from client: 1 bytes read"
4209
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004210run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004211 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4212 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004213 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004214 0 \
4215 -s "Read from client: 1 bytes read"
4216
4217requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004218run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004219 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004220 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004221 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004222 0 \
4223 -s "Read from client: 1 bytes read"
4224
Hanno Becker8501f982017-11-10 08:59:04 +00004225requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004226run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004227 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4228 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4229 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004230 0 \
4231 -s "Read from client: 1 bytes read"
4232
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004233run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004234 "$P_SRV" \
4235 "$P_CLI request_size=1 force_version=tls1_1 \
4236 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4237 0 \
4238 -s "Read from client: 1 bytes read"
4239
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004240run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004241 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004242 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004243 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004244 0 \
4245 -s "Read from client: 1 bytes read"
4246
4247requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004248run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004249 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004250 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004251 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004252 0 \
4253 -s "Read from client: 1 bytes read"
4254
4255requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004256run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004257 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004258 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004259 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004260 0 \
4261 -s "Read from client: 1 bytes read"
4262
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004263run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004264 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004265 "$P_CLI request_size=1 force_version=tls1_1 \
4266 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4267 0 \
4268 -s "Read from client: 1 bytes read"
4269
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004270run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004271 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004272 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004273 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004274 0 \
4275 -s "Read from client: 1 bytes read"
4276
Hanno Becker8501f982017-11-10 08:59:04 +00004277requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004278run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004279 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004280 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004281 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004282 0 \
4283 -s "Read from client: 1 bytes read"
4284
Hanno Becker32c55012017-11-10 08:42:54 +00004285requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004286run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004287 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004288 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004289 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004290 0 \
4291 -s "Read from client: 1 bytes read"
4292
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004293run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004294 "$P_SRV" \
4295 "$P_CLI request_size=1 force_version=tls1_2 \
4296 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4297 0 \
4298 -s "Read from client: 1 bytes read"
4299
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004300run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004301 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004302 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004303 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004304 0 \
4305 -s "Read from client: 1 bytes read"
4306
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004307run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004308 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004309 "$P_CLI request_size=1 force_version=tls1_2 \
4310 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004311 0 \
4312 -s "Read from client: 1 bytes read"
4313
Hanno Becker32c55012017-11-10 08:42:54 +00004314requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004315run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004316 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004317 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004318 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004319 0 \
4320 -s "Read from client: 1 bytes read"
4321
Hanno Becker8501f982017-11-10 08:59:04 +00004322requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004323run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004324 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004325 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004326 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004327 0 \
4328 -s "Read from client: 1 bytes read"
4329
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004330run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004331 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004332 "$P_CLI request_size=1 force_version=tls1_2 \
4333 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4334 0 \
4335 -s "Read from client: 1 bytes read"
4336
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004337run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004338 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004339 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004340 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004341 0 \
4342 -s "Read from client: 1 bytes read"
4343
Hanno Becker32c55012017-11-10 08:42:54 +00004344requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004345run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004346 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004347 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004348 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004349 0 \
4350 -s "Read from client: 1 bytes read"
4351
Hanno Becker8501f982017-11-10 08:59:04 +00004352requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004353run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004354 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004355 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004356 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004357 0 \
4358 -s "Read from client: 1 bytes read"
4359
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004360run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004361 "$P_SRV" \
4362 "$P_CLI request_size=1 force_version=tls1_2 \
4363 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4364 0 \
4365 -s "Read from client: 1 bytes read"
4366
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004367run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004368 "$P_SRV" \
4369 "$P_CLI request_size=1 force_version=tls1_2 \
4370 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4371 0 \
4372 -s "Read from client: 1 bytes read"
4373
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004374# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004375
4376requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004377run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004378 "$P_SRV dtls=1 force_version=dtls1" \
4379 "$P_CLI dtls=1 request_size=1 \
4380 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4381 0 \
4382 -s "Read from client: 1 bytes read"
4383
4384requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004385run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004386 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4387 "$P_CLI dtls=1 request_size=1 \
4388 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4389 0 \
4390 -s "Read from client: 1 bytes read"
4391
4392requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4393requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004394run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004395 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4396 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004397 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4398 0 \
4399 -s "Read from client: 1 bytes read"
4400
4401requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4402requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004403run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004404 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004405 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004406 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004407 0 \
4408 -s "Read from client: 1 bytes read"
4409
4410requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004411run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004412 "$P_SRV dtls=1 force_version=dtls1_2" \
4413 "$P_CLI dtls=1 request_size=1 \
4414 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4415 0 \
4416 -s "Read from client: 1 bytes read"
4417
4418requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004419run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004420 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004421 "$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
4427requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004428run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004429 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004430 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004431 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004432 0 \
4433 -s "Read from client: 1 bytes read"
4434
4435requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4436requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004437run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004438 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004439 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004440 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004441 0 \
4442 -s "Read from client: 1 bytes read"
4443
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004444# Tests for small server packets
4445
4446requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4447run_test "Small server packet SSLv3 BlockCipher" \
4448 "$P_SRV response_size=1 min_version=ssl3" \
4449 "$P_CLI force_version=ssl3 \
4450 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4451 0 \
4452 -c "Read from server: 1 bytes read"
4453
4454requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4455run_test "Small server packet SSLv3 StreamCipher" \
4456 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4457 "$P_CLI force_version=ssl3 \
4458 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4459 0 \
4460 -c "Read from server: 1 bytes read"
4461
4462run_test "Small server packet TLS 1.0 BlockCipher" \
4463 "$P_SRV response_size=1" \
4464 "$P_CLI force_version=tls1 \
4465 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4466 0 \
4467 -c "Read from server: 1 bytes read"
4468
4469run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4470 "$P_SRV response_size=1" \
4471 "$P_CLI force_version=tls1 etm=0 \
4472 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4473 0 \
4474 -c "Read from server: 1 bytes read"
4475
4476requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4477run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4478 "$P_SRV response_size=1 trunc_hmac=1" \
4479 "$P_CLI force_version=tls1 \
4480 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4481 0 \
4482 -c "Read from server: 1 bytes read"
4483
4484requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4485run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4486 "$P_SRV response_size=1 trunc_hmac=1" \
4487 "$P_CLI force_version=tls1 \
4488 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4489 0 \
4490 -c "Read from server: 1 bytes read"
4491
4492run_test "Small server packet TLS 1.0 StreamCipher" \
4493 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4494 "$P_CLI force_version=tls1 \
4495 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4496 0 \
4497 -c "Read from server: 1 bytes read"
4498
4499run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4500 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4501 "$P_CLI force_version=tls1 \
4502 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4503 0 \
4504 -c "Read from server: 1 bytes read"
4505
4506requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4507run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4508 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4509 "$P_CLI force_version=tls1 \
4510 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4511 0 \
4512 -c "Read from server: 1 bytes read"
4513
4514requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4515run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4516 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4517 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4518 trunc_hmac=1 etm=0" \
4519 0 \
4520 -c "Read from server: 1 bytes read"
4521
4522run_test "Small server packet TLS 1.1 BlockCipher" \
4523 "$P_SRV response_size=1" \
4524 "$P_CLI force_version=tls1_1 \
4525 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4526 0 \
4527 -c "Read from server: 1 bytes read"
4528
4529run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4530 "$P_SRV response_size=1" \
4531 "$P_CLI force_version=tls1_1 \
4532 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4533 0 \
4534 -c "Read from server: 1 bytes read"
4535
4536requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4537run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4538 "$P_SRV response_size=1 trunc_hmac=1" \
4539 "$P_CLI force_version=tls1_1 \
4540 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4541 0 \
4542 -c "Read from server: 1 bytes read"
4543
4544requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4545run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4546 "$P_SRV response_size=1 trunc_hmac=1" \
4547 "$P_CLI force_version=tls1_1 \
4548 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4549 0 \
4550 -c "Read from server: 1 bytes read"
4551
4552run_test "Small server packet TLS 1.1 StreamCipher" \
4553 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4554 "$P_CLI force_version=tls1_1 \
4555 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4556 0 \
4557 -c "Read from server: 1 bytes read"
4558
4559run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4560 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4561 "$P_CLI force_version=tls1_1 \
4562 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4563 0 \
4564 -c "Read from server: 1 bytes read"
4565
4566requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4567run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4568 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4569 "$P_CLI force_version=tls1_1 \
4570 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4571 0 \
4572 -c "Read from server: 1 bytes read"
4573
4574requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4575run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4576 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4577 "$P_CLI force_version=tls1_1 \
4578 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4579 0 \
4580 -c "Read from server: 1 bytes read"
4581
4582run_test "Small server packet TLS 1.2 BlockCipher" \
4583 "$P_SRV response_size=1" \
4584 "$P_CLI force_version=tls1_2 \
4585 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4586 0 \
4587 -c "Read from server: 1 bytes read"
4588
4589run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4590 "$P_SRV response_size=1" \
4591 "$P_CLI force_version=tls1_2 \
4592 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4593 0 \
4594 -c "Read from server: 1 bytes read"
4595
4596run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4597 "$P_SRV response_size=1" \
4598 "$P_CLI force_version=tls1_2 \
4599 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4600 0 \
4601 -c "Read from server: 1 bytes read"
4602
4603requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4604run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4605 "$P_SRV response_size=1 trunc_hmac=1" \
4606 "$P_CLI force_version=tls1_2 \
4607 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4608 0 \
4609 -c "Read from server: 1 bytes read"
4610
4611requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4612run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4613 "$P_SRV response_size=1 trunc_hmac=1" \
4614 "$P_CLI force_version=tls1_2 \
4615 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4616 0 \
4617 -c "Read from server: 1 bytes read"
4618
4619run_test "Small server packet TLS 1.2 StreamCipher" \
4620 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4621 "$P_CLI force_version=tls1_2 \
4622 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4623 0 \
4624 -c "Read from server: 1 bytes read"
4625
4626run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4627 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4628 "$P_CLI force_version=tls1_2 \
4629 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4630 0 \
4631 -c "Read from server: 1 bytes read"
4632
4633requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4634run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4635 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4636 "$P_CLI force_version=tls1_2 \
4637 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4638 0 \
4639 -c "Read from server: 1 bytes read"
4640
4641requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4642run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4643 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4644 "$P_CLI force_version=tls1_2 \
4645 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4646 0 \
4647 -c "Read from server: 1 bytes read"
4648
4649run_test "Small server packet TLS 1.2 AEAD" \
4650 "$P_SRV response_size=1" \
4651 "$P_CLI force_version=tls1_2 \
4652 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4653 0 \
4654 -c "Read from server: 1 bytes read"
4655
4656run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4657 "$P_SRV response_size=1" \
4658 "$P_CLI force_version=tls1_2 \
4659 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4660 0 \
4661 -c "Read from server: 1 bytes read"
4662
4663# Tests for small server packets in DTLS
4664
4665requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4666run_test "Small server packet DTLS 1.0" \
4667 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4668 "$P_CLI dtls=1 \
4669 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4670 0 \
4671 -c "Read from server: 1 bytes read"
4672
4673requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4674run_test "Small server packet DTLS 1.0, without EtM" \
4675 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4676 "$P_CLI dtls=1 \
4677 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4678 0 \
4679 -c "Read from server: 1 bytes read"
4680
4681requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4682requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4683run_test "Small server packet DTLS 1.0, truncated hmac" \
4684 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4685 "$P_CLI dtls=1 trunc_hmac=1 \
4686 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4687 0 \
4688 -c "Read from server: 1 bytes read"
4689
4690requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4691requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4692run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4693 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4694 "$P_CLI dtls=1 \
4695 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4696 0 \
4697 -c "Read from server: 1 bytes read"
4698
4699requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4700run_test "Small server packet DTLS 1.2" \
4701 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4702 "$P_CLI dtls=1 \
4703 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4704 0 \
4705 -c "Read from server: 1 bytes read"
4706
4707requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4708run_test "Small server packet DTLS 1.2, without EtM" \
4709 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
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
4716requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4717run_test "Small server packet DTLS 1.2, truncated hmac" \
4718 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4719 "$P_CLI dtls=1 \
4720 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4721 0 \
4722 -c "Read from server: 1 bytes read"
4723
4724requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4725requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4726run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4727 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4728 "$P_CLI dtls=1 \
4729 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4730 0 \
4731 -c "Read from server: 1 bytes read"
4732
Janos Follath00efff72016-05-06 13:48:23 +01004733# A test for extensions in SSLv3
4734
4735requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4736run_test "SSLv3 with extensions, server side" \
4737 "$P_SRV min_version=ssl3 debug_level=3" \
4738 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4739 0 \
4740 -S "dumping 'client hello extensions'" \
4741 -S "server hello, total extension length:"
4742
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004743# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004744
Angus Grattonc4dd0732018-04-11 16:28:39 +10004745# How many fragments do we expect to write $1 bytes?
4746fragments_for_write() {
4747 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4748}
4749
Janos Follathe2681a42016-03-07 15:57:05 +00004750requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004751run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004752 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004753 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004754 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4755 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004756 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4757 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004758
Janos Follathe2681a42016-03-07 15:57:05 +00004759requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004760run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004761 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004762 "$P_CLI request_size=16384 force_version=ssl3 \
4763 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4764 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004765 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4766 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004767
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004768run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004769 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004770 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004771 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4772 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004773 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4774 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004775
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004776run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004777 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004778 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4779 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4780 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004781 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004782
Hanno Becker32c55012017-11-10 08:42:54 +00004783requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004784run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004785 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004786 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004787 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004788 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004789 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4790 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004791
Hanno Becker32c55012017-11-10 08:42:54 +00004792requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004793run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004794 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004795 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004796 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004797 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004798 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004799
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004800run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004801 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004802 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004803 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4804 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004805 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004806
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004807run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004808 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4809 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004810 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004811 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004812 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004813
4814requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004815run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004816 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004817 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004818 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004819 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004820 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004821
Hanno Becker278fc7a2017-11-10 09:16:28 +00004822requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004823run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004824 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004825 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004826 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004827 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004828 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4829 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004830
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004831run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004832 "$P_SRV" \
4833 "$P_CLI request_size=16384 force_version=tls1_1 \
4834 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4835 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004836 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4837 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004838
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004839run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004840 "$P_SRV" \
4841 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4842 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004843 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004844 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004845
Hanno Becker32c55012017-11-10 08:42:54 +00004846requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004847run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004848 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004849 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004850 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004851 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004852 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004853
Hanno Becker32c55012017-11-10 08:42:54 +00004854requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004855run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004856 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004857 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004858 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004859 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004860 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004861
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004862run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004863 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4864 "$P_CLI request_size=16384 force_version=tls1_1 \
4865 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4866 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004867 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4868 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004869
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004870run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004871 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004872 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004873 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004874 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004875 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4876 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004877
Hanno Becker278fc7a2017-11-10 09:16:28 +00004878requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004879run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004880 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004881 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004882 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004883 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004884 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004885
Hanno Becker278fc7a2017-11-10 09:16:28 +00004886requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004887run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004888 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004889 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004890 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004891 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004892 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4893 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004894
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004895run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004896 "$P_SRV" \
4897 "$P_CLI request_size=16384 force_version=tls1_2 \
4898 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4899 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004900 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4901 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004902
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004903run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004904 "$P_SRV" \
4905 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4906 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4907 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004908 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004909
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004910run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004911 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004912 "$P_CLI request_size=16384 force_version=tls1_2 \
4913 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004914 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004915 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4916 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004917
Hanno Becker32c55012017-11-10 08:42:54 +00004918requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004919run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004920 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004921 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004922 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004923 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004924 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004925
Hanno Becker278fc7a2017-11-10 09:16:28 +00004926requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004927run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004928 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004929 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004930 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004931 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004932 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4933 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004934
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004935run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004936 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004937 "$P_CLI request_size=16384 force_version=tls1_2 \
4938 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4939 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004940 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4941 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004942
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004943run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004944 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004945 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004946 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4947 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004948 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004949
Hanno Becker32c55012017-11-10 08:42:54 +00004950requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004951run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004952 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004953 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004954 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004955 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004956 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004957
Hanno Becker278fc7a2017-11-10 09:16:28 +00004958requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004959run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004960 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004961 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004962 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004963 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004964 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4965 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004966
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004967run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004968 "$P_SRV" \
4969 "$P_CLI request_size=16384 force_version=tls1_2 \
4970 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4971 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004972 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4973 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004974
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004975run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004976 "$P_SRV" \
4977 "$P_CLI request_size=16384 force_version=tls1_2 \
4978 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4979 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004980 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4981 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004982
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004983# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004984requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4985run_test "Large server packet SSLv3 StreamCipher" \
4986 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4987 "$P_CLI force_version=ssl3 \
4988 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4989 0 \
4990 -c "Read from server: 16384 bytes read"
4991
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04004992# Checking next 4 tests logs for 1n-1 split against BEAST too
4993requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4994run_test "Large server packet SSLv3 BlockCipher" \
4995 "$P_SRV response_size=16384 min_version=ssl3" \
4996 "$P_CLI force_version=ssl3 recsplit=0 \
4997 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4998 0 \
4999 -c "Read from server: 1 bytes read"\
5000 -c "16383 bytes read"\
5001 -C "Read from server: 16384 bytes read"
5002
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005003run_test "Large server packet TLS 1.0 BlockCipher" \
5004 "$P_SRV response_size=16384" \
5005 "$P_CLI force_version=tls1 recsplit=0 \
5006 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5007 0 \
5008 -c "Read from server: 1 bytes read"\
5009 -c "16383 bytes read"\
5010 -C "Read from server: 16384 bytes read"
5011
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005012run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5013 "$P_SRV response_size=16384" \
5014 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5015 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5016 0 \
5017 -c "Read from server: 1 bytes read"\
5018 -c "16383 bytes read"\
5019 -C "Read from server: 16384 bytes read"
5020
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005021requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5022run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5023 "$P_SRV response_size=16384" \
5024 "$P_CLI force_version=tls1 recsplit=0 \
5025 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5026 trunc_hmac=1" \
5027 0 \
5028 -c "Read from server: 1 bytes read"\
5029 -c "16383 bytes read"\
5030 -C "Read from server: 16384 bytes read"
5031
5032requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5033run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5034 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5035 "$P_CLI force_version=tls1 \
5036 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5037 trunc_hmac=1" \
5038 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005039 -s "16384 bytes written in 1 fragments" \
5040 -c "Read from server: 16384 bytes read"
5041
5042run_test "Large server packet TLS 1.0 StreamCipher" \
5043 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5044 "$P_CLI force_version=tls1 \
5045 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5046 0 \
5047 -s "16384 bytes written in 1 fragments" \
5048 -c "Read from server: 16384 bytes read"
5049
5050run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5051 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5052 "$P_CLI force_version=tls1 \
5053 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5054 0 \
5055 -s "16384 bytes written in 1 fragments" \
5056 -c "Read from server: 16384 bytes read"
5057
5058requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5059run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5060 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5061 "$P_CLI force_version=tls1 \
5062 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5063 0 \
5064 -s "16384 bytes written in 1 fragments" \
5065 -c "Read from server: 16384 bytes read"
5066
5067requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5068run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5069 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5070 "$P_CLI force_version=tls1 \
5071 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5072 0 \
5073 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005074 -c "Read from server: 16384 bytes read"
5075
5076run_test "Large server packet TLS 1.1 BlockCipher" \
5077 "$P_SRV response_size=16384" \
5078 "$P_CLI force_version=tls1_1 \
5079 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5080 0 \
5081 -c "Read from server: 16384 bytes read"
5082
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005083run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5084 "$P_SRV response_size=16384" \
5085 "$P_CLI force_version=tls1_1 etm=0 \
5086 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005087 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005088 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005089 -c "Read from server: 16384 bytes read"
5090
5091requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5092run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5093 "$P_SRV response_size=16384" \
5094 "$P_CLI force_version=tls1_1 \
5095 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5096 trunc_hmac=1" \
5097 0 \
5098 -c "Read from server: 16384 bytes read"
5099
5100requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005101run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5102 "$P_SRV response_size=16384 trunc_hmac=1" \
5103 "$P_CLI force_version=tls1_1 \
5104 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5105 0 \
5106 -s "16384 bytes written in 1 fragments" \
5107 -c "Read from server: 16384 bytes read"
5108
5109run_test "Large server packet TLS 1.1 StreamCipher" \
5110 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5111 "$P_CLI force_version=tls1_1 \
5112 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5113 0 \
5114 -c "Read from server: 16384 bytes read"
5115
5116run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5117 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5118 "$P_CLI force_version=tls1_1 \
5119 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5120 0 \
5121 -s "16384 bytes written in 1 fragments" \
5122 -c "Read from server: 16384 bytes read"
5123
5124requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005125run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5126 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5127 "$P_CLI force_version=tls1_1 \
5128 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5129 trunc_hmac=1" \
5130 0 \
5131 -c "Read from server: 16384 bytes read"
5132
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005133run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5134 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5135 "$P_CLI force_version=tls1_1 \
5136 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5137 0 \
5138 -s "16384 bytes written in 1 fragments" \
5139 -c "Read from server: 16384 bytes read"
5140
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005141run_test "Large server packet TLS 1.2 BlockCipher" \
5142 "$P_SRV response_size=16384" \
5143 "$P_CLI force_version=tls1_2 \
5144 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5145 0 \
5146 -c "Read from server: 16384 bytes read"
5147
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005148run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5149 "$P_SRV response_size=16384" \
5150 "$P_CLI force_version=tls1_2 etm=0 \
5151 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5152 0 \
5153 -s "16384 bytes written in 1 fragments" \
5154 -c "Read from server: 16384 bytes read"
5155
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005156run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5157 "$P_SRV response_size=16384" \
5158 "$P_CLI force_version=tls1_2 \
5159 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5160 0 \
5161 -c "Read from server: 16384 bytes read"
5162
5163requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5164run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5165 "$P_SRV response_size=16384" \
5166 "$P_CLI force_version=tls1_2 \
5167 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5168 trunc_hmac=1" \
5169 0 \
5170 -c "Read from server: 16384 bytes read"
5171
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005172run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5173 "$P_SRV response_size=16384 trunc_hmac=1" \
5174 "$P_CLI force_version=tls1_2 \
5175 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5176 0 \
5177 -s "16384 bytes written in 1 fragments" \
5178 -c "Read from server: 16384 bytes read"
5179
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005180run_test "Large server packet TLS 1.2 StreamCipher" \
5181 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5182 "$P_CLI force_version=tls1_2 \
5183 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5184 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005185 -s "16384 bytes written in 1 fragments" \
5186 -c "Read from server: 16384 bytes read"
5187
5188run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5189 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5190 "$P_CLI force_version=tls1_2 \
5191 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5192 0 \
5193 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005194 -c "Read from server: 16384 bytes read"
5195
5196requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5197run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5198 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5199 "$P_CLI force_version=tls1_2 \
5200 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5201 trunc_hmac=1" \
5202 0 \
5203 -c "Read from server: 16384 bytes read"
5204
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005205requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5206run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5207 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5208 "$P_CLI force_version=tls1_2 \
5209 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5210 0 \
5211 -s "16384 bytes written in 1 fragments" \
5212 -c "Read from server: 16384 bytes read"
5213
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005214run_test "Large server packet TLS 1.2 AEAD" \
5215 "$P_SRV response_size=16384" \
5216 "$P_CLI force_version=tls1_2 \
5217 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5218 0 \
5219 -c "Read from server: 16384 bytes read"
5220
5221run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5222 "$P_SRV response_size=16384" \
5223 "$P_CLI force_version=tls1_2 \
5224 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5225 0 \
5226 -c "Read from server: 16384 bytes read"
5227
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005228# Tests for restartable ECC
5229
5230requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5231run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005232 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005233 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005234 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005235 debug_level=1" \
5236 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005237 -C "x509_verify_cert.*4b00" \
5238 -C "mbedtls_pk_verify.*4b00" \
5239 -C "mbedtls_ecdh_make_public.*4b00" \
5240 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005241
5242requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5243run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005244 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005245 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005246 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005247 debug_level=1 ec_max_ops=0" \
5248 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005249 -C "x509_verify_cert.*4b00" \
5250 -C "mbedtls_pk_verify.*4b00" \
5251 -C "mbedtls_ecdh_make_public.*4b00" \
5252 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005253
5254requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5255run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005256 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005257 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005258 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005259 debug_level=1 ec_max_ops=65535" \
5260 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005261 -C "x509_verify_cert.*4b00" \
5262 -C "mbedtls_pk_verify.*4b00" \
5263 -C "mbedtls_ecdh_make_public.*4b00" \
5264 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005265
5266requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5267run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005268 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005269 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005270 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005271 debug_level=1 ec_max_ops=1000" \
5272 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005273 -c "x509_verify_cert.*4b00" \
5274 -c "mbedtls_pk_verify.*4b00" \
5275 -c "mbedtls_ecdh_make_public.*4b00" \
5276 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005277
5278requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005279run_test "EC restart: TLS, max_ops=1000, badsign" \
5280 "$P_SRV auth_mode=required \
5281 crt_file=data_files/server5-badsign.crt \
5282 key_file=data_files/server5.key" \
5283 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5284 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5285 debug_level=1 ec_max_ops=1000" \
5286 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005287 -c "x509_verify_cert.*4b00" \
5288 -C "mbedtls_pk_verify.*4b00" \
5289 -C "mbedtls_ecdh_make_public.*4b00" \
5290 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005291 -c "! The certificate is not correctly signed by the trusted CA" \
5292 -c "! mbedtls_ssl_handshake returned" \
5293 -c "X509 - Certificate verification failed"
5294
5295requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5296run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5297 "$P_SRV auth_mode=required \
5298 crt_file=data_files/server5-badsign.crt \
5299 key_file=data_files/server5.key" \
5300 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5301 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5302 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5303 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005304 -c "x509_verify_cert.*4b00" \
5305 -c "mbedtls_pk_verify.*4b00" \
5306 -c "mbedtls_ecdh_make_public.*4b00" \
5307 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005308 -c "! The certificate is not correctly signed by the trusted CA" \
5309 -C "! mbedtls_ssl_handshake returned" \
5310 -C "X509 - Certificate verification failed"
5311
5312requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5313run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5314 "$P_SRV auth_mode=required \
5315 crt_file=data_files/server5-badsign.crt \
5316 key_file=data_files/server5.key" \
5317 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5318 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5319 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5320 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005321 -C "x509_verify_cert.*4b00" \
5322 -c "mbedtls_pk_verify.*4b00" \
5323 -c "mbedtls_ecdh_make_public.*4b00" \
5324 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005325 -C "! The certificate is not correctly signed by the trusted CA" \
5326 -C "! mbedtls_ssl_handshake returned" \
5327 -C "X509 - Certificate verification failed"
5328
5329requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005330run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005331 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005332 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005333 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005334 dtls=1 debug_level=1 ec_max_ops=1000" \
5335 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005336 -c "x509_verify_cert.*4b00" \
5337 -c "mbedtls_pk_verify.*4b00" \
5338 -c "mbedtls_ecdh_make_public.*4b00" \
5339 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005340
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005341requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5342run_test "EC restart: TLS, max_ops=1000 no client auth" \
5343 "$P_SRV" \
5344 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5345 debug_level=1 ec_max_ops=1000" \
5346 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005347 -c "x509_verify_cert.*4b00" \
5348 -c "mbedtls_pk_verify.*4b00" \
5349 -c "mbedtls_ecdh_make_public.*4b00" \
5350 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005351
5352requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5353run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5354 "$P_SRV psk=abc123" \
5355 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5356 psk=abc123 debug_level=1 ec_max_ops=1000" \
5357 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005358 -C "x509_verify_cert.*4b00" \
5359 -C "mbedtls_pk_verify.*4b00" \
5360 -C "mbedtls_ecdh_make_public.*4b00" \
5361 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005362
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005363# Tests of asynchronous private key support in SSL
5364
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005365requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005366run_test "SSL async private: sign, delay=0" \
5367 "$P_SRV \
5368 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005369 "$P_CLI" \
5370 0 \
5371 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005372 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005373
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005374requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005375run_test "SSL async private: sign, delay=1" \
5376 "$P_SRV \
5377 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005378 "$P_CLI" \
5379 0 \
5380 -s "Async sign callback: using key slot " \
5381 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005382 -s "Async resume (slot [0-9]): sign done, status=0"
5383
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005384requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5385run_test "SSL async private: sign, delay=2" \
5386 "$P_SRV \
5387 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5388 "$P_CLI" \
5389 0 \
5390 -s "Async sign callback: using key slot " \
5391 -U "Async sign callback: using key slot " \
5392 -s "Async resume (slot [0-9]): call 1 more times." \
5393 -s "Async resume (slot [0-9]): call 0 more times." \
5394 -s "Async resume (slot [0-9]): sign done, status=0"
5395
Gilles Peskined3268832018-04-26 06:23:59 +02005396# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5397# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5398requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5399requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5400run_test "SSL async private: sign, RSA, TLS 1.1" \
5401 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5402 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5403 "$P_CLI force_version=tls1_1" \
5404 0 \
5405 -s "Async sign callback: using key slot " \
5406 -s "Async resume (slot [0-9]): sign done, status=0"
5407
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005408requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005409run_test "SSL async private: sign, SNI" \
5410 "$P_SRV debug_level=3 \
5411 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5412 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5413 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5414 "$P_CLI server_name=polarssl.example" \
5415 0 \
5416 -s "Async sign callback: using key slot " \
5417 -s "Async resume (slot [0-9]): sign done, status=0" \
5418 -s "parse ServerName extension" \
5419 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5420 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5421
5422requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005423run_test "SSL async private: decrypt, delay=0" \
5424 "$P_SRV \
5425 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5426 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5427 0 \
5428 -s "Async decrypt callback: using key slot " \
5429 -s "Async resume (slot [0-9]): decrypt done, status=0"
5430
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005431requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005432run_test "SSL async private: decrypt, delay=1" \
5433 "$P_SRV \
5434 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5435 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5436 0 \
5437 -s "Async decrypt callback: using key slot " \
5438 -s "Async resume (slot [0-9]): call 0 more times." \
5439 -s "Async resume (slot [0-9]): decrypt done, status=0"
5440
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005441requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005442run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5443 "$P_SRV psk=abc123 \
5444 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5445 "$P_CLI psk=abc123 \
5446 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5447 0 \
5448 -s "Async decrypt callback: using key slot " \
5449 -s "Async resume (slot [0-9]): decrypt done, status=0"
5450
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005451requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005452run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5453 "$P_SRV psk=abc123 \
5454 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5455 "$P_CLI psk=abc123 \
5456 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5457 0 \
5458 -s "Async decrypt callback: using key slot " \
5459 -s "Async resume (slot [0-9]): call 0 more times." \
5460 -s "Async resume (slot [0-9]): decrypt done, status=0"
5461
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005462requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005463run_test "SSL async private: sign callback not present" \
5464 "$P_SRV \
5465 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5466 "$P_CLI; [ \$? -eq 1 ] &&
5467 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5468 0 \
5469 -S "Async sign callback" \
5470 -s "! mbedtls_ssl_handshake returned" \
5471 -s "The own private key or pre-shared key is not set, but needed" \
5472 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5473 -s "Successful connection"
5474
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005475requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005476run_test "SSL async private: decrypt callback not present" \
5477 "$P_SRV debug_level=1 \
5478 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5479 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5480 [ \$? -eq 1 ] && $P_CLI" \
5481 0 \
5482 -S "Async decrypt callback" \
5483 -s "! mbedtls_ssl_handshake returned" \
5484 -s "got no RSA private key" \
5485 -s "Async resume (slot [0-9]): sign done, status=0" \
5486 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005487
5488# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005489requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005490run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005491 "$P_SRV \
5492 async_operations=s async_private_delay1=1 \
5493 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5494 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005495 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5496 0 \
5497 -s "Async sign callback: using key slot 0," \
5498 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005499 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005500
5501# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005502requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005503run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005504 "$P_SRV \
5505 async_operations=s async_private_delay2=1 \
5506 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5507 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005508 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5509 0 \
5510 -s "Async sign callback: using key slot 0," \
5511 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005512 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005513
5514# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005515requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005516run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005517 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005518 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005519 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5520 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005521 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5522 0 \
5523 -s "Async sign callback: using key slot 1," \
5524 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005525 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005526
5527# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005528requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005529run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005530 "$P_SRV \
5531 async_operations=s async_private_delay1=1 \
5532 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5533 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005534 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5535 0 \
5536 -s "Async sign callback: no key matches this certificate."
5537
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005538requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005539run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005540 "$P_SRV \
5541 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5542 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005543 "$P_CLI" \
5544 1 \
5545 -s "Async sign callback: injected error" \
5546 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005547 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005548 -s "! mbedtls_ssl_handshake returned"
5549
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005550requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005551run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005552 "$P_SRV \
5553 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5554 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005555 "$P_CLI" \
5556 1 \
5557 -s "Async sign callback: using key slot " \
5558 -S "Async resume" \
5559 -s "Async cancel"
5560
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005561requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005562run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005563 "$P_SRV \
5564 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5565 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005566 "$P_CLI" \
5567 1 \
5568 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005569 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005570 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005571 -s "! mbedtls_ssl_handshake returned"
5572
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005573requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005574run_test "SSL async private: decrypt, error in start" \
5575 "$P_SRV \
5576 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5577 async_private_error=1" \
5578 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5579 1 \
5580 -s "Async decrypt callback: injected error" \
5581 -S "Async resume" \
5582 -S "Async cancel" \
5583 -s "! mbedtls_ssl_handshake returned"
5584
5585requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5586run_test "SSL async private: decrypt, cancel after start" \
5587 "$P_SRV \
5588 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5589 async_private_error=2" \
5590 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5591 1 \
5592 -s "Async decrypt callback: using key slot " \
5593 -S "Async resume" \
5594 -s "Async cancel"
5595
5596requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5597run_test "SSL async private: decrypt, error in resume" \
5598 "$P_SRV \
5599 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5600 async_private_error=3" \
5601 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5602 1 \
5603 -s "Async decrypt callback: using key slot " \
5604 -s "Async resume callback: decrypt done but injected error" \
5605 -S "Async cancel" \
5606 -s "! mbedtls_ssl_handshake returned"
5607
5608requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005609run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005610 "$P_SRV \
5611 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5612 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005613 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5614 0 \
5615 -s "Async cancel" \
5616 -s "! mbedtls_ssl_handshake returned" \
5617 -s "Async resume" \
5618 -s "Successful connection"
5619
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005620requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005621run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005622 "$P_SRV \
5623 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5624 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005625 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5626 0 \
5627 -s "! mbedtls_ssl_handshake returned" \
5628 -s "Async resume" \
5629 -s "Successful connection"
5630
5631# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005632requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005633run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005634 "$P_SRV \
5635 async_operations=s async_private_delay1=1 async_private_error=-2 \
5636 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5637 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005638 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5639 [ \$? -eq 1 ] &&
5640 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5641 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005642 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005643 -S "Async resume" \
5644 -s "Async cancel" \
5645 -s "! mbedtls_ssl_handshake returned" \
5646 -s "Async sign callback: no key matches this certificate." \
5647 -s "Successful connection"
5648
5649# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005650requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005651run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005652 "$P_SRV \
5653 async_operations=s async_private_delay1=1 async_private_error=-3 \
5654 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5655 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005656 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5657 [ \$? -eq 1 ] &&
5658 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5659 0 \
5660 -s "Async resume" \
5661 -s "! mbedtls_ssl_handshake returned" \
5662 -s "Async sign callback: no key matches this certificate." \
5663 -s "Successful connection"
5664
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005665requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005666requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005667run_test "SSL async private: renegotiation: client-initiated; sign" \
5668 "$P_SRV \
5669 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005670 exchanges=2 renegotiation=1" \
5671 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5672 0 \
5673 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005674 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005675
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005676requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005677requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005678run_test "SSL async private: renegotiation: server-initiated; sign" \
5679 "$P_SRV \
5680 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005681 exchanges=2 renegotiation=1 renegotiate=1" \
5682 "$P_CLI exchanges=2 renegotiation=1" \
5683 0 \
5684 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005685 -s "Async resume (slot [0-9]): sign done, status=0"
5686
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005687requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005688requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5689run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5690 "$P_SRV \
5691 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5692 exchanges=2 renegotiation=1" \
5693 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5694 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5695 0 \
5696 -s "Async decrypt callback: using key slot " \
5697 -s "Async resume (slot [0-9]): decrypt done, status=0"
5698
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005699requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005700requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5701run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5702 "$P_SRV \
5703 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5704 exchanges=2 renegotiation=1 renegotiate=1" \
5705 "$P_CLI exchanges=2 renegotiation=1 \
5706 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5707 0 \
5708 -s "Async decrypt callback: using key slot " \
5709 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005710
Ron Eldor58093c82018-06-28 13:22:05 +03005711# Tests for ECC extensions (rfc 4492)
5712
Ron Eldor643df7c2018-06-28 16:17:00 +03005713requires_config_enabled MBEDTLS_AES_C
5714requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5715requires_config_enabled MBEDTLS_SHA256_C
5716requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005717run_test "Force a non ECC ciphersuite in the client side" \
5718 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005719 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005720 0 \
5721 -C "client hello, adding supported_elliptic_curves extension" \
5722 -C "client hello, adding supported_point_formats extension" \
5723 -S "found supported elliptic curves extension" \
5724 -S "found supported point formats extension"
5725
Ron Eldor643df7c2018-06-28 16:17:00 +03005726requires_config_enabled MBEDTLS_AES_C
5727requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5728requires_config_enabled MBEDTLS_SHA256_C
5729requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005730run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005731 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005732 "$P_CLI debug_level=3" \
5733 0 \
5734 -C "found supported_point_formats extension" \
5735 -S "server hello, supported_point_formats extension"
5736
Ron Eldor643df7c2018-06-28 16:17:00 +03005737requires_config_enabled MBEDTLS_AES_C
5738requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5739requires_config_enabled MBEDTLS_SHA256_C
5740requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005741run_test "Force an ECC ciphersuite in the client side" \
5742 "$P_SRV debug_level=3" \
5743 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5744 0 \
5745 -c "client hello, adding supported_elliptic_curves extension" \
5746 -c "client hello, adding supported_point_formats extension" \
5747 -s "found supported elliptic curves extension" \
5748 -s "found supported point formats extension"
5749
Ron Eldor643df7c2018-06-28 16:17:00 +03005750requires_config_enabled MBEDTLS_AES_C
5751requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5752requires_config_enabled MBEDTLS_SHA256_C
5753requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005754run_test "Force an ECC ciphersuite in the server side" \
5755 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5756 "$P_CLI debug_level=3" \
5757 0 \
5758 -c "found supported_point_formats extension" \
5759 -s "server hello, supported_point_formats extension"
5760
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005761# Tests for DTLS HelloVerifyRequest
5762
5763run_test "DTLS cookie: enabled" \
5764 "$P_SRV dtls=1 debug_level=2" \
5765 "$P_CLI dtls=1 debug_level=2" \
5766 0 \
5767 -s "cookie verification failed" \
5768 -s "cookie verification passed" \
5769 -S "cookie verification skipped" \
5770 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005771 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005772 -S "SSL - The requested feature is not available"
5773
5774run_test "DTLS cookie: disabled" \
5775 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5776 "$P_CLI dtls=1 debug_level=2" \
5777 0 \
5778 -S "cookie verification failed" \
5779 -S "cookie verification passed" \
5780 -s "cookie verification skipped" \
5781 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005782 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005783 -S "SSL - The requested feature is not available"
5784
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005785run_test "DTLS cookie: default (failing)" \
5786 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5787 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5788 1 \
5789 -s "cookie verification failed" \
5790 -S "cookie verification passed" \
5791 -S "cookie verification skipped" \
5792 -C "received hello verify request" \
5793 -S "hello verification requested" \
5794 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005795
5796requires_ipv6
5797run_test "DTLS cookie: enabled, IPv6" \
5798 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5799 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5800 0 \
5801 -s "cookie verification failed" \
5802 -s "cookie verification passed" \
5803 -S "cookie verification skipped" \
5804 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005805 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005806 -S "SSL - The requested feature is not available"
5807
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005808run_test "DTLS cookie: enabled, nbio" \
5809 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5810 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5811 0 \
5812 -s "cookie verification failed" \
5813 -s "cookie verification passed" \
5814 -S "cookie verification skipped" \
5815 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005816 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005817 -S "SSL - The requested feature is not available"
5818
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005819# Tests for client reconnecting from the same port with DTLS
5820
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005821not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005822run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005823 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5824 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005825 0 \
5826 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005827 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005828 -S "Client initiated reconnection from same port"
5829
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005830not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005831run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005832 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5833 "$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 +02005834 0 \
5835 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005836 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005837 -s "Client initiated reconnection from same port"
5838
Paul Bakker362689d2016-05-13 10:33:25 +01005839not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5840run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005841 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5842 "$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 +02005843 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005844 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005845 -s "Client initiated reconnection from same port"
5846
Paul Bakker362689d2016-05-13 10:33:25 +01005847only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5848run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5849 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5850 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5851 0 \
5852 -S "The operation timed out" \
5853 -s "Client initiated reconnection from same port"
5854
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005855run_test "DTLS client reconnect from same port: no cookies" \
5856 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005857 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5858 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005859 -s "The operation timed out" \
5860 -S "Client initiated reconnection from same port"
5861
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005862run_test "DTLS client reconnect from same port: attacker-injected" \
5863 -p "$P_PXY inject_clihlo=1" \
5864 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5865 "$P_CLI dtls=1 exchanges=2" \
5866 0 \
5867 -s "possible client reconnect from the same port" \
5868 -S "Client initiated reconnection from same port"
5869
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005870# Tests for various cases of client authentication with DTLS
5871# (focused on handshake flows and message parsing)
5872
5873run_test "DTLS client auth: required" \
5874 "$P_SRV dtls=1 auth_mode=required" \
5875 "$P_CLI dtls=1" \
5876 0 \
5877 -s "Verifying peer X.509 certificate... ok"
5878
5879run_test "DTLS client auth: optional, client has no cert" \
5880 "$P_SRV dtls=1 auth_mode=optional" \
5881 "$P_CLI dtls=1 crt_file=none key_file=none" \
5882 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005883 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005884
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005885run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005886 "$P_SRV dtls=1 auth_mode=none" \
5887 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5888 0 \
5889 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005890 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005891
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005892run_test "DTLS wrong PSK: badmac alert" \
5893 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5894 "$P_CLI dtls=1 psk=abc124" \
5895 1 \
5896 -s "SSL - Verification of the message MAC failed" \
5897 -c "SSL - A fatal alert message was received from our peer"
5898
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005899# Tests for receiving fragmented handshake messages with DTLS
5900
5901requires_gnutls
5902run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5903 "$G_SRV -u --mtu 2048 -a" \
5904 "$P_CLI dtls=1 debug_level=2" \
5905 0 \
5906 -C "found fragmented DTLS handshake message" \
5907 -C "error"
5908
5909requires_gnutls
5910run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5911 "$G_SRV -u --mtu 512" \
5912 "$P_CLI dtls=1 debug_level=2" \
5913 0 \
5914 -c "found fragmented DTLS handshake message" \
5915 -C "error"
5916
5917requires_gnutls
5918run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5919 "$G_SRV -u --mtu 128" \
5920 "$P_CLI dtls=1 debug_level=2" \
5921 0 \
5922 -c "found fragmented DTLS handshake message" \
5923 -C "error"
5924
5925requires_gnutls
5926run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5927 "$G_SRV -u --mtu 128" \
5928 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5929 0 \
5930 -c "found fragmented DTLS handshake message" \
5931 -C "error"
5932
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005933requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005934requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005935run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5936 "$G_SRV -u --mtu 256" \
5937 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5938 0 \
5939 -c "found fragmented DTLS handshake message" \
5940 -c "client hello, adding renegotiation extension" \
5941 -c "found renegotiation extension" \
5942 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005943 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005944 -C "error" \
5945 -s "Extra-header:"
5946
5947requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005948requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005949run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5950 "$G_SRV -u --mtu 256" \
5951 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5952 0 \
5953 -c "found fragmented DTLS handshake message" \
5954 -c "client hello, adding renegotiation extension" \
5955 -c "found renegotiation extension" \
5956 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005957 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005958 -C "error" \
5959 -s "Extra-header:"
5960
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005961run_test "DTLS reassembly: no fragmentation (openssl server)" \
5962 "$O_SRV -dtls1 -mtu 2048" \
5963 "$P_CLI dtls=1 debug_level=2" \
5964 0 \
5965 -C "found fragmented DTLS handshake message" \
5966 -C "error"
5967
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005968run_test "DTLS reassembly: some fragmentation (openssl server)" \
5969 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005970 "$P_CLI dtls=1 debug_level=2" \
5971 0 \
5972 -c "found fragmented DTLS handshake message" \
5973 -C "error"
5974
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005975run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005976 "$O_SRV -dtls1 -mtu 256" \
5977 "$P_CLI dtls=1 debug_level=2" \
5978 0 \
5979 -c "found fragmented DTLS handshake message" \
5980 -C "error"
5981
5982run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5983 "$O_SRV -dtls1 -mtu 256" \
5984 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5985 0 \
5986 -c "found fragmented DTLS handshake message" \
5987 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005988
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005989# Tests for sending fragmented handshake messages with DTLS
5990#
5991# Use client auth when we need the client to send large messages,
5992# and use large cert chains on both sides too (the long chains we have all use
5993# both RSA and ECDSA, but ideally we should have long chains with either).
5994# Sizes reached (UDP payload):
5995# - 2037B for server certificate
5996# - 1542B for client certificate
5997# - 1013B for newsessionticket
5998# - all others below 512B
5999# All those tests assume MAX_CONTENT_LEN is at least 2048
6000
6001requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6002requires_config_enabled MBEDTLS_RSA_C
6003requires_config_enabled MBEDTLS_ECDSA_C
6004requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6005run_test "DTLS fragmenting: none (for reference)" \
6006 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6007 crt_file=data_files/server7_int-ca.crt \
6008 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006009 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006010 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006011 "$P_CLI dtls=1 debug_level=2 \
6012 crt_file=data_files/server8_int-ca2.crt \
6013 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006014 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006015 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006016 0 \
6017 -S "found fragmented DTLS handshake message" \
6018 -C "found fragmented DTLS handshake message" \
6019 -C "error"
6020
6021requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6022requires_config_enabled MBEDTLS_RSA_C
6023requires_config_enabled MBEDTLS_ECDSA_C
6024requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006025run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006026 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6027 crt_file=data_files/server7_int-ca.crt \
6028 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006029 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006030 max_frag_len=1024" \
6031 "$P_CLI dtls=1 debug_level=2 \
6032 crt_file=data_files/server8_int-ca2.crt \
6033 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006034 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006035 max_frag_len=2048" \
6036 0 \
6037 -S "found fragmented DTLS handshake message" \
6038 -c "found fragmented DTLS handshake message" \
6039 -C "error"
6040
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006041# With the MFL extension, the server has no way of forcing
6042# the client to not exceed a certain MTU; hence, the following
6043# test can't be replicated with an MTU proxy such as the one
6044# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006045requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6046requires_config_enabled MBEDTLS_RSA_C
6047requires_config_enabled MBEDTLS_ECDSA_C
6048requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006049run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006050 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6051 crt_file=data_files/server7_int-ca.crt \
6052 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006053 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006054 max_frag_len=512" \
6055 "$P_CLI dtls=1 debug_level=2 \
6056 crt_file=data_files/server8_int-ca2.crt \
6057 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006058 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006059 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006060 0 \
6061 -S "found fragmented DTLS handshake message" \
6062 -c "found fragmented DTLS handshake message" \
6063 -C "error"
6064
6065requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6066requires_config_enabled MBEDTLS_RSA_C
6067requires_config_enabled MBEDTLS_ECDSA_C
6068requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006069run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006070 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6071 crt_file=data_files/server7_int-ca.crt \
6072 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006073 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006074 max_frag_len=2048" \
6075 "$P_CLI dtls=1 debug_level=2 \
6076 crt_file=data_files/server8_int-ca2.crt \
6077 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006078 hs_timeout=2500-60000 \
6079 max_frag_len=1024" \
6080 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006081 -S "found fragmented DTLS handshake message" \
6082 -c "found fragmented DTLS handshake message" \
6083 -C "error"
6084
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006085# While not required by the standard defining the MFL extension
6086# (according to which it only applies to records, not to datagrams),
6087# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6088# as otherwise there wouldn't be any means to communicate MTU restrictions
6089# to the peer.
6090# The next test checks that no datagrams significantly larger than the
6091# negotiated MFL are sent.
6092requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6093requires_config_enabled MBEDTLS_RSA_C
6094requires_config_enabled MBEDTLS_ECDSA_C
6095requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6096run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006097 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006098 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6099 crt_file=data_files/server7_int-ca.crt \
6100 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006101 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006102 max_frag_len=2048" \
6103 "$P_CLI dtls=1 debug_level=2 \
6104 crt_file=data_files/server8_int-ca2.crt \
6105 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006106 hs_timeout=2500-60000 \
6107 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006108 0 \
6109 -S "found fragmented DTLS handshake message" \
6110 -c "found fragmented DTLS handshake message" \
6111 -C "error"
6112
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006113requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6114requires_config_enabled MBEDTLS_RSA_C
6115requires_config_enabled MBEDTLS_ECDSA_C
6116requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006117run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006118 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6119 crt_file=data_files/server7_int-ca.crt \
6120 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006121 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006122 max_frag_len=2048" \
6123 "$P_CLI dtls=1 debug_level=2 \
6124 crt_file=data_files/server8_int-ca2.crt \
6125 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006126 hs_timeout=2500-60000 \
6127 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006128 0 \
6129 -s "found fragmented DTLS handshake message" \
6130 -c "found fragmented DTLS handshake message" \
6131 -C "error"
6132
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006133# While not required by the standard defining the MFL extension
6134# (according to which it only applies to records, not to datagrams),
6135# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6136# as otherwise there wouldn't be any means to communicate MTU restrictions
6137# to the peer.
6138# The next test checks that no datagrams significantly larger than the
6139# negotiated MFL are sent.
6140requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6141requires_config_enabled MBEDTLS_RSA_C
6142requires_config_enabled MBEDTLS_ECDSA_C
6143requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6144run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006145 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006146 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6147 crt_file=data_files/server7_int-ca.crt \
6148 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006149 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006150 max_frag_len=2048" \
6151 "$P_CLI dtls=1 debug_level=2 \
6152 crt_file=data_files/server8_int-ca2.crt \
6153 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006154 hs_timeout=2500-60000 \
6155 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006156 0 \
6157 -s "found fragmented DTLS handshake message" \
6158 -c "found fragmented DTLS handshake message" \
6159 -C "error"
6160
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006161requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6162requires_config_enabled MBEDTLS_RSA_C
6163requires_config_enabled MBEDTLS_ECDSA_C
6164run_test "DTLS fragmenting: none (for reference) (MTU)" \
6165 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6166 crt_file=data_files/server7_int-ca.crt \
6167 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006168 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006169 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006170 "$P_CLI dtls=1 debug_level=2 \
6171 crt_file=data_files/server8_int-ca2.crt \
6172 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006173 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006174 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006175 0 \
6176 -S "found fragmented DTLS handshake message" \
6177 -C "found fragmented DTLS handshake message" \
6178 -C "error"
6179
6180requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6181requires_config_enabled MBEDTLS_RSA_C
6182requires_config_enabled MBEDTLS_ECDSA_C
6183run_test "DTLS fragmenting: client (MTU)" \
6184 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6185 crt_file=data_files/server7_int-ca.crt \
6186 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006187 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006188 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006189 "$P_CLI dtls=1 debug_level=2 \
6190 crt_file=data_files/server8_int-ca2.crt \
6191 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006192 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006193 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006194 0 \
6195 -s "found fragmented DTLS handshake message" \
6196 -C "found fragmented DTLS handshake message" \
6197 -C "error"
6198
6199requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6200requires_config_enabled MBEDTLS_RSA_C
6201requires_config_enabled MBEDTLS_ECDSA_C
6202run_test "DTLS fragmenting: server (MTU)" \
6203 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6204 crt_file=data_files/server7_int-ca.crt \
6205 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006206 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006207 mtu=512" \
6208 "$P_CLI dtls=1 debug_level=2 \
6209 crt_file=data_files/server8_int-ca2.crt \
6210 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006211 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006212 mtu=2048" \
6213 0 \
6214 -S "found fragmented DTLS handshake message" \
6215 -c "found fragmented DTLS handshake message" \
6216 -C "error"
6217
6218requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6219requires_config_enabled MBEDTLS_RSA_C
6220requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006221run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006222 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006223 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6224 crt_file=data_files/server7_int-ca.crt \
6225 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006226 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006227 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006228 "$P_CLI dtls=1 debug_level=2 \
6229 crt_file=data_files/server8_int-ca2.crt \
6230 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006231 hs_timeout=2500-60000 \
6232 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006233 0 \
6234 -s "found fragmented DTLS handshake message" \
6235 -c "found fragmented DTLS handshake message" \
6236 -C "error"
6237
Andrzej Kurek77826052018-10-11 07:34:08 -04006238# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006239requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6240requires_config_enabled MBEDTLS_RSA_C
6241requires_config_enabled MBEDTLS_ECDSA_C
6242requires_config_enabled MBEDTLS_SHA256_C
6243requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6244requires_config_enabled MBEDTLS_AES_C
6245requires_config_enabled MBEDTLS_GCM_C
6246run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006247 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006248 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6249 crt_file=data_files/server7_int-ca.crt \
6250 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006251 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006252 mtu=512" \
6253 "$P_CLI dtls=1 debug_level=2 \
6254 crt_file=data_files/server8_int-ca2.crt \
6255 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006256 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6257 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006258 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006259 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006260 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006261 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006262 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006263
Andrzej Kurek7311c782018-10-11 06:49:41 -04006264# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006265# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006266# The ratio of max/min timeout should ideally equal 4 to accept two
6267# retransmissions, but in some cases (like both the server and client using
6268# fragmentation and auto-reduction) an extra retransmission might occur,
6269# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006270not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006271requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6272requires_config_enabled MBEDTLS_RSA_C
6273requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006274requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6275requires_config_enabled MBEDTLS_AES_C
6276requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006277run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6278 -p "$P_PXY mtu=508" \
6279 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6280 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006281 key_file=data_files/server7.key \
6282 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006283 "$P_CLI dtls=1 debug_level=2 \
6284 crt_file=data_files/server8_int-ca2.crt \
6285 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006286 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6287 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006288 0 \
6289 -s "found fragmented DTLS handshake message" \
6290 -c "found fragmented DTLS handshake message" \
6291 -C "error"
6292
Andrzej Kurek77826052018-10-11 07:34:08 -04006293# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006294only_with_valgrind
6295requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6296requires_config_enabled MBEDTLS_RSA_C
6297requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006298requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6299requires_config_enabled MBEDTLS_AES_C
6300requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006301run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6302 -p "$P_PXY mtu=508" \
6303 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6304 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006305 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006306 hs_timeout=250-10000" \
6307 "$P_CLI dtls=1 debug_level=2 \
6308 crt_file=data_files/server8_int-ca2.crt \
6309 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006310 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006311 hs_timeout=250-10000" \
6312 0 \
6313 -s "found fragmented DTLS handshake message" \
6314 -c "found fragmented DTLS handshake message" \
6315 -C "error"
6316
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006317# 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 +02006318# OTOH the client might resend if the server is to slow to reset after sending
6319# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006320not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006321requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6322requires_config_enabled MBEDTLS_RSA_C
6323requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006324run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006325 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006326 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6327 crt_file=data_files/server7_int-ca.crt \
6328 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006329 hs_timeout=10000-60000 \
6330 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006331 "$P_CLI dtls=1 debug_level=2 \
6332 crt_file=data_files/server8_int-ca2.crt \
6333 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006334 hs_timeout=10000-60000 \
6335 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006336 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006337 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006338 -s "found fragmented DTLS handshake message" \
6339 -c "found fragmented DTLS handshake message" \
6340 -C "error"
6341
Andrzej Kurek77826052018-10-11 07:34:08 -04006342# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006343# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6344# OTOH the client might resend if the server is to slow to reset after sending
6345# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006346not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006347requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6348requires_config_enabled MBEDTLS_RSA_C
6349requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006350requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6351requires_config_enabled MBEDTLS_AES_C
6352requires_config_enabled MBEDTLS_GCM_C
6353run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006354 -p "$P_PXY mtu=512" \
6355 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6356 crt_file=data_files/server7_int-ca.crt \
6357 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006358 hs_timeout=10000-60000 \
6359 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006360 "$P_CLI dtls=1 debug_level=2 \
6361 crt_file=data_files/server8_int-ca2.crt \
6362 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006363 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6364 hs_timeout=10000-60000 \
6365 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006366 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006367 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006368 -s "found fragmented DTLS handshake message" \
6369 -c "found fragmented DTLS handshake message" \
6370 -C "error"
6371
Andrzej Kurek7311c782018-10-11 06:49:41 -04006372not_with_valgrind # spurious autoreduction due to timeout
6373requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6374requires_config_enabled MBEDTLS_RSA_C
6375requires_config_enabled MBEDTLS_ECDSA_C
6376run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006377 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006378 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6379 crt_file=data_files/server7_int-ca.crt \
6380 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006381 hs_timeout=10000-60000 \
6382 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006383 "$P_CLI dtls=1 debug_level=2 \
6384 crt_file=data_files/server8_int-ca2.crt \
6385 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006386 hs_timeout=10000-60000 \
6387 mtu=1024 nbio=2" \
6388 0 \
6389 -S "autoreduction" \
6390 -s "found fragmented DTLS handshake message" \
6391 -c "found fragmented DTLS handshake message" \
6392 -C "error"
6393
Andrzej Kurek77826052018-10-11 07:34:08 -04006394# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006395not_with_valgrind # spurious autoreduction due to timeout
6396requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6397requires_config_enabled MBEDTLS_RSA_C
6398requires_config_enabled MBEDTLS_ECDSA_C
6399requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6400requires_config_enabled MBEDTLS_AES_C
6401requires_config_enabled MBEDTLS_GCM_C
6402run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6403 -p "$P_PXY mtu=512" \
6404 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6405 crt_file=data_files/server7_int-ca.crt \
6406 key_file=data_files/server7.key \
6407 hs_timeout=10000-60000 \
6408 mtu=512 nbio=2" \
6409 "$P_CLI dtls=1 debug_level=2 \
6410 crt_file=data_files/server8_int-ca2.crt \
6411 key_file=data_files/server8.key \
6412 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6413 hs_timeout=10000-60000 \
6414 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006415 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006416 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006417 -s "found fragmented DTLS handshake message" \
6418 -c "found fragmented DTLS handshake message" \
6419 -C "error"
6420
Andrzej Kurek77826052018-10-11 07:34:08 -04006421# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006422# This ensures things still work after session_reset().
6423# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006424# Since we don't support reading fragmented ClientHello yet,
6425# up the MTU to 1450 (larger than ClientHello with session ticket,
6426# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006427# An autoreduction on the client-side might happen if the server is
6428# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006429# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006430# resumed listening, which would result in a spurious autoreduction.
6431not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006432requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6433requires_config_enabled MBEDTLS_RSA_C
6434requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006435requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6436requires_config_enabled MBEDTLS_AES_C
6437requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006438run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6439 -p "$P_PXY mtu=1450" \
6440 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6441 crt_file=data_files/server7_int-ca.crt \
6442 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006443 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006444 mtu=1450" \
6445 "$P_CLI dtls=1 debug_level=2 \
6446 crt_file=data_files/server8_int-ca2.crt \
6447 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006448 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006449 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006450 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006451 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006452 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006453 -s "found fragmented DTLS handshake message" \
6454 -c "found fragmented DTLS handshake message" \
6455 -C "error"
6456
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006457# An autoreduction on the client-side might happen if the server is
6458# slow to reset, therefore omitting '-C "autoreduction"' below.
6459not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006460requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6461requires_config_enabled MBEDTLS_RSA_C
6462requires_config_enabled MBEDTLS_ECDSA_C
6463requires_config_enabled MBEDTLS_SHA256_C
6464requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6465requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6466requires_config_enabled MBEDTLS_CHACHAPOLY_C
6467run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6468 -p "$P_PXY mtu=512" \
6469 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6470 crt_file=data_files/server7_int-ca.crt \
6471 key_file=data_files/server7.key \
6472 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006473 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006474 mtu=512" \
6475 "$P_CLI dtls=1 debug_level=2 \
6476 crt_file=data_files/server8_int-ca2.crt \
6477 key_file=data_files/server8.key \
6478 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006479 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006480 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006481 mtu=512" \
6482 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006483 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006484 -s "found fragmented DTLS handshake message" \
6485 -c "found fragmented DTLS handshake message" \
6486 -C "error"
6487
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006488# An autoreduction on the client-side might happen if the server is
6489# slow to reset, therefore omitting '-C "autoreduction"' below.
6490not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006491requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6492requires_config_enabled MBEDTLS_RSA_C
6493requires_config_enabled MBEDTLS_ECDSA_C
6494requires_config_enabled MBEDTLS_SHA256_C
6495requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6496requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6497requires_config_enabled MBEDTLS_AES_C
6498requires_config_enabled MBEDTLS_GCM_C
6499run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6500 -p "$P_PXY mtu=512" \
6501 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6502 crt_file=data_files/server7_int-ca.crt \
6503 key_file=data_files/server7.key \
6504 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006505 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006506 mtu=512" \
6507 "$P_CLI dtls=1 debug_level=2 \
6508 crt_file=data_files/server8_int-ca2.crt \
6509 key_file=data_files/server8.key \
6510 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006511 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006512 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006513 mtu=512" \
6514 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006515 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006516 -s "found fragmented DTLS handshake message" \
6517 -c "found fragmented DTLS handshake message" \
6518 -C "error"
6519
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006520# An autoreduction on the client-side might happen if the server is
6521# slow to reset, therefore omitting '-C "autoreduction"' below.
6522not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006523requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6524requires_config_enabled MBEDTLS_RSA_C
6525requires_config_enabled MBEDTLS_ECDSA_C
6526requires_config_enabled MBEDTLS_SHA256_C
6527requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6528requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6529requires_config_enabled MBEDTLS_AES_C
6530requires_config_enabled MBEDTLS_CCM_C
6531run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006532 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006533 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6534 crt_file=data_files/server7_int-ca.crt \
6535 key_file=data_files/server7.key \
6536 exchanges=2 renegotiation=1 \
6537 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006538 hs_timeout=10000-60000 \
6539 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006540 "$P_CLI dtls=1 debug_level=2 \
6541 crt_file=data_files/server8_int-ca2.crt \
6542 key_file=data_files/server8.key \
6543 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006544 hs_timeout=10000-60000 \
6545 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006546 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006547 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006548 -s "found fragmented DTLS handshake message" \
6549 -c "found fragmented DTLS handshake message" \
6550 -C "error"
6551
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006552# An autoreduction on the client-side might happen if the server is
6553# slow to reset, therefore omitting '-C "autoreduction"' below.
6554not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006555requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6556requires_config_enabled MBEDTLS_RSA_C
6557requires_config_enabled MBEDTLS_ECDSA_C
6558requires_config_enabled MBEDTLS_SHA256_C
6559requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6560requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6561requires_config_enabled MBEDTLS_AES_C
6562requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6563requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6564run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006565 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006566 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6567 crt_file=data_files/server7_int-ca.crt \
6568 key_file=data_files/server7.key \
6569 exchanges=2 renegotiation=1 \
6570 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006571 hs_timeout=10000-60000 \
6572 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006573 "$P_CLI dtls=1 debug_level=2 \
6574 crt_file=data_files/server8_int-ca2.crt \
6575 key_file=data_files/server8.key \
6576 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006577 hs_timeout=10000-60000 \
6578 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006579 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006580 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006581 -s "found fragmented DTLS handshake message" \
6582 -c "found fragmented DTLS handshake message" \
6583 -C "error"
6584
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006585# An autoreduction on the client-side might happen if the server is
6586# slow to reset, therefore omitting '-C "autoreduction"' below.
6587not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006588requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6589requires_config_enabled MBEDTLS_RSA_C
6590requires_config_enabled MBEDTLS_ECDSA_C
6591requires_config_enabled MBEDTLS_SHA256_C
6592requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6593requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6594requires_config_enabled MBEDTLS_AES_C
6595requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6596run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006597 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006598 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6599 crt_file=data_files/server7_int-ca.crt \
6600 key_file=data_files/server7.key \
6601 exchanges=2 renegotiation=1 \
6602 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006603 hs_timeout=10000-60000 \
6604 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006605 "$P_CLI dtls=1 debug_level=2 \
6606 crt_file=data_files/server8_int-ca2.crt \
6607 key_file=data_files/server8.key \
6608 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006609 hs_timeout=10000-60000 \
6610 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006611 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006612 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006613 -s "found fragmented DTLS handshake message" \
6614 -c "found fragmented DTLS handshake message" \
6615 -C "error"
6616
Andrzej Kurek77826052018-10-11 07:34:08 -04006617# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006618requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6619requires_config_enabled MBEDTLS_RSA_C
6620requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006621requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6622requires_config_enabled MBEDTLS_AES_C
6623requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006624client_needs_more_time 2
6625run_test "DTLS fragmenting: proxy MTU + 3d" \
6626 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006627 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006628 crt_file=data_files/server7_int-ca.crt \
6629 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006630 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006631 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006632 crt_file=data_files/server8_int-ca2.crt \
6633 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006634 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006635 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006636 0 \
6637 -s "found fragmented DTLS handshake message" \
6638 -c "found fragmented DTLS handshake message" \
6639 -C "error"
6640
Andrzej Kurek77826052018-10-11 07:34:08 -04006641# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006642requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6643requires_config_enabled MBEDTLS_RSA_C
6644requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006645requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6646requires_config_enabled MBEDTLS_AES_C
6647requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006648client_needs_more_time 2
6649run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6650 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6651 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6652 crt_file=data_files/server7_int-ca.crt \
6653 key_file=data_files/server7.key \
6654 hs_timeout=250-10000 mtu=512 nbio=2" \
6655 "$P_CLI dtls=1 debug_level=2 \
6656 crt_file=data_files/server8_int-ca2.crt \
6657 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006658 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006659 hs_timeout=250-10000 mtu=512 nbio=2" \
6660 0 \
6661 -s "found fragmented DTLS handshake message" \
6662 -c "found fragmented DTLS handshake message" \
6663 -C "error"
6664
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006665# interop tests for DTLS fragmentating with reliable connection
6666#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006667# here and below we just want to test that the we fragment in a way that
6668# pleases other implementations, so we don't need the peer to fragment
6669requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6670requires_config_enabled MBEDTLS_RSA_C
6671requires_config_enabled MBEDTLS_ECDSA_C
6672requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006673requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006674run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6675 "$G_SRV -u" \
6676 "$P_CLI dtls=1 debug_level=2 \
6677 crt_file=data_files/server8_int-ca2.crt \
6678 key_file=data_files/server8.key \
6679 mtu=512 force_version=dtls1_2" \
6680 0 \
6681 -c "fragmenting handshake message" \
6682 -C "error"
6683
6684requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6685requires_config_enabled MBEDTLS_RSA_C
6686requires_config_enabled MBEDTLS_ECDSA_C
6687requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006688requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006689run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6690 "$G_SRV -u" \
6691 "$P_CLI dtls=1 debug_level=2 \
6692 crt_file=data_files/server8_int-ca2.crt \
6693 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006694 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006695 0 \
6696 -c "fragmenting handshake message" \
6697 -C "error"
6698
Hanno Beckerb9a00862018-08-28 10:20:22 +01006699# We use --insecure for the GnuTLS client because it expects
6700# the hostname / IP it connects to to be the name used in the
6701# certificate obtained from the server. Here, however, it
6702# connects to 127.0.0.1 while our test certificates use 'localhost'
6703# as the server name in the certificate. This will make the
6704# certifiate validation fail, but passing --insecure makes
6705# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006706requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6707requires_config_enabled MBEDTLS_RSA_C
6708requires_config_enabled MBEDTLS_ECDSA_C
6709requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006710requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006711requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006712run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006713 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006714 crt_file=data_files/server7_int-ca.crt \
6715 key_file=data_files/server7.key \
6716 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006717 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006718 0 \
6719 -s "fragmenting handshake message"
6720
Hanno Beckerb9a00862018-08-28 10:20:22 +01006721# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006722requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6723requires_config_enabled MBEDTLS_RSA_C
6724requires_config_enabled MBEDTLS_ECDSA_C
6725requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006726requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006727requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006728run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006729 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006730 crt_file=data_files/server7_int-ca.crt \
6731 key_file=data_files/server7.key \
6732 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006733 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006734 0 \
6735 -s "fragmenting handshake message"
6736
6737requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6738requires_config_enabled MBEDTLS_RSA_C
6739requires_config_enabled MBEDTLS_ECDSA_C
6740requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6741run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6742 "$O_SRV -dtls1_2 -verify 10" \
6743 "$P_CLI dtls=1 debug_level=2 \
6744 crt_file=data_files/server8_int-ca2.crt \
6745 key_file=data_files/server8.key \
6746 mtu=512 force_version=dtls1_2" \
6747 0 \
6748 -c "fragmenting handshake message" \
6749 -C "error"
6750
6751requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6752requires_config_enabled MBEDTLS_RSA_C
6753requires_config_enabled MBEDTLS_ECDSA_C
6754requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6755run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6756 "$O_SRV -dtls1 -verify 10" \
6757 "$P_CLI dtls=1 debug_level=2 \
6758 crt_file=data_files/server8_int-ca2.crt \
6759 key_file=data_files/server8.key \
6760 mtu=512 force_version=dtls1" \
6761 0 \
6762 -c "fragmenting handshake message" \
6763 -C "error"
6764
6765requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6766requires_config_enabled MBEDTLS_RSA_C
6767requires_config_enabled MBEDTLS_ECDSA_C
6768requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6769run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6770 "$P_SRV dtls=1 debug_level=2 \
6771 crt_file=data_files/server7_int-ca.crt \
6772 key_file=data_files/server7.key \
6773 mtu=512 force_version=dtls1_2" \
6774 "$O_CLI -dtls1_2" \
6775 0 \
6776 -s "fragmenting handshake message"
6777
6778requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6779requires_config_enabled MBEDTLS_RSA_C
6780requires_config_enabled MBEDTLS_ECDSA_C
6781requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6782run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6783 "$P_SRV dtls=1 debug_level=2 \
6784 crt_file=data_files/server7_int-ca.crt \
6785 key_file=data_files/server7.key \
6786 mtu=512 force_version=dtls1" \
6787 "$O_CLI -dtls1" \
6788 0 \
6789 -s "fragmenting handshake message"
6790
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006791# interop tests for DTLS fragmentating with unreliable connection
6792#
6793# again we just want to test that the we fragment in a way that
6794# pleases other implementations, so we don't need the peer to fragment
6795requires_gnutls_next
6796requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6797requires_config_enabled MBEDTLS_RSA_C
6798requires_config_enabled MBEDTLS_ECDSA_C
6799requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006800client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006801run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6802 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6803 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006804 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006805 crt_file=data_files/server8_int-ca2.crt \
6806 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006807 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006808 0 \
6809 -c "fragmenting handshake message" \
6810 -C "error"
6811
6812requires_gnutls_next
6813requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6814requires_config_enabled MBEDTLS_RSA_C
6815requires_config_enabled MBEDTLS_ECDSA_C
6816requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006817client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006818run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6819 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6820 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006821 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006822 crt_file=data_files/server8_int-ca2.crt \
6823 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006824 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006825 0 \
6826 -c "fragmenting handshake message" \
6827 -C "error"
6828
k-stachowiakabb843e2019-02-18 16:14:03 +01006829requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006830requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6831requires_config_enabled MBEDTLS_RSA_C
6832requires_config_enabled MBEDTLS_ECDSA_C
6833requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6834client_needs_more_time 4
6835run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6836 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6837 "$P_SRV dtls=1 debug_level=2 \
6838 crt_file=data_files/server7_int-ca.crt \
6839 key_file=data_files/server7.key \
6840 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006841 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006842 0 \
6843 -s "fragmenting handshake message"
6844
k-stachowiakabb843e2019-02-18 16:14:03 +01006845requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006846requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6847requires_config_enabled MBEDTLS_RSA_C
6848requires_config_enabled MBEDTLS_ECDSA_C
6849requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6850client_needs_more_time 4
6851run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6852 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6853 "$P_SRV dtls=1 debug_level=2 \
6854 crt_file=data_files/server7_int-ca.crt \
6855 key_file=data_files/server7.key \
6856 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006857 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006858 0 \
6859 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006860
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006861## Interop test with OpenSSL might trigger a bug in recent versions (including
6862## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006863## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006864## They should be re-enabled once a fixed version of OpenSSL is available
6865## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006866skip_next_test
6867requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6868requires_config_enabled MBEDTLS_RSA_C
6869requires_config_enabled MBEDTLS_ECDSA_C
6870requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6871client_needs_more_time 4
6872run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6873 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6874 "$O_SRV -dtls1_2 -verify 10" \
6875 "$P_CLI dtls=1 debug_level=2 \
6876 crt_file=data_files/server8_int-ca2.crt \
6877 key_file=data_files/server8.key \
6878 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6879 0 \
6880 -c "fragmenting handshake message" \
6881 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006882
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006883skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006884requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6885requires_config_enabled MBEDTLS_RSA_C
6886requires_config_enabled MBEDTLS_ECDSA_C
6887requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006888client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006889run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6890 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006891 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006892 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006893 crt_file=data_files/server8_int-ca2.crt \
6894 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006895 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006896 0 \
6897 -c "fragmenting handshake message" \
6898 -C "error"
6899
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006900skip_next_test
6901requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6902requires_config_enabled MBEDTLS_RSA_C
6903requires_config_enabled MBEDTLS_ECDSA_C
6904requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6905client_needs_more_time 4
6906run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6907 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6908 "$P_SRV dtls=1 debug_level=2 \
6909 crt_file=data_files/server7_int-ca.crt \
6910 key_file=data_files/server7.key \
6911 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6912 "$O_CLI -dtls1_2" \
6913 0 \
6914 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006915
6916# -nbio is added to prevent s_client from blocking in case of duplicated
6917# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006918skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006919requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6920requires_config_enabled MBEDTLS_RSA_C
6921requires_config_enabled MBEDTLS_ECDSA_C
6922requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006923client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006924run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
6925 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006926 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006927 crt_file=data_files/server7_int-ca.crt \
6928 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006929 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006930 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006931 0 \
6932 -s "fragmenting handshake message"
6933
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006934# Tests for specific things with "unreliable" UDP connection
6935
6936not_with_valgrind # spurious resend due to timeout
6937run_test "DTLS proxy: reference" \
6938 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006939 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
6940 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006941 0 \
6942 -C "replayed record" \
6943 -S "replayed record" \
6944 -C "record from another epoch" \
6945 -S "record from another epoch" \
6946 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006947 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006948 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006949 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006950 -c "HTTP/1.0 200 OK"
6951
6952not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006953run_test "DTLS proxy: duplicate every packet" \
6954 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006955 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
6956 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006957 0 \
6958 -c "replayed record" \
6959 -s "replayed record" \
6960 -c "record from another epoch" \
6961 -s "record from another epoch" \
6962 -S "resend" \
6963 -s "Extra-header:" \
6964 -c "HTTP/1.0 200 OK"
6965
6966run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
6967 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006968 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
6969 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006970 0 \
6971 -c "replayed record" \
6972 -S "replayed record" \
6973 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006974 -s "record from another epoch" \
6975 -c "resend" \
6976 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006977 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006978 -c "HTTP/1.0 200 OK"
6979
6980run_test "DTLS proxy: multiple records in same datagram" \
6981 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006982 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6983 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006984 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006985 -c "next record in same datagram" \
6986 -s "next record in same datagram"
6987
6988run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
6989 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006990 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6991 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006992 0 \
6993 -c "next record in same datagram" \
6994 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006995
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006996run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
6997 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006998 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
6999 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007000 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007001 -c "discarding invalid record (mac)" \
7002 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007003 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007004 -c "HTTP/1.0 200 OK" \
7005 -S "too many records with bad MAC" \
7006 -S "Verification of the message MAC failed"
7007
7008run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
7009 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007010 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7011 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007012 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007013 -C "discarding invalid record (mac)" \
7014 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007015 -S "Extra-header:" \
7016 -C "HTTP/1.0 200 OK" \
7017 -s "too many records with bad MAC" \
7018 -s "Verification of the message MAC failed"
7019
7020run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7021 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007022 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7023 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007024 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007025 -c "discarding invalid record (mac)" \
7026 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007027 -s "Extra-header:" \
7028 -c "HTTP/1.0 200 OK" \
7029 -S "too many records with bad MAC" \
7030 -S "Verification of the message MAC failed"
7031
7032run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7033 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007034 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7035 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007036 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007037 -c "discarding invalid record (mac)" \
7038 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007039 -s "Extra-header:" \
7040 -c "HTTP/1.0 200 OK" \
7041 -s "too many records with bad MAC" \
7042 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007043
7044run_test "DTLS proxy: delay ChangeCipherSpec" \
7045 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007046 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7047 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007048 0 \
7049 -c "record from another epoch" \
7050 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007051 -s "Extra-header:" \
7052 -c "HTTP/1.0 200 OK"
7053
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007054# Tests for reordering support with DTLS
7055
Hanno Becker56cdfd12018-08-17 13:42:15 +01007056run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7057 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007058 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7059 hs_timeout=2500-60000" \
7060 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7061 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007062 0 \
7063 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007064 -c "Next handshake message has been buffered - load"\
7065 -S "Buffering HS message" \
7066 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007067 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007068 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007069 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007070 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007071
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007072run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7073 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007074 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7075 hs_timeout=2500-60000" \
7076 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7077 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007078 0 \
7079 -c "Buffering HS message" \
7080 -c "found fragmented DTLS handshake message"\
7081 -c "Next handshake message 1 not or only partially bufffered" \
7082 -c "Next handshake message has been buffered - load"\
7083 -S "Buffering HS message" \
7084 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007085 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007086 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007087 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007088 -S "Remember CCS message"
7089
Hanno Beckera1adcca2018-08-24 14:41:07 +01007090# The client buffers the ServerKeyExchange before receiving the fragmented
7091# Certificate message; at the time of writing, together these are aroudn 1200b
7092# in size, so that the bound below ensures that the certificate can be reassembled
7093# while keeping the ServerKeyExchange.
7094requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7095run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007096 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007097 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7098 hs_timeout=2500-60000" \
7099 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7100 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007101 0 \
7102 -c "Buffering HS message" \
7103 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007104 -C "attempt to make space by freeing buffered messages" \
7105 -S "Buffering HS message" \
7106 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007107 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007108 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007109 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007110 -S "Remember CCS message"
7111
7112# The size constraints ensure that the delayed certificate message can't
7113# be reassembled while keeping the ServerKeyExchange message, but it can
7114# when dropping it first.
7115requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7116requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7117run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7118 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007119 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7120 hs_timeout=2500-60000" \
7121 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7122 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007123 0 \
7124 -c "Buffering HS message" \
7125 -c "attempt to make space by freeing buffered future messages" \
7126 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007127 -S "Buffering HS message" \
7128 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007129 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007130 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007131 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007132 -S "Remember CCS message"
7133
Hanno Becker56cdfd12018-08-17 13:42:15 +01007134run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7135 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007136 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7137 hs_timeout=2500-60000" \
7138 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7139 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007140 0 \
7141 -C "Buffering HS message" \
7142 -C "Next handshake message has been buffered - load"\
7143 -s "Buffering HS message" \
7144 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007145 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007146 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007147 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007148 -S "Remember CCS message"
7149
7150run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7151 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007152 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7153 hs_timeout=2500-60000" \
7154 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7155 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007156 0 \
7157 -C "Buffering HS message" \
7158 -C "Next handshake message has been buffered - load"\
7159 -S "Buffering HS message" \
7160 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007161 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007162 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007163 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007164 -S "Remember CCS message"
7165
7166run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7167 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007168 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7169 hs_timeout=2500-60000" \
7170 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7171 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007172 0 \
7173 -C "Buffering HS message" \
7174 -C "Next handshake message has been buffered - load"\
7175 -S "Buffering HS message" \
7176 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007177 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007178 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007179 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007180 -s "Remember CCS message"
7181
Hanno Beckera1adcca2018-08-24 14:41:07 +01007182run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007183 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007184 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7185 hs_timeout=2500-60000" \
7186 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7187 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007188 0 \
7189 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007190 -s "Found buffered record from current epoch - load" \
7191 -c "Buffer record from epoch 1" \
7192 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007193
Hanno Beckera1adcca2018-08-24 14:41:07 +01007194# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7195# from the server are delayed, so that the encrypted Finished message
7196# is received and buffered. When the fragmented NewSessionTicket comes
7197# in afterwards, the encrypted Finished message must be freed in order
7198# to make space for the NewSessionTicket to be reassembled.
7199# This works only in very particular circumstances:
7200# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7201# of the NewSessionTicket, but small enough to also allow buffering of
7202# the encrypted Finished message.
7203# - The MTU setting on the server must be so small that the NewSessionTicket
7204# needs to be fragmented.
7205# - All messages sent by the server must be small enough to be either sent
7206# without fragmentation or be reassembled within the bounds of
7207# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7208# handshake, omitting CRTs.
7209requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7210requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7211run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7212 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7213 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7214 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7215 0 \
7216 -s "Buffer record from epoch 1" \
7217 -s "Found buffered record from current epoch - load" \
7218 -c "Buffer record from epoch 1" \
7219 -C "Found buffered record from current epoch - load" \
7220 -c "Enough space available after freeing future epoch record"
7221
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007222# Tests for "randomly unreliable connection": try a variety of flows and peers
7223
7224client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007225run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7226 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007227 "$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 +02007228 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007229 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007230 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7231 0 \
7232 -s "Extra-header:" \
7233 -c "HTTP/1.0 200 OK"
7234
Janos Follath74537a62016-09-02 13:45:28 +01007235client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007236run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7237 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007238 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7239 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007240 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7241 0 \
7242 -s "Extra-header:" \
7243 -c "HTTP/1.0 200 OK"
7244
Janos Follath74537a62016-09-02 13:45:28 +01007245client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007246run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7247 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007248 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7249 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007250 0 \
7251 -s "Extra-header:" \
7252 -c "HTTP/1.0 200 OK"
7253
Janos Follath74537a62016-09-02 13:45:28 +01007254client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007255run_test "DTLS proxy: 3d, FS, client auth" \
7256 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007257 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7258 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007259 0 \
7260 -s "Extra-header:" \
7261 -c "HTTP/1.0 200 OK"
7262
Janos Follath74537a62016-09-02 13:45:28 +01007263client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007264run_test "DTLS proxy: 3d, FS, ticket" \
7265 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007266 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7267 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007268 0 \
7269 -s "Extra-header:" \
7270 -c "HTTP/1.0 200 OK"
7271
Janos Follath74537a62016-09-02 13:45:28 +01007272client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007273run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7274 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007275 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7276 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007277 0 \
7278 -s "Extra-header:" \
7279 -c "HTTP/1.0 200 OK"
7280
Janos Follath74537a62016-09-02 13:45:28 +01007281client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007282run_test "DTLS proxy: 3d, max handshake, nbio" \
7283 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007284 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007285 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007286 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007287 0 \
7288 -s "Extra-header:" \
7289 -c "HTTP/1.0 200 OK"
7290
Janos Follath74537a62016-09-02 13:45:28 +01007291client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007292run_test "DTLS proxy: 3d, min handshake, resumption" \
7293 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007294 "$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 +02007295 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007296 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007297 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007298 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7299 0 \
7300 -s "a session has been resumed" \
7301 -c "a session has been resumed" \
7302 -s "Extra-header:" \
7303 -c "HTTP/1.0 200 OK"
7304
Janos Follath74537a62016-09-02 13:45:28 +01007305client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007306run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
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=0 auth_mode=none \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007309 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007310 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007311 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007312 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7313 0 \
7314 -s "a session has been resumed" \
7315 -c "a session has been resumed" \
7316 -s "Extra-header:" \
7317 -c "HTTP/1.0 200 OK"
7318
Janos Follath74537a62016-09-02 13:45:28 +01007319client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007320requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007321run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007322 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007323 "$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 +02007324 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007325 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007326 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007327 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7328 0 \
7329 -c "=> renegotiate" \
7330 -s "=> renegotiate" \
7331 -s "Extra-header:" \
7332 -c "HTTP/1.0 200 OK"
7333
Janos Follath74537a62016-09-02 13:45:28 +01007334client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007335requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007336run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7337 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007338 "$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 +02007339 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007340 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007341 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007342 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7343 0 \
7344 -c "=> renegotiate" \
7345 -s "=> renegotiate" \
7346 -s "Extra-header:" \
7347 -c "HTTP/1.0 200 OK"
7348
Janos Follath74537a62016-09-02 13:45:28 +01007349client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007350requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007351run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007352 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007353 "$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 +02007354 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007355 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007356 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007357 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007358 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7359 0 \
7360 -c "=> renegotiate" \
7361 -s "=> renegotiate" \
7362 -s "Extra-header:" \
7363 -c "HTTP/1.0 200 OK"
7364
Janos Follath74537a62016-09-02 13:45:28 +01007365client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007366requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007367run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007368 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007369 "$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 +02007370 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007371 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007372 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007373 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007374 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7375 0 \
7376 -c "=> renegotiate" \
7377 -s "=> renegotiate" \
7378 -s "Extra-header:" \
7379 -c "HTTP/1.0 200 OK"
7380
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007381## Interop tests with OpenSSL might trigger a bug in recent versions (including
7382## all versions installed on the CI machines), reported here:
7383## Bug report: https://github.com/openssl/openssl/issues/6902
7384## They should be re-enabled once a fixed version of OpenSSL is available
7385## (this should happen in some 1.1.1_ release according to the ticket).
7386skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007387client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007388not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007389run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007390 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7391 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007392 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007393 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007394 -c "HTTP/1.0 200 OK"
7395
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007396skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007397client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007398not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007399run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7400 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7401 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007402 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007403 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007404 -c "HTTP/1.0 200 OK"
7405
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007406skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007407client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007408not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007409run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7410 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7411 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007412 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007413 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007414 -c "HTTP/1.0 200 OK"
7415
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007416requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007417client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007418not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007419run_test "DTLS proxy: 3d, gnutls server" \
7420 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7421 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007422 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007423 0 \
7424 -s "Extra-header:" \
7425 -c "Extra-header:"
7426
k-stachowiakabb843e2019-02-18 16:14:03 +01007427requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007428client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007429not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007430run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7431 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007432 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007433 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007434 0 \
7435 -s "Extra-header:" \
7436 -c "Extra-header:"
7437
k-stachowiakabb843e2019-02-18 16:14:03 +01007438requires_gnutls_next
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é-Gonnard6093d812014-09-29 17:52:57 +02007441run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7442 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007443 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007444 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007445 0 \
7446 -s "Extra-header:" \
7447 -c "Extra-header:"
7448
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007449# Final report
7450
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007451echo "------------------------------------------------------------------------"
7452
7453if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007454 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007455else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007456 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007457fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007458PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007459echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007460
7461exit $FAILS