blob: f97f0870d6df94a8b820bb653996831a6f1145b9 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Bence Szépkútia2947ac2020-08-19 16:37:36 +02005# Copyright The Mbed TLS Contributors
Bence Szépkútif744bd72020-06-05 13:02:18 +02006# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7#
8# This file is provided under the Apache License 2.0, or the
9# GNU General Public License v2.0 or later.
10#
11# **********
12# Apache License 2.0:
Bence Szépkúti51b41d52020-05-26 01:54:15 +020013#
14# Licensed under the Apache License, Version 2.0 (the "License"); you may
15# not use this file except in compliance with the License.
16# You may obtain a copy of the License at
17#
18# http://www.apache.org/licenses/LICENSE-2.0
19#
20# Unless required by applicable law or agreed to in writing, software
21# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23# See the License for the specific language governing permissions and
24# limitations under the License.
25#
Bence Szépkútif744bd72020-06-05 13:02:18 +020026# **********
27#
28# **********
29# GNU General Public License v2.0 or later:
30#
31# This program is free software; you can redistribute it and/or modify
32# it under the terms of the GNU General Public License as published by
33# the Free Software Foundation; either version 2 of the License, or
34# (at your option) any later version.
35#
36# This program is distributed in the hope that it will be useful,
37# but WITHOUT ANY WARRANTY; without even the implied warranty of
38# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39# GNU General Public License for more details.
40#
41# You should have received a copy of the GNU General Public License along
42# with this program; if not, write to the Free Software Foundation, Inc.,
43# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
44#
45# **********
46#
Simon Butcher58eddef2016-05-19 23:43:11 +010047# Purpose
48#
49# Executes tests to prove various TLS/SSL options and extensions.
50#
51# The goal is not to cover every ciphersuite/version, but instead to cover
52# specific options (max fragment length, truncated hmac, etc) or procedures
53# (session resumption from cache or ticket, renego, etc).
54#
55# The tests assume a build with default options, with exceptions expressed
56# with a dependency. The tests focus on functionality and do not consider
57# performance.
58#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010059
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010060set -u
61
Jaeden Ameroa258ccd2019-07-03 13:51:04 +010062# Limit the size of each log to 10 GiB, in case of failures with this script
63# where it may output seemingly unlimited length error logs.
64ulimit -f 20971520
65
Angus Grattonc4dd0732018-04-11 16:28:39 +100066if cd $( dirname $0 ); then :; else
67 echo "cd $( dirname $0 ) failed" >&2
68 exit 1
69fi
70
Antonin Décimod5f47592019-01-23 15:24:37 +010071# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010072: ${P_SRV:=../programs/ssl/ssl_server2}
73: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020074: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010075: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020076: ${GNUTLS_CLI:=gnutls-cli}
77: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020078: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010079
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020080O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010081O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020082G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010083G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020084TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010085
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020086# alternative versions of OpenSSL and GnuTLS (no default path)
87
88if [ -n "${OPENSSL_LEGACY:-}" ]; then
89 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
90 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
91else
92 O_LEGACY_SRV=false
93 O_LEGACY_CLI=false
94fi
95
Hanno Becker58e9dc32018-08-17 15:53:21 +010096if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020097 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
98else
99 G_NEXT_SRV=false
100fi
101
Hanno Becker58e9dc32018-08-17 15:53:21 +0100102if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200103 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
104else
105 G_NEXT_CLI=false
106fi
107
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100108TESTS=0
109FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200110SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100111
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000112CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +0200113
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100114MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100115FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200116EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100117
Paul Bakkere20310a2016-05-10 11:18:17 +0100118SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +0100119RUN_TEST_NUMBER=''
120
Paul Bakkeracaac852016-05-10 11:47:13 +0100121PRESERVE_LOGS=0
122
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200123# Pick a "unique" server port in the range 10000-19999, and a proxy
124# port which is this plus 10000. Each port number may be independently
125# overridden by a command line option.
126SRV_PORT=$(($$ % 10000 + 10000))
127PXY_PORT=$((SRV_PORT + 10000))
128
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100129print_usage() {
130 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100131 printf " -h|--help\tPrint this help.\n"
132 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200133 printf " -f|--filter\tOnly matching tests are executed (substring or BRE)\n"
134 printf " -e|--exclude\tMatching tests are excluded (substring or BRE)\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100135 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100136 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100137 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200138 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
139 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100140 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100141}
142
143get_options() {
144 while [ $# -gt 0 ]; do
145 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100146 -f|--filter)
147 shift; FILTER=$1
148 ;;
149 -e|--exclude)
150 shift; EXCLUDE=$1
151 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100152 -m|--memcheck)
153 MEMCHECK=1
154 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100155 -n|--number)
156 shift; RUN_TEST_NUMBER=$1
157 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100158 -s|--show-numbers)
159 SHOW_TEST_NUMBER=1
160 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100161 -p|--preserve-logs)
162 PRESERVE_LOGS=1
163 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200164 --port)
165 shift; SRV_PORT=$1
166 ;;
167 --proxy-port)
168 shift; PXY_PORT=$1
169 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100170 --seed)
171 shift; SEED="$1"
172 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100173 -h|--help)
174 print_usage
175 exit 0
176 ;;
177 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200178 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100179 print_usage
180 exit 1
181 ;;
182 esac
183 shift
184 done
185}
186
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200187# Read boolean configuration options from config.h for easy and quick
188# testing. Skip non-boolean options (with something other than spaces
189# and a comment after "#define SYMBOL"). The variable contains a
190# space-separated list of symbols.
191CONFIGS_ENABLED=" $(<"$CONFIG_H" \
192 sed -n 's!^ *#define *\([A-Za-z][0-9A-Z_a-z]*\) *\(/*\)*!\1!p' |
193 tr '\n' ' ')"
194
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100195# Skip next test; use this macro to skip tests which are legitimate
196# in theory and expected to be re-introduced at some point, but
197# aren't expected to succeed at the moment due to problems outside
198# our control (such as bugs in other TLS implementations).
199skip_next_test() {
200 SKIP_NEXT="YES"
201}
202
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100203# skip next test if the flag is not enabled in config.h
204requires_config_enabled() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200205 case $CONFIGS_ENABLED in
206 *" $1 "*) :;;
207 *) SKIP_NEXT="YES";;
208 esac
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100209}
210
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200211# skip next test if the flag is enabled in config.h
212requires_config_disabled() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200213 case $CONFIGS_ENABLED in
214 *" $1 "*) SKIP_NEXT="YES";;
215 esac
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200216}
217
Hanno Becker7c48dd12018-08-28 16:09:22 +0100218get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100219 # This function uses the query_config command line option to query the
220 # required Mbed TLS compile time configuration from the ssl_server2
221 # program. The command will always return a success value if the
222 # configuration is defined and the value will be printed to stdout.
223 #
224 # Note that if the configuration is not defined or is defined to nothing,
225 # the output of this function will be an empty string.
226 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100227}
228
229requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100230 VAL="$( get_config_value_or_default "$1" )"
231 if [ -z "$VAL" ]; then
232 # Should never happen
233 echo "Mbed TLS configuration $1 is not defined"
234 exit 1
235 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100236 SKIP_NEXT="YES"
237 fi
238}
239
240requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100241 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100242 if [ -z "$VAL" ]; then
243 # Should never happen
244 echo "Mbed TLS configuration $1 is not defined"
245 exit 1
246 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100247 SKIP_NEXT="YES"
248 fi
249}
250
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200251# skip next test if OpenSSL doesn't support FALLBACK_SCSV
252requires_openssl_with_fallback_scsv() {
253 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
254 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
255 then
256 OPENSSL_HAS_FBSCSV="YES"
257 else
258 OPENSSL_HAS_FBSCSV="NO"
259 fi
260 fi
261 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
262 SKIP_NEXT="YES"
263 fi
264}
265
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200266# skip next test if GnuTLS isn't available
267requires_gnutls() {
268 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200269 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200270 GNUTLS_AVAILABLE="YES"
271 else
272 GNUTLS_AVAILABLE="NO"
273 fi
274 fi
275 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
276 SKIP_NEXT="YES"
277 fi
278}
279
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200280# skip next test if GnuTLS-next isn't available
281requires_gnutls_next() {
282 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
283 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
284 GNUTLS_NEXT_AVAILABLE="YES"
285 else
286 GNUTLS_NEXT_AVAILABLE="NO"
287 fi
288 fi
289 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
290 SKIP_NEXT="YES"
291 fi
292}
293
294# skip next test if OpenSSL-legacy isn't available
295requires_openssl_legacy() {
296 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
297 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
298 OPENSSL_LEGACY_AVAILABLE="YES"
299 else
300 OPENSSL_LEGACY_AVAILABLE="NO"
301 fi
302 fi
303 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
304 SKIP_NEXT="YES"
305 fi
306}
307
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200308# skip next test if IPv6 isn't available on this host
309requires_ipv6() {
310 if [ -z "${HAS_IPV6:-}" ]; then
311 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
312 SRV_PID=$!
313 sleep 1
314 kill $SRV_PID >/dev/null 2>&1
315 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
316 HAS_IPV6="NO"
317 else
318 HAS_IPV6="YES"
319 fi
320 rm -r $SRV_OUT
321 fi
322
323 if [ "$HAS_IPV6" = "NO" ]; then
324 SKIP_NEXT="YES"
325 fi
326}
327
Andrzej Kurekb4593462018-10-11 08:43:30 -0400328# skip next test if it's i686 or uname is not available
329requires_not_i686() {
330 if [ -z "${IS_I686:-}" ]; then
331 IS_I686="YES"
332 if which "uname" >/dev/null 2>&1; then
333 if [ -z "$(uname -a | grep i686)" ]; then
334 IS_I686="NO"
335 fi
336 fi
337 fi
338 if [ "$IS_I686" = "YES" ]; then
339 SKIP_NEXT="YES"
340 fi
341}
342
Angus Grattonc4dd0732018-04-11 16:28:39 +1000343# Calculate the input & output maximum content lengths set in the config
344MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
345MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
346MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
347
348if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
349 MAX_CONTENT_LEN="$MAX_IN_LEN"
350fi
351if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
352 MAX_CONTENT_LEN="$MAX_OUT_LEN"
353fi
354
355# skip the next test if the SSL output buffer is less than 16KB
356requires_full_size_output_buffer() {
357 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
358 SKIP_NEXT="YES"
359 fi
360}
361
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200362# skip the next test if valgrind is in use
363not_with_valgrind() {
364 if [ "$MEMCHECK" -gt 0 ]; then
365 SKIP_NEXT="YES"
366 fi
367}
368
Paul Bakker362689d2016-05-13 10:33:25 +0100369# skip the next test if valgrind is NOT in use
370only_with_valgrind() {
371 if [ "$MEMCHECK" -eq 0 ]; then
372 SKIP_NEXT="YES"
373 fi
374}
375
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200376# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100377client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200378 CLI_DELAY_FACTOR=$1
379}
380
Janos Follath74537a62016-09-02 13:45:28 +0100381# wait for the given seconds after the client finished in the next test
382server_needs_more_time() {
383 SRV_DELAY_SECONDS=$1
384}
385
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100386# print_name <name>
387print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100388 TESTS=$(( $TESTS + 1 ))
389 LINE=""
390
391 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
392 LINE="$TESTS "
393 fi
394
395 LINE="$LINE$1"
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200396 printf "%s " "$LINE"
Paul Bakkere20310a2016-05-10 11:18:17 +0100397 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100398 for i in `seq 1 $LEN`; do printf '.'; done
399 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100400
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100401}
402
403# fail <message>
404fail() {
405 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100406 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100407
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200408 mv $SRV_OUT o-srv-${TESTS}.log
409 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200410 if [ -n "$PXY_CMD" ]; then
411 mv $PXY_OUT o-pxy-${TESTS}.log
412 fi
413 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100414
Manuel Pégourié-Gonnarde63fc6d2020-06-08 11:49:05 +0200415 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200416 echo " ! server output:"
417 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200418 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200419 echo " ! client output:"
420 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200421 if [ -n "$PXY_CMD" ]; then
422 echo " ! ========================================================"
423 echo " ! proxy output:"
424 cat o-pxy-${TESTS}.log
425 fi
426 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200427 fi
428
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200429 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100430}
431
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100432# is_polar <cmd_line>
433is_polar() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200434 case "$1" in
435 *ssl_client2*) true;;
436 *ssl_server2*) true;;
437 *) false;;
438 esac
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100439}
440
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200441# openssl s_server doesn't have -www with DTLS
442check_osrv_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200443 case "$SRV_CMD" in
444 *s_server*-dtls*)
445 NEEDS_INPUT=1
446 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )";;
447 *) NEEDS_INPUT=0;;
448 esac
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200449}
450
451# provide input to commands that need it
452provide_input() {
453 if [ $NEEDS_INPUT -eq 0 ]; then
454 return
455 fi
456
457 while true; do
458 echo "HTTP/1.0 200 OK"
459 sleep 1
460 done
461}
462
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100463# has_mem_err <log_file_name>
464has_mem_err() {
465 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
466 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
467 then
468 return 1 # false: does not have errors
469 else
470 return 0 # true: has errors
471 fi
472}
473
Unknown43dc0d62019-09-02 10:42:57 -0400474# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100475if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400476 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100477 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200478 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100479 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200480 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100481 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200482 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100483 # Make a tight loop, server normally takes less than 1s to start.
484 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
485 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400486 echo "$3 START TIMEOUT"
487 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100488 break
489 fi
490 # Linux and *BSD support decimal arguments to sleep. On other
491 # OSes this may be a tight loop.
492 sleep 0.1 2>/dev/null || true
493 done
494 }
495else
Unknown43dc0d62019-09-02 10:42:57 -0400496 echo "Warning: lsof not available, wait_app_start = sleep"
497 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200498 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100499 }
500fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200501
Unknown43dc0d62019-09-02 10:42:57 -0400502# Wait for server process $2 to be listening on port $1.
503wait_server_start() {
504 wait_app_start $1 $2 "SERVER" $SRV_OUT
505}
506
507# Wait for proxy process $2 to be listening on port $1.
508wait_proxy_start() {
509 wait_app_start $1 $2 "PROXY" $PXY_OUT
510}
511
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100512# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100513# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100514# acceptable bounds
515check_server_hello_time() {
516 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100517 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100518 # Get the Unix timestamp for now
519 CUR_TIME=$(date +'%s')
520 THRESHOLD_IN_SECS=300
521
522 # Check if the ServerHello time was printed
523 if [ -z "$SERVER_HELLO_TIME" ]; then
524 return 1
525 fi
526
527 # Check the time in ServerHello is within acceptable bounds
528 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
529 # The time in ServerHello is at least 5 minutes before now
530 return 1
531 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100532 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100533 return 1
534 else
535 return 0
536 fi
537}
538
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200539# wait for client to terminate and set CLI_EXIT
540# must be called right after starting the client
541wait_client_done() {
542 CLI_PID=$!
543
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200544 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
545 CLI_DELAY_FACTOR=1
546
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200547 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200548 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200549
550 wait $CLI_PID
551 CLI_EXIT=$?
552
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200553 kill $DOG_PID >/dev/null 2>&1
554 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200555
556 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100557
558 sleep $SRV_DELAY_SECONDS
559 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200560}
561
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200562# check if the given command uses dtls and sets global variable DTLS
563detect_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200564 case "$1" in
565 *dtls=1*|-dtls|-u) DTLS=1;;
566 *) DTLS=0;;
567 esac
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200568}
569
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200570# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100571# Options: -s pattern pattern that must be present in server output
572# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100573# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100574# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100575# -S pattern pattern that must be absent in server output
576# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100577# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100578# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100579run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100580 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200581 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100582
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200583 if is_excluded "$NAME"; then
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200584 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100585 return
586 fi
587
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100588 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100589
Paul Bakkerb7584a52016-05-10 10:50:43 +0100590 # Do we only run numbered tests?
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200591 if [ -n "$RUN_TEST_NUMBER" ]; then
592 case ",$RUN_TEST_NUMBER," in
593 *",$TESTS,"*) :;;
594 *) SKIP_NEXT="YES";;
595 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100596 fi
597
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200598 # should we skip?
599 if [ "X$SKIP_NEXT" = "XYES" ]; then
600 SKIP_NEXT="NO"
601 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200602 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200603 return
604 fi
605
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200606 # does this test use a proxy?
607 if [ "X$1" = "X-p" ]; then
608 PXY_CMD="$2"
609 shift 2
610 else
611 PXY_CMD=""
612 fi
613
614 # get commands and client output
615 SRV_CMD="$1"
616 CLI_CMD="$2"
617 CLI_EXPECT="$3"
618 shift 3
619
Hanno Becker7a11e722019-05-10 14:38:42 +0100620 # Check if test uses files
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200621 case "$SRV_CMD $CLI_CMD" in
622 *data_files/*)
623 requires_config_enabled MBEDTLS_FS_IO;;
624 esac
Hanno Becker7a11e722019-05-10 14:38:42 +0100625
626 # should we skip?
627 if [ "X$SKIP_NEXT" = "XYES" ]; then
628 SKIP_NEXT="NO"
629 echo "SKIP"
630 SKIPS=$(( $SKIPS + 1 ))
631 return
632 fi
633
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200634 # update DTLS variable
635 detect_dtls "$SRV_CMD"
636
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200637 # if the test uses DTLS but no custom proxy, add a simple proxy
638 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200639 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200640 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200641 case " $SRV_CMD " in
642 *' server_addr=::1 '*)
643 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
644 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200645 fi
646
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200647 # fix client port
648 if [ -n "$PXY_CMD" ]; then
649 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
650 else
651 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
652 fi
653
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100654 # prepend valgrind to our commands if active
655 if [ "$MEMCHECK" -gt 0 ]; then
656 if is_polar "$SRV_CMD"; then
657 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
658 fi
659 if is_polar "$CLI_CMD"; then
660 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
661 fi
662 fi
663
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200664 TIMES_LEFT=2
665 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200666 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200667
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200668 # run the commands
669 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda1919ad2020-07-27 09:45:32 +0200670 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200671 $PXY_CMD >> $PXY_OUT 2>&1 &
672 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400673 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200674 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200675
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200676 check_osrv_dtls
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200677 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200678 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
679 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100680 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200681
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200682 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200683 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
684 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100685
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100686 sleep 0.05
687
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200688 # terminate the server (and the proxy)
689 kill $SRV_PID
690 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100691
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200692 if [ -n "$PXY_CMD" ]; then
693 kill $PXY_PID >/dev/null 2>&1
694 wait $PXY_PID
695 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100696
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200697 # retry only on timeouts
698 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
699 printf "RETRY "
700 else
701 TIMES_LEFT=0
702 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200703 done
704
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100705 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200706 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100707 # expected client exit to incorrectly succeed in case of catastrophic
708 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100709 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200710 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100711 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100712 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100713 return
714 fi
715 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100716 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200717 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100718 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100719 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100720 return
721 fi
722 fi
723
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100724 # check server exit code
725 if [ $? != 0 ]; then
726 fail "server fail"
727 return
728 fi
729
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100730 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100731 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
732 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100733 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200734 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100735 return
736 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100737
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100738 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200739 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100740 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100741 while [ $# -gt 0 ]
742 do
743 case $1 in
744 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100745 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 +0100746 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100747 return
748 fi
749 ;;
750
751 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100752 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 +0100753 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100754 return
755 fi
756 ;;
757
758 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100759 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 +0100760 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100761 return
762 fi
763 ;;
764
765 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100766 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 +0100767 fail "pattern '$2' MUST NOT be present in the Client output"
768 return
769 fi
770 ;;
771
772 # The filtering in the following two options (-u and -U) do the following
773 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100774 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100775 # - keep one of each non-unique line
776 # - count how many lines remain
777 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
778 # if there were no duplicates.
779 "-U")
780 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
781 fail "lines following pattern '$2' must be unique in Server output"
782 return
783 fi
784 ;;
785
786 "-u")
787 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
788 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100789 return
790 fi
791 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100792 "-F")
793 if ! $2 "$SRV_OUT"; then
794 fail "function call to '$2' failed on Server output"
795 return
796 fi
797 ;;
798 "-f")
799 if ! $2 "$CLI_OUT"; then
800 fail "function call to '$2' failed on Client output"
801 return
802 fi
803 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100804
805 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200806 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100807 exit 1
808 esac
809 shift 2
810 done
811
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100812 # check valgrind's results
813 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200814 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100815 fail "Server has memory errors"
816 return
817 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200818 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100819 fail "Client has memory errors"
820 return
821 fi
822 fi
823
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100824 # if we're here, everything is ok
825 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100826 if [ "$PRESERVE_LOGS" -gt 0 ]; then
827 mv $SRV_OUT o-srv-${TESTS}.log
828 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100829 if [ -n "$PXY_CMD" ]; then
830 mv $PXY_OUT o-pxy-${TESTS}.log
831 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100832 fi
833
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200834 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100835}
836
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100837cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200838 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200839 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
840 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
841 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
842 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100843 exit 1
844}
845
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100846#
847# MAIN
848#
849
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100850get_options "$@"
851
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200852# Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell
853# patterns rather than regular expressions, use a case statement instead
854# of calling grep. To keep the optimizer simple, it is incomplete and only
855# detects simple cases: plain substring, everything, nothing.
856#
857# As an exception, the character '.' is treated as an ordinary character
858# if it is the only special character in the string. This is because it's
859# rare to need "any one character", but needing a literal '.' is common
860# (e.g. '-f "DTLS 1.2"').
861need_grep=
862case "$FILTER" in
863 '^$') simple_filter=;;
864 '.*') simple_filter='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200865 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200866 need_grep=1;;
867 *) # No regexp or shell-pattern special character
868 simple_filter="*$FILTER*";;
869esac
870case "$EXCLUDE" in
871 '^$') simple_exclude=;;
872 '.*') simple_exclude='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200873 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200874 need_grep=1;;
875 *) # No regexp or shell-pattern special character
876 simple_exclude="*$EXCLUDE*";;
877esac
878if [ -n "$need_grep" ]; then
879 is_excluded () {
880 ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE"
881 }
882else
883 is_excluded () {
884 case "$1" in
885 $simple_exclude) true;;
886 $simple_filter) false;;
887 *) true;;
888 esac
889 }
890fi
891
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100892# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100893P_SRV_BIN="${P_SRV%%[ ]*}"
894P_CLI_BIN="${P_CLI%%[ ]*}"
895P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100896if [ ! -x "$P_SRV_BIN" ]; then
897 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100898 exit 1
899fi
Hanno Becker17c04932017-10-10 14:44:53 +0100900if [ ! -x "$P_CLI_BIN" ]; then
901 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100902 exit 1
903fi
Hanno Becker17c04932017-10-10 14:44:53 +0100904if [ ! -x "$P_PXY_BIN" ]; then
905 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200906 exit 1
907fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100908if [ "$MEMCHECK" -gt 0 ]; then
909 if which valgrind >/dev/null 2>&1; then :; else
910 echo "Memcheck not possible. Valgrind not found"
911 exit 1
912 fi
913fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100914if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
915 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100916 exit 1
917fi
918
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200919# used by watchdog
920MAIN_PID="$$"
921
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100922# We use somewhat arbitrary delays for tests:
923# - how long do we wait for the server to start (when lsof not available)?
924# - how long do we allow for the client to finish?
925# (not to check performance, just to avoid waiting indefinitely)
926# Things are slower with valgrind, so give extra time here.
927#
928# Note: without lsof, there is a trade-off between the running time of this
929# script and the risk of spurious errors because we didn't wait long enough.
930# The watchdog delay on the other hand doesn't affect normal running time of
931# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200932if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100933 START_DELAY=6
934 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200935else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100936 START_DELAY=2
937 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200938fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100939
940# some particular tests need more time:
941# - for the client, we multiply the usual watchdog limit by a factor
942# - for the server, we sleep for a number of seconds after the client exits
943# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200944CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100945SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200946
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200947# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000948# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200949P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
950P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100951P_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 +0200952O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200953O_CLI="$O_CLI -connect localhost:+SRV_PORT"
954G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200955G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200956
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200957if [ -n "${OPENSSL_LEGACY:-}" ]; then
958 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
959 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
960fi
961
Hanno Becker58e9dc32018-08-17 15:53:21 +0100962if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200963 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
964fi
965
Hanno Becker58e9dc32018-08-17 15:53:21 +0100966if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200967 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200968fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100969
Gilles Peskine62469d92017-05-10 10:13:59 +0200970# Allow SHA-1, because many of our test certificates use it
971P_SRV="$P_SRV allow_sha1=1"
972P_CLI="$P_CLI allow_sha1=1"
973
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200974# Also pick a unique name for intermediate files
975SRV_OUT="srv_out.$$"
976CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200977PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200978SESSION="session.$$"
979
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200980SKIP_NEXT="NO"
981
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100982trap cleanup INT TERM HUP
983
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200984# Basic test
985
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200986# Checks that:
987# - things work with all ciphersuites active (used with config-full in all.sh)
988# - the expected (highest security) parameters are selected
989# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200990run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200991 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200992 "$P_CLI" \
993 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200994 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200995 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200996 -s "client hello v3, signature_algorithm ext: 6" \
997 -s "ECDHE curve: secp521r1" \
998 -S "error" \
999 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001000
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001001run_test "Default, DTLS" \
1002 "$P_SRV dtls=1" \
1003 "$P_CLI dtls=1" \
1004 0 \
1005 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001006 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001007
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +01001008requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1009run_test "Default (compression enabled)" \
1010 "$P_SRV debug_level=3" \
1011 "$P_CLI debug_level=3" \
1012 0 \
1013 -s "Allocating compression buffer" \
1014 -c "Allocating compression buffer" \
1015 -s "Record expansion is unknown (compression)" \
1016 -c "Record expansion is unknown (compression)" \
1017 -S "error" \
1018 -C "error"
1019
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001020# Test current time in ServerHello
1021requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001022run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001023 "$P_SRV debug_level=3" \
1024 "$P_CLI debug_level=3" \
1025 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001026 -f "check_server_hello_time" \
1027 -F "check_server_hello_time"
1028
Simon Butcher8e004102016-10-14 00:48:33 +01001029# Test for uniqueness of IVs in AEAD ciphersuites
1030run_test "Unique IV in GCM" \
1031 "$P_SRV exchanges=20 debug_level=4" \
1032 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1033 0 \
1034 -u "IV used" \
1035 -U "IV used"
1036
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001037# Tests for rc4 option
1038
Simon Butchera410af52016-05-19 22:12:18 +01001039requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001040run_test "RC4: server disabled, client enabled" \
1041 "$P_SRV" \
1042 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1043 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001044 -s "SSL - The server has no ciphersuites in common"
1045
Simon Butchera410af52016-05-19 22:12:18 +01001046requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001047run_test "RC4: server half, client enabled" \
1048 "$P_SRV arc4=1" \
1049 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1050 1 \
1051 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001052
1053run_test "RC4: server enabled, client disabled" \
1054 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1055 "$P_CLI" \
1056 1 \
1057 -s "SSL - The server has no ciphersuites in common"
1058
1059run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001060 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001061 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1062 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001063 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001064 -S "SSL - The server has no ciphersuites in common"
1065
Hanno Beckerd26bb202018-08-17 09:54:10 +01001066# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1067
1068requires_gnutls
1069requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1070run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1071 "$G_SRV"\
1072 "$P_CLI force_version=tls1_1" \
1073 0
1074
1075requires_gnutls
1076requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1077run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1078 "$G_SRV"\
1079 "$P_CLI force_version=tls1" \
1080 0
1081
Gilles Peskinebc70a182017-05-09 15:59:24 +02001082# Tests for SHA-1 support
1083
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001084requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001085run_test "SHA-1 forbidden by default in server certificate" \
1086 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1087 "$P_CLI debug_level=2 allow_sha1=0" \
1088 1 \
1089 -c "The certificate is signed with an unacceptable hash"
1090
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001091requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1092run_test "SHA-1 forbidden by default in server certificate" \
1093 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1094 "$P_CLI debug_level=2 allow_sha1=0" \
1095 0
1096
Gilles Peskinebc70a182017-05-09 15:59:24 +02001097run_test "SHA-1 explicitly allowed in server certificate" \
1098 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1099 "$P_CLI allow_sha1=1" \
1100 0
1101
1102run_test "SHA-256 allowed by default in server certificate" \
1103 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1104 "$P_CLI allow_sha1=0" \
1105 0
1106
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001107requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001108run_test "SHA-1 forbidden by default in client certificate" \
1109 "$P_SRV auth_mode=required allow_sha1=0" \
1110 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1111 1 \
1112 -s "The certificate is signed with an unacceptable hash"
1113
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001114requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1115run_test "SHA-1 forbidden by default in client certificate" \
1116 "$P_SRV auth_mode=required allow_sha1=0" \
1117 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1118 0
1119
Gilles Peskinebc70a182017-05-09 15:59:24 +02001120run_test "SHA-1 explicitly allowed in client certificate" \
1121 "$P_SRV auth_mode=required allow_sha1=1" \
1122 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1123 0
1124
1125run_test "SHA-256 allowed by default in client certificate" \
1126 "$P_SRV auth_mode=required allow_sha1=0" \
1127 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1128 0
1129
Hanno Becker7ae8a762018-08-14 15:43:35 +01001130# Tests for datagram packing
1131run_test "DTLS: multiple records in same datagram, client and server" \
1132 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1133 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1134 0 \
1135 -c "next record in same datagram" \
1136 -s "next record in same datagram"
1137
1138run_test "DTLS: multiple records in same datagram, client only" \
1139 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1140 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1141 0 \
1142 -s "next record in same datagram" \
1143 -C "next record in same datagram"
1144
1145run_test "DTLS: multiple records in same datagram, server only" \
1146 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1147 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1148 0 \
1149 -S "next record in same datagram" \
1150 -c "next record in same datagram"
1151
1152run_test "DTLS: multiple records in same datagram, neither client nor server" \
1153 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1154 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1155 0 \
1156 -S "next record in same datagram" \
1157 -C "next record in same datagram"
1158
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001159# Tests for Truncated HMAC extension
1160
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001161run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001162 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001163 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001164 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001165 -s "dumping 'expected mac' (20 bytes)" \
1166 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001167
Hanno Becker32c55012017-11-10 08:42:54 +00001168requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001169run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001170 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001171 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001172 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001173 -s "dumping 'expected mac' (20 bytes)" \
1174 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001175
Hanno Becker32c55012017-11-10 08:42:54 +00001176requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001177run_test "Truncated HMAC: client enabled, server default" \
1178 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001179 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001180 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001181 -s "dumping 'expected mac' (20 bytes)" \
1182 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001183
Hanno Becker32c55012017-11-10 08:42:54 +00001184requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001185run_test "Truncated HMAC: client enabled, server disabled" \
1186 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001187 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001188 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001189 -s "dumping 'expected mac' (20 bytes)" \
1190 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001191
Hanno Becker32c55012017-11-10 08:42:54 +00001192requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001193run_test "Truncated HMAC: client disabled, server enabled" \
1194 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001195 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001196 0 \
1197 -s "dumping 'expected mac' (20 bytes)" \
1198 -S "dumping 'expected mac' (10 bytes)"
1199
1200requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001201run_test "Truncated HMAC: client enabled, server enabled" \
1202 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001203 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001204 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001205 -S "dumping 'expected mac' (20 bytes)" \
1206 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001207
Hanno Becker4c4f4102017-11-10 09:16:05 +00001208run_test "Truncated HMAC, DTLS: client default, server default" \
1209 "$P_SRV dtls=1 debug_level=4" \
1210 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1211 0 \
1212 -s "dumping 'expected mac' (20 bytes)" \
1213 -S "dumping 'expected mac' (10 bytes)"
1214
1215requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1216run_test "Truncated HMAC, DTLS: client disabled, server default" \
1217 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001218 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001219 0 \
1220 -s "dumping 'expected mac' (20 bytes)" \
1221 -S "dumping 'expected mac' (10 bytes)"
1222
1223requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1224run_test "Truncated HMAC, DTLS: client enabled, server default" \
1225 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001226 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001227 0 \
1228 -s "dumping 'expected mac' (20 bytes)" \
1229 -S "dumping 'expected mac' (10 bytes)"
1230
1231requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1232run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1233 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001234 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001235 0 \
1236 -s "dumping 'expected mac' (20 bytes)" \
1237 -S "dumping 'expected mac' (10 bytes)"
1238
1239requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1240run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1241 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001242 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001243 0 \
1244 -s "dumping 'expected mac' (20 bytes)" \
1245 -S "dumping 'expected mac' (10 bytes)"
1246
1247requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1248run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1249 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001250 "$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 +01001251 0 \
1252 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001253 -s "dumping 'expected mac' (10 bytes)"
1254
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001255# Tests for Encrypt-then-MAC extension
1256
1257run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001258 "$P_SRV debug_level=3 \
1259 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001260 "$P_CLI debug_level=3" \
1261 0 \
1262 -c "client hello, adding encrypt_then_mac extension" \
1263 -s "found encrypt then mac extension" \
1264 -s "server hello, adding encrypt then mac extension" \
1265 -c "found encrypt_then_mac extension" \
1266 -c "using encrypt then mac" \
1267 -s "using encrypt then mac"
1268
1269run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001270 "$P_SRV debug_level=3 etm=0 \
1271 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001272 "$P_CLI debug_level=3 etm=1" \
1273 0 \
1274 -c "client hello, adding encrypt_then_mac extension" \
1275 -s "found encrypt then mac extension" \
1276 -S "server hello, adding encrypt then mac extension" \
1277 -C "found encrypt_then_mac extension" \
1278 -C "using encrypt then mac" \
1279 -S "using encrypt then mac"
1280
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001281run_test "Encrypt then MAC: client enabled, aead cipher" \
1282 "$P_SRV debug_level=3 etm=1 \
1283 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1284 "$P_CLI debug_level=3 etm=1" \
1285 0 \
1286 -c "client hello, adding encrypt_then_mac extension" \
1287 -s "found encrypt then mac extension" \
1288 -S "server hello, adding encrypt then mac extension" \
1289 -C "found encrypt_then_mac extension" \
1290 -C "using encrypt then mac" \
1291 -S "using encrypt then mac"
1292
1293run_test "Encrypt then MAC: client enabled, stream cipher" \
1294 "$P_SRV debug_level=3 etm=1 \
1295 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001296 "$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 +01001297 0 \
1298 -c "client hello, adding encrypt_then_mac extension" \
1299 -s "found encrypt then mac extension" \
1300 -S "server hello, adding encrypt then mac extension" \
1301 -C "found encrypt_then_mac extension" \
1302 -C "using encrypt then mac" \
1303 -S "using encrypt then mac"
1304
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001305run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001306 "$P_SRV debug_level=3 etm=1 \
1307 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001308 "$P_CLI debug_level=3 etm=0" \
1309 0 \
1310 -C "client hello, adding encrypt_then_mac extension" \
1311 -S "found encrypt then mac extension" \
1312 -S "server hello, adding encrypt then mac extension" \
1313 -C "found encrypt_then_mac extension" \
1314 -C "using encrypt then mac" \
1315 -S "using encrypt then mac"
1316
Janos Follathe2681a42016-03-07 15:57:05 +00001317requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001318run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001319 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001320 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001321 "$P_CLI debug_level=3 force_version=ssl3" \
1322 0 \
1323 -C "client hello, adding encrypt_then_mac extension" \
1324 -S "found encrypt then mac extension" \
1325 -S "server hello, adding encrypt then mac extension" \
1326 -C "found encrypt_then_mac extension" \
1327 -C "using encrypt then mac" \
1328 -S "using encrypt then mac"
1329
Janos Follathe2681a42016-03-07 15:57:05 +00001330requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001331run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001332 "$P_SRV debug_level=3 force_version=ssl3 \
1333 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001334 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001335 0 \
1336 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001337 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001338 -S "server hello, adding encrypt then mac extension" \
1339 -C "found encrypt_then_mac extension" \
1340 -C "using encrypt then mac" \
1341 -S "using encrypt then mac"
1342
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001343# Tests for Extended Master Secret extension
1344
1345run_test "Extended Master Secret: default" \
1346 "$P_SRV debug_level=3" \
1347 "$P_CLI debug_level=3" \
1348 0 \
1349 -c "client hello, adding extended_master_secret extension" \
1350 -s "found extended master secret extension" \
1351 -s "server hello, adding extended master secret extension" \
1352 -c "found extended_master_secret extension" \
1353 -c "using extended master secret" \
1354 -s "using extended master secret"
1355
1356run_test "Extended Master Secret: client enabled, server disabled" \
1357 "$P_SRV debug_level=3 extended_ms=0" \
1358 "$P_CLI debug_level=3 extended_ms=1" \
1359 0 \
1360 -c "client hello, adding extended_master_secret extension" \
1361 -s "found extended master secret extension" \
1362 -S "server hello, adding extended master secret extension" \
1363 -C "found extended_master_secret extension" \
1364 -C "using extended master secret" \
1365 -S "using extended master secret"
1366
1367run_test "Extended Master Secret: client disabled, server enabled" \
1368 "$P_SRV debug_level=3 extended_ms=1" \
1369 "$P_CLI debug_level=3 extended_ms=0" \
1370 0 \
1371 -C "client hello, adding extended_master_secret extension" \
1372 -S "found extended master secret extension" \
1373 -S "server hello, adding extended master secret extension" \
1374 -C "found extended_master_secret extension" \
1375 -C "using extended master secret" \
1376 -S "using extended master secret"
1377
Janos Follathe2681a42016-03-07 15:57:05 +00001378requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001379run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001380 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001381 "$P_CLI debug_level=3 force_version=ssl3" \
1382 0 \
1383 -C "client hello, adding extended_master_secret extension" \
1384 -S "found extended master secret extension" \
1385 -S "server hello, adding extended master secret extension" \
1386 -C "found extended_master_secret extension" \
1387 -C "using extended master secret" \
1388 -S "using extended master secret"
1389
Janos Follathe2681a42016-03-07 15:57:05 +00001390requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001391run_test "Extended Master Secret: client enabled, server SSLv3" \
1392 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001393 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001394 0 \
1395 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001396 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001397 -S "server hello, adding extended master secret extension" \
1398 -C "found extended_master_secret extension" \
1399 -C "using extended master secret" \
1400 -S "using extended master secret"
1401
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001402# Tests for FALLBACK_SCSV
1403
1404run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001405 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001406 "$P_CLI debug_level=3 force_version=tls1_1" \
1407 0 \
1408 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001409 -S "received FALLBACK_SCSV" \
1410 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001411 -C "is a fatal alert message (msg 86)"
1412
1413run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001414 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001415 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1416 0 \
1417 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001418 -S "received FALLBACK_SCSV" \
1419 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001420 -C "is a fatal alert message (msg 86)"
1421
1422run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001423 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001424 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001425 1 \
1426 -c "adding FALLBACK_SCSV" \
1427 -s "received FALLBACK_SCSV" \
1428 -s "inapropriate fallback" \
1429 -c "is a fatal alert message (msg 86)"
1430
1431run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001432 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001433 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001434 0 \
1435 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001436 -s "received FALLBACK_SCSV" \
1437 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001438 -C "is a fatal alert message (msg 86)"
1439
1440requires_openssl_with_fallback_scsv
1441run_test "Fallback SCSV: default, openssl server" \
1442 "$O_SRV" \
1443 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1444 0 \
1445 -C "adding FALLBACK_SCSV" \
1446 -C "is a fatal alert message (msg 86)"
1447
1448requires_openssl_with_fallback_scsv
1449run_test "Fallback SCSV: enabled, openssl server" \
1450 "$O_SRV" \
1451 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1452 1 \
1453 -c "adding FALLBACK_SCSV" \
1454 -c "is a fatal alert message (msg 86)"
1455
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001456requires_openssl_with_fallback_scsv
1457run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001458 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001459 "$O_CLI -tls1_1" \
1460 0 \
1461 -S "received FALLBACK_SCSV" \
1462 -S "inapropriate fallback"
1463
1464requires_openssl_with_fallback_scsv
1465run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001466 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001467 "$O_CLI -tls1_1 -fallback_scsv" \
1468 1 \
1469 -s "received FALLBACK_SCSV" \
1470 -s "inapropriate fallback"
1471
1472requires_openssl_with_fallback_scsv
1473run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001474 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001475 "$O_CLI -fallback_scsv" \
1476 0 \
1477 -s "received FALLBACK_SCSV" \
1478 -S "inapropriate fallback"
1479
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001480# Test sending and receiving empty application data records
1481
1482run_test "Encrypt then MAC: empty application data record" \
1483 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1484 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1485 0 \
1486 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1487 -s "dumping 'input payload after decrypt' (0 bytes)" \
1488 -c "0 bytes written in 1 fragments"
1489
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001490run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001491 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1492 "$P_CLI auth_mode=none etm=0 request_size=0" \
1493 0 \
1494 -s "dumping 'input payload after decrypt' (0 bytes)" \
1495 -c "0 bytes written in 1 fragments"
1496
1497run_test "Encrypt then MAC, DTLS: empty application data record" \
1498 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1499 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1500 0 \
1501 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1502 -s "dumping 'input payload after decrypt' (0 bytes)" \
1503 -c "0 bytes written in 1 fragments"
1504
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001505run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001506 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1507 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1508 0 \
1509 -s "dumping 'input payload after decrypt' (0 bytes)" \
1510 -c "0 bytes written in 1 fragments"
1511
Gilles Peskined50177f2017-05-16 17:53:03 +02001512## ClientHello generated with
1513## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1514## then manually twiddling the ciphersuite list.
1515## The ClientHello content is spelled out below as a hex string as
1516## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1517## The expected response is an inappropriate_fallback alert.
1518requires_openssl_with_fallback_scsv
1519run_test "Fallback SCSV: beginning of list" \
1520 "$P_SRV debug_level=2" \
1521 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1522 0 \
1523 -s "received FALLBACK_SCSV" \
1524 -s "inapropriate fallback"
1525
1526requires_openssl_with_fallback_scsv
1527run_test "Fallback SCSV: end of list" \
1528 "$P_SRV debug_level=2" \
1529 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1530 0 \
1531 -s "received FALLBACK_SCSV" \
1532 -s "inapropriate fallback"
1533
1534## Here the expected response is a valid ServerHello prefix, up to the random.
1535requires_openssl_with_fallback_scsv
1536run_test "Fallback SCSV: not in list" \
1537 "$P_SRV debug_level=2" \
1538 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1539 0 \
1540 -S "received FALLBACK_SCSV" \
1541 -S "inapropriate fallback"
1542
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001543# Tests for CBC 1/n-1 record splitting
1544
1545run_test "CBC Record splitting: TLS 1.2, no splitting" \
1546 "$P_SRV" \
1547 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1548 request_size=123 force_version=tls1_2" \
1549 0 \
1550 -s "Read from client: 123 bytes read" \
1551 -S "Read from client: 1 bytes read" \
1552 -S "122 bytes read"
1553
1554run_test "CBC Record splitting: TLS 1.1, no splitting" \
1555 "$P_SRV" \
1556 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1557 request_size=123 force_version=tls1_1" \
1558 0 \
1559 -s "Read from client: 123 bytes read" \
1560 -S "Read from client: 1 bytes read" \
1561 -S "122 bytes read"
1562
1563run_test "CBC Record splitting: TLS 1.0, splitting" \
1564 "$P_SRV" \
1565 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1566 request_size=123 force_version=tls1" \
1567 0 \
1568 -S "Read from client: 123 bytes read" \
1569 -s "Read from client: 1 bytes read" \
1570 -s "122 bytes read"
1571
Janos Follathe2681a42016-03-07 15:57:05 +00001572requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001573run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001574 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001575 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1576 request_size=123 force_version=ssl3" \
1577 0 \
1578 -S "Read from client: 123 bytes read" \
1579 -s "Read from client: 1 bytes read" \
1580 -s "122 bytes read"
1581
1582run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001583 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001584 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1585 request_size=123 force_version=tls1" \
1586 0 \
1587 -s "Read from client: 123 bytes read" \
1588 -S "Read from client: 1 bytes read" \
1589 -S "122 bytes read"
1590
1591run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1592 "$P_SRV" \
1593 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1594 request_size=123 force_version=tls1 recsplit=0" \
1595 0 \
1596 -s "Read from client: 123 bytes read" \
1597 -S "Read from client: 1 bytes read" \
1598 -S "122 bytes read"
1599
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001600run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1601 "$P_SRV nbio=2" \
1602 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1603 request_size=123 force_version=tls1" \
1604 0 \
1605 -S "Read from client: 123 bytes read" \
1606 -s "Read from client: 1 bytes read" \
1607 -s "122 bytes read"
1608
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001609# Tests for Session Tickets
1610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001611run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001612 "$P_SRV debug_level=3 tickets=1" \
1613 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001614 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001615 -c "client hello, adding session ticket extension" \
1616 -s "found session ticket extension" \
1617 -s "server hello, adding session ticket extension" \
1618 -c "found session_ticket extension" \
1619 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001620 -S "session successfully restored from cache" \
1621 -s "session successfully restored from ticket" \
1622 -s "a session has been resumed" \
1623 -c "a session has been resumed"
1624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001625run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001626 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1627 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001628 0 \
1629 -c "client hello, adding session ticket extension" \
1630 -s "found session ticket extension" \
1631 -s "server hello, adding session ticket extension" \
1632 -c "found session_ticket extension" \
1633 -c "parse new session ticket" \
1634 -S "session successfully restored from cache" \
1635 -s "session successfully restored from ticket" \
1636 -s "a session has been resumed" \
1637 -c "a session has been resumed"
1638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001639run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001640 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1641 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001642 0 \
1643 -c "client hello, adding session ticket extension" \
1644 -s "found session ticket extension" \
1645 -s "server hello, adding session ticket extension" \
1646 -c "found session_ticket extension" \
1647 -c "parse new session ticket" \
1648 -S "session successfully restored from cache" \
1649 -S "session successfully restored from ticket" \
1650 -S "a session has been resumed" \
1651 -C "a session has been resumed"
1652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001653run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001654 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001655 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001656 0 \
1657 -c "client hello, adding session ticket extension" \
1658 -c "found session_ticket extension" \
1659 -c "parse new session ticket" \
1660 -c "a session has been resumed"
1661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001662run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001663 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001664 "( $O_CLI -sess_out $SESSION; \
1665 $O_CLI -sess_in $SESSION; \
1666 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001667 0 \
1668 -s "found session ticket extension" \
1669 -s "server hello, adding session ticket extension" \
1670 -S "session successfully restored from cache" \
1671 -s "session successfully restored from ticket" \
1672 -s "a session has been resumed"
1673
Hanno Becker1d739932018-08-21 13:55:22 +01001674# Tests for Session Tickets with DTLS
1675
1676run_test "Session resume using tickets, DTLS: basic" \
1677 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001678 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001679 0 \
1680 -c "client hello, adding session ticket extension" \
1681 -s "found session ticket extension" \
1682 -s "server hello, adding session ticket extension" \
1683 -c "found session_ticket extension" \
1684 -c "parse new session ticket" \
1685 -S "session successfully restored from cache" \
1686 -s "session successfully restored from ticket" \
1687 -s "a session has been resumed" \
1688 -c "a session has been resumed"
1689
1690run_test "Session resume using tickets, DTLS: cache disabled" \
1691 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001692 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001693 0 \
1694 -c "client hello, adding session ticket extension" \
1695 -s "found session ticket extension" \
1696 -s "server hello, adding session ticket extension" \
1697 -c "found session_ticket extension" \
1698 -c "parse new session ticket" \
1699 -S "session successfully restored from cache" \
1700 -s "session successfully restored from ticket" \
1701 -s "a session has been resumed" \
1702 -c "a session has been resumed"
1703
1704run_test "Session resume using tickets, DTLS: timeout" \
1705 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001706 "$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 +01001707 0 \
1708 -c "client hello, adding session ticket extension" \
1709 -s "found session ticket extension" \
1710 -s "server hello, adding session ticket extension" \
1711 -c "found session_ticket extension" \
1712 -c "parse new session ticket" \
1713 -S "session successfully restored from cache" \
1714 -S "session successfully restored from ticket" \
1715 -S "a session has been resumed" \
1716 -C "a session has been resumed"
1717
1718run_test "Session resume using tickets, DTLS: openssl server" \
1719 "$O_SRV -dtls1" \
1720 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1721 0 \
1722 -c "client hello, adding session ticket extension" \
1723 -c "found session_ticket extension" \
1724 -c "parse new session ticket" \
1725 -c "a session has been resumed"
1726
1727run_test "Session resume using tickets, DTLS: openssl client" \
1728 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1729 "( $O_CLI -dtls1 -sess_out $SESSION; \
1730 $O_CLI -dtls1 -sess_in $SESSION; \
1731 rm -f $SESSION )" \
1732 0 \
1733 -s "found session ticket extension" \
1734 -s "server hello, adding session ticket extension" \
1735 -S "session successfully restored from cache" \
1736 -s "session successfully restored from ticket" \
1737 -s "a session has been resumed"
1738
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001739# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001741run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001742 "$P_SRV debug_level=3 tickets=0" \
1743 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001744 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001745 -c "client hello, adding session ticket extension" \
1746 -s "found session ticket extension" \
1747 -S "server hello, adding session ticket extension" \
1748 -C "found session_ticket extension" \
1749 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001750 -s "session successfully restored from cache" \
1751 -S "session successfully restored from ticket" \
1752 -s "a session has been resumed" \
1753 -c "a session has been resumed"
1754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001755run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001756 "$P_SRV debug_level=3 tickets=1" \
1757 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001758 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001759 -C "client hello, adding session ticket extension" \
1760 -S "found session ticket extension" \
1761 -S "server hello, adding session ticket extension" \
1762 -C "found session_ticket extension" \
1763 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001764 -s "session successfully restored from cache" \
1765 -S "session successfully restored from ticket" \
1766 -s "a session has been resumed" \
1767 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001769run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001770 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1771 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001772 0 \
1773 -S "session successfully restored from cache" \
1774 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001775 -S "a session has been resumed" \
1776 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001778run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001779 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1780 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001781 0 \
1782 -s "session successfully restored from cache" \
1783 -S "session successfully restored from ticket" \
1784 -s "a session has been resumed" \
1785 -c "a session has been resumed"
1786
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001787run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001788 "$P_SRV debug_level=3 tickets=0" \
1789 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001790 0 \
1791 -s "session successfully restored from cache" \
1792 -S "session successfully restored from ticket" \
1793 -s "a session has been resumed" \
1794 -c "a session has been resumed"
1795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001796run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001797 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1798 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001799 0 \
1800 -S "session successfully restored from cache" \
1801 -S "session successfully restored from ticket" \
1802 -S "a session has been resumed" \
1803 -C "a session has been resumed"
1804
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001805run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001806 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1807 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001808 0 \
1809 -s "session successfully restored from cache" \
1810 -S "session successfully restored from ticket" \
1811 -s "a session has been resumed" \
1812 -c "a session has been resumed"
1813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001814run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001815 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001816 "( $O_CLI -sess_out $SESSION; \
1817 $O_CLI -sess_in $SESSION; \
1818 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001819 0 \
1820 -s "found session ticket extension" \
1821 -S "server hello, adding session ticket extension" \
1822 -s "session successfully restored from cache" \
1823 -S "session successfully restored from ticket" \
1824 -s "a session has been resumed"
1825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001826run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001827 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001828 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001829 0 \
1830 -C "found session_ticket extension" \
1831 -C "parse new session ticket" \
1832 -c "a session has been resumed"
1833
Hanno Becker1d739932018-08-21 13:55:22 +01001834# Tests for Session Resume based on session-ID and cache, DTLS
1835
1836run_test "Session resume using cache, DTLS: tickets enabled on client" \
1837 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001838 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001839 0 \
1840 -c "client hello, adding session ticket extension" \
1841 -s "found session ticket extension" \
1842 -S "server hello, adding session ticket extension" \
1843 -C "found session_ticket extension" \
1844 -C "parse new session ticket" \
1845 -s "session successfully restored from cache" \
1846 -S "session successfully restored from ticket" \
1847 -s "a session has been resumed" \
1848 -c "a session has been resumed"
1849
1850run_test "Session resume using cache, DTLS: tickets enabled on server" \
1851 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001852 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001853 0 \
1854 -C "client hello, adding session ticket extension" \
1855 -S "found session ticket extension" \
1856 -S "server hello, adding session ticket extension" \
1857 -C "found session_ticket extension" \
1858 -C "parse new session ticket" \
1859 -s "session successfully restored from cache" \
1860 -S "session successfully restored from ticket" \
1861 -s "a session has been resumed" \
1862 -c "a session has been resumed"
1863
1864run_test "Session resume using cache, DTLS: cache_max=0" \
1865 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001866 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001867 0 \
1868 -S "session successfully restored from cache" \
1869 -S "session successfully restored from ticket" \
1870 -S "a session has been resumed" \
1871 -C "a session has been resumed"
1872
1873run_test "Session resume using cache, DTLS: cache_max=1" \
1874 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001875 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001876 0 \
1877 -s "session successfully restored from cache" \
1878 -S "session successfully restored from ticket" \
1879 -s "a session has been resumed" \
1880 -c "a session has been resumed"
1881
1882run_test "Session resume using cache, DTLS: timeout > delay" \
1883 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001884 "$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 +01001885 0 \
1886 -s "session successfully restored from cache" \
1887 -S "session successfully restored from ticket" \
1888 -s "a session has been resumed" \
1889 -c "a session has been resumed"
1890
1891run_test "Session resume using cache, DTLS: timeout < delay" \
1892 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001893 "$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 +01001894 0 \
1895 -S "session successfully restored from cache" \
1896 -S "session successfully restored from ticket" \
1897 -S "a session has been resumed" \
1898 -C "a session has been resumed"
1899
1900run_test "Session resume using cache, DTLS: no timeout" \
1901 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001902 "$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 +01001903 0 \
1904 -s "session successfully restored from cache" \
1905 -S "session successfully restored from ticket" \
1906 -s "a session has been resumed" \
1907 -c "a session has been resumed"
1908
1909run_test "Session resume using cache, DTLS: openssl client" \
1910 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1911 "( $O_CLI -dtls1 -sess_out $SESSION; \
1912 $O_CLI -dtls1 -sess_in $SESSION; \
1913 rm -f $SESSION )" \
1914 0 \
1915 -s "found session ticket extension" \
1916 -S "server hello, adding session ticket extension" \
1917 -s "session successfully restored from cache" \
1918 -S "session successfully restored from ticket" \
1919 -s "a session has been resumed"
1920
1921run_test "Session resume using cache, DTLS: openssl server" \
1922 "$O_SRV -dtls1" \
1923 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1924 0 \
1925 -C "found session_ticket extension" \
1926 -C "parse new session ticket" \
1927 -c "a session has been resumed"
1928
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001929# Tests for Max Fragment Length extension
1930
Angus Grattonc4dd0732018-04-11 16:28:39 +10001931if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02001932 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 +01001933 exit 1
1934fi
1935
Angus Grattonc4dd0732018-04-11 16:28:39 +10001936if [ $MAX_CONTENT_LEN -ne 16384 ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02001937 echo "Using non-default maximum content length $MAX_CONTENT_LEN"
Angus Grattonc4dd0732018-04-11 16:28:39 +10001938fi
1939
Hanno Becker4aed27e2017-09-18 15:00:34 +01001940requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001941run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001942 "$P_SRV debug_level=3" \
1943 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001944 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001945 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1946 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001947 -C "client hello, adding max_fragment_length extension" \
1948 -S "found max fragment length extension" \
1949 -S "server hello, max_fragment_length extension" \
1950 -C "found max_fragment_length extension"
1951
Hanno Becker4aed27e2017-09-18 15:00:34 +01001952requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001953run_test "Max fragment length: enabled, default, larger message" \
1954 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001955 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001956 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001957 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1958 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001959 -C "client hello, adding max_fragment_length extension" \
1960 -S "found max fragment length extension" \
1961 -S "server hello, max_fragment_length extension" \
1962 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001963 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1964 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001965 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001966
1967requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1968run_test "Max fragment length, DTLS: enabled, default, larger message" \
1969 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001970 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001971 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001972 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1973 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001974 -C "client hello, adding max_fragment_length extension" \
1975 -S "found max fragment length extension" \
1976 -S "server hello, max_fragment_length extension" \
1977 -C "found max_fragment_length extension" \
1978 -c "fragment larger than.*maximum "
1979
Angus Grattonc4dd0732018-04-11 16:28:39 +10001980# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1981# (session fragment length will be 16384 regardless of mbedtls
1982# content length configuration.)
1983
Hanno Beckerc5266962017-09-18 15:01:50 +01001984requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1985run_test "Max fragment length: disabled, larger message" \
1986 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001987 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001988 0 \
1989 -C "Maximum fragment length is 16384" \
1990 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001991 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1992 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001993 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001994
1995requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1996run_test "Max fragment length DTLS: disabled, larger message" \
1997 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001998 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001999 1 \
2000 -C "Maximum fragment length is 16384" \
2001 -S "Maximum fragment length is 16384" \
2002 -c "fragment larger than.*maximum "
2003
2004requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002005run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002006 "$P_SRV debug_level=3" \
2007 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002008 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002009 -c "Maximum fragment length is 4096" \
2010 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002011 -c "client hello, adding max_fragment_length extension" \
2012 -s "found max fragment length extension" \
2013 -s "server hello, max_fragment_length extension" \
2014 -c "found max_fragment_length extension"
2015
Hanno Becker4aed27e2017-09-18 15:00:34 +01002016requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002017run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002018 "$P_SRV debug_level=3 max_frag_len=4096" \
2019 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002020 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002021 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002022 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002023 -C "client hello, adding max_fragment_length extension" \
2024 -S "found max fragment length extension" \
2025 -S "server hello, max_fragment_length extension" \
2026 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002027
Hanno Becker4aed27e2017-09-18 15:00:34 +01002028requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002029requires_gnutls
2030run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002031 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002032 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002033 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002034 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002035 -c "client hello, adding max_fragment_length extension" \
2036 -c "found max_fragment_length extension"
2037
Hanno Becker4aed27e2017-09-18 15:00:34 +01002038requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002039run_test "Max fragment length: client, message just fits" \
2040 "$P_SRV debug_level=3" \
2041 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
2042 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002043 -c "Maximum fragment length is 2048" \
2044 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002045 -c "client hello, adding max_fragment_length extension" \
2046 -s "found max fragment length extension" \
2047 -s "server hello, max_fragment_length extension" \
2048 -c "found max_fragment_length extension" \
2049 -c "2048 bytes written in 1 fragments" \
2050 -s "2048 bytes read"
2051
Hanno Becker4aed27e2017-09-18 15:00:34 +01002052requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002053run_test "Max fragment length: client, larger message" \
2054 "$P_SRV debug_level=3" \
2055 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2056 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002057 -c "Maximum fragment length is 2048" \
2058 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002059 -c "client hello, adding max_fragment_length extension" \
2060 -s "found max fragment length extension" \
2061 -s "server hello, max_fragment_length extension" \
2062 -c "found max_fragment_length extension" \
2063 -c "2345 bytes written in 2 fragments" \
2064 -s "2048 bytes read" \
2065 -s "297 bytes read"
2066
Hanno Becker4aed27e2017-09-18 15:00:34 +01002067requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002068run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002069 "$P_SRV debug_level=3 dtls=1" \
2070 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2071 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002072 -c "Maximum fragment length is 2048" \
2073 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002074 -c "client hello, adding max_fragment_length extension" \
2075 -s "found max fragment length extension" \
2076 -s "server hello, max_fragment_length extension" \
2077 -c "found max_fragment_length extension" \
2078 -c "fragment larger than.*maximum"
2079
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002080# Tests for renegotiation
2081
Hanno Becker6a243642017-10-12 15:18:45 +01002082# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002083run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002084 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002085 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002086 0 \
2087 -C "client hello, adding renegotiation extension" \
2088 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2089 -S "found renegotiation extension" \
2090 -s "server hello, secure renegotiation extension" \
2091 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002092 -C "=> renegotiate" \
2093 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002094 -S "write hello request"
2095
Hanno Becker6a243642017-10-12 15:18:45 +01002096requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002097run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002098 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002099 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002100 0 \
2101 -c "client hello, adding renegotiation extension" \
2102 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2103 -s "found renegotiation extension" \
2104 -s "server hello, secure renegotiation extension" \
2105 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002106 -c "=> renegotiate" \
2107 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002108 -S "write hello request"
2109
Hanno Becker6a243642017-10-12 15:18:45 +01002110requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002111run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002112 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002113 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002114 0 \
2115 -c "client hello, adding renegotiation extension" \
2116 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2117 -s "found renegotiation extension" \
2118 -s "server hello, secure renegotiation extension" \
2119 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002120 -c "=> renegotiate" \
2121 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002122 -s "write hello request"
2123
Janos Follathb0f148c2017-10-05 12:29:42 +01002124# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2125# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2126# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002127requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002128run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2129 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2130 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2131 0 \
2132 -c "client hello, adding renegotiation extension" \
2133 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2134 -s "found renegotiation extension" \
2135 -s "server hello, secure renegotiation extension" \
2136 -c "found renegotiation extension" \
2137 -c "=> renegotiate" \
2138 -s "=> renegotiate" \
2139 -S "write hello request" \
2140 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2141
2142# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2143# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2144# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002145requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002146run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2147 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2148 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2149 0 \
2150 -c "client hello, adding renegotiation extension" \
2151 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2152 -s "found renegotiation extension" \
2153 -s "server hello, secure renegotiation extension" \
2154 -c "found renegotiation extension" \
2155 -c "=> renegotiate" \
2156 -s "=> renegotiate" \
2157 -s "write hello request" \
2158 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2159
Hanno Becker6a243642017-10-12 15:18:45 +01002160requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002161run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002162 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002163 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002164 0 \
2165 -c "client hello, adding renegotiation extension" \
2166 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2167 -s "found renegotiation extension" \
2168 -s "server hello, secure renegotiation extension" \
2169 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002170 -c "=> renegotiate" \
2171 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002172 -s "write hello request"
2173
Hanno Becker6a243642017-10-12 15:18:45 +01002174requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002175run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002176 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002177 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002178 1 \
2179 -c "client hello, adding renegotiation extension" \
2180 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2181 -S "found renegotiation extension" \
2182 -s "server hello, secure renegotiation extension" \
2183 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002184 -c "=> renegotiate" \
2185 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002186 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002187 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002188 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002189
Hanno Becker6a243642017-10-12 15:18:45 +01002190requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002191run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002192 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002193 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002194 0 \
2195 -C "client hello, adding renegotiation extension" \
2196 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2197 -S "found renegotiation extension" \
2198 -s "server hello, secure renegotiation extension" \
2199 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002200 -C "=> renegotiate" \
2201 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002202 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002203 -S "SSL - An unexpected message was received from our peer" \
2204 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002205
Hanno Becker6a243642017-10-12 15:18:45 +01002206requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002208 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002209 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002210 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002211 0 \
2212 -C "client hello, adding renegotiation extension" \
2213 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2214 -S "found renegotiation extension" \
2215 -s "server hello, secure renegotiation extension" \
2216 -c "found renegotiation extension" \
2217 -C "=> renegotiate" \
2218 -S "=> renegotiate" \
2219 -s "write hello request" \
2220 -S "SSL - An unexpected message was received from our peer" \
2221 -S "failed"
2222
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002223# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002224requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002225run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002226 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002227 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002228 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002229 0 \
2230 -C "client hello, adding renegotiation extension" \
2231 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2232 -S "found renegotiation extension" \
2233 -s "server hello, secure renegotiation extension" \
2234 -c "found renegotiation extension" \
2235 -C "=> renegotiate" \
2236 -S "=> renegotiate" \
2237 -s "write hello request" \
2238 -S "SSL - An unexpected message was received from our peer" \
2239 -S "failed"
2240
Hanno Becker6a243642017-10-12 15:18:45 +01002241requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002242run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002243 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002244 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002245 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002246 0 \
2247 -C "client hello, adding renegotiation extension" \
2248 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2249 -S "found renegotiation extension" \
2250 -s "server hello, secure renegotiation extension" \
2251 -c "found renegotiation extension" \
2252 -C "=> renegotiate" \
2253 -S "=> renegotiate" \
2254 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002255 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002256
Hanno Becker6a243642017-10-12 15:18:45 +01002257requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002258run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002259 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002260 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002261 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002262 0 \
2263 -c "client hello, adding renegotiation extension" \
2264 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2265 -s "found renegotiation extension" \
2266 -s "server hello, secure renegotiation extension" \
2267 -c "found renegotiation extension" \
2268 -c "=> renegotiate" \
2269 -s "=> renegotiate" \
2270 -s "write hello request" \
2271 -S "SSL - An unexpected message was received from our peer" \
2272 -S "failed"
2273
Hanno Becker6a243642017-10-12 15:18:45 +01002274requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002275run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002276 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002277 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2278 0 \
2279 -C "client hello, adding renegotiation extension" \
2280 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2281 -S "found renegotiation extension" \
2282 -s "server hello, secure renegotiation extension" \
2283 -c "found renegotiation extension" \
2284 -S "record counter limit reached: renegotiate" \
2285 -C "=> renegotiate" \
2286 -S "=> renegotiate" \
2287 -S "write hello request" \
2288 -S "SSL - An unexpected message was received from our peer" \
2289 -S "failed"
2290
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002291# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002292requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002293run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002294 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002295 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002296 0 \
2297 -c "client hello, adding renegotiation extension" \
2298 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2299 -s "found renegotiation extension" \
2300 -s "server hello, secure renegotiation extension" \
2301 -c "found renegotiation extension" \
2302 -s "record counter limit reached: renegotiate" \
2303 -c "=> renegotiate" \
2304 -s "=> renegotiate" \
2305 -s "write hello request" \
2306 -S "SSL - An unexpected message was received from our peer" \
2307 -S "failed"
2308
Hanno Becker6a243642017-10-12 15:18:45 +01002309requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002310run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002311 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002312 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002313 0 \
2314 -c "client hello, adding renegotiation extension" \
2315 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2316 -s "found renegotiation extension" \
2317 -s "server hello, secure renegotiation extension" \
2318 -c "found renegotiation extension" \
2319 -s "record counter limit reached: renegotiate" \
2320 -c "=> renegotiate" \
2321 -s "=> renegotiate" \
2322 -s "write hello request" \
2323 -S "SSL - An unexpected message was received from our peer" \
2324 -S "failed"
2325
Hanno Becker6a243642017-10-12 15:18:45 +01002326requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002327run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002328 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002329 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2330 0 \
2331 -C "client hello, adding renegotiation extension" \
2332 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2333 -S "found renegotiation extension" \
2334 -s "server hello, secure renegotiation extension" \
2335 -c "found renegotiation extension" \
2336 -S "record counter limit reached: renegotiate" \
2337 -C "=> renegotiate" \
2338 -S "=> renegotiate" \
2339 -S "write hello request" \
2340 -S "SSL - An unexpected message was received from our peer" \
2341 -S "failed"
2342
Hanno Becker6a243642017-10-12 15:18:45 +01002343requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002344run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002345 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002346 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002347 0 \
2348 -c "client hello, adding renegotiation extension" \
2349 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2350 -s "found renegotiation extension" \
2351 -s "server hello, secure renegotiation extension" \
2352 -c "found renegotiation extension" \
2353 -c "=> renegotiate" \
2354 -s "=> renegotiate" \
2355 -S "write hello request"
2356
Hanno Becker6a243642017-10-12 15:18:45 +01002357requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002358run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002359 "$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 +02002360 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002361 0 \
2362 -c "client hello, adding renegotiation extension" \
2363 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2364 -s "found renegotiation extension" \
2365 -s "server hello, secure renegotiation extension" \
2366 -c "found renegotiation extension" \
2367 -c "=> renegotiate" \
2368 -s "=> renegotiate" \
2369 -s "write hello request"
2370
Hanno Becker6a243642017-10-12 15:18:45 +01002371requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002372run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002373 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002374 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002375 0 \
2376 -c "client hello, adding renegotiation extension" \
2377 -c "found renegotiation extension" \
2378 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002379 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002380 -C "error" \
2381 -c "HTTP/1.0 200 [Oo][Kk]"
2382
Paul Bakker539d9722015-02-08 16:18:35 +01002383requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002384requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002385run_test "Renegotiation: gnutls server strict, client-initiated" \
2386 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002387 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002388 0 \
2389 -c "client hello, adding renegotiation extension" \
2390 -c "found renegotiation extension" \
2391 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002392 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002393 -C "error" \
2394 -c "HTTP/1.0 200 [Oo][Kk]"
2395
Paul Bakker539d9722015-02-08 16:18:35 +01002396requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002397requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002398run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2399 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2400 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2401 1 \
2402 -c "client hello, adding renegotiation extension" \
2403 -C "found renegotiation extension" \
2404 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002405 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002406 -c "error" \
2407 -C "HTTP/1.0 200 [Oo][Kk]"
2408
Paul Bakker539d9722015-02-08 16:18:35 +01002409requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002410requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002411run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2412 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2413 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2414 allow_legacy=0" \
2415 1 \
2416 -c "client hello, adding renegotiation extension" \
2417 -C "found renegotiation extension" \
2418 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002419 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002420 -c "error" \
2421 -C "HTTP/1.0 200 [Oo][Kk]"
2422
Paul Bakker539d9722015-02-08 16:18:35 +01002423requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002424requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002425run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2426 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2427 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2428 allow_legacy=1" \
2429 0 \
2430 -c "client hello, adding renegotiation extension" \
2431 -C "found renegotiation extension" \
2432 -c "=> renegotiate" \
2433 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002434 -C "error" \
2435 -c "HTTP/1.0 200 [Oo][Kk]"
2436
Hanno Becker6a243642017-10-12 15:18:45 +01002437requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002438run_test "Renegotiation: DTLS, client-initiated" \
2439 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2440 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2441 0 \
2442 -c "client hello, adding renegotiation extension" \
2443 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2444 -s "found renegotiation extension" \
2445 -s "server hello, secure renegotiation extension" \
2446 -c "found renegotiation extension" \
2447 -c "=> renegotiate" \
2448 -s "=> renegotiate" \
2449 -S "write hello request"
2450
Hanno Becker6a243642017-10-12 15:18:45 +01002451requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002452run_test "Renegotiation: DTLS, server-initiated" \
2453 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002454 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2455 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002456 0 \
2457 -c "client hello, adding renegotiation extension" \
2458 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2459 -s "found renegotiation extension" \
2460 -s "server hello, secure renegotiation extension" \
2461 -c "found renegotiation extension" \
2462 -c "=> renegotiate" \
2463 -s "=> renegotiate" \
2464 -s "write hello request"
2465
Hanno Becker6a243642017-10-12 15:18:45 +01002466requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002467run_test "Renegotiation: DTLS, renego_period overflow" \
2468 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2469 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2470 0 \
2471 -c "client hello, adding renegotiation extension" \
2472 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2473 -s "found renegotiation extension" \
2474 -s "server hello, secure renegotiation extension" \
2475 -s "record counter limit reached: renegotiate" \
2476 -c "=> renegotiate" \
2477 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002478 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002479
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002480requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002481requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002482run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2483 "$G_SRV -u --mtu 4096" \
2484 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2485 0 \
2486 -c "client hello, adding renegotiation extension" \
2487 -c "found renegotiation extension" \
2488 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002489 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002490 -C "error" \
2491 -s "Extra-header:"
2492
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002493# Test for the "secure renegotation" extension only (no actual renegotiation)
2494
Paul Bakker539d9722015-02-08 16:18:35 +01002495requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002496run_test "Renego ext: gnutls server strict, client default" \
2497 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2498 "$P_CLI debug_level=3" \
2499 0 \
2500 -c "found renegotiation extension" \
2501 -C "error" \
2502 -c "HTTP/1.0 200 [Oo][Kk]"
2503
Paul Bakker539d9722015-02-08 16:18:35 +01002504requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002505run_test "Renego ext: gnutls server unsafe, client default" \
2506 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2507 "$P_CLI debug_level=3" \
2508 0 \
2509 -C "found renegotiation extension" \
2510 -C "error" \
2511 -c "HTTP/1.0 200 [Oo][Kk]"
2512
Paul Bakker539d9722015-02-08 16:18:35 +01002513requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002514run_test "Renego ext: gnutls server unsafe, client break legacy" \
2515 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2516 "$P_CLI debug_level=3 allow_legacy=-1" \
2517 1 \
2518 -C "found renegotiation extension" \
2519 -c "error" \
2520 -C "HTTP/1.0 200 [Oo][Kk]"
2521
Paul Bakker539d9722015-02-08 16:18:35 +01002522requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002523run_test "Renego ext: gnutls client strict, server default" \
2524 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002525 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002526 0 \
2527 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2528 -s "server hello, secure renegotiation extension"
2529
Paul Bakker539d9722015-02-08 16:18:35 +01002530requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002531run_test "Renego ext: gnutls client unsafe, server default" \
2532 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002533 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002534 0 \
2535 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2536 -S "server hello, secure renegotiation extension"
2537
Paul Bakker539d9722015-02-08 16:18:35 +01002538requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002539run_test "Renego ext: gnutls client unsafe, server break legacy" \
2540 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002541 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002542 1 \
2543 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2544 -S "server hello, secure renegotiation extension"
2545
Janos Follath0b242342016-02-17 10:11:21 +00002546# Tests for silently dropping trailing extra bytes in .der certificates
2547
2548requires_gnutls
2549run_test "DER format: no trailing bytes" \
2550 "$P_SRV crt_file=data_files/server5-der0.crt \
2551 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002552 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002553 0 \
2554 -c "Handshake was completed" \
2555
2556requires_gnutls
2557run_test "DER format: with a trailing zero byte" \
2558 "$P_SRV crt_file=data_files/server5-der1a.crt \
2559 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002560 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002561 0 \
2562 -c "Handshake was completed" \
2563
2564requires_gnutls
2565run_test "DER format: with a trailing random byte" \
2566 "$P_SRV crt_file=data_files/server5-der1b.crt \
2567 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002568 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002569 0 \
2570 -c "Handshake was completed" \
2571
2572requires_gnutls
2573run_test "DER format: with 2 trailing random bytes" \
2574 "$P_SRV crt_file=data_files/server5-der2.crt \
2575 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002576 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002577 0 \
2578 -c "Handshake was completed" \
2579
2580requires_gnutls
2581run_test "DER format: with 4 trailing random bytes" \
2582 "$P_SRV crt_file=data_files/server5-der4.crt \
2583 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002584 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002585 0 \
2586 -c "Handshake was completed" \
2587
2588requires_gnutls
2589run_test "DER format: with 8 trailing random bytes" \
2590 "$P_SRV crt_file=data_files/server5-der8.crt \
2591 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002592 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002593 0 \
2594 -c "Handshake was completed" \
2595
2596requires_gnutls
2597run_test "DER format: with 9 trailing random bytes" \
2598 "$P_SRV crt_file=data_files/server5-der9.crt \
2599 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002600 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002601 0 \
2602 -c "Handshake was completed" \
2603
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002604# Tests for auth_mode
2605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002606run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002607 "$P_SRV crt_file=data_files/server5-badsign.crt \
2608 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002609 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002610 1 \
2611 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002612 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002613 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002614 -c "X509 - Certificate verification failed"
2615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002616run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002617 "$P_SRV crt_file=data_files/server5-badsign.crt \
2618 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002619 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002620 0 \
2621 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002622 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002623 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002624 -C "X509 - Certificate verification failed"
2625
Hanno Beckere6706e62017-05-15 16:05:15 +01002626run_test "Authentication: server goodcert, client optional, no trusted CA" \
2627 "$P_SRV" \
2628 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2629 0 \
2630 -c "x509_verify_cert() returned" \
2631 -c "! The certificate is not correctly signed by the trusted CA" \
2632 -c "! Certificate verification flags"\
2633 -C "! mbedtls_ssl_handshake returned" \
2634 -C "X509 - Certificate verification failed" \
2635 -C "SSL - No CA Chain is set, but required to operate"
2636
2637run_test "Authentication: server goodcert, client required, no trusted CA" \
2638 "$P_SRV" \
2639 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2640 1 \
2641 -c "x509_verify_cert() returned" \
2642 -c "! The certificate is not correctly signed by the trusted CA" \
2643 -c "! Certificate verification flags"\
2644 -c "! mbedtls_ssl_handshake returned" \
2645 -c "SSL - No CA Chain is set, but required to operate"
2646
2647# The purpose of the next two tests is to test the client's behaviour when receiving a server
2648# certificate with an unsupported elliptic curve. This should usually not happen because
2649# the client informs the server about the supported curves - it does, though, in the
2650# corner case of a static ECDH suite, because the server doesn't check the curve on that
2651# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2652# different means to have the server ignoring the client's supported curve list.
2653
2654requires_config_enabled MBEDTLS_ECP_C
2655run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2656 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2657 crt_file=data_files/server5.ku-ka.crt" \
2658 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2659 1 \
2660 -c "bad certificate (EC key curve)"\
2661 -c "! Certificate verification flags"\
2662 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2663
2664requires_config_enabled MBEDTLS_ECP_C
2665run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2666 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2667 crt_file=data_files/server5.ku-ka.crt" \
2668 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2669 1 \
2670 -c "bad certificate (EC key curve)"\
2671 -c "! Certificate verification flags"\
2672 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002674run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002675 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002676 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002677 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002678 0 \
2679 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002680 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002681 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002682 -C "X509 - Certificate verification failed"
2683
Simon Butcher99000142016-10-13 17:21:01 +01002684run_test "Authentication: client SHA256, server required" \
2685 "$P_SRV auth_mode=required" \
2686 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2687 key_file=data_files/server6.key \
2688 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2689 0 \
2690 -c "Supported Signature Algorithm found: 4," \
2691 -c "Supported Signature Algorithm found: 5,"
2692
2693run_test "Authentication: client SHA384, server required" \
2694 "$P_SRV auth_mode=required" \
2695 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2696 key_file=data_files/server6.key \
2697 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2698 0 \
2699 -c "Supported Signature Algorithm found: 4," \
2700 -c "Supported Signature Algorithm found: 5,"
2701
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002702requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2703run_test "Authentication: client has no cert, server required (SSLv3)" \
2704 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2705 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2706 key_file=data_files/server5.key" \
2707 1 \
2708 -S "skip write certificate request" \
2709 -C "skip parse certificate request" \
2710 -c "got a certificate request" \
2711 -c "got no certificate to send" \
2712 -S "x509_verify_cert() returned" \
2713 -s "client has no certificate" \
2714 -s "! mbedtls_ssl_handshake returned" \
2715 -c "! mbedtls_ssl_handshake returned" \
2716 -s "No client certification received from the client, but required by the authentication mode"
2717
2718run_test "Authentication: client has no cert, server required (TLS)" \
2719 "$P_SRV debug_level=3 auth_mode=required" \
2720 "$P_CLI debug_level=3 crt_file=none \
2721 key_file=data_files/server5.key" \
2722 1 \
2723 -S "skip write certificate request" \
2724 -C "skip parse certificate request" \
2725 -c "got a certificate request" \
2726 -c "= write certificate$" \
2727 -C "skip write certificate$" \
2728 -S "x509_verify_cert() returned" \
2729 -s "client has no certificate" \
2730 -s "! mbedtls_ssl_handshake returned" \
2731 -c "! mbedtls_ssl_handshake returned" \
2732 -s "No client certification received from the client, but required by the authentication mode"
2733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002734run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002735 "$P_SRV debug_level=3 auth_mode=required" \
2736 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002737 key_file=data_files/server5.key" \
2738 1 \
2739 -S "skip write certificate request" \
2740 -C "skip parse certificate request" \
2741 -c "got a certificate request" \
2742 -C "skip write certificate" \
2743 -C "skip write certificate verify" \
2744 -S "skip parse certificate verify" \
2745 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002746 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002747 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002748 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002749 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002750 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002751# We don't check that the client receives the alert because it might
2752# detect that its write end of the connection is closed and abort
2753# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002754
Janos Follath89baba22017-04-10 14:34:35 +01002755run_test "Authentication: client cert not trusted, server required" \
2756 "$P_SRV debug_level=3 auth_mode=required" \
2757 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2758 key_file=data_files/server5.key" \
2759 1 \
2760 -S "skip write certificate request" \
2761 -C "skip parse certificate request" \
2762 -c "got a certificate request" \
2763 -C "skip write certificate" \
2764 -C "skip write certificate verify" \
2765 -S "skip parse certificate verify" \
2766 -s "x509_verify_cert() returned" \
2767 -s "! The certificate is not correctly signed by the trusted CA" \
2768 -s "! mbedtls_ssl_handshake returned" \
2769 -c "! mbedtls_ssl_handshake returned" \
2770 -s "X509 - Certificate verification failed"
2771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002772run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002773 "$P_SRV debug_level=3 auth_mode=optional" \
2774 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002775 key_file=data_files/server5.key" \
2776 0 \
2777 -S "skip write certificate request" \
2778 -C "skip parse certificate request" \
2779 -c "got a certificate request" \
2780 -C "skip write certificate" \
2781 -C "skip write certificate verify" \
2782 -S "skip parse certificate verify" \
2783 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002784 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002785 -S "! mbedtls_ssl_handshake returned" \
2786 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002787 -S "X509 - Certificate verification failed"
2788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002789run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002790 "$P_SRV debug_level=3 auth_mode=none" \
2791 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002792 key_file=data_files/server5.key" \
2793 0 \
2794 -s "skip write certificate request" \
2795 -C "skip parse certificate request" \
2796 -c "got no certificate request" \
2797 -c "skip write certificate" \
2798 -c "skip write certificate verify" \
2799 -s "skip parse certificate verify" \
2800 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002801 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002802 -S "! mbedtls_ssl_handshake returned" \
2803 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002804 -S "X509 - Certificate verification failed"
2805
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002806run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002807 "$P_SRV debug_level=3 auth_mode=optional" \
2808 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002809 0 \
2810 -S "skip write certificate request" \
2811 -C "skip parse certificate request" \
2812 -c "got a certificate request" \
2813 -C "skip write certificate$" \
2814 -C "got no certificate to send" \
2815 -S "SSLv3 client has no certificate" \
2816 -c "skip write certificate verify" \
2817 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002818 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002819 -S "! mbedtls_ssl_handshake returned" \
2820 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002821 -S "X509 - Certificate verification failed"
2822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002823run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002824 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002825 "$O_CLI" \
2826 0 \
2827 -S "skip write certificate request" \
2828 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002829 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002830 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002831 -S "X509 - Certificate verification failed"
2832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002833run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002834 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002835 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002836 0 \
2837 -C "skip parse certificate request" \
2838 -c "got a certificate request" \
2839 -C "skip write certificate$" \
2840 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002841 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002842
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002843run_test "Authentication: client no cert, openssl server required" \
2844 "$O_SRV -Verify 10" \
2845 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2846 1 \
2847 -C "skip parse certificate request" \
2848 -c "got a certificate request" \
2849 -C "skip write certificate$" \
2850 -c "skip write certificate verify" \
2851 -c "! mbedtls_ssl_handshake returned"
2852
Janos Follathe2681a42016-03-07 15:57:05 +00002853requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002854run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002855 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002856 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002857 0 \
2858 -S "skip write certificate request" \
2859 -C "skip parse certificate request" \
2860 -c "got a certificate request" \
2861 -C "skip write certificate$" \
2862 -c "skip write certificate verify" \
2863 -c "got no certificate to send" \
2864 -s "SSLv3 client has no certificate" \
2865 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002866 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002867 -S "! mbedtls_ssl_handshake returned" \
2868 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002869 -S "X509 - Certificate verification failed"
2870
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002871# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2872# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002873
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002874MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002875MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002876
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002877if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002878 cat <<EOF
2879${CONFIG_H} contains a value for the configuration of
2880MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script's
2881test value of ${MAX_IM_CA}.
Simon Butcher06b78632017-07-28 01:00:17 +01002882
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002883The tests assume this value and if it changes, the tests in this
2884script should also be adjusted.
2885EOF
Simon Butcher06b78632017-07-28 01:00:17 +01002886 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002887fi
2888
Angus Grattonc4dd0732018-04-11 16:28:39 +10002889requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002890run_test "Authentication: server max_int chain, client default" \
2891 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2892 key_file=data_files/dir-maxpath/09.key" \
2893 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2894 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002895 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002896
Angus Grattonc4dd0732018-04-11 16:28:39 +10002897requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002898run_test "Authentication: server max_int+1 chain, client default" \
2899 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2900 key_file=data_files/dir-maxpath/10.key" \
2901 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2902 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002903 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002904
Angus Grattonc4dd0732018-04-11 16:28:39 +10002905requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002906run_test "Authentication: server max_int+1 chain, client optional" \
2907 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2908 key_file=data_files/dir-maxpath/10.key" \
2909 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2910 auth_mode=optional" \
2911 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002912 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002913
Angus Grattonc4dd0732018-04-11 16:28:39 +10002914requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002915run_test "Authentication: server max_int+1 chain, client none" \
2916 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2917 key_file=data_files/dir-maxpath/10.key" \
2918 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2919 auth_mode=none" \
2920 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002921 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002922
Angus Grattonc4dd0732018-04-11 16:28:39 +10002923requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002924run_test "Authentication: client max_int+1 chain, server default" \
2925 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2926 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2927 key_file=data_files/dir-maxpath/10.key" \
2928 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002929 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002930
Angus Grattonc4dd0732018-04-11 16:28:39 +10002931requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002932run_test "Authentication: client max_int+1 chain, server optional" \
2933 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2934 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2935 key_file=data_files/dir-maxpath/10.key" \
2936 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002937 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002938
Angus Grattonc4dd0732018-04-11 16:28:39 +10002939requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002940run_test "Authentication: client max_int+1 chain, server required" \
2941 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2942 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2943 key_file=data_files/dir-maxpath/10.key" \
2944 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002945 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002946
Angus Grattonc4dd0732018-04-11 16:28:39 +10002947requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002948run_test "Authentication: client max_int chain, server required" \
2949 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2950 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2951 key_file=data_files/dir-maxpath/09.key" \
2952 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002953 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002954
Janos Follath89baba22017-04-10 14:34:35 +01002955# Tests for CA list in CertificateRequest messages
2956
2957run_test "Authentication: send CA list in CertificateRequest (default)" \
2958 "$P_SRV debug_level=3 auth_mode=required" \
2959 "$P_CLI crt_file=data_files/server6.crt \
2960 key_file=data_files/server6.key" \
2961 0 \
2962 -s "requested DN"
2963
2964run_test "Authentication: do not send CA list in CertificateRequest" \
2965 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2966 "$P_CLI crt_file=data_files/server6.crt \
2967 key_file=data_files/server6.key" \
2968 0 \
2969 -S "requested DN"
2970
2971run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2972 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2973 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2974 key_file=data_files/server5.key" \
2975 1 \
2976 -S "requested DN" \
2977 -s "x509_verify_cert() returned" \
2978 -s "! The certificate is not correctly signed by the trusted CA" \
2979 -s "! mbedtls_ssl_handshake returned" \
2980 -c "! mbedtls_ssl_handshake returned" \
2981 -s "X509 - Certificate verification failed"
2982
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002983# Tests for certificate selection based on SHA verson
2984
2985run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2986 "$P_SRV crt_file=data_files/server5.crt \
2987 key_file=data_files/server5.key \
2988 crt_file2=data_files/server5-sha1.crt \
2989 key_file2=data_files/server5.key" \
2990 "$P_CLI force_version=tls1_2" \
2991 0 \
2992 -c "signed using.*ECDSA with SHA256" \
2993 -C "signed using.*ECDSA with SHA1"
2994
2995run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2996 "$P_SRV crt_file=data_files/server5.crt \
2997 key_file=data_files/server5.key \
2998 crt_file2=data_files/server5-sha1.crt \
2999 key_file2=data_files/server5.key" \
3000 "$P_CLI force_version=tls1_1" \
3001 0 \
3002 -C "signed using.*ECDSA with SHA256" \
3003 -c "signed using.*ECDSA with SHA1"
3004
3005run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
3006 "$P_SRV crt_file=data_files/server5.crt \
3007 key_file=data_files/server5.key \
3008 crt_file2=data_files/server5-sha1.crt \
3009 key_file2=data_files/server5.key" \
3010 "$P_CLI force_version=tls1" \
3011 0 \
3012 -C "signed using.*ECDSA with SHA256" \
3013 -c "signed using.*ECDSA with SHA1"
3014
3015run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
3016 "$P_SRV crt_file=data_files/server5.crt \
3017 key_file=data_files/server5.key \
3018 crt_file2=data_files/server6.crt \
3019 key_file2=data_files/server6.key" \
3020 "$P_CLI force_version=tls1_1" \
3021 0 \
3022 -c "serial number.*09" \
3023 -c "signed using.*ECDSA with SHA256" \
3024 -C "signed using.*ECDSA with SHA1"
3025
3026run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
3027 "$P_SRV crt_file=data_files/server6.crt \
3028 key_file=data_files/server6.key \
3029 crt_file2=data_files/server5.crt \
3030 key_file2=data_files/server5.key" \
3031 "$P_CLI force_version=tls1_1" \
3032 0 \
3033 -c "serial number.*0A" \
3034 -c "signed using.*ECDSA with SHA256" \
3035 -C "signed using.*ECDSA with SHA1"
3036
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003037# tests for SNI
3038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003039run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003040 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003041 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003042 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003043 0 \
3044 -S "parse ServerName extension" \
3045 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3046 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003048run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003049 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003050 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003051 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 +02003052 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003053 0 \
3054 -s "parse ServerName extension" \
3055 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3056 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003058run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003059 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003060 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003061 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 +02003062 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003063 0 \
3064 -s "parse ServerName extension" \
3065 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3066 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003068run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003069 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003070 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003071 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 +02003072 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003073 1 \
3074 -s "parse ServerName extension" \
3075 -s "ssl_sni_wrapper() returned" \
3076 -s "mbedtls_ssl_handshake returned" \
3077 -c "mbedtls_ssl_handshake returned" \
3078 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003079
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003080run_test "SNI: client auth no override: optional" \
3081 "$P_SRV debug_level=3 auth_mode=optional \
3082 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3083 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3084 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003085 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003086 -S "skip write certificate request" \
3087 -C "skip parse certificate request" \
3088 -c "got a certificate request" \
3089 -C "skip write certificate" \
3090 -C "skip write certificate verify" \
3091 -S "skip parse certificate verify"
3092
3093run_test "SNI: client auth override: none -> optional" \
3094 "$P_SRV debug_level=3 auth_mode=none \
3095 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3096 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3097 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003098 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003099 -S "skip write certificate request" \
3100 -C "skip parse certificate request" \
3101 -c "got a certificate request" \
3102 -C "skip write certificate" \
3103 -C "skip write certificate verify" \
3104 -S "skip parse certificate verify"
3105
3106run_test "SNI: client auth override: optional -> none" \
3107 "$P_SRV debug_level=3 auth_mode=optional \
3108 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3109 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3110 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003111 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003112 -s "skip write certificate request" \
3113 -C "skip parse certificate request" \
3114 -c "got no certificate request" \
3115 -c "skip write certificate" \
3116 -c "skip write certificate verify" \
3117 -s "skip parse certificate verify"
3118
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003119run_test "SNI: CA no override" \
3120 "$P_SRV debug_level=3 auth_mode=optional \
3121 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3122 ca_file=data_files/test-ca.crt \
3123 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3124 "$P_CLI debug_level=3 server_name=localhost \
3125 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3126 1 \
3127 -S "skip write certificate request" \
3128 -C "skip parse certificate request" \
3129 -c "got a certificate request" \
3130 -C "skip write certificate" \
3131 -C "skip write certificate verify" \
3132 -S "skip parse certificate verify" \
3133 -s "x509_verify_cert() returned" \
3134 -s "! The certificate is not correctly signed by the trusted CA" \
3135 -S "The certificate has been revoked (is on a CRL)"
3136
3137run_test "SNI: CA override" \
3138 "$P_SRV debug_level=3 auth_mode=optional \
3139 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3140 ca_file=data_files/test-ca.crt \
3141 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3142 "$P_CLI debug_level=3 server_name=localhost \
3143 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3144 0 \
3145 -S "skip write certificate request" \
3146 -C "skip parse certificate request" \
3147 -c "got a certificate request" \
3148 -C "skip write certificate" \
3149 -C "skip write certificate verify" \
3150 -S "skip parse certificate verify" \
3151 -S "x509_verify_cert() returned" \
3152 -S "! The certificate is not correctly signed by the trusted CA" \
3153 -S "The certificate has been revoked (is on a CRL)"
3154
3155run_test "SNI: CA override with CRL" \
3156 "$P_SRV debug_level=3 auth_mode=optional \
3157 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3158 ca_file=data_files/test-ca.crt \
3159 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3160 "$P_CLI debug_level=3 server_name=localhost \
3161 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3162 1 \
3163 -S "skip write certificate request" \
3164 -C "skip parse certificate request" \
3165 -c "got a certificate request" \
3166 -C "skip write certificate" \
3167 -C "skip write certificate verify" \
3168 -S "skip parse certificate verify" \
3169 -s "x509_verify_cert() returned" \
3170 -S "! The certificate is not correctly signed by the trusted CA" \
3171 -s "The certificate has been revoked (is on a CRL)"
3172
Andres AG1a834452016-12-07 10:01:30 +00003173# Tests for SNI and DTLS
3174
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003175run_test "SNI: DTLS, no SNI callback" \
3176 "$P_SRV debug_level=3 dtls=1 \
3177 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3178 "$P_CLI server_name=localhost dtls=1" \
3179 0 \
3180 -S "parse ServerName extension" \
3181 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3182 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3183
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003184run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003185 "$P_SRV debug_level=3 dtls=1 \
3186 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3187 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3188 "$P_CLI server_name=localhost dtls=1" \
3189 0 \
3190 -s "parse ServerName extension" \
3191 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3192 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3193
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003194run_test "SNI: DTLS, matching cert 2" \
3195 "$P_SRV debug_level=3 dtls=1 \
3196 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3197 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3198 "$P_CLI server_name=polarssl.example dtls=1" \
3199 0 \
3200 -s "parse ServerName extension" \
3201 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3202 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3203
3204run_test "SNI: DTLS, no matching cert" \
3205 "$P_SRV debug_level=3 dtls=1 \
3206 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3207 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3208 "$P_CLI server_name=nonesuch.example dtls=1" \
3209 1 \
3210 -s "parse ServerName extension" \
3211 -s "ssl_sni_wrapper() returned" \
3212 -s "mbedtls_ssl_handshake returned" \
3213 -c "mbedtls_ssl_handshake returned" \
3214 -c "SSL - A fatal alert message was received from our peer"
3215
3216run_test "SNI: DTLS, client auth no override: optional" \
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 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3220 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3221 0 \
3222 -S "skip write certificate request" \
3223 -C "skip parse certificate request" \
3224 -c "got a certificate request" \
3225 -C "skip write certificate" \
3226 -C "skip write certificate verify" \
3227 -S "skip parse certificate verify"
3228
3229run_test "SNI: DTLS, client auth override: none -> optional" \
3230 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3231 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3232 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3233 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3234 0 \
3235 -S "skip write certificate request" \
3236 -C "skip parse certificate request" \
3237 -c "got a certificate request" \
3238 -C "skip write certificate" \
3239 -C "skip write certificate verify" \
3240 -S "skip parse certificate verify"
3241
3242run_test "SNI: DTLS, client auth override: optional -> none" \
3243 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3244 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3245 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3246 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3247 0 \
3248 -s "skip write certificate request" \
3249 -C "skip parse certificate request" \
3250 -c "got no certificate request" \
3251 -c "skip write certificate" \
3252 -c "skip write certificate verify" \
3253 -s "skip parse certificate verify"
3254
3255run_test "SNI: DTLS, CA no override" \
3256 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3257 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3258 ca_file=data_files/test-ca.crt \
3259 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3260 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3261 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3262 1 \
3263 -S "skip write certificate request" \
3264 -C "skip parse certificate request" \
3265 -c "got a certificate request" \
3266 -C "skip write certificate" \
3267 -C "skip write certificate verify" \
3268 -S "skip parse certificate verify" \
3269 -s "x509_verify_cert() returned" \
3270 -s "! The certificate is not correctly signed by the trusted CA" \
3271 -S "The certificate has been revoked (is on a CRL)"
3272
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003273run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003274 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3275 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3276 ca_file=data_files/test-ca.crt \
3277 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3278 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3279 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3280 0 \
3281 -S "skip write certificate request" \
3282 -C "skip parse certificate request" \
3283 -c "got a certificate request" \
3284 -C "skip write certificate" \
3285 -C "skip write certificate verify" \
3286 -S "skip parse certificate verify" \
3287 -S "x509_verify_cert() returned" \
3288 -S "! The certificate is not correctly signed by the trusted CA" \
3289 -S "The certificate has been revoked (is on a CRL)"
3290
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003291run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003292 "$P_SRV debug_level=3 auth_mode=optional \
3293 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3294 ca_file=data_files/test-ca.crt \
3295 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3296 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3297 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3298 1 \
3299 -S "skip write certificate request" \
3300 -C "skip parse certificate request" \
3301 -c "got a certificate request" \
3302 -C "skip write certificate" \
3303 -C "skip write certificate verify" \
3304 -S "skip parse certificate verify" \
3305 -s "x509_verify_cert() returned" \
3306 -S "! The certificate is not correctly signed by the trusted CA" \
3307 -s "The certificate has been revoked (is on a CRL)"
3308
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003309# Tests for non-blocking I/O: exercise a variety of handshake flows
3310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003311run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003312 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3313 "$P_CLI nbio=2 tickets=0" \
3314 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003315 -S "mbedtls_ssl_handshake returned" \
3316 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003317 -c "Read from server: .* bytes read"
3318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003319run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003320 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3321 "$P_CLI nbio=2 tickets=0" \
3322 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003323 -S "mbedtls_ssl_handshake returned" \
3324 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003325 -c "Read from server: .* bytes read"
3326
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003327run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003328 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3329 "$P_CLI nbio=2 tickets=1" \
3330 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003331 -S "mbedtls_ssl_handshake returned" \
3332 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003333 -c "Read from server: .* bytes read"
3334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003335run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003336 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3337 "$P_CLI nbio=2 tickets=1" \
3338 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003339 -S "mbedtls_ssl_handshake returned" \
3340 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003341 -c "Read from server: .* bytes read"
3342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003343run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003344 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3345 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3346 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003347 -S "mbedtls_ssl_handshake returned" \
3348 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003349 -c "Read from server: .* bytes read"
3350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003351run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003352 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3353 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3354 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003355 -S "mbedtls_ssl_handshake returned" \
3356 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003357 -c "Read from server: .* bytes read"
3358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003359run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003360 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3361 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3362 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003363 -S "mbedtls_ssl_handshake returned" \
3364 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003365 -c "Read from server: .* bytes read"
3366
Hanno Becker00076712017-11-15 16:39:08 +00003367# Tests for event-driven I/O: exercise a variety of handshake flows
3368
3369run_test "Event-driven I/O: basic handshake" \
3370 "$P_SRV event=1 tickets=0 auth_mode=none" \
3371 "$P_CLI event=1 tickets=0" \
3372 0 \
3373 -S "mbedtls_ssl_handshake returned" \
3374 -C "mbedtls_ssl_handshake returned" \
3375 -c "Read from server: .* bytes read"
3376
3377run_test "Event-driven I/O: client auth" \
3378 "$P_SRV event=1 tickets=0 auth_mode=required" \
3379 "$P_CLI event=1 tickets=0" \
3380 0 \
3381 -S "mbedtls_ssl_handshake returned" \
3382 -C "mbedtls_ssl_handshake returned" \
3383 -c "Read from server: .* bytes read"
3384
3385run_test "Event-driven I/O: ticket" \
3386 "$P_SRV event=1 tickets=1 auth_mode=none" \
3387 "$P_CLI event=1 tickets=1" \
3388 0 \
3389 -S "mbedtls_ssl_handshake returned" \
3390 -C "mbedtls_ssl_handshake returned" \
3391 -c "Read from server: .* bytes read"
3392
3393run_test "Event-driven I/O: ticket + client auth" \
3394 "$P_SRV event=1 tickets=1 auth_mode=required" \
3395 "$P_CLI event=1 tickets=1" \
3396 0 \
3397 -S "mbedtls_ssl_handshake returned" \
3398 -C "mbedtls_ssl_handshake returned" \
3399 -c "Read from server: .* bytes read"
3400
3401run_test "Event-driven I/O: ticket + client auth + resume" \
3402 "$P_SRV event=1 tickets=1 auth_mode=required" \
3403 "$P_CLI event=1 tickets=1 reconnect=1" \
3404 0 \
3405 -S "mbedtls_ssl_handshake returned" \
3406 -C "mbedtls_ssl_handshake returned" \
3407 -c "Read from server: .* bytes read"
3408
3409run_test "Event-driven I/O: ticket + resume" \
3410 "$P_SRV event=1 tickets=1 auth_mode=none" \
3411 "$P_CLI event=1 tickets=1 reconnect=1" \
3412 0 \
3413 -S "mbedtls_ssl_handshake returned" \
3414 -C "mbedtls_ssl_handshake returned" \
3415 -c "Read from server: .* bytes read"
3416
3417run_test "Event-driven I/O: session-id resume" \
3418 "$P_SRV event=1 tickets=0 auth_mode=none" \
3419 "$P_CLI event=1 tickets=0 reconnect=1" \
3420 0 \
3421 -S "mbedtls_ssl_handshake returned" \
3422 -C "mbedtls_ssl_handshake returned" \
3423 -c "Read from server: .* bytes read"
3424
Hanno Becker6a33f592018-03-13 11:38:46 +00003425run_test "Event-driven I/O, DTLS: basic handshake" \
3426 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3427 "$P_CLI dtls=1 event=1 tickets=0" \
3428 0 \
3429 -c "Read from server: .* bytes read"
3430
3431run_test "Event-driven I/O, DTLS: client auth" \
3432 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3433 "$P_CLI dtls=1 event=1 tickets=0" \
3434 0 \
3435 -c "Read from server: .* bytes read"
3436
3437run_test "Event-driven I/O, DTLS: ticket" \
3438 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3439 "$P_CLI dtls=1 event=1 tickets=1" \
3440 0 \
3441 -c "Read from server: .* bytes read"
3442
3443run_test "Event-driven I/O, DTLS: ticket + client auth" \
3444 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3445 "$P_CLI dtls=1 event=1 tickets=1" \
3446 0 \
3447 -c "Read from server: .* bytes read"
3448
3449run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3450 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003451 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003452 0 \
3453 -c "Read from server: .* bytes read"
3454
3455run_test "Event-driven I/O, DTLS: ticket + resume" \
3456 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003457 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003458 0 \
3459 -c "Read from server: .* bytes read"
3460
3461run_test "Event-driven I/O, DTLS: session-id resume" \
3462 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003463 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003464 0 \
3465 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003466
3467# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3468# During session resumption, the client will send its ApplicationData record
3469# within the same datagram as the Finished messages. In this situation, the
3470# server MUST NOT idle on the underlying transport after handshake completion,
3471# because the ApplicationData request has already been queued internally.
3472run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003473 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003474 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003475 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003476 0 \
3477 -c "Read from server: .* bytes read"
3478
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003479# Tests for version negotiation
3480
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003481run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003482 "$P_SRV" \
3483 "$P_CLI" \
3484 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003485 -S "mbedtls_ssl_handshake returned" \
3486 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003487 -s "Protocol is TLSv1.2" \
3488 -c "Protocol is TLSv1.2"
3489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003490run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003491 "$P_SRV" \
3492 "$P_CLI max_version=tls1_1" \
3493 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003494 -S "mbedtls_ssl_handshake returned" \
3495 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003496 -s "Protocol is TLSv1.1" \
3497 -c "Protocol is TLSv1.1"
3498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003499run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003500 "$P_SRV max_version=tls1_1" \
3501 "$P_CLI" \
3502 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003503 -S "mbedtls_ssl_handshake returned" \
3504 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003505 -s "Protocol is TLSv1.1" \
3506 -c "Protocol is TLSv1.1"
3507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003508run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003509 "$P_SRV max_version=tls1_1" \
3510 "$P_CLI max_version=tls1_1" \
3511 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003512 -S "mbedtls_ssl_handshake returned" \
3513 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003514 -s "Protocol is TLSv1.1" \
3515 -c "Protocol is TLSv1.1"
3516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003517run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003518 "$P_SRV min_version=tls1_1" \
3519 "$P_CLI max_version=tls1_1" \
3520 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003521 -S "mbedtls_ssl_handshake returned" \
3522 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003523 -s "Protocol is TLSv1.1" \
3524 -c "Protocol is TLSv1.1"
3525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003526run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003527 "$P_SRV max_version=tls1_1" \
3528 "$P_CLI min_version=tls1_1" \
3529 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003530 -S "mbedtls_ssl_handshake returned" \
3531 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003532 -s "Protocol is TLSv1.1" \
3533 -c "Protocol is TLSv1.1"
3534
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003535run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003536 "$P_SRV max_version=tls1_1" \
3537 "$P_CLI min_version=tls1_2" \
3538 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003539 -s "mbedtls_ssl_handshake returned" \
3540 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003541 -c "SSL - Handshake protocol not within min/max boundaries"
3542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003543run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003544 "$P_SRV min_version=tls1_2" \
3545 "$P_CLI max_version=tls1_1" \
3546 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003547 -s "mbedtls_ssl_handshake returned" \
3548 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003549 -s "SSL - Handshake protocol not within min/max boundaries"
3550
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003551# Tests for ALPN extension
3552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003553run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003554 "$P_SRV debug_level=3" \
3555 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003556 0 \
3557 -C "client hello, adding alpn extension" \
3558 -S "found alpn extension" \
3559 -C "got an alert message, type: \\[2:120]" \
3560 -S "server hello, adding alpn extension" \
3561 -C "found alpn extension " \
3562 -C "Application Layer Protocol is" \
3563 -S "Application Layer Protocol is"
3564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003565run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003566 "$P_SRV debug_level=3" \
3567 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003568 0 \
3569 -c "client hello, adding alpn extension" \
3570 -s "found alpn extension" \
3571 -C "got an alert message, type: \\[2:120]" \
3572 -S "server hello, adding alpn extension" \
3573 -C "found alpn extension " \
3574 -c "Application Layer Protocol is (none)" \
3575 -S "Application Layer Protocol is"
3576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003577run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003578 "$P_SRV debug_level=3 alpn=abc,1234" \
3579 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003580 0 \
3581 -C "client hello, adding alpn extension" \
3582 -S "found alpn extension" \
3583 -C "got an alert message, type: \\[2:120]" \
3584 -S "server hello, adding alpn extension" \
3585 -C "found alpn extension " \
3586 -C "Application Layer Protocol is" \
3587 -s "Application Layer Protocol is (none)"
3588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003589run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003590 "$P_SRV debug_level=3 alpn=abc,1234" \
3591 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003592 0 \
3593 -c "client hello, adding alpn extension" \
3594 -s "found alpn extension" \
3595 -C "got an alert message, type: \\[2:120]" \
3596 -s "server hello, adding alpn extension" \
3597 -c "found alpn extension" \
3598 -c "Application Layer Protocol is abc" \
3599 -s "Application Layer Protocol is abc"
3600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003601run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003602 "$P_SRV debug_level=3 alpn=abc,1234" \
3603 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003604 0 \
3605 -c "client hello, adding alpn extension" \
3606 -s "found alpn extension" \
3607 -C "got an alert message, type: \\[2:120]" \
3608 -s "server hello, adding alpn extension" \
3609 -c "found alpn extension" \
3610 -c "Application Layer Protocol is abc" \
3611 -s "Application Layer Protocol is abc"
3612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003613run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003614 "$P_SRV debug_level=3 alpn=abc,1234" \
3615 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003616 0 \
3617 -c "client hello, adding alpn extension" \
3618 -s "found alpn extension" \
3619 -C "got an alert message, type: \\[2:120]" \
3620 -s "server hello, adding alpn extension" \
3621 -c "found alpn extension" \
3622 -c "Application Layer Protocol is 1234" \
3623 -s "Application Layer Protocol is 1234"
3624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003625run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003626 "$P_SRV debug_level=3 alpn=abc,123" \
3627 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003628 1 \
3629 -c "client hello, adding alpn extension" \
3630 -s "found alpn extension" \
3631 -c "got an alert message, type: \\[2:120]" \
3632 -S "server hello, adding alpn extension" \
3633 -C "found alpn extension" \
3634 -C "Application Layer Protocol is 1234" \
3635 -S "Application Layer Protocol is 1234"
3636
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003637
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003638# Tests for keyUsage in leaf certificates, part 1:
3639# server-side certificate/suite selection
3640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003641run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003642 "$P_SRV key_file=data_files/server2.key \
3643 crt_file=data_files/server2.ku-ds.crt" \
3644 "$P_CLI" \
3645 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003646 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003647
3648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003649run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003650 "$P_SRV key_file=data_files/server2.key \
3651 crt_file=data_files/server2.ku-ke.crt" \
3652 "$P_CLI" \
3653 0 \
3654 -c "Ciphersuite is TLS-RSA-WITH-"
3655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003656run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003657 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003658 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003659 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003660 1 \
3661 -C "Ciphersuite is "
3662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003663run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003664 "$P_SRV key_file=data_files/server5.key \
3665 crt_file=data_files/server5.ku-ds.crt" \
3666 "$P_CLI" \
3667 0 \
3668 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3669
3670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003671run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003672 "$P_SRV key_file=data_files/server5.key \
3673 crt_file=data_files/server5.ku-ka.crt" \
3674 "$P_CLI" \
3675 0 \
3676 -c "Ciphersuite is TLS-ECDH-"
3677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003678run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003679 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003680 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003681 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003682 1 \
3683 -C "Ciphersuite is "
3684
3685# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003686# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003688run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003689 "$O_SRV -key data_files/server2.key \
3690 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003691 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003692 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3693 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003694 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003695 -C "Processing of the Certificate handshake message failed" \
3696 -c "Ciphersuite is TLS-"
3697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003698run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003699 "$O_SRV -key data_files/server2.key \
3700 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003701 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003702 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3703 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003704 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003705 -C "Processing of the Certificate handshake message failed" \
3706 -c "Ciphersuite is TLS-"
3707
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003708run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003709 "$O_SRV -key data_files/server2.key \
3710 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003711 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003712 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3713 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003714 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003715 -C "Processing of the Certificate handshake message failed" \
3716 -c "Ciphersuite is TLS-"
3717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003718run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003719 "$O_SRV -key data_files/server2.key \
3720 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003721 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003722 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3723 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003724 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003725 -c "Processing of the Certificate handshake message failed" \
3726 -C "Ciphersuite is TLS-"
3727
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003728run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3729 "$O_SRV -key data_files/server2.key \
3730 -cert data_files/server2.ku-ke.crt" \
3731 "$P_CLI debug_level=1 auth_mode=optional \
3732 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3733 0 \
3734 -c "bad certificate (usage extensions)" \
3735 -C "Processing of the Certificate handshake message failed" \
3736 -c "Ciphersuite is TLS-" \
3737 -c "! Usage does not match the keyUsage extension"
3738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003739run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003740 "$O_SRV -key data_files/server2.key \
3741 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003742 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003743 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3744 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003745 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003746 -C "Processing of the Certificate handshake message failed" \
3747 -c "Ciphersuite is TLS-"
3748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003749run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003750 "$O_SRV -key data_files/server2.key \
3751 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003752 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003753 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3754 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003755 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003756 -c "Processing of the Certificate handshake message failed" \
3757 -C "Ciphersuite is TLS-"
3758
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003759run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3760 "$O_SRV -key data_files/server2.key \
3761 -cert data_files/server2.ku-ds.crt" \
3762 "$P_CLI debug_level=1 auth_mode=optional \
3763 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3764 0 \
3765 -c "bad certificate (usage extensions)" \
3766 -C "Processing of the Certificate handshake message failed" \
3767 -c "Ciphersuite is TLS-" \
3768 -c "! Usage does not match the keyUsage extension"
3769
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003770# Tests for keyUsage in leaf certificates, part 3:
3771# server-side checking of client cert
3772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003773run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003774 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003775 "$O_CLI -key data_files/server2.key \
3776 -cert data_files/server2.ku-ds.crt" \
3777 0 \
3778 -S "bad certificate (usage extensions)" \
3779 -S "Processing of the Certificate handshake message failed"
3780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003781run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003782 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003783 "$O_CLI -key data_files/server2.key \
3784 -cert data_files/server2.ku-ke.crt" \
3785 0 \
3786 -s "bad certificate (usage extensions)" \
3787 -S "Processing of the Certificate handshake message failed"
3788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003789run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003790 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003791 "$O_CLI -key data_files/server2.key \
3792 -cert data_files/server2.ku-ke.crt" \
3793 1 \
3794 -s "bad certificate (usage extensions)" \
3795 -s "Processing of the Certificate handshake message failed"
3796
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003797run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003798 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003799 "$O_CLI -key data_files/server5.key \
3800 -cert data_files/server5.ku-ds.crt" \
3801 0 \
3802 -S "bad certificate (usage extensions)" \
3803 -S "Processing of the Certificate handshake message failed"
3804
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003805run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003806 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003807 "$O_CLI -key data_files/server5.key \
3808 -cert data_files/server5.ku-ka.crt" \
3809 0 \
3810 -s "bad certificate (usage extensions)" \
3811 -S "Processing of the Certificate handshake message failed"
3812
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003813# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003815run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003816 "$P_SRV key_file=data_files/server5.key \
3817 crt_file=data_files/server5.eku-srv.crt" \
3818 "$P_CLI" \
3819 0
3820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003821run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003822 "$P_SRV key_file=data_files/server5.key \
3823 crt_file=data_files/server5.eku-srv.crt" \
3824 "$P_CLI" \
3825 0
3826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003827run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003828 "$P_SRV key_file=data_files/server5.key \
3829 crt_file=data_files/server5.eku-cs_any.crt" \
3830 "$P_CLI" \
3831 0
3832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003833run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003834 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003835 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003836 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003837 1
3838
3839# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003841run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003842 "$O_SRV -key data_files/server5.key \
3843 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003844 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003845 0 \
3846 -C "bad certificate (usage extensions)" \
3847 -C "Processing of the Certificate handshake message failed" \
3848 -c "Ciphersuite is TLS-"
3849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003850run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003851 "$O_SRV -key data_files/server5.key \
3852 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003853 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003854 0 \
3855 -C "bad certificate (usage extensions)" \
3856 -C "Processing of the Certificate handshake message failed" \
3857 -c "Ciphersuite is TLS-"
3858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003859run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003860 "$O_SRV -key data_files/server5.key \
3861 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003862 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003863 0 \
3864 -C "bad certificate (usage extensions)" \
3865 -C "Processing of the Certificate handshake message failed" \
3866 -c "Ciphersuite is TLS-"
3867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003868run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003869 "$O_SRV -key data_files/server5.key \
3870 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003871 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003872 1 \
3873 -c "bad certificate (usage extensions)" \
3874 -c "Processing of the Certificate handshake message failed" \
3875 -C "Ciphersuite is TLS-"
3876
3877# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003879run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003880 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003881 "$O_CLI -key data_files/server5.key \
3882 -cert data_files/server5.eku-cli.crt" \
3883 0 \
3884 -S "bad certificate (usage extensions)" \
3885 -S "Processing of the Certificate handshake message failed"
3886
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003887run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003888 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003889 "$O_CLI -key data_files/server5.key \
3890 -cert data_files/server5.eku-srv_cli.crt" \
3891 0 \
3892 -S "bad certificate (usage extensions)" \
3893 -S "Processing of the Certificate handshake message failed"
3894
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003895run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003896 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003897 "$O_CLI -key data_files/server5.key \
3898 -cert data_files/server5.eku-cs_any.crt" \
3899 0 \
3900 -S "bad certificate (usage extensions)" \
3901 -S "Processing of the Certificate handshake message failed"
3902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003903run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003904 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003905 "$O_CLI -key data_files/server5.key \
3906 -cert data_files/server5.eku-cs.crt" \
3907 0 \
3908 -s "bad certificate (usage extensions)" \
3909 -S "Processing of the Certificate handshake message failed"
3910
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003911run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003912 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003913 "$O_CLI -key data_files/server5.key \
3914 -cert data_files/server5.eku-cs.crt" \
3915 1 \
3916 -s "bad certificate (usage extensions)" \
3917 -s "Processing of the Certificate handshake message failed"
3918
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003919# Tests for DHM parameters loading
3920
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003921run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003922 "$P_SRV" \
3923 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3924 debug_level=3" \
3925 0 \
3926 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003927 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003929run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003930 "$P_SRV dhm_file=data_files/dhparams.pem" \
3931 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3932 debug_level=3" \
3933 0 \
3934 -c "value of 'DHM: P ' (1024 bits)" \
3935 -c "value of 'DHM: G ' (2 bits)"
3936
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003937# Tests for DHM client-side size checking
3938
3939run_test "DHM size: server default, client default, OK" \
3940 "$P_SRV" \
3941 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3942 debug_level=1" \
3943 0 \
3944 -C "DHM prime too short:"
3945
3946run_test "DHM size: server default, client 2048, OK" \
3947 "$P_SRV" \
3948 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3949 debug_level=1 dhmlen=2048" \
3950 0 \
3951 -C "DHM prime too short:"
3952
3953run_test "DHM size: server 1024, client default, OK" \
3954 "$P_SRV dhm_file=data_files/dhparams.pem" \
3955 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3956 debug_level=1" \
3957 0 \
3958 -C "DHM prime too short:"
3959
3960run_test "DHM size: server 1000, client default, rejected" \
3961 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3962 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3963 debug_level=1" \
3964 1 \
3965 -c "DHM prime too short:"
3966
3967run_test "DHM size: server default, client 2049, rejected" \
3968 "$P_SRV" \
3969 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3970 debug_level=1 dhmlen=2049" \
3971 1 \
3972 -c "DHM prime too short:"
3973
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003974# Tests for PSK callback
3975
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003976run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003977 "$P_SRV psk=abc123 psk_identity=foo" \
3978 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3979 psk_identity=foo psk=abc123" \
3980 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003981 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003982 -S "SSL - Unknown identity received" \
3983 -S "SSL - Verification of the message MAC failed"
3984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003985run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003986 "$P_SRV" \
3987 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3988 psk_identity=foo psk=abc123" \
3989 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003990 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003991 -S "SSL - Unknown identity received" \
3992 -S "SSL - Verification of the message MAC failed"
3993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003994run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003995 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3996 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3997 psk_identity=foo psk=abc123" \
3998 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003999 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004000 -s "SSL - Unknown identity received" \
4001 -S "SSL - Verification of the message MAC failed"
4002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004003run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004004 "$P_SRV psk_list=abc,dead,def,beef" \
4005 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4006 psk_identity=abc psk=dead" \
4007 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004008 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004009 -S "SSL - Unknown identity received" \
4010 -S "SSL - Verification of the message MAC failed"
4011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004012run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004013 "$P_SRV psk_list=abc,dead,def,beef" \
4014 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4015 psk_identity=def psk=beef" \
4016 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004017 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004018 -S "SSL - Unknown identity received" \
4019 -S "SSL - Verification of the message MAC failed"
4020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004021run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004022 "$P_SRV psk_list=abc,dead,def,beef" \
4023 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4024 psk_identity=ghi psk=beef" \
4025 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004026 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004027 -s "SSL - Unknown identity received" \
4028 -S "SSL - Verification of the message MAC failed"
4029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004030run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004031 "$P_SRV psk_list=abc,dead,def,beef" \
4032 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4033 psk_identity=abc psk=beef" \
4034 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004035 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004036 -S "SSL - Unknown identity received" \
4037 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004038
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004039# Tests for EC J-PAKE
4040
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004041requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004042run_test "ECJPAKE: client not configured" \
4043 "$P_SRV debug_level=3" \
4044 "$P_CLI debug_level=3" \
4045 0 \
4046 -C "add ciphersuite: c0ff" \
4047 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004048 -S "found ecjpake kkpp extension" \
4049 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004050 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004051 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004052 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004053 -S "None of the common ciphersuites is usable"
4054
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004055requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004056run_test "ECJPAKE: server not configured" \
4057 "$P_SRV debug_level=3" \
4058 "$P_CLI debug_level=3 ecjpake_pw=bla \
4059 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4060 1 \
4061 -c "add ciphersuite: c0ff" \
4062 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004063 -s "found ecjpake kkpp extension" \
4064 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004065 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004066 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004067 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004068 -s "None of the common ciphersuites is usable"
4069
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004070requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004071run_test "ECJPAKE: working, TLS" \
4072 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4073 "$P_CLI debug_level=3 ecjpake_pw=bla \
4074 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004075 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004076 -c "add ciphersuite: c0ff" \
4077 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004078 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004079 -s "found ecjpake kkpp extension" \
4080 -S "skip ecjpake kkpp extension" \
4081 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004082 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004083 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004084 -S "None of the common ciphersuites is usable" \
4085 -S "SSL - Verification of the message MAC failed"
4086
Janos Follath74537a62016-09-02 13:45:28 +01004087server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004088requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004089run_test "ECJPAKE: password mismatch, TLS" \
4090 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4091 "$P_CLI debug_level=3 ecjpake_pw=bad \
4092 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4093 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004094 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004095 -s "SSL - Verification of the message MAC failed"
4096
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004097requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004098run_test "ECJPAKE: working, DTLS" \
4099 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4100 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4101 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4102 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004103 -c "re-using cached ecjpake parameters" \
4104 -S "SSL - Verification of the message MAC failed"
4105
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004106requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004107run_test "ECJPAKE: working, DTLS, no cookie" \
4108 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4109 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4110 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4111 0 \
4112 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004113 -S "SSL - Verification of the message MAC failed"
4114
Janos Follath74537a62016-09-02 13:45:28 +01004115server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004116requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004117run_test "ECJPAKE: password mismatch, DTLS" \
4118 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4119 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4120 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4121 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004122 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004123 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004124
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004125# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004126requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004127run_test "ECJPAKE: working, DTLS, nolog" \
4128 "$P_SRV dtls=1 ecjpake_pw=bla" \
4129 "$P_CLI dtls=1 ecjpake_pw=bla \
4130 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4131 0
4132
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004133# Tests for ciphersuites per version
4134
Janos Follathe2681a42016-03-07 15:57:05 +00004135requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004136requires_config_enabled MBEDTLS_CAMELLIA_C
4137requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004138run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004139 "$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 +02004140 "$P_CLI force_version=ssl3" \
4141 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004142 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004143
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004144requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4145requires_config_enabled MBEDTLS_CAMELLIA_C
4146requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004147run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004148 "$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 +01004149 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004150 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004151 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004152
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004153requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4154requires_config_enabled MBEDTLS_CAMELLIA_C
4155requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004156run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004157 "$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 +02004158 "$P_CLI force_version=tls1_1" \
4159 0 \
4160 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4161
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004162requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4163requires_config_enabled MBEDTLS_CAMELLIA_C
4164requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004165run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004166 "$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 +02004167 "$P_CLI force_version=tls1_2" \
4168 0 \
4169 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4170
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004171# Test for ClientHello without extensions
4172
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004173requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004174run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004175 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004176 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004177 0 \
4178 -s "dumping 'client hello extensions' (0 bytes)"
4179
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004180# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004181
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004182run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004183 "$P_SRV" \
4184 "$P_CLI request_size=100" \
4185 0 \
4186 -s "Read from client: 100 bytes read$"
4187
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004188run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004189 "$P_SRV" \
4190 "$P_CLI request_size=500" \
4191 0 \
4192 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004193
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004194# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004195
Janos Follathe2681a42016-03-07 15:57:05 +00004196requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004197run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004198 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004199 "$P_CLI request_size=1 force_version=ssl3 \
4200 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4201 0 \
4202 -s "Read from client: 1 bytes read"
4203
Janos Follathe2681a42016-03-07 15:57:05 +00004204requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004205run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004206 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004207 "$P_CLI request_size=1 force_version=ssl3 \
4208 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4209 0 \
4210 -s "Read from client: 1 bytes read"
4211
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004212run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004213 "$P_SRV" \
4214 "$P_CLI request_size=1 force_version=tls1 \
4215 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4216 0 \
4217 -s "Read from client: 1 bytes read"
4218
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004219run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004220 "$P_SRV" \
4221 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4222 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4223 0 \
4224 -s "Read from client: 1 bytes read"
4225
Hanno Becker32c55012017-11-10 08:42:54 +00004226requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004227run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004228 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004229 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004230 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004231 0 \
4232 -s "Read from client: 1 bytes read"
4233
Hanno Becker32c55012017-11-10 08:42:54 +00004234requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004235run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004236 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004237 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004238 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004239 0 \
4240 -s "Read from client: 1 bytes read"
4241
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004242run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004243 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004244 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004245 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4246 0 \
4247 -s "Read from client: 1 bytes read"
4248
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004249run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004250 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4251 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004252 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004253 0 \
4254 -s "Read from client: 1 bytes read"
4255
4256requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004257run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004258 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004259 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004260 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004261 0 \
4262 -s "Read from client: 1 bytes read"
4263
Hanno Becker8501f982017-11-10 08:59:04 +00004264requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004265run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004266 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4267 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4268 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004269 0 \
4270 -s "Read from client: 1 bytes read"
4271
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004272run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004273 "$P_SRV" \
4274 "$P_CLI request_size=1 force_version=tls1_1 \
4275 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4276 0 \
4277 -s "Read from client: 1 bytes read"
4278
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004279run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004280 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004281 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004282 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004283 0 \
4284 -s "Read from client: 1 bytes read"
4285
4286requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004287run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004288 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004289 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004290 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004291 0 \
4292 -s "Read from client: 1 bytes read"
4293
4294requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004295run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004296 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004297 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004298 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004299 0 \
4300 -s "Read from client: 1 bytes read"
4301
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004302run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004303 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004304 "$P_CLI request_size=1 force_version=tls1_1 \
4305 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4306 0 \
4307 -s "Read from client: 1 bytes read"
4308
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004309run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004310 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004311 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004312 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004313 0 \
4314 -s "Read from client: 1 bytes read"
4315
Hanno Becker8501f982017-11-10 08:59:04 +00004316requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004317run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004318 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004319 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004320 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004321 0 \
4322 -s "Read from client: 1 bytes read"
4323
Hanno Becker32c55012017-11-10 08:42:54 +00004324requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004325run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004326 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004327 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004328 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004329 0 \
4330 -s "Read from client: 1 bytes read"
4331
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004332run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004333 "$P_SRV" \
4334 "$P_CLI request_size=1 force_version=tls1_2 \
4335 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4336 0 \
4337 -s "Read from client: 1 bytes read"
4338
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004339run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004340 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004341 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004342 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004343 0 \
4344 -s "Read from client: 1 bytes read"
4345
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004346run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004347 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004348 "$P_CLI request_size=1 force_version=tls1_2 \
4349 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004350 0 \
4351 -s "Read from client: 1 bytes read"
4352
Hanno Becker32c55012017-11-10 08:42:54 +00004353requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004354run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004355 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004356 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004357 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004358 0 \
4359 -s "Read from client: 1 bytes read"
4360
Hanno Becker8501f982017-11-10 08:59:04 +00004361requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004362run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004363 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004364 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004365 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004366 0 \
4367 -s "Read from client: 1 bytes read"
4368
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004369run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004370 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004371 "$P_CLI request_size=1 force_version=tls1_2 \
4372 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4373 0 \
4374 -s "Read from client: 1 bytes read"
4375
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004376run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004377 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004378 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004379 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004380 0 \
4381 -s "Read from client: 1 bytes read"
4382
Hanno Becker32c55012017-11-10 08:42:54 +00004383requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004384run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004385 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004386 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004387 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004388 0 \
4389 -s "Read from client: 1 bytes read"
4390
Hanno Becker8501f982017-11-10 08:59:04 +00004391requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004392run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004393 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004394 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004395 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004396 0 \
4397 -s "Read from client: 1 bytes read"
4398
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004399run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004400 "$P_SRV" \
4401 "$P_CLI request_size=1 force_version=tls1_2 \
4402 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4403 0 \
4404 -s "Read from client: 1 bytes read"
4405
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004406run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004407 "$P_SRV" \
4408 "$P_CLI request_size=1 force_version=tls1_2 \
4409 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4410 0 \
4411 -s "Read from client: 1 bytes read"
4412
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004413# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004414
4415requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004416run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004417 "$P_SRV dtls=1 force_version=dtls1" \
4418 "$P_CLI dtls=1 request_size=1 \
4419 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4420 0 \
4421 -s "Read from client: 1 bytes read"
4422
4423requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004424run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004425 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4426 "$P_CLI dtls=1 request_size=1 \
4427 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4428 0 \
4429 -s "Read from client: 1 bytes read"
4430
4431requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4432requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004433run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004434 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4435 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004436 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4437 0 \
4438 -s "Read from client: 1 bytes read"
4439
4440requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4441requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004442run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004443 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004444 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004445 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004446 0 \
4447 -s "Read from client: 1 bytes read"
4448
4449requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004450run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004451 "$P_SRV dtls=1 force_version=dtls1_2" \
4452 "$P_CLI dtls=1 request_size=1 \
4453 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4454 0 \
4455 -s "Read from client: 1 bytes read"
4456
4457requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004458run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004459 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004460 "$P_CLI dtls=1 request_size=1 \
4461 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4462 0 \
4463 -s "Read from client: 1 bytes read"
4464
4465requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4466requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004467run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004468 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004469 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004470 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004471 0 \
4472 -s "Read from client: 1 bytes read"
4473
4474requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4475requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004476run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004477 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004478 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004479 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004480 0 \
4481 -s "Read from client: 1 bytes read"
4482
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004483# Tests for small server packets
4484
4485requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4486run_test "Small server packet SSLv3 BlockCipher" \
4487 "$P_SRV response_size=1 min_version=ssl3" \
4488 "$P_CLI force_version=ssl3 \
4489 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4490 0 \
4491 -c "Read from server: 1 bytes read"
4492
4493requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4494run_test "Small server packet SSLv3 StreamCipher" \
4495 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4496 "$P_CLI force_version=ssl3 \
4497 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4498 0 \
4499 -c "Read from server: 1 bytes read"
4500
4501run_test "Small server packet TLS 1.0 BlockCipher" \
4502 "$P_SRV response_size=1" \
4503 "$P_CLI force_version=tls1 \
4504 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4505 0 \
4506 -c "Read from server: 1 bytes read"
4507
4508run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4509 "$P_SRV response_size=1" \
4510 "$P_CLI force_version=tls1 etm=0 \
4511 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4512 0 \
4513 -c "Read from server: 1 bytes read"
4514
4515requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4516run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4517 "$P_SRV response_size=1 trunc_hmac=1" \
4518 "$P_CLI force_version=tls1 \
4519 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4520 0 \
4521 -c "Read from server: 1 bytes read"
4522
4523requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4524run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4525 "$P_SRV response_size=1 trunc_hmac=1" \
4526 "$P_CLI force_version=tls1 \
4527 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4528 0 \
4529 -c "Read from server: 1 bytes read"
4530
4531run_test "Small server packet TLS 1.0 StreamCipher" \
4532 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4533 "$P_CLI force_version=tls1 \
4534 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4535 0 \
4536 -c "Read from server: 1 bytes read"
4537
4538run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4539 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4540 "$P_CLI force_version=tls1 \
4541 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4542 0 \
4543 -c "Read from server: 1 bytes read"
4544
4545requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4546run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4547 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4548 "$P_CLI force_version=tls1 \
4549 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4550 0 \
4551 -c "Read from server: 1 bytes read"
4552
4553requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4554run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4555 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4556 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4557 trunc_hmac=1 etm=0" \
4558 0 \
4559 -c "Read from server: 1 bytes read"
4560
4561run_test "Small server packet TLS 1.1 BlockCipher" \
4562 "$P_SRV response_size=1" \
4563 "$P_CLI force_version=tls1_1 \
4564 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4565 0 \
4566 -c "Read from server: 1 bytes read"
4567
4568run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4569 "$P_SRV response_size=1" \
4570 "$P_CLI force_version=tls1_1 \
4571 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4572 0 \
4573 -c "Read from server: 1 bytes read"
4574
4575requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4576run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4577 "$P_SRV response_size=1 trunc_hmac=1" \
4578 "$P_CLI force_version=tls1_1 \
4579 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4580 0 \
4581 -c "Read from server: 1 bytes read"
4582
4583requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4584run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4585 "$P_SRV response_size=1 trunc_hmac=1" \
4586 "$P_CLI force_version=tls1_1 \
4587 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4588 0 \
4589 -c "Read from server: 1 bytes read"
4590
4591run_test "Small server packet TLS 1.1 StreamCipher" \
4592 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4593 "$P_CLI force_version=tls1_1 \
4594 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4595 0 \
4596 -c "Read from server: 1 bytes read"
4597
4598run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4599 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4600 "$P_CLI force_version=tls1_1 \
4601 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4602 0 \
4603 -c "Read from server: 1 bytes read"
4604
4605requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4606run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4607 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4608 "$P_CLI force_version=tls1_1 \
4609 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4610 0 \
4611 -c "Read from server: 1 bytes read"
4612
4613requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4614run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4615 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4616 "$P_CLI force_version=tls1_1 \
4617 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4618 0 \
4619 -c "Read from server: 1 bytes read"
4620
4621run_test "Small server packet TLS 1.2 BlockCipher" \
4622 "$P_SRV response_size=1" \
4623 "$P_CLI force_version=tls1_2 \
4624 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4625 0 \
4626 -c "Read from server: 1 bytes read"
4627
4628run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4629 "$P_SRV response_size=1" \
4630 "$P_CLI force_version=tls1_2 \
4631 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4632 0 \
4633 -c "Read from server: 1 bytes read"
4634
4635run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4636 "$P_SRV response_size=1" \
4637 "$P_CLI force_version=tls1_2 \
4638 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4639 0 \
4640 -c "Read from server: 1 bytes read"
4641
4642requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4643run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4644 "$P_SRV response_size=1 trunc_hmac=1" \
4645 "$P_CLI force_version=tls1_2 \
4646 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4647 0 \
4648 -c "Read from server: 1 bytes read"
4649
4650requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4651run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4652 "$P_SRV response_size=1 trunc_hmac=1" \
4653 "$P_CLI force_version=tls1_2 \
4654 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4655 0 \
4656 -c "Read from server: 1 bytes read"
4657
4658run_test "Small server packet TLS 1.2 StreamCipher" \
4659 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4660 "$P_CLI force_version=tls1_2 \
4661 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4662 0 \
4663 -c "Read from server: 1 bytes read"
4664
4665run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4666 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4667 "$P_CLI force_version=tls1_2 \
4668 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4669 0 \
4670 -c "Read from server: 1 bytes read"
4671
4672requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4673run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4674 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4675 "$P_CLI force_version=tls1_2 \
4676 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4677 0 \
4678 -c "Read from server: 1 bytes read"
4679
4680requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4681run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4682 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4683 "$P_CLI force_version=tls1_2 \
4684 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4685 0 \
4686 -c "Read from server: 1 bytes read"
4687
4688run_test "Small server packet TLS 1.2 AEAD" \
4689 "$P_SRV response_size=1" \
4690 "$P_CLI force_version=tls1_2 \
4691 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4692 0 \
4693 -c "Read from server: 1 bytes read"
4694
4695run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4696 "$P_SRV response_size=1" \
4697 "$P_CLI force_version=tls1_2 \
4698 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4699 0 \
4700 -c "Read from server: 1 bytes read"
4701
4702# Tests for small server packets in DTLS
4703
4704requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4705run_test "Small server packet DTLS 1.0" \
4706 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4707 "$P_CLI dtls=1 \
4708 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4709 0 \
4710 -c "Read from server: 1 bytes read"
4711
4712requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4713run_test "Small server packet DTLS 1.0, without EtM" \
4714 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4715 "$P_CLI dtls=1 \
4716 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4717 0 \
4718 -c "Read from server: 1 bytes read"
4719
4720requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4721requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4722run_test "Small server packet DTLS 1.0, truncated hmac" \
4723 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4724 "$P_CLI dtls=1 trunc_hmac=1 \
4725 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4726 0 \
4727 -c "Read from server: 1 bytes read"
4728
4729requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4730requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4731run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4732 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4733 "$P_CLI dtls=1 \
4734 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4735 0 \
4736 -c "Read from server: 1 bytes read"
4737
4738requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4739run_test "Small server packet DTLS 1.2" \
4740 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4741 "$P_CLI dtls=1 \
4742 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4743 0 \
4744 -c "Read from server: 1 bytes read"
4745
4746requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4747run_test "Small server packet DTLS 1.2, without EtM" \
4748 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4749 "$P_CLI dtls=1 \
4750 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4751 0 \
4752 -c "Read from server: 1 bytes read"
4753
4754requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4755requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4756run_test "Small server packet DTLS 1.2, truncated hmac" \
4757 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4758 "$P_CLI dtls=1 \
4759 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4760 0 \
4761 -c "Read from server: 1 bytes read"
4762
4763requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4764requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4765run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4766 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4767 "$P_CLI dtls=1 \
4768 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4769 0 \
4770 -c "Read from server: 1 bytes read"
4771
Janos Follath00efff72016-05-06 13:48:23 +01004772# A test for extensions in SSLv3
4773
4774requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4775run_test "SSLv3 with extensions, server side" \
4776 "$P_SRV min_version=ssl3 debug_level=3" \
4777 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4778 0 \
4779 -S "dumping 'client hello extensions'" \
4780 -S "server hello, total extension length:"
4781
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004782# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004783
Angus Grattonc4dd0732018-04-11 16:28:39 +10004784# How many fragments do we expect to write $1 bytes?
4785fragments_for_write() {
4786 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4787}
4788
Janos Follathe2681a42016-03-07 15:57:05 +00004789requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004790run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004791 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004792 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004793 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4794 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004795 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4796 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004797
Janos Follathe2681a42016-03-07 15:57:05 +00004798requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004799run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004800 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004801 "$P_CLI request_size=16384 force_version=ssl3 \
4802 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4803 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004804 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4805 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004806
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004807run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004808 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004809 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004810 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4811 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004812 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4813 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004814
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004815run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004816 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004817 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4818 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4819 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004820 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004821
Hanno Becker32c55012017-11-10 08:42:54 +00004822requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004823run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004824 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004825 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004826 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
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
Hanno Becker32c55012017-11-10 08:42:54 +00004831requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004832run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004833 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004834 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004835 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004836 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004837 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004838
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004839run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004840 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004841 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004842 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4843 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004844 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004845
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004846run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004847 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4848 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004849 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004850 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004851 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004852
4853requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004854run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004855 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004856 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004857 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004858 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004859 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004860
Hanno Becker278fc7a2017-11-10 09:16:28 +00004861requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004862run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004863 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004864 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004865 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004866 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 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004871 "$P_SRV" \
4872 "$P_CLI request_size=16384 force_version=tls1_1 \
4873 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4874 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
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004878run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004879 "$P_SRV" \
4880 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4881 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004882 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004883 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004884
Hanno Becker32c55012017-11-10 08:42:54 +00004885requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004886run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004887 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004888 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004889 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004890 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004891 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004892
Hanno Becker32c55012017-11-10 08:42:54 +00004893requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004894run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004895 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004896 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004897 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004898 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004899 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004900
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004901run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004902 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4903 "$P_CLI request_size=16384 force_version=tls1_1 \
4904 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4905 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004906 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4907 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004908
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004909run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004910 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004911 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004912 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004913 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004914 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4915 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004916
Hanno Becker278fc7a2017-11-10 09:16:28 +00004917requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004918run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004919 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004920 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004921 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004922 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004923 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004924
Hanno Becker278fc7a2017-11-10 09:16:28 +00004925requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004926run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004927 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004928 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004929 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004930 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004931 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4932 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004933
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004934run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004935 "$P_SRV" \
4936 "$P_CLI request_size=16384 force_version=tls1_2 \
4937 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4938 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004939 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4940 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004941
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004942run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004943 "$P_SRV" \
4944 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4945 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4946 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004947 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004948
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004949run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004950 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004951 "$P_CLI request_size=16384 force_version=tls1_2 \
4952 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004953 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004954 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4955 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004956
Hanno Becker32c55012017-11-10 08:42:54 +00004957requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004958run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004959 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004960 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004961 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004962 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004963 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004964
Hanno Becker278fc7a2017-11-10 09:16:28 +00004965requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004966run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004967 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004968 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004969 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004970 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004971 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4972 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004973
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004974run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004975 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004976 "$P_CLI request_size=16384 force_version=tls1_2 \
4977 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4978 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004979 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4980 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004981
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004982run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004983 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004984 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004985 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4986 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004987 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004988
Hanno Becker32c55012017-11-10 08:42:54 +00004989requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004990run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004991 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004992 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004993 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004994 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004995 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004996
Hanno Becker278fc7a2017-11-10 09:16:28 +00004997requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004998run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004999 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005000 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005001 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005002 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005003 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5004 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005005
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005006run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005007 "$P_SRV" \
5008 "$P_CLI request_size=16384 force_version=tls1_2 \
5009 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5010 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005011 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5012 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005013
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005014run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005015 "$P_SRV" \
5016 "$P_CLI request_size=16384 force_version=tls1_2 \
5017 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5018 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005019 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5020 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005021
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005022# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005023requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5024run_test "Large server packet SSLv3 StreamCipher" \
5025 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5026 "$P_CLI force_version=ssl3 \
5027 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5028 0 \
5029 -c "Read from server: 16384 bytes read"
5030
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04005031# Checking next 4 tests logs for 1n-1 split against BEAST too
5032requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5033run_test "Large server packet SSLv3 BlockCipher" \
5034 "$P_SRV response_size=16384 min_version=ssl3" \
5035 "$P_CLI force_version=ssl3 recsplit=0 \
5036 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5037 0 \
5038 -c "Read from server: 1 bytes read"\
5039 -c "16383 bytes read"\
5040 -C "Read from server: 16384 bytes read"
5041
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005042run_test "Large server packet TLS 1.0 BlockCipher" \
5043 "$P_SRV response_size=16384" \
5044 "$P_CLI force_version=tls1 recsplit=0 \
5045 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5046 0 \
5047 -c "Read from server: 1 bytes read"\
5048 -c "16383 bytes read"\
5049 -C "Read from server: 16384 bytes read"
5050
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005051run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5052 "$P_SRV response_size=16384" \
5053 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5054 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5055 0 \
5056 -c "Read from server: 1 bytes read"\
5057 -c "16383 bytes read"\
5058 -C "Read from server: 16384 bytes read"
5059
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005060requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5061run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5062 "$P_SRV response_size=16384" \
5063 "$P_CLI force_version=tls1 recsplit=0 \
5064 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5065 trunc_hmac=1" \
5066 0 \
5067 -c "Read from server: 1 bytes read"\
5068 -c "16383 bytes read"\
5069 -C "Read from server: 16384 bytes read"
5070
5071requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5072run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5073 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5074 "$P_CLI force_version=tls1 \
5075 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5076 trunc_hmac=1" \
5077 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005078 -s "16384 bytes written in 1 fragments" \
5079 -c "Read from server: 16384 bytes read"
5080
5081run_test "Large server packet TLS 1.0 StreamCipher" \
5082 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5083 "$P_CLI force_version=tls1 \
5084 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5085 0 \
5086 -s "16384 bytes written in 1 fragments" \
5087 -c "Read from server: 16384 bytes read"
5088
5089run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5090 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5091 "$P_CLI force_version=tls1 \
5092 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5093 0 \
5094 -s "16384 bytes written in 1 fragments" \
5095 -c "Read from server: 16384 bytes read"
5096
5097requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5098run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5099 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5100 "$P_CLI force_version=tls1 \
5101 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5102 0 \
5103 -s "16384 bytes written in 1 fragments" \
5104 -c "Read from server: 16384 bytes read"
5105
5106requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5107run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5108 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5109 "$P_CLI force_version=tls1 \
5110 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5111 0 \
5112 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005113 -c "Read from server: 16384 bytes read"
5114
5115run_test "Large server packet TLS 1.1 BlockCipher" \
5116 "$P_SRV response_size=16384" \
5117 "$P_CLI force_version=tls1_1 \
5118 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5119 0 \
5120 -c "Read from server: 16384 bytes read"
5121
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005122run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5123 "$P_SRV response_size=16384" \
5124 "$P_CLI force_version=tls1_1 etm=0 \
5125 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005126 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005127 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005128 -c "Read from server: 16384 bytes read"
5129
5130requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5131run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5132 "$P_SRV response_size=16384" \
5133 "$P_CLI force_version=tls1_1 \
5134 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5135 trunc_hmac=1" \
5136 0 \
5137 -c "Read from server: 16384 bytes read"
5138
5139requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005140run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5141 "$P_SRV response_size=16384 trunc_hmac=1" \
5142 "$P_CLI force_version=tls1_1 \
5143 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5144 0 \
5145 -s "16384 bytes written in 1 fragments" \
5146 -c "Read from server: 16384 bytes read"
5147
5148run_test "Large server packet TLS 1.1 StreamCipher" \
5149 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5150 "$P_CLI force_version=tls1_1 \
5151 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5152 0 \
5153 -c "Read from server: 16384 bytes read"
5154
5155run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5156 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5157 "$P_CLI force_version=tls1_1 \
5158 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5159 0 \
5160 -s "16384 bytes written in 1 fragments" \
5161 -c "Read from server: 16384 bytes read"
5162
5163requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005164run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5165 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5166 "$P_CLI force_version=tls1_1 \
5167 force_ciphersuite=TLS-RSA-WITH-RC4-128-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.1 StreamCipher, without EtM, truncated MAC" \
5173 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5174 "$P_CLI force_version=tls1_1 \
5175 force_ciphersuite=TLS-RSA-WITH-RC4-128-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 BlockCipher" \
5181 "$P_SRV response_size=16384" \
5182 "$P_CLI force_version=tls1_2 \
5183 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5184 0 \
5185 -c "Read from server: 16384 bytes read"
5186
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005187run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5188 "$P_SRV response_size=16384" \
5189 "$P_CLI force_version=tls1_2 etm=0 \
5190 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5191 0 \
5192 -s "16384 bytes written in 1 fragments" \
5193 -c "Read from server: 16384 bytes read"
5194
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005195run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5196 "$P_SRV response_size=16384" \
5197 "$P_CLI force_version=tls1_2 \
5198 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5199 0 \
5200 -c "Read from server: 16384 bytes read"
5201
5202requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5203run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5204 "$P_SRV response_size=16384" \
5205 "$P_CLI force_version=tls1_2 \
5206 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5207 trunc_hmac=1" \
5208 0 \
5209 -c "Read from server: 16384 bytes read"
5210
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005211run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5212 "$P_SRV response_size=16384 trunc_hmac=1" \
5213 "$P_CLI force_version=tls1_2 \
5214 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5215 0 \
5216 -s "16384 bytes written in 1 fragments" \
5217 -c "Read from server: 16384 bytes read"
5218
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005219run_test "Large server packet TLS 1.2 StreamCipher" \
5220 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5221 "$P_CLI force_version=tls1_2 \
5222 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5223 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005224 -s "16384 bytes written in 1 fragments" \
5225 -c "Read from server: 16384 bytes read"
5226
5227run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5228 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5229 "$P_CLI force_version=tls1_2 \
5230 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5231 0 \
5232 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005233 -c "Read from server: 16384 bytes read"
5234
5235requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5236run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5237 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5238 "$P_CLI force_version=tls1_2 \
5239 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5240 trunc_hmac=1" \
5241 0 \
5242 -c "Read from server: 16384 bytes read"
5243
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005244requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5245run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5246 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5247 "$P_CLI force_version=tls1_2 \
5248 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5249 0 \
5250 -s "16384 bytes written in 1 fragments" \
5251 -c "Read from server: 16384 bytes read"
5252
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005253run_test "Large server packet TLS 1.2 AEAD" \
5254 "$P_SRV response_size=16384" \
5255 "$P_CLI force_version=tls1_2 \
5256 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5257 0 \
5258 -c "Read from server: 16384 bytes read"
5259
5260run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5261 "$P_SRV response_size=16384" \
5262 "$P_CLI force_version=tls1_2 \
5263 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5264 0 \
5265 -c "Read from server: 16384 bytes read"
5266
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005267# Tests for restartable ECC
5268
5269requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5270run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005271 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005272 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005273 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005274 debug_level=1" \
5275 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005276 -C "x509_verify_cert.*4b00" \
5277 -C "mbedtls_pk_verify.*4b00" \
5278 -C "mbedtls_ecdh_make_public.*4b00" \
5279 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005280
5281requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5282run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005283 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005284 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005285 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005286 debug_level=1 ec_max_ops=0" \
5287 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005288 -C "x509_verify_cert.*4b00" \
5289 -C "mbedtls_pk_verify.*4b00" \
5290 -C "mbedtls_ecdh_make_public.*4b00" \
5291 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005292
5293requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5294run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005295 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005296 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005297 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005298 debug_level=1 ec_max_ops=65535" \
5299 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005300 -C "x509_verify_cert.*4b00" \
5301 -C "mbedtls_pk_verify.*4b00" \
5302 -C "mbedtls_ecdh_make_public.*4b00" \
5303 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005304
5305requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5306run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005307 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005308 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005309 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005310 debug_level=1 ec_max_ops=1000" \
5311 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005312 -c "x509_verify_cert.*4b00" \
5313 -c "mbedtls_pk_verify.*4b00" \
5314 -c "mbedtls_ecdh_make_public.*4b00" \
5315 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005316
5317requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005318run_test "EC restart: TLS, max_ops=1000, badsign" \
5319 "$P_SRV auth_mode=required \
5320 crt_file=data_files/server5-badsign.crt \
5321 key_file=data_files/server5.key" \
5322 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5323 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5324 debug_level=1 ec_max_ops=1000" \
5325 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005326 -c "x509_verify_cert.*4b00" \
5327 -C "mbedtls_pk_verify.*4b00" \
5328 -C "mbedtls_ecdh_make_public.*4b00" \
5329 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005330 -c "! The certificate is not correctly signed by the trusted CA" \
5331 -c "! mbedtls_ssl_handshake returned" \
5332 -c "X509 - Certificate verification failed"
5333
5334requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5335run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5336 "$P_SRV auth_mode=required \
5337 crt_file=data_files/server5-badsign.crt \
5338 key_file=data_files/server5.key" \
5339 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5340 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5341 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5342 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005343 -c "x509_verify_cert.*4b00" \
5344 -c "mbedtls_pk_verify.*4b00" \
5345 -c "mbedtls_ecdh_make_public.*4b00" \
5346 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005347 -c "! The certificate is not correctly signed by the trusted CA" \
5348 -C "! mbedtls_ssl_handshake returned" \
5349 -C "X509 - Certificate verification failed"
5350
5351requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5352run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5353 "$P_SRV auth_mode=required \
5354 crt_file=data_files/server5-badsign.crt \
5355 key_file=data_files/server5.key" \
5356 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5357 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5358 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5359 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005360 -C "x509_verify_cert.*4b00" \
5361 -c "mbedtls_pk_verify.*4b00" \
5362 -c "mbedtls_ecdh_make_public.*4b00" \
5363 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005364 -C "! The certificate is not correctly signed by the trusted CA" \
5365 -C "! mbedtls_ssl_handshake returned" \
5366 -C "X509 - Certificate verification failed"
5367
5368requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005369run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005370 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005371 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005372 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005373 dtls=1 debug_level=1 ec_max_ops=1000" \
5374 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005375 -c "x509_verify_cert.*4b00" \
5376 -c "mbedtls_pk_verify.*4b00" \
5377 -c "mbedtls_ecdh_make_public.*4b00" \
5378 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005379
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005380requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5381run_test "EC restart: TLS, max_ops=1000 no client auth" \
5382 "$P_SRV" \
5383 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5384 debug_level=1 ec_max_ops=1000" \
5385 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005386 -c "x509_verify_cert.*4b00" \
5387 -c "mbedtls_pk_verify.*4b00" \
5388 -c "mbedtls_ecdh_make_public.*4b00" \
5389 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005390
5391requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5392run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5393 "$P_SRV psk=abc123" \
5394 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5395 psk=abc123 debug_level=1 ec_max_ops=1000" \
5396 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005397 -C "x509_verify_cert.*4b00" \
5398 -C "mbedtls_pk_verify.*4b00" \
5399 -C "mbedtls_ecdh_make_public.*4b00" \
5400 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005401
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005402# Tests of asynchronous private key support in SSL
5403
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005404requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005405run_test "SSL async private: sign, delay=0" \
5406 "$P_SRV \
5407 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005408 "$P_CLI" \
5409 0 \
5410 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005411 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005412
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005413requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005414run_test "SSL async private: sign, delay=1" \
5415 "$P_SRV \
5416 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005417 "$P_CLI" \
5418 0 \
5419 -s "Async sign callback: using key slot " \
5420 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005421 -s "Async resume (slot [0-9]): sign done, status=0"
5422
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005423requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5424run_test "SSL async private: sign, delay=2" \
5425 "$P_SRV \
5426 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5427 "$P_CLI" \
5428 0 \
5429 -s "Async sign callback: using key slot " \
5430 -U "Async sign callback: using key slot " \
5431 -s "Async resume (slot [0-9]): call 1 more times." \
5432 -s "Async resume (slot [0-9]): call 0 more times." \
5433 -s "Async resume (slot [0-9]): sign done, status=0"
5434
Gilles Peskined3268832018-04-26 06:23:59 +02005435# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5436# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5437requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5438requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5439run_test "SSL async private: sign, RSA, TLS 1.1" \
5440 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5441 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5442 "$P_CLI force_version=tls1_1" \
5443 0 \
5444 -s "Async sign callback: using key slot " \
5445 -s "Async resume (slot [0-9]): sign done, status=0"
5446
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005447requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005448run_test "SSL async private: sign, SNI" \
5449 "$P_SRV debug_level=3 \
5450 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5451 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5452 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5453 "$P_CLI server_name=polarssl.example" \
5454 0 \
5455 -s "Async sign callback: using key slot " \
5456 -s "Async resume (slot [0-9]): sign done, status=0" \
5457 -s "parse ServerName extension" \
5458 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5459 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5460
5461requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005462run_test "SSL async private: decrypt, delay=0" \
5463 "$P_SRV \
5464 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5465 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5466 0 \
5467 -s "Async decrypt callback: using key slot " \
5468 -s "Async resume (slot [0-9]): decrypt done, status=0"
5469
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005470requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005471run_test "SSL async private: decrypt, delay=1" \
5472 "$P_SRV \
5473 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5474 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5475 0 \
5476 -s "Async decrypt callback: using key slot " \
5477 -s "Async resume (slot [0-9]): call 0 more times." \
5478 -s "Async resume (slot [0-9]): decrypt done, status=0"
5479
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005480requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005481run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5482 "$P_SRV psk=abc123 \
5483 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5484 "$P_CLI psk=abc123 \
5485 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5486 0 \
5487 -s "Async decrypt callback: using key slot " \
5488 -s "Async resume (slot [0-9]): decrypt done, status=0"
5489
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005490requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005491run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5492 "$P_SRV psk=abc123 \
5493 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5494 "$P_CLI psk=abc123 \
5495 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5496 0 \
5497 -s "Async decrypt callback: using key slot " \
5498 -s "Async resume (slot [0-9]): call 0 more times." \
5499 -s "Async resume (slot [0-9]): decrypt done, status=0"
5500
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005501requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005502run_test "SSL async private: sign callback not present" \
5503 "$P_SRV \
5504 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5505 "$P_CLI; [ \$? -eq 1 ] &&
5506 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5507 0 \
5508 -S "Async sign callback" \
5509 -s "! mbedtls_ssl_handshake returned" \
5510 -s "The own private key or pre-shared key is not set, but needed" \
5511 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5512 -s "Successful connection"
5513
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005514requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005515run_test "SSL async private: decrypt callback not present" \
5516 "$P_SRV debug_level=1 \
5517 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5518 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5519 [ \$? -eq 1 ] && $P_CLI" \
5520 0 \
5521 -S "Async decrypt callback" \
5522 -s "! mbedtls_ssl_handshake returned" \
5523 -s "got no RSA private key" \
5524 -s "Async resume (slot [0-9]): sign done, status=0" \
5525 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005526
5527# key1: ECDSA, key2: RSA; use key1 from slot 0
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: slot 0 used with key1" \
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-ECDSA-WITH-AES-128-CBC-SHA256" \
5535 0 \
5536 -s "Async sign callback: using key slot 0," \
5537 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005538 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005539
5540# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005541requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005542run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005543 "$P_SRV \
5544 async_operations=s async_private_delay2=1 \
5545 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5546 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005547 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5548 0 \
5549 -s "Async sign callback: using key slot 0," \
5550 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005551 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005552
5553# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005554requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005555run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005556 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005557 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005558 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5559 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005560 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5561 0 \
5562 -s "Async sign callback: using key slot 1," \
5563 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005564 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005565
5566# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005567requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005568run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005569 "$P_SRV \
5570 async_operations=s async_private_delay1=1 \
5571 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5572 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005573 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5574 0 \
5575 -s "Async sign callback: no key matches this certificate."
5576
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005577requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005578run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005579 "$P_SRV \
5580 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5581 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005582 "$P_CLI" \
5583 1 \
5584 -s "Async sign callback: injected error" \
5585 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005586 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005587 -s "! mbedtls_ssl_handshake returned"
5588
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005589requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005590run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005591 "$P_SRV \
5592 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5593 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005594 "$P_CLI" \
5595 1 \
5596 -s "Async sign callback: using key slot " \
5597 -S "Async resume" \
5598 -s "Async cancel"
5599
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005600requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005601run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005602 "$P_SRV \
5603 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5604 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005605 "$P_CLI" \
5606 1 \
5607 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005608 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005609 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005610 -s "! mbedtls_ssl_handshake returned"
5611
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005612requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005613run_test "SSL async private: decrypt, error in start" \
5614 "$P_SRV \
5615 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5616 async_private_error=1" \
5617 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5618 1 \
5619 -s "Async decrypt callback: injected error" \
5620 -S "Async resume" \
5621 -S "Async cancel" \
5622 -s "! mbedtls_ssl_handshake returned"
5623
5624requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5625run_test "SSL async private: decrypt, cancel after start" \
5626 "$P_SRV \
5627 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5628 async_private_error=2" \
5629 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5630 1 \
5631 -s "Async decrypt callback: using key slot " \
5632 -S "Async resume" \
5633 -s "Async cancel"
5634
5635requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5636run_test "SSL async private: decrypt, error in resume" \
5637 "$P_SRV \
5638 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5639 async_private_error=3" \
5640 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5641 1 \
5642 -s "Async decrypt callback: using key slot " \
5643 -s "Async resume callback: decrypt done but injected error" \
5644 -S "Async cancel" \
5645 -s "! mbedtls_ssl_handshake returned"
5646
5647requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005648run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005649 "$P_SRV \
5650 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5651 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005652 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5653 0 \
5654 -s "Async cancel" \
5655 -s "! mbedtls_ssl_handshake returned" \
5656 -s "Async resume" \
5657 -s "Successful connection"
5658
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005659requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005660run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005661 "$P_SRV \
5662 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5663 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005664 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5665 0 \
5666 -s "! mbedtls_ssl_handshake returned" \
5667 -s "Async resume" \
5668 -s "Successful connection"
5669
5670# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005671requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005672run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005673 "$P_SRV \
5674 async_operations=s async_private_delay1=1 async_private_error=-2 \
5675 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5676 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005677 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5678 [ \$? -eq 1 ] &&
5679 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5680 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005681 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005682 -S "Async resume" \
5683 -s "Async cancel" \
5684 -s "! mbedtls_ssl_handshake returned" \
5685 -s "Async sign callback: no key matches this certificate." \
5686 -s "Successful connection"
5687
5688# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005689requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005690run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005691 "$P_SRV \
5692 async_operations=s async_private_delay1=1 async_private_error=-3 \
5693 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5694 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005695 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5696 [ \$? -eq 1 ] &&
5697 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5698 0 \
5699 -s "Async resume" \
5700 -s "! mbedtls_ssl_handshake returned" \
5701 -s "Async sign callback: no key matches this certificate." \
5702 -s "Successful connection"
5703
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005704requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005705requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005706run_test "SSL async private: renegotiation: client-initiated; sign" \
5707 "$P_SRV \
5708 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005709 exchanges=2 renegotiation=1" \
5710 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5711 0 \
5712 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005713 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005714
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005715requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005716requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005717run_test "SSL async private: renegotiation: server-initiated; sign" \
5718 "$P_SRV \
5719 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005720 exchanges=2 renegotiation=1 renegotiate=1" \
5721 "$P_CLI exchanges=2 renegotiation=1" \
5722 0 \
5723 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005724 -s "Async resume (slot [0-9]): sign done, status=0"
5725
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005726requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005727requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5728run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5729 "$P_SRV \
5730 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5731 exchanges=2 renegotiation=1" \
5732 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5733 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5734 0 \
5735 -s "Async decrypt callback: using key slot " \
5736 -s "Async resume (slot [0-9]): decrypt done, status=0"
5737
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005738requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005739requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5740run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5741 "$P_SRV \
5742 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5743 exchanges=2 renegotiation=1 renegotiate=1" \
5744 "$P_CLI exchanges=2 renegotiation=1 \
5745 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5746 0 \
5747 -s "Async decrypt callback: using key slot " \
5748 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005749
Ron Eldor58093c82018-06-28 13:22:05 +03005750# Tests for ECC extensions (rfc 4492)
5751
Ron Eldor643df7c2018-06-28 16:17:00 +03005752requires_config_enabled MBEDTLS_AES_C
5753requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5754requires_config_enabled MBEDTLS_SHA256_C
5755requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005756run_test "Force a non ECC ciphersuite in the client side" \
5757 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005758 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005759 0 \
5760 -C "client hello, adding supported_elliptic_curves extension" \
5761 -C "client hello, adding supported_point_formats extension" \
5762 -S "found supported elliptic curves extension" \
5763 -S "found supported point formats extension"
5764
Ron Eldor643df7c2018-06-28 16:17:00 +03005765requires_config_enabled MBEDTLS_AES_C
5766requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5767requires_config_enabled MBEDTLS_SHA256_C
5768requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005769run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005770 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005771 "$P_CLI debug_level=3" \
5772 0 \
5773 -C "found supported_point_formats extension" \
5774 -S "server hello, supported_point_formats extension"
5775
Ron Eldor643df7c2018-06-28 16:17:00 +03005776requires_config_enabled MBEDTLS_AES_C
5777requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5778requires_config_enabled MBEDTLS_SHA256_C
5779requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005780run_test "Force an ECC ciphersuite in the client side" \
5781 "$P_SRV debug_level=3" \
5782 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5783 0 \
5784 -c "client hello, adding supported_elliptic_curves extension" \
5785 -c "client hello, adding supported_point_formats extension" \
5786 -s "found supported elliptic curves extension" \
5787 -s "found supported point formats extension"
5788
Ron Eldor643df7c2018-06-28 16:17:00 +03005789requires_config_enabled MBEDTLS_AES_C
5790requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5791requires_config_enabled MBEDTLS_SHA256_C
5792requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005793run_test "Force an ECC ciphersuite in the server side" \
5794 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5795 "$P_CLI debug_level=3" \
5796 0 \
5797 -c "found supported_point_formats extension" \
5798 -s "server hello, supported_point_formats extension"
5799
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005800# Tests for DTLS HelloVerifyRequest
5801
5802run_test "DTLS cookie: enabled" \
5803 "$P_SRV dtls=1 debug_level=2" \
5804 "$P_CLI dtls=1 debug_level=2" \
5805 0 \
5806 -s "cookie verification failed" \
5807 -s "cookie verification passed" \
5808 -S "cookie verification skipped" \
5809 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005810 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005811 -S "SSL - The requested feature is not available"
5812
5813run_test "DTLS cookie: disabled" \
5814 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5815 "$P_CLI dtls=1 debug_level=2" \
5816 0 \
5817 -S "cookie verification failed" \
5818 -S "cookie verification passed" \
5819 -s "cookie verification skipped" \
5820 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005821 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005822 -S "SSL - The requested feature is not available"
5823
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005824run_test "DTLS cookie: default (failing)" \
5825 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5826 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5827 1 \
5828 -s "cookie verification failed" \
5829 -S "cookie verification passed" \
5830 -S "cookie verification skipped" \
5831 -C "received hello verify request" \
5832 -S "hello verification requested" \
5833 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005834
5835requires_ipv6
5836run_test "DTLS cookie: enabled, IPv6" \
5837 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5838 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5839 0 \
5840 -s "cookie verification failed" \
5841 -s "cookie verification passed" \
5842 -S "cookie verification skipped" \
5843 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005844 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005845 -S "SSL - The requested feature is not available"
5846
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005847run_test "DTLS cookie: enabled, nbio" \
5848 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5849 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5850 0 \
5851 -s "cookie verification failed" \
5852 -s "cookie verification passed" \
5853 -S "cookie verification skipped" \
5854 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005855 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005856 -S "SSL - The requested feature is not available"
5857
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005858# Tests for client reconnecting from the same port with DTLS
5859
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005860not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005861run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005862 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5863 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005864 0 \
5865 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005866 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005867 -S "Client initiated reconnection from same port"
5868
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005869not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005870run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005871 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5872 "$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 +02005873 0 \
5874 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005875 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005876 -s "Client initiated reconnection from same port"
5877
Paul Bakker362689d2016-05-13 10:33:25 +01005878not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5879run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005880 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5881 "$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 +02005882 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005883 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005884 -s "Client initiated reconnection from same port"
5885
Paul Bakker362689d2016-05-13 10:33:25 +01005886only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5887run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5888 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5889 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5890 0 \
5891 -S "The operation timed out" \
5892 -s "Client initiated reconnection from same port"
5893
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005894run_test "DTLS client reconnect from same port: no cookies" \
5895 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005896 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5897 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005898 -s "The operation timed out" \
5899 -S "Client initiated reconnection from same port"
5900
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005901run_test "DTLS client reconnect from same port: attacker-injected" \
5902 -p "$P_PXY inject_clihlo=1" \
5903 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5904 "$P_CLI dtls=1 exchanges=2" \
5905 0 \
5906 -s "possible client reconnect from the same port" \
5907 -S "Client initiated reconnection from same port"
5908
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005909# Tests for various cases of client authentication with DTLS
5910# (focused on handshake flows and message parsing)
5911
5912run_test "DTLS client auth: required" \
5913 "$P_SRV dtls=1 auth_mode=required" \
5914 "$P_CLI dtls=1" \
5915 0 \
5916 -s "Verifying peer X.509 certificate... ok"
5917
5918run_test "DTLS client auth: optional, client has no cert" \
5919 "$P_SRV dtls=1 auth_mode=optional" \
5920 "$P_CLI dtls=1 crt_file=none key_file=none" \
5921 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005922 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005923
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005924run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005925 "$P_SRV dtls=1 auth_mode=none" \
5926 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5927 0 \
5928 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005929 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005930
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005931run_test "DTLS wrong PSK: badmac alert" \
5932 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5933 "$P_CLI dtls=1 psk=abc124" \
5934 1 \
5935 -s "SSL - Verification of the message MAC failed" \
5936 -c "SSL - A fatal alert message was received from our peer"
5937
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005938# Tests for receiving fragmented handshake messages with DTLS
5939
5940requires_gnutls
5941run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5942 "$G_SRV -u --mtu 2048 -a" \
5943 "$P_CLI dtls=1 debug_level=2" \
5944 0 \
5945 -C "found fragmented DTLS handshake message" \
5946 -C "error"
5947
5948requires_gnutls
5949run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5950 "$G_SRV -u --mtu 512" \
5951 "$P_CLI dtls=1 debug_level=2" \
5952 0 \
5953 -c "found fragmented DTLS handshake message" \
5954 -C "error"
5955
5956requires_gnutls
5957run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5958 "$G_SRV -u --mtu 128" \
5959 "$P_CLI dtls=1 debug_level=2" \
5960 0 \
5961 -c "found fragmented DTLS handshake message" \
5962 -C "error"
5963
5964requires_gnutls
5965run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5966 "$G_SRV -u --mtu 128" \
5967 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5968 0 \
5969 -c "found fragmented DTLS handshake message" \
5970 -C "error"
5971
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005972requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005973requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005974run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5975 "$G_SRV -u --mtu 256" \
5976 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5977 0 \
5978 -c "found fragmented DTLS handshake message" \
5979 -c "client hello, adding renegotiation extension" \
5980 -c "found renegotiation extension" \
5981 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005982 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005983 -C "error" \
5984 -s "Extra-header:"
5985
5986requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005987requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005988run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5989 "$G_SRV -u --mtu 256" \
5990 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5991 0 \
5992 -c "found fragmented DTLS handshake message" \
5993 -c "client hello, adding renegotiation extension" \
5994 -c "found renegotiation extension" \
5995 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005996 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005997 -C "error" \
5998 -s "Extra-header:"
5999
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006000run_test "DTLS reassembly: no fragmentation (openssl server)" \
6001 "$O_SRV -dtls1 -mtu 2048" \
6002 "$P_CLI dtls=1 debug_level=2" \
6003 0 \
6004 -C "found fragmented DTLS handshake message" \
6005 -C "error"
6006
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006007run_test "DTLS reassembly: some fragmentation (openssl server)" \
6008 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006009 "$P_CLI dtls=1 debug_level=2" \
6010 0 \
6011 -c "found fragmented DTLS handshake message" \
6012 -C "error"
6013
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006014run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006015 "$O_SRV -dtls1 -mtu 256" \
6016 "$P_CLI dtls=1 debug_level=2" \
6017 0 \
6018 -c "found fragmented DTLS handshake message" \
6019 -C "error"
6020
6021run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6022 "$O_SRV -dtls1 -mtu 256" \
6023 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6024 0 \
6025 -c "found fragmented DTLS handshake message" \
6026 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006027
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006028# Tests for sending fragmented handshake messages with DTLS
6029#
6030# Use client auth when we need the client to send large messages,
6031# and use large cert chains on both sides too (the long chains we have all use
6032# both RSA and ECDSA, but ideally we should have long chains with either).
6033# Sizes reached (UDP payload):
6034# - 2037B for server certificate
6035# - 1542B for client certificate
6036# - 1013B for newsessionticket
6037# - all others below 512B
6038# All those tests assume MAX_CONTENT_LEN is at least 2048
6039
6040requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6041requires_config_enabled MBEDTLS_RSA_C
6042requires_config_enabled MBEDTLS_ECDSA_C
6043requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6044run_test "DTLS fragmenting: none (for reference)" \
6045 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6046 crt_file=data_files/server7_int-ca.crt \
6047 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006048 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006049 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006050 "$P_CLI dtls=1 debug_level=2 \
6051 crt_file=data_files/server8_int-ca2.crt \
6052 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006053 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006054 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006055 0 \
6056 -S "found fragmented DTLS handshake message" \
6057 -C "found fragmented DTLS handshake message" \
6058 -C "error"
6059
6060requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6061requires_config_enabled MBEDTLS_RSA_C
6062requires_config_enabled MBEDTLS_ECDSA_C
6063requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006064run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006065 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6066 crt_file=data_files/server7_int-ca.crt \
6067 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006068 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006069 max_frag_len=1024" \
6070 "$P_CLI dtls=1 debug_level=2 \
6071 crt_file=data_files/server8_int-ca2.crt \
6072 key_file=data_files/server8.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 0 \
6076 -S "found fragmented DTLS handshake message" \
6077 -c "found fragmented DTLS handshake message" \
6078 -C "error"
6079
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006080# With the MFL extension, the server has no way of forcing
6081# the client to not exceed a certain MTU; hence, the following
6082# test can't be replicated with an MTU proxy such as the one
6083# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006084requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6085requires_config_enabled MBEDTLS_RSA_C
6086requires_config_enabled MBEDTLS_ECDSA_C
6087requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006088run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006089 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6090 crt_file=data_files/server7_int-ca.crt \
6091 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006092 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006093 max_frag_len=512" \
6094 "$P_CLI dtls=1 debug_level=2 \
6095 crt_file=data_files/server8_int-ca2.crt \
6096 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006097 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006098 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006099 0 \
6100 -S "found fragmented DTLS handshake message" \
6101 -c "found fragmented DTLS handshake message" \
6102 -C "error"
6103
6104requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6105requires_config_enabled MBEDTLS_RSA_C
6106requires_config_enabled MBEDTLS_ECDSA_C
6107requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006108run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006109 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6110 crt_file=data_files/server7_int-ca.crt \
6111 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006112 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006113 max_frag_len=2048" \
6114 "$P_CLI dtls=1 debug_level=2 \
6115 crt_file=data_files/server8_int-ca2.crt \
6116 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006117 hs_timeout=2500-60000 \
6118 max_frag_len=1024" \
6119 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006120 -S "found fragmented DTLS handshake message" \
6121 -c "found fragmented DTLS handshake message" \
6122 -C "error"
6123
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006124# While not required by the standard defining the MFL extension
6125# (according to which it only applies to records, not to datagrams),
6126# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6127# as otherwise there wouldn't be any means to communicate MTU restrictions
6128# to the peer.
6129# The next test checks that no datagrams significantly larger than the
6130# negotiated MFL are sent.
6131requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6132requires_config_enabled MBEDTLS_RSA_C
6133requires_config_enabled MBEDTLS_ECDSA_C
6134requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6135run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006136 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006137 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6138 crt_file=data_files/server7_int-ca.crt \
6139 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006140 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006141 max_frag_len=2048" \
6142 "$P_CLI dtls=1 debug_level=2 \
6143 crt_file=data_files/server8_int-ca2.crt \
6144 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006145 hs_timeout=2500-60000 \
6146 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006147 0 \
6148 -S "found fragmented DTLS handshake message" \
6149 -c "found fragmented DTLS handshake message" \
6150 -C "error"
6151
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006152requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6153requires_config_enabled MBEDTLS_RSA_C
6154requires_config_enabled MBEDTLS_ECDSA_C
6155requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006156run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006157 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6158 crt_file=data_files/server7_int-ca.crt \
6159 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006160 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006161 max_frag_len=2048" \
6162 "$P_CLI dtls=1 debug_level=2 \
6163 crt_file=data_files/server8_int-ca2.crt \
6164 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006165 hs_timeout=2500-60000 \
6166 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006167 0 \
6168 -s "found fragmented DTLS handshake message" \
6169 -c "found fragmented DTLS handshake message" \
6170 -C "error"
6171
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006172# While not required by the standard defining the MFL extension
6173# (according to which it only applies to records, not to datagrams),
6174# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6175# as otherwise there wouldn't be any means to communicate MTU restrictions
6176# to the peer.
6177# The next test checks that no datagrams significantly larger than the
6178# negotiated MFL are sent.
6179requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6180requires_config_enabled MBEDTLS_RSA_C
6181requires_config_enabled MBEDTLS_ECDSA_C
6182requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6183run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006184 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006185 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6186 crt_file=data_files/server7_int-ca.crt \
6187 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006188 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006189 max_frag_len=2048" \
6190 "$P_CLI dtls=1 debug_level=2 \
6191 crt_file=data_files/server8_int-ca2.crt \
6192 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006193 hs_timeout=2500-60000 \
6194 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006195 0 \
6196 -s "found fragmented DTLS handshake message" \
6197 -c "found fragmented DTLS handshake message" \
6198 -C "error"
6199
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006200requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6201requires_config_enabled MBEDTLS_RSA_C
6202requires_config_enabled MBEDTLS_ECDSA_C
6203run_test "DTLS fragmenting: none (for reference) (MTU)" \
6204 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6205 crt_file=data_files/server7_int-ca.crt \
6206 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006207 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006208 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006209 "$P_CLI dtls=1 debug_level=2 \
6210 crt_file=data_files/server8_int-ca2.crt \
6211 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006212 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006213 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006214 0 \
6215 -S "found fragmented DTLS handshake message" \
6216 -C "found fragmented DTLS handshake message" \
6217 -C "error"
6218
6219requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6220requires_config_enabled MBEDTLS_RSA_C
6221requires_config_enabled MBEDTLS_ECDSA_C
6222run_test "DTLS fragmenting: client (MTU)" \
6223 "$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 Kurek948fe802018-10-05 15:42:44 -04006226 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006227 mtu=4096" \
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 Kurek948fe802018-10-05 15:42:44 -04006231 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006232 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
6238requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6239requires_config_enabled MBEDTLS_RSA_C
6240requires_config_enabled MBEDTLS_ECDSA_C
6241run_test "DTLS fragmenting: server (MTU)" \
6242 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6243 crt_file=data_files/server7_int-ca.crt \
6244 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006245 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006246 mtu=512" \
6247 "$P_CLI dtls=1 debug_level=2 \
6248 crt_file=data_files/server8_int-ca2.crt \
6249 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006250 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006251 mtu=2048" \
6252 0 \
6253 -S "found fragmented DTLS handshake message" \
6254 -c "found fragmented DTLS handshake message" \
6255 -C "error"
6256
6257requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6258requires_config_enabled MBEDTLS_RSA_C
6259requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006260run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006261 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006262 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6263 crt_file=data_files/server7_int-ca.crt \
6264 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006265 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006266 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006267 "$P_CLI dtls=1 debug_level=2 \
6268 crt_file=data_files/server8_int-ca2.crt \
6269 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006270 hs_timeout=2500-60000 \
6271 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006272 0 \
6273 -s "found fragmented DTLS handshake message" \
6274 -c "found fragmented DTLS handshake message" \
6275 -C "error"
6276
Andrzej Kurek77826052018-10-11 07:34:08 -04006277# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006278requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6279requires_config_enabled MBEDTLS_RSA_C
6280requires_config_enabled MBEDTLS_ECDSA_C
6281requires_config_enabled MBEDTLS_SHA256_C
6282requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6283requires_config_enabled MBEDTLS_AES_C
6284requires_config_enabled MBEDTLS_GCM_C
6285run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006286 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006287 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6288 crt_file=data_files/server7_int-ca.crt \
6289 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006290 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006291 mtu=512" \
6292 "$P_CLI dtls=1 debug_level=2 \
6293 crt_file=data_files/server8_int-ca2.crt \
6294 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006295 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6296 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006297 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006298 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006299 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006300 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006301 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006302
Andrzej Kurek7311c782018-10-11 06:49:41 -04006303# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006304# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006305# The ratio of max/min timeout should ideally equal 4 to accept two
6306# retransmissions, but in some cases (like both the server and client using
6307# fragmentation and auto-reduction) an extra retransmission might occur,
6308# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006309not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006310requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6311requires_config_enabled MBEDTLS_RSA_C
6312requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006313requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6314requires_config_enabled MBEDTLS_AES_C
6315requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006316run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6317 -p "$P_PXY mtu=508" \
6318 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6319 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006320 key_file=data_files/server7.key \
6321 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006322 "$P_CLI dtls=1 debug_level=2 \
6323 crt_file=data_files/server8_int-ca2.crt \
6324 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006325 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6326 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006327 0 \
6328 -s "found fragmented DTLS handshake message" \
6329 -c "found fragmented DTLS handshake message" \
6330 -C "error"
6331
Andrzej Kurek77826052018-10-11 07:34:08 -04006332# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006333only_with_valgrind
6334requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6335requires_config_enabled MBEDTLS_RSA_C
6336requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006337requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6338requires_config_enabled MBEDTLS_AES_C
6339requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006340run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6341 -p "$P_PXY mtu=508" \
6342 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6343 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006344 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006345 hs_timeout=250-10000" \
6346 "$P_CLI dtls=1 debug_level=2 \
6347 crt_file=data_files/server8_int-ca2.crt \
6348 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006349 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006350 hs_timeout=250-10000" \
6351 0 \
6352 -s "found fragmented DTLS handshake message" \
6353 -c "found fragmented DTLS handshake message" \
6354 -C "error"
6355
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006356# 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 +02006357# OTOH the client might resend if the server is to slow to reset after sending
6358# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006359not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006360requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6361requires_config_enabled MBEDTLS_RSA_C
6362requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006363run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006364 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006365 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6366 crt_file=data_files/server7_int-ca.crt \
6367 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006368 hs_timeout=10000-60000 \
6369 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006370 "$P_CLI dtls=1 debug_level=2 \
6371 crt_file=data_files/server8_int-ca2.crt \
6372 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006373 hs_timeout=10000-60000 \
6374 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006375 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006376 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006377 -s "found fragmented DTLS handshake message" \
6378 -c "found fragmented DTLS handshake message" \
6379 -C "error"
6380
Andrzej Kurek77826052018-10-11 07:34:08 -04006381# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006382# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6383# OTOH the client might resend if the server is to slow to reset after sending
6384# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006385not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006386requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6387requires_config_enabled MBEDTLS_RSA_C
6388requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006389requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6390requires_config_enabled MBEDTLS_AES_C
6391requires_config_enabled MBEDTLS_GCM_C
6392run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006393 -p "$P_PXY mtu=512" \
6394 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6395 crt_file=data_files/server7_int-ca.crt \
6396 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006397 hs_timeout=10000-60000 \
6398 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006399 "$P_CLI dtls=1 debug_level=2 \
6400 crt_file=data_files/server8_int-ca2.crt \
6401 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006402 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6403 hs_timeout=10000-60000 \
6404 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006405 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006406 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006407 -s "found fragmented DTLS handshake message" \
6408 -c "found fragmented DTLS handshake message" \
6409 -C "error"
6410
Andrzej Kurek7311c782018-10-11 06:49:41 -04006411not_with_valgrind # spurious autoreduction due to timeout
6412requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6413requires_config_enabled MBEDTLS_RSA_C
6414requires_config_enabled MBEDTLS_ECDSA_C
6415run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006416 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006417 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6418 crt_file=data_files/server7_int-ca.crt \
6419 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006420 hs_timeout=10000-60000 \
6421 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006422 "$P_CLI dtls=1 debug_level=2 \
6423 crt_file=data_files/server8_int-ca2.crt \
6424 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006425 hs_timeout=10000-60000 \
6426 mtu=1024 nbio=2" \
6427 0 \
6428 -S "autoreduction" \
6429 -s "found fragmented DTLS handshake message" \
6430 -c "found fragmented DTLS handshake message" \
6431 -C "error"
6432
Andrzej Kurek77826052018-10-11 07:34:08 -04006433# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006434not_with_valgrind # spurious autoreduction due to timeout
6435requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6436requires_config_enabled MBEDTLS_RSA_C
6437requires_config_enabled MBEDTLS_ECDSA_C
6438requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6439requires_config_enabled MBEDTLS_AES_C
6440requires_config_enabled MBEDTLS_GCM_C
6441run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6442 -p "$P_PXY mtu=512" \
6443 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6444 crt_file=data_files/server7_int-ca.crt \
6445 key_file=data_files/server7.key \
6446 hs_timeout=10000-60000 \
6447 mtu=512 nbio=2" \
6448 "$P_CLI dtls=1 debug_level=2 \
6449 crt_file=data_files/server8_int-ca2.crt \
6450 key_file=data_files/server8.key \
6451 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6452 hs_timeout=10000-60000 \
6453 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006454 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006455 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006456 -s "found fragmented DTLS handshake message" \
6457 -c "found fragmented DTLS handshake message" \
6458 -C "error"
6459
Andrzej Kurek77826052018-10-11 07:34:08 -04006460# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006461# This ensures things still work after session_reset().
6462# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006463# Since we don't support reading fragmented ClientHello yet,
6464# up the MTU to 1450 (larger than ClientHello with session ticket,
6465# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006466# An autoreduction on the client-side might happen if the server is
6467# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006468# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006469# resumed listening, which would result in a spurious autoreduction.
6470not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006471requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6472requires_config_enabled MBEDTLS_RSA_C
6473requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006474requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6475requires_config_enabled MBEDTLS_AES_C
6476requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006477run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6478 -p "$P_PXY mtu=1450" \
6479 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6480 crt_file=data_files/server7_int-ca.crt \
6481 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006482 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006483 mtu=1450" \
6484 "$P_CLI dtls=1 debug_level=2 \
6485 crt_file=data_files/server8_int-ca2.crt \
6486 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006487 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006488 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006489 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006490 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006491 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006492 -s "found fragmented DTLS handshake message" \
6493 -c "found fragmented DTLS handshake message" \
6494 -C "error"
6495
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006496# An autoreduction on the client-side might happen if the server is
6497# slow to reset, therefore omitting '-C "autoreduction"' below.
6498not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006499requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6500requires_config_enabled MBEDTLS_RSA_C
6501requires_config_enabled MBEDTLS_ECDSA_C
6502requires_config_enabled MBEDTLS_SHA256_C
6503requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6504requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6505requires_config_enabled MBEDTLS_CHACHAPOLY_C
6506run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6507 -p "$P_PXY mtu=512" \
6508 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6509 crt_file=data_files/server7_int-ca.crt \
6510 key_file=data_files/server7.key \
6511 exchanges=2 renegotiation=1 \
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 "$P_CLI dtls=1 debug_level=2 \
6515 crt_file=data_files/server8_int-ca2.crt \
6516 key_file=data_files/server8.key \
6517 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006518 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006519 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006520 mtu=512" \
6521 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006522 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006523 -s "found fragmented DTLS handshake message" \
6524 -c "found fragmented DTLS handshake message" \
6525 -C "error"
6526
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006527# An autoreduction on the client-side might happen if the server is
6528# slow to reset, therefore omitting '-C "autoreduction"' below.
6529not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006530requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6531requires_config_enabled MBEDTLS_RSA_C
6532requires_config_enabled MBEDTLS_ECDSA_C
6533requires_config_enabled MBEDTLS_SHA256_C
6534requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6535requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6536requires_config_enabled MBEDTLS_AES_C
6537requires_config_enabled MBEDTLS_GCM_C
6538run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6539 -p "$P_PXY mtu=512" \
6540 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6541 crt_file=data_files/server7_int-ca.crt \
6542 key_file=data_files/server7.key \
6543 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006544 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006545 mtu=512" \
6546 "$P_CLI dtls=1 debug_level=2 \
6547 crt_file=data_files/server8_int-ca2.crt \
6548 key_file=data_files/server8.key \
6549 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006550 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006551 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006552 mtu=512" \
6553 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006554 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006555 -s "found fragmented DTLS handshake message" \
6556 -c "found fragmented DTLS handshake message" \
6557 -C "error"
6558
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006559# An autoreduction on the client-side might happen if the server is
6560# slow to reset, therefore omitting '-C "autoreduction"' below.
6561not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006562requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6563requires_config_enabled MBEDTLS_RSA_C
6564requires_config_enabled MBEDTLS_ECDSA_C
6565requires_config_enabled MBEDTLS_SHA256_C
6566requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6567requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6568requires_config_enabled MBEDTLS_AES_C
6569requires_config_enabled MBEDTLS_CCM_C
6570run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006571 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006572 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6573 crt_file=data_files/server7_int-ca.crt \
6574 key_file=data_files/server7.key \
6575 exchanges=2 renegotiation=1 \
6576 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
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 "$P_CLI dtls=1 debug_level=2 \
6580 crt_file=data_files/server8_int-ca2.crt \
6581 key_file=data_files/server8.key \
6582 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006583 hs_timeout=10000-60000 \
6584 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006585 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006586 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006587 -s "found fragmented DTLS handshake message" \
6588 -c "found fragmented DTLS handshake message" \
6589 -C "error"
6590
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006591# An autoreduction on the client-side might happen if the server is
6592# slow to reset, therefore omitting '-C "autoreduction"' below.
6593not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006594requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6595requires_config_enabled MBEDTLS_RSA_C
6596requires_config_enabled MBEDTLS_ECDSA_C
6597requires_config_enabled MBEDTLS_SHA256_C
6598requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6599requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6600requires_config_enabled MBEDTLS_AES_C
6601requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6602requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6603run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006604 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006605 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6606 crt_file=data_files/server7_int-ca.crt \
6607 key_file=data_files/server7.key \
6608 exchanges=2 renegotiation=1 \
6609 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006610 hs_timeout=10000-60000 \
6611 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006612 "$P_CLI dtls=1 debug_level=2 \
6613 crt_file=data_files/server8_int-ca2.crt \
6614 key_file=data_files/server8.key \
6615 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006616 hs_timeout=10000-60000 \
6617 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006618 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006619 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006620 -s "found fragmented DTLS handshake message" \
6621 -c "found fragmented DTLS handshake message" \
6622 -C "error"
6623
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006624# An autoreduction on the client-side might happen if the server is
6625# slow to reset, therefore omitting '-C "autoreduction"' below.
6626not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006627requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6628requires_config_enabled MBEDTLS_RSA_C
6629requires_config_enabled MBEDTLS_ECDSA_C
6630requires_config_enabled MBEDTLS_SHA256_C
6631requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6632requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6633requires_config_enabled MBEDTLS_AES_C
6634requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6635run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006636 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006637 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6638 crt_file=data_files/server7_int-ca.crt \
6639 key_file=data_files/server7.key \
6640 exchanges=2 renegotiation=1 \
6641 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006642 hs_timeout=10000-60000 \
6643 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006644 "$P_CLI dtls=1 debug_level=2 \
6645 crt_file=data_files/server8_int-ca2.crt \
6646 key_file=data_files/server8.key \
6647 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006648 hs_timeout=10000-60000 \
6649 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006650 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006651 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006652 -s "found fragmented DTLS handshake message" \
6653 -c "found fragmented DTLS handshake message" \
6654 -C "error"
6655
Andrzej Kurek77826052018-10-11 07:34:08 -04006656# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006657requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6658requires_config_enabled MBEDTLS_RSA_C
6659requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006660requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6661requires_config_enabled MBEDTLS_AES_C
6662requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006663client_needs_more_time 2
6664run_test "DTLS fragmenting: proxy MTU + 3d" \
6665 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006666 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006667 crt_file=data_files/server7_int-ca.crt \
6668 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006669 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006670 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006671 crt_file=data_files/server8_int-ca2.crt \
6672 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006673 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006674 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006675 0 \
6676 -s "found fragmented DTLS handshake message" \
6677 -c "found fragmented DTLS handshake message" \
6678 -C "error"
6679
Andrzej Kurek77826052018-10-11 07:34:08 -04006680# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006681requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6682requires_config_enabled MBEDTLS_RSA_C
6683requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006684requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6685requires_config_enabled MBEDTLS_AES_C
6686requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006687client_needs_more_time 2
6688run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6689 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6690 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6691 crt_file=data_files/server7_int-ca.crt \
6692 key_file=data_files/server7.key \
6693 hs_timeout=250-10000 mtu=512 nbio=2" \
6694 "$P_CLI dtls=1 debug_level=2 \
6695 crt_file=data_files/server8_int-ca2.crt \
6696 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006697 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006698 hs_timeout=250-10000 mtu=512 nbio=2" \
6699 0 \
6700 -s "found fragmented DTLS handshake message" \
6701 -c "found fragmented DTLS handshake message" \
6702 -C "error"
6703
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006704# interop tests for DTLS fragmentating with reliable connection
6705#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006706# here and below we just want to test that the we fragment in a way that
6707# pleases other implementations, so we don't need the peer to fragment
6708requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6709requires_config_enabled MBEDTLS_RSA_C
6710requires_config_enabled MBEDTLS_ECDSA_C
6711requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006712requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006713run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6714 "$G_SRV -u" \
6715 "$P_CLI dtls=1 debug_level=2 \
6716 crt_file=data_files/server8_int-ca2.crt \
6717 key_file=data_files/server8.key \
6718 mtu=512 force_version=dtls1_2" \
6719 0 \
6720 -c "fragmenting handshake message" \
6721 -C "error"
6722
6723requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6724requires_config_enabled MBEDTLS_RSA_C
6725requires_config_enabled MBEDTLS_ECDSA_C
6726requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006727requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006728run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6729 "$G_SRV -u" \
6730 "$P_CLI dtls=1 debug_level=2 \
6731 crt_file=data_files/server8_int-ca2.crt \
6732 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006733 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006734 0 \
6735 -c "fragmenting handshake message" \
6736 -C "error"
6737
Hanno Beckerb9a00862018-08-28 10:20:22 +01006738# We use --insecure for the GnuTLS client because it expects
6739# the hostname / IP it connects to to be the name used in the
6740# certificate obtained from the server. Here, however, it
6741# connects to 127.0.0.1 while our test certificates use 'localhost'
6742# as the server name in the certificate. This will make the
6743# certifiate validation fail, but passing --insecure makes
6744# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006745requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6746requires_config_enabled MBEDTLS_RSA_C
6747requires_config_enabled MBEDTLS_ECDSA_C
6748requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006749requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006750requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006751run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006752 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006753 crt_file=data_files/server7_int-ca.crt \
6754 key_file=data_files/server7.key \
6755 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006756 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006757 0 \
6758 -s "fragmenting handshake message"
6759
Hanno Beckerb9a00862018-08-28 10:20:22 +01006760# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006761requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6762requires_config_enabled MBEDTLS_RSA_C
6763requires_config_enabled MBEDTLS_ECDSA_C
6764requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006765requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006766requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006767run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006768 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006769 crt_file=data_files/server7_int-ca.crt \
6770 key_file=data_files/server7.key \
6771 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006772 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006773 0 \
6774 -s "fragmenting handshake message"
6775
6776requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6777requires_config_enabled MBEDTLS_RSA_C
6778requires_config_enabled MBEDTLS_ECDSA_C
6779requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6780run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6781 "$O_SRV -dtls1_2 -verify 10" \
6782 "$P_CLI dtls=1 debug_level=2 \
6783 crt_file=data_files/server8_int-ca2.crt \
6784 key_file=data_files/server8.key \
6785 mtu=512 force_version=dtls1_2" \
6786 0 \
6787 -c "fragmenting handshake message" \
6788 -C "error"
6789
6790requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6791requires_config_enabled MBEDTLS_RSA_C
6792requires_config_enabled MBEDTLS_ECDSA_C
6793requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6794run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6795 "$O_SRV -dtls1 -verify 10" \
6796 "$P_CLI dtls=1 debug_level=2 \
6797 crt_file=data_files/server8_int-ca2.crt \
6798 key_file=data_files/server8.key \
6799 mtu=512 force_version=dtls1" \
6800 0 \
6801 -c "fragmenting handshake message" \
6802 -C "error"
6803
6804requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6805requires_config_enabled MBEDTLS_RSA_C
6806requires_config_enabled MBEDTLS_ECDSA_C
6807requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6808run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6809 "$P_SRV dtls=1 debug_level=2 \
6810 crt_file=data_files/server7_int-ca.crt \
6811 key_file=data_files/server7.key \
6812 mtu=512 force_version=dtls1_2" \
6813 "$O_CLI -dtls1_2" \
6814 0 \
6815 -s "fragmenting handshake message"
6816
6817requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6818requires_config_enabled MBEDTLS_RSA_C
6819requires_config_enabled MBEDTLS_ECDSA_C
6820requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6821run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6822 "$P_SRV dtls=1 debug_level=2 \
6823 crt_file=data_files/server7_int-ca.crt \
6824 key_file=data_files/server7.key \
6825 mtu=512 force_version=dtls1" \
6826 "$O_CLI -dtls1" \
6827 0 \
6828 -s "fragmenting handshake message"
6829
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006830# interop tests for DTLS fragmentating with unreliable connection
6831#
6832# again we just want to test that the we fragment in a way that
6833# pleases other implementations, so we don't need the peer to fragment
6834requires_gnutls_next
6835requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6836requires_config_enabled MBEDTLS_RSA_C
6837requires_config_enabled MBEDTLS_ECDSA_C
6838requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006839client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006840run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6841 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6842 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006843 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006844 crt_file=data_files/server8_int-ca2.crt \
6845 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006846 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006847 0 \
6848 -c "fragmenting handshake message" \
6849 -C "error"
6850
6851requires_gnutls_next
6852requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6853requires_config_enabled MBEDTLS_RSA_C
6854requires_config_enabled MBEDTLS_ECDSA_C
6855requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006856client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006857run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6858 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6859 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006860 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006861 crt_file=data_files/server8_int-ca2.crt \
6862 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006863 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006864 0 \
6865 -c "fragmenting handshake message" \
6866 -C "error"
6867
k-stachowiakabb843e2019-02-18 16:14:03 +01006868requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006869requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6870requires_config_enabled MBEDTLS_RSA_C
6871requires_config_enabled MBEDTLS_ECDSA_C
6872requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6873client_needs_more_time 4
6874run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6875 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6876 "$P_SRV dtls=1 debug_level=2 \
6877 crt_file=data_files/server7_int-ca.crt \
6878 key_file=data_files/server7.key \
6879 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006880 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006881 0 \
6882 -s "fragmenting handshake message"
6883
k-stachowiakabb843e2019-02-18 16:14:03 +01006884requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006885requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6886requires_config_enabled MBEDTLS_RSA_C
6887requires_config_enabled MBEDTLS_ECDSA_C
6888requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6889client_needs_more_time 4
6890run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6891 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6892 "$P_SRV dtls=1 debug_level=2 \
6893 crt_file=data_files/server7_int-ca.crt \
6894 key_file=data_files/server7.key \
6895 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006896 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006897 0 \
6898 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006899
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006900## Interop test with OpenSSL might trigger a bug in recent versions (including
6901## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006902## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006903## They should be re-enabled once a fixed version of OpenSSL is available
6904## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006905skip_next_test
6906requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6907requires_config_enabled MBEDTLS_RSA_C
6908requires_config_enabled MBEDTLS_ECDSA_C
6909requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6910client_needs_more_time 4
6911run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6912 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6913 "$O_SRV -dtls1_2 -verify 10" \
6914 "$P_CLI dtls=1 debug_level=2 \
6915 crt_file=data_files/server8_int-ca2.crt \
6916 key_file=data_files/server8.key \
6917 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6918 0 \
6919 -c "fragmenting handshake message" \
6920 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006921
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006922skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006923requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6924requires_config_enabled MBEDTLS_RSA_C
6925requires_config_enabled MBEDTLS_ECDSA_C
6926requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006927client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006928run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6929 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006930 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006931 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006932 crt_file=data_files/server8_int-ca2.crt \
6933 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006934 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006935 0 \
6936 -c "fragmenting handshake message" \
6937 -C "error"
6938
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006939skip_next_test
6940requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6941requires_config_enabled MBEDTLS_RSA_C
6942requires_config_enabled MBEDTLS_ECDSA_C
6943requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6944client_needs_more_time 4
6945run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6946 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6947 "$P_SRV dtls=1 debug_level=2 \
6948 crt_file=data_files/server7_int-ca.crt \
6949 key_file=data_files/server7.key \
6950 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6951 "$O_CLI -dtls1_2" \
6952 0 \
6953 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006954
6955# -nbio is added to prevent s_client from blocking in case of duplicated
6956# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006957skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006958requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6959requires_config_enabled MBEDTLS_RSA_C
6960requires_config_enabled MBEDTLS_ECDSA_C
6961requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006962client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006963run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
6964 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006965 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006966 crt_file=data_files/server7_int-ca.crt \
6967 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006968 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006969 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006970 0 \
6971 -s "fragmenting handshake message"
6972
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006973# Tests for specific things with "unreliable" UDP connection
6974
6975not_with_valgrind # spurious resend due to timeout
6976run_test "DTLS proxy: reference" \
6977 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006978 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
6979 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006980 0 \
6981 -C "replayed record" \
6982 -S "replayed record" \
6983 -C "record from another epoch" \
6984 -S "record from another epoch" \
6985 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006986 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006987 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006988 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006989 -c "HTTP/1.0 200 OK"
6990
6991not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006992run_test "DTLS proxy: duplicate every packet" \
6993 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006994 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
6995 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006996 0 \
6997 -c "replayed record" \
6998 -s "replayed record" \
6999 -c "record from another epoch" \
7000 -s "record from another epoch" \
7001 -S "resend" \
7002 -s "Extra-header:" \
7003 -c "HTTP/1.0 200 OK"
7004
7005run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7006 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007007 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7008 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007009 0 \
7010 -c "replayed record" \
7011 -S "replayed record" \
7012 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007013 -s "record from another epoch" \
7014 -c "resend" \
7015 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007016 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007017 -c "HTTP/1.0 200 OK"
7018
7019run_test "DTLS proxy: multiple records in same datagram" \
7020 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007021 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7022 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007023 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007024 -c "next record in same datagram" \
7025 -s "next record in same datagram"
7026
7027run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7028 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007029 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7030 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007031 0 \
7032 -c "next record in same datagram" \
7033 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007034
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007035run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7036 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007037 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7038 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007039 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007040 -c "discarding invalid record (mac)" \
7041 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007042 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007043 -c "HTTP/1.0 200 OK" \
7044 -S "too many records with bad MAC" \
7045 -S "Verification of the message MAC failed"
7046
7047run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
7048 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007049 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7050 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007051 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007052 -C "discarding invalid record (mac)" \
7053 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007054 -S "Extra-header:" \
7055 -C "HTTP/1.0 200 OK" \
7056 -s "too many records with bad MAC" \
7057 -s "Verification of the message MAC failed"
7058
7059run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7060 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007061 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7062 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007063 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007064 -c "discarding invalid record (mac)" \
7065 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007066 -s "Extra-header:" \
7067 -c "HTTP/1.0 200 OK" \
7068 -S "too many records with bad MAC" \
7069 -S "Verification of the message MAC failed"
7070
7071run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7072 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007073 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7074 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007075 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007076 -c "discarding invalid record (mac)" \
7077 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007078 -s "Extra-header:" \
7079 -c "HTTP/1.0 200 OK" \
7080 -s "too many records with bad MAC" \
7081 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007082
7083run_test "DTLS proxy: delay ChangeCipherSpec" \
7084 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007085 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7086 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007087 0 \
7088 -c "record from another epoch" \
7089 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007090 -s "Extra-header:" \
7091 -c "HTTP/1.0 200 OK"
7092
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007093# Tests for reordering support with DTLS
7094
Hanno Becker56cdfd12018-08-17 13:42:15 +01007095run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7096 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007097 "$P_SRV 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 Beckere3842212018-08-16 15:28:59 +01007101 0 \
7102 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007103 -c "Next handshake message has been buffered - load"\
7104 -S "Buffering HS message" \
7105 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007106 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007107 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007108 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007109 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007110
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007111run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7112 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007113 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7114 hs_timeout=2500-60000" \
7115 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7116 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007117 0 \
7118 -c "Buffering HS message" \
7119 -c "found fragmented DTLS handshake message"\
7120 -c "Next handshake message 1 not or only partially bufffered" \
7121 -c "Next handshake message has been buffered - load"\
7122 -S "Buffering HS message" \
7123 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007124 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007125 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007126 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007127 -S "Remember CCS message"
7128
Hanno Beckera1adcca2018-08-24 14:41:07 +01007129# The client buffers the ServerKeyExchange before receiving the fragmented
7130# Certificate message; at the time of writing, together these are aroudn 1200b
7131# in size, so that the bound below ensures that the certificate can be reassembled
7132# while keeping the ServerKeyExchange.
7133requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7134run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007135 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007136 "$P_SRV mtu=512 dgram_packing=0 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 Beckere3567052018-08-21 16:50:43 +01007140 0 \
7141 -c "Buffering HS message" \
7142 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007143 -C "attempt to make space by freeing buffered messages" \
7144 -S "Buffering HS message" \
7145 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007146 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007147 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007148 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007149 -S "Remember CCS message"
7150
7151# The size constraints ensure that the delayed certificate message can't
7152# be reassembled while keeping the ServerKeyExchange message, but it can
7153# when dropping it first.
7154requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7155requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7156run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7157 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007158 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7159 hs_timeout=2500-60000" \
7160 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7161 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007162 0 \
7163 -c "Buffering HS message" \
7164 -c "attempt to make space by freeing buffered future messages" \
7165 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007166 -S "Buffering HS message" \
7167 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007168 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007169 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007170 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007171 -S "Remember CCS message"
7172
Hanno Becker56cdfd12018-08-17 13:42:15 +01007173run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7174 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007175 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7176 hs_timeout=2500-60000" \
7177 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7178 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007179 0 \
7180 -C "Buffering HS message" \
7181 -C "Next handshake message has been buffered - load"\
7182 -s "Buffering HS message" \
7183 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007184 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007185 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007186 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007187 -S "Remember CCS message"
7188
7189run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7190 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007191 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7192 hs_timeout=2500-60000" \
7193 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7194 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007195 0 \
7196 -C "Buffering HS message" \
7197 -C "Next handshake message has been buffered - load"\
7198 -S "Buffering HS message" \
7199 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007200 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007201 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007202 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007203 -S "Remember CCS message"
7204
7205run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7206 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007207 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7208 hs_timeout=2500-60000" \
7209 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7210 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007211 0 \
7212 -C "Buffering HS message" \
7213 -C "Next handshake message has been buffered - load"\
7214 -S "Buffering HS message" \
7215 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007216 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007217 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007218 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007219 -s "Remember CCS message"
7220
Hanno Beckera1adcca2018-08-24 14:41:07 +01007221run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007222 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007223 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7224 hs_timeout=2500-60000" \
7225 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7226 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007227 0 \
7228 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007229 -s "Found buffered record from current epoch - load" \
7230 -c "Buffer record from epoch 1" \
7231 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007232
Hanno Beckera1adcca2018-08-24 14:41:07 +01007233# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7234# from the server are delayed, so that the encrypted Finished message
7235# is received and buffered. When the fragmented NewSessionTicket comes
7236# in afterwards, the encrypted Finished message must be freed in order
7237# to make space for the NewSessionTicket to be reassembled.
7238# This works only in very particular circumstances:
7239# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7240# of the NewSessionTicket, but small enough to also allow buffering of
7241# the encrypted Finished message.
7242# - The MTU setting on the server must be so small that the NewSessionTicket
7243# needs to be fragmented.
7244# - All messages sent by the server must be small enough to be either sent
7245# without fragmentation or be reassembled within the bounds of
7246# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7247# handshake, omitting CRTs.
7248requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7249requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7250run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7251 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7252 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7253 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7254 0 \
7255 -s "Buffer record from epoch 1" \
7256 -s "Found buffered record from current epoch - load" \
7257 -c "Buffer record from epoch 1" \
7258 -C "Found buffered record from current epoch - load" \
7259 -c "Enough space available after freeing future epoch record"
7260
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007261# Tests for "randomly unreliable connection": try a variety of flows and peers
7262
7263client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007264run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
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=0 auth_mode=none \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007267 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007268 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007269 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7270 0 \
7271 -s "Extra-header:" \
7272 -c "HTTP/1.0 200 OK"
7273
Janos Follath74537a62016-09-02 13:45:28 +01007274client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007275run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7276 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007277 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7278 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007279 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7280 0 \
7281 -s "Extra-header:" \
7282 -c "HTTP/1.0 200 OK"
7283
Janos Follath74537a62016-09-02 13:45:28 +01007284client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007285run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7286 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007287 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7288 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007289 0 \
7290 -s "Extra-header:" \
7291 -c "HTTP/1.0 200 OK"
7292
Janos Follath74537a62016-09-02 13:45:28 +01007293client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007294run_test "DTLS proxy: 3d, FS, client auth" \
7295 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007296 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7297 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007298 0 \
7299 -s "Extra-header:" \
7300 -c "HTTP/1.0 200 OK"
7301
Janos Follath74537a62016-09-02 13:45:28 +01007302client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007303run_test "DTLS proxy: 3d, FS, ticket" \
7304 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007305 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7306 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007307 0 \
7308 -s "Extra-header:" \
7309 -c "HTTP/1.0 200 OK"
7310
Janos Follath74537a62016-09-02 13:45:28 +01007311client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007312run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7313 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007314 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7315 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007316 0 \
7317 -s "Extra-header:" \
7318 -c "HTTP/1.0 200 OK"
7319
Janos Follath74537a62016-09-02 13:45:28 +01007320client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007321run_test "DTLS proxy: 3d, max handshake, nbio" \
7322 -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 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007324 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007325 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007326 0 \
7327 -s "Extra-header:" \
7328 -c "HTTP/1.0 200 OK"
7329
Janos Follath74537a62016-09-02 13:45:28 +01007330client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007331run_test "DTLS proxy: 3d, min handshake, resumption" \
7332 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007333 "$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 +02007334 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007335 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007336 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007337 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7338 0 \
7339 -s "a session has been resumed" \
7340 -c "a session has been resumed" \
7341 -s "Extra-header:" \
7342 -c "HTTP/1.0 200 OK"
7343
Janos Follath74537a62016-09-02 13:45:28 +01007344client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007345run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7346 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007347 "$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 +02007348 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007349 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007350 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007351 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7352 0 \
7353 -s "a session has been resumed" \
7354 -c "a session has been resumed" \
7355 -s "Extra-header:" \
7356 -c "HTTP/1.0 200 OK"
7357
Janos Follath74537a62016-09-02 13:45:28 +01007358client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007359requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007360run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007361 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007362 "$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 +02007363 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007364 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007365 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007366 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7367 0 \
7368 -c "=> renegotiate" \
7369 -s "=> renegotiate" \
7370 -s "Extra-header:" \
7371 -c "HTTP/1.0 200 OK"
7372
Janos Follath74537a62016-09-02 13:45:28 +01007373client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007374requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007375run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7376 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007377 "$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 +02007378 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007379 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007380 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007381 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7382 0 \
7383 -c "=> renegotiate" \
7384 -s "=> renegotiate" \
7385 -s "Extra-header:" \
7386 -c "HTTP/1.0 200 OK"
7387
Janos Follath74537a62016-09-02 13:45:28 +01007388client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007389requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007390run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007391 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007392 "$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 +02007393 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007394 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007395 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007396 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007397 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7398 0 \
7399 -c "=> renegotiate" \
7400 -s "=> renegotiate" \
7401 -s "Extra-header:" \
7402 -c "HTTP/1.0 200 OK"
7403
Janos Follath74537a62016-09-02 13:45:28 +01007404client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007405requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007406run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007407 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007408 "$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 +02007409 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007410 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007411 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007412 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007413 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7414 0 \
7415 -c "=> renegotiate" \
7416 -s "=> renegotiate" \
7417 -s "Extra-header:" \
7418 -c "HTTP/1.0 200 OK"
7419
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007420## Interop tests with OpenSSL might trigger a bug in recent versions (including
7421## all versions installed on the CI machines), reported here:
7422## Bug report: https://github.com/openssl/openssl/issues/6902
7423## They should be re-enabled once a fixed version of OpenSSL is available
7424## (this should happen in some 1.1.1_ release according to the ticket).
7425skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007426client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007427not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007428run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007429 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7430 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007431 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007432 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007433 -c "HTTP/1.0 200 OK"
7434
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007435skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007436client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007437not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007438run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7439 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7440 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007441 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007442 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007443 -c "HTTP/1.0 200 OK"
7444
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007445skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007446client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007447not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007448run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7449 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7450 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007451 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007452 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007453 -c "HTTP/1.0 200 OK"
7454
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007455requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007456client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007457not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007458run_test "DTLS proxy: 3d, gnutls server" \
7459 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7460 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007461 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007462 0 \
7463 -s "Extra-header:" \
7464 -c "Extra-header:"
7465
k-stachowiakabb843e2019-02-18 16:14:03 +01007466requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007467client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007468not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007469run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7470 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007471 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007472 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007473 0 \
7474 -s "Extra-header:" \
7475 -c "Extra-header:"
7476
k-stachowiakabb843e2019-02-18 16:14:03 +01007477requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007478client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007479not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007480run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7481 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007482 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007483 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007484 0 \
7485 -s "Extra-header:" \
7486 -c "Extra-header:"
7487
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007488# Final report
7489
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007490echo "------------------------------------------------------------------------"
7491
7492if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007493 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007494else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007495 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007496fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007497PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007498echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007499
7500exit $FAILS