blob: bd894e18bb69a7afbb0eb031448ae777f91c075c [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
Yuto Takano0807e1d2021-07-02 10:10:49 +0100266# skip next test if either IN_CONTENT_LEN or MAX_CONTENT_LEN are below a value
267requires_max_content_len() {
268 requires_config_value_at_least "MBEDTLS_SSL_IN_CONTENT_LEN" $1
269 requires_config_value_at_least "MBEDTLS_SSL_OUT_CONTENT_LEN" $1
270}
271
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200272# skip next test if GnuTLS isn't available
273requires_gnutls() {
274 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200275 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200276 GNUTLS_AVAILABLE="YES"
277 else
278 GNUTLS_AVAILABLE="NO"
279 fi
280 fi
281 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
282 SKIP_NEXT="YES"
283 fi
284}
285
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200286# skip next test if GnuTLS-next isn't available
287requires_gnutls_next() {
288 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
289 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
290 GNUTLS_NEXT_AVAILABLE="YES"
291 else
292 GNUTLS_NEXT_AVAILABLE="NO"
293 fi
294 fi
295 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
296 SKIP_NEXT="YES"
297 fi
298}
299
300# skip next test if OpenSSL-legacy isn't available
301requires_openssl_legacy() {
302 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
303 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
304 OPENSSL_LEGACY_AVAILABLE="YES"
305 else
306 OPENSSL_LEGACY_AVAILABLE="NO"
307 fi
308 fi
309 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
310 SKIP_NEXT="YES"
311 fi
312}
313
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200314# skip next test if IPv6 isn't available on this host
315requires_ipv6() {
316 if [ -z "${HAS_IPV6:-}" ]; then
317 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
318 SRV_PID=$!
319 sleep 1
320 kill $SRV_PID >/dev/null 2>&1
321 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
322 HAS_IPV6="NO"
323 else
324 HAS_IPV6="YES"
325 fi
326 rm -r $SRV_OUT
327 fi
328
329 if [ "$HAS_IPV6" = "NO" ]; then
330 SKIP_NEXT="YES"
331 fi
332}
333
Andrzej Kurekb4593462018-10-11 08:43:30 -0400334# skip next test if it's i686 or uname is not available
335requires_not_i686() {
336 if [ -z "${IS_I686:-}" ]; then
337 IS_I686="YES"
338 if which "uname" >/dev/null 2>&1; then
339 if [ -z "$(uname -a | grep i686)" ]; then
340 IS_I686="NO"
341 fi
342 fi
343 fi
344 if [ "$IS_I686" = "YES" ]; then
345 SKIP_NEXT="YES"
346 fi
347}
348
Angus Grattonc4dd0732018-04-11 16:28:39 +1000349# Calculate the input & output maximum content lengths set in the config
Yuto Takanobbf657a2021-06-22 07:16:40 +0100350MAX_CONTENT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_MAX_CONTENT_LEN" )
351MAX_IN_LEN=$( get_config_value_or_default "MBEDTLS_SSL_IN_CONTENT_LEN" )
352MAX_OUT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_OUT_CONTENT_LEN" )
Angus Grattonc4dd0732018-04-11 16:28:39 +1000353
Yuto Takano2e580ce2021-06-21 19:43:33 +0100354# Calculate the maximum content length that fits both
Angus Grattonc4dd0732018-04-11 16:28:39 +1000355if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
356 MAX_CONTENT_LEN="$MAX_IN_LEN"
357fi
358if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
359 MAX_CONTENT_LEN="$MAX_OUT_LEN"
360fi
361
362# skip the next test if the SSL output buffer is less than 16KB
363requires_full_size_output_buffer() {
364 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
365 SKIP_NEXT="YES"
366 fi
367}
368
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200369# skip the next test if valgrind is in use
370not_with_valgrind() {
371 if [ "$MEMCHECK" -gt 0 ]; then
372 SKIP_NEXT="YES"
373 fi
374}
375
Paul Bakker362689d2016-05-13 10:33:25 +0100376# skip the next test if valgrind is NOT in use
377only_with_valgrind() {
378 if [ "$MEMCHECK" -eq 0 ]; then
379 SKIP_NEXT="YES"
380 fi
381}
382
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200383# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100384client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200385 CLI_DELAY_FACTOR=$1
386}
387
Janos Follath74537a62016-09-02 13:45:28 +0100388# wait for the given seconds after the client finished in the next test
389server_needs_more_time() {
390 SRV_DELAY_SECONDS=$1
391}
392
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100393# print_name <name>
394print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100395 TESTS=$(( $TESTS + 1 ))
396 LINE=""
397
398 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
399 LINE="$TESTS "
400 fi
401
402 LINE="$LINE$1"
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200403 printf "%s " "$LINE"
Paul Bakkere20310a2016-05-10 11:18:17 +0100404 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100405 for i in `seq 1 $LEN`; do printf '.'; done
406 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100407
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100408}
409
410# fail <message>
411fail() {
412 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100413 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100414
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200415 mv $SRV_OUT o-srv-${TESTS}.log
416 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200417 if [ -n "$PXY_CMD" ]; then
418 mv $PXY_OUT o-pxy-${TESTS}.log
419 fi
420 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100421
Manuel Pégourié-Gonnarde63fc6d2020-06-08 11:49:05 +0200422 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200423 echo " ! server output:"
424 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200425 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200426 echo " ! client output:"
427 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200428 if [ -n "$PXY_CMD" ]; then
429 echo " ! ========================================================"
430 echo " ! proxy output:"
431 cat o-pxy-${TESTS}.log
432 fi
433 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200434 fi
435
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200436 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100437}
438
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100439# is_polar <cmd_line>
440is_polar() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200441 case "$1" in
442 *ssl_client2*) true;;
443 *ssl_server2*) true;;
444 *) false;;
445 esac
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100446}
447
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200448# openssl s_server doesn't have -www with DTLS
449check_osrv_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200450 case "$SRV_CMD" in
451 *s_server*-dtls*)
452 NEEDS_INPUT=1
453 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )";;
454 *) NEEDS_INPUT=0;;
455 esac
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200456}
457
458# provide input to commands that need it
459provide_input() {
460 if [ $NEEDS_INPUT -eq 0 ]; then
461 return
462 fi
463
464 while true; do
465 echo "HTTP/1.0 200 OK"
466 sleep 1
467 done
468}
469
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100470# has_mem_err <log_file_name>
471has_mem_err() {
472 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
473 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
474 then
475 return 1 # false: does not have errors
476 else
477 return 0 # true: has errors
478 fi
479}
480
Unknown43dc0d62019-09-02 10:42:57 -0400481# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100482if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400483 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100484 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200485 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100486 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200487 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100488 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200489 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100490 # Make a tight loop, server normally takes less than 1s to start.
491 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
492 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400493 echo "$3 START TIMEOUT"
494 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100495 break
496 fi
497 # Linux and *BSD support decimal arguments to sleep. On other
498 # OSes this may be a tight loop.
499 sleep 0.1 2>/dev/null || true
500 done
501 }
502else
Unknown43dc0d62019-09-02 10:42:57 -0400503 echo "Warning: lsof not available, wait_app_start = sleep"
504 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200505 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100506 }
507fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200508
Unknown43dc0d62019-09-02 10:42:57 -0400509# Wait for server process $2 to be listening on port $1.
510wait_server_start() {
511 wait_app_start $1 $2 "SERVER" $SRV_OUT
512}
513
514# Wait for proxy process $2 to be listening on port $1.
515wait_proxy_start() {
516 wait_app_start $1 $2 "PROXY" $PXY_OUT
517}
518
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100519# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100520# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100521# acceptable bounds
522check_server_hello_time() {
523 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100524 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100525 # Get the Unix timestamp for now
526 CUR_TIME=$(date +'%s')
527 THRESHOLD_IN_SECS=300
528
529 # Check if the ServerHello time was printed
530 if [ -z "$SERVER_HELLO_TIME" ]; then
531 return 1
532 fi
533
534 # Check the time in ServerHello is within acceptable bounds
535 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
536 # The time in ServerHello is at least 5 minutes before now
537 return 1
538 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100539 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100540 return 1
541 else
542 return 0
543 fi
544}
545
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200546# wait for client to terminate and set CLI_EXIT
547# must be called right after starting the client
548wait_client_done() {
549 CLI_PID=$!
550
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200551 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
552 CLI_DELAY_FACTOR=1
553
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200554 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200555 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200556
557 wait $CLI_PID
558 CLI_EXIT=$?
559
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200560 kill $DOG_PID >/dev/null 2>&1
561 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200562
563 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100564
565 sleep $SRV_DELAY_SECONDS
566 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200567}
568
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200569# check if the given command uses dtls and sets global variable DTLS
570detect_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200571 case "$1" in
572 *dtls=1*|-dtls|-u) DTLS=1;;
573 *) DTLS=0;;
574 esac
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200575}
576
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200577# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100578# Options: -s pattern pattern that must be present in server output
579# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100580# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100581# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100582# -S pattern pattern that must be absent in server output
583# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100584# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100585# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100586run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100587 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200588 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100589
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200590 if is_excluded "$NAME"; then
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200591 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100592 return
593 fi
594
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100595 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100596
Paul Bakkerb7584a52016-05-10 10:50:43 +0100597 # Do we only run numbered tests?
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200598 if [ -n "$RUN_TEST_NUMBER" ]; then
599 case ",$RUN_TEST_NUMBER," in
600 *",$TESTS,"*) :;;
601 *) SKIP_NEXT="YES";;
602 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100603 fi
604
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200605 # should we skip?
606 if [ "X$SKIP_NEXT" = "XYES" ]; then
607 SKIP_NEXT="NO"
608 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200609 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200610 return
611 fi
612
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200613 # does this test use a proxy?
614 if [ "X$1" = "X-p" ]; then
615 PXY_CMD="$2"
616 shift 2
617 else
618 PXY_CMD=""
619 fi
620
621 # get commands and client output
622 SRV_CMD="$1"
623 CLI_CMD="$2"
624 CLI_EXPECT="$3"
625 shift 3
626
Hanno Becker7a11e722019-05-10 14:38:42 +0100627 # Check if test uses files
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200628 case "$SRV_CMD $CLI_CMD" in
629 *data_files/*)
630 requires_config_enabled MBEDTLS_FS_IO;;
631 esac
Hanno Becker7a11e722019-05-10 14:38:42 +0100632
633 # should we skip?
634 if [ "X$SKIP_NEXT" = "XYES" ]; then
635 SKIP_NEXT="NO"
636 echo "SKIP"
637 SKIPS=$(( $SKIPS + 1 ))
638 return
639 fi
640
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200641 # update DTLS variable
642 detect_dtls "$SRV_CMD"
643
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200644 # if the test uses DTLS but no custom proxy, add a simple proxy
645 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200646 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200647 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200648 case " $SRV_CMD " in
649 *' server_addr=::1 '*)
650 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
651 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200652 fi
653
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200654 # fix client port
655 if [ -n "$PXY_CMD" ]; then
656 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
657 else
658 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
659 fi
660
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100661 # prepend valgrind to our commands if active
662 if [ "$MEMCHECK" -gt 0 ]; then
663 if is_polar "$SRV_CMD"; then
664 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
665 fi
666 if is_polar "$CLI_CMD"; then
667 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
668 fi
669 fi
670
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200671 TIMES_LEFT=2
672 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200673 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200674
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200675 # run the commands
676 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda1919ad2020-07-27 09:45:32 +0200677 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200678 $PXY_CMD >> $PXY_OUT 2>&1 &
679 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400680 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200681 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200682
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200683 check_osrv_dtls
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200684 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200685 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
686 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100687 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200688
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200689 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200690 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
691 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100692
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100693 sleep 0.05
694
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200695 # terminate the server (and the proxy)
696 kill $SRV_PID
697 wait $SRV_PID
Gilles Peskine634fe272021-02-02 23:29:03 +0100698 SRV_RET=$?
Hanno Beckerd82d8462017-05-29 21:37:46 +0100699
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200700 if [ -n "$PXY_CMD" ]; then
701 kill $PXY_PID >/dev/null 2>&1
702 wait $PXY_PID
703 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100704
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200705 # retry only on timeouts
706 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
707 printf "RETRY "
708 else
709 TIMES_LEFT=0
710 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200711 done
712
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100713 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200714 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100715 # expected client exit to incorrectly succeed in case of catastrophic
716 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100717 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200718 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100719 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100720 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100721 return
722 fi
723 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100724 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200725 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100726 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100727 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100728 return
729 fi
730 fi
731
Gilles Peskine2cf44b62021-02-09 21:01:33 +0100732 # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
733 # exit with status 0 when interrupted by a signal, and we don't really
734 # care anyway), in case e.g. the server reports a memory leak.
735 if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then
Gilles Peskine634fe272021-02-02 23:29:03 +0100736 fail "Server exited with status $SRV_RET"
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100737 return
738 fi
739
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100740 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100741 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
742 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100743 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200744 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100745 return
746 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100747
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100748 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200749 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100750 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100751 while [ $# -gt 0 ]
752 do
753 case $1 in
754 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100755 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 +0100756 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100757 return
758 fi
759 ;;
760
761 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100762 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 +0100763 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100764 return
765 fi
766 ;;
767
768 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100769 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 +0100770 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100771 return
772 fi
773 ;;
774
775 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100776 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 +0100777 fail "pattern '$2' MUST NOT be present in the Client output"
778 return
779 fi
780 ;;
781
782 # The filtering in the following two options (-u and -U) do the following
783 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100784 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100785 # - keep one of each non-unique line
786 # - count how many lines remain
787 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
788 # if there were no duplicates.
789 "-U")
790 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
791 fail "lines following pattern '$2' must be unique in Server output"
792 return
793 fi
794 ;;
795
796 "-u")
797 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
798 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100799 return
800 fi
801 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100802 "-F")
803 if ! $2 "$SRV_OUT"; then
804 fail "function call to '$2' failed on Server output"
805 return
806 fi
807 ;;
808 "-f")
809 if ! $2 "$CLI_OUT"; then
810 fail "function call to '$2' failed on Client output"
811 return
812 fi
813 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100814
815 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200816 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100817 exit 1
818 esac
819 shift 2
820 done
821
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100822 # check valgrind's results
823 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200824 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100825 fail "Server has memory errors"
826 return
827 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200828 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100829 fail "Client has memory errors"
830 return
831 fi
832 fi
833
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100834 # if we're here, everything is ok
835 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100836 if [ "$PRESERVE_LOGS" -gt 0 ]; then
837 mv $SRV_OUT o-srv-${TESTS}.log
838 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100839 if [ -n "$PXY_CMD" ]; then
840 mv $PXY_OUT o-pxy-${TESTS}.log
841 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100842 fi
843
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200844 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100845}
846
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100847cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200848 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200849 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
850 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
851 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
852 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100853 exit 1
854}
855
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100856#
857# MAIN
858#
859
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100860get_options "$@"
861
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200862# Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell
863# patterns rather than regular expressions, use a case statement instead
864# of calling grep. To keep the optimizer simple, it is incomplete and only
865# detects simple cases: plain substring, everything, nothing.
866#
867# As an exception, the character '.' is treated as an ordinary character
868# if it is the only special character in the string. This is because it's
869# rare to need "any one character", but needing a literal '.' is common
870# (e.g. '-f "DTLS 1.2"').
871need_grep=
872case "$FILTER" in
873 '^$') simple_filter=;;
874 '.*') simple_filter='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200875 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200876 need_grep=1;;
877 *) # No regexp or shell-pattern special character
878 simple_filter="*$FILTER*";;
879esac
880case "$EXCLUDE" in
881 '^$') simple_exclude=;;
882 '.*') simple_exclude='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200883 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200884 need_grep=1;;
885 *) # No regexp or shell-pattern special character
886 simple_exclude="*$EXCLUDE*";;
887esac
888if [ -n "$need_grep" ]; then
889 is_excluded () {
890 ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE"
891 }
892else
893 is_excluded () {
894 case "$1" in
895 $simple_exclude) true;;
896 $simple_filter) false;;
897 *) true;;
898 esac
899 }
900fi
901
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100902# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100903P_SRV_BIN="${P_SRV%%[ ]*}"
904P_CLI_BIN="${P_CLI%%[ ]*}"
905P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100906if [ ! -x "$P_SRV_BIN" ]; then
907 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100908 exit 1
909fi
Hanno Becker17c04932017-10-10 14:44:53 +0100910if [ ! -x "$P_CLI_BIN" ]; then
911 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100912 exit 1
913fi
Hanno Becker17c04932017-10-10 14:44:53 +0100914if [ ! -x "$P_PXY_BIN" ]; then
915 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200916 exit 1
917fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100918if [ "$MEMCHECK" -gt 0 ]; then
919 if which valgrind >/dev/null 2>&1; then :; else
920 echo "Memcheck not possible. Valgrind not found"
921 exit 1
922 fi
923fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100924if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
925 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100926 exit 1
927fi
928
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200929# used by watchdog
930MAIN_PID="$$"
931
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100932# We use somewhat arbitrary delays for tests:
933# - how long do we wait for the server to start (when lsof not available)?
934# - how long do we allow for the client to finish?
935# (not to check performance, just to avoid waiting indefinitely)
936# Things are slower with valgrind, so give extra time here.
937#
938# Note: without lsof, there is a trade-off between the running time of this
939# script and the risk of spurious errors because we didn't wait long enough.
940# The watchdog delay on the other hand doesn't affect normal running time of
941# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200942if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100943 START_DELAY=6
944 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200945else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100946 START_DELAY=2
947 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200948fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100949
950# some particular tests need more time:
951# - for the client, we multiply the usual watchdog limit by a factor
952# - for the server, we sleep for a number of seconds after the client exits
953# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200954CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100955SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200956
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200957# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000958# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200959P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
960P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100961P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Gilles Peskine63a2b912021-04-01 14:00:11 +0200962O_SRV="$O_SRV -accept $SRV_PORT"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200963O_CLI="$O_CLI -connect localhost:+SRV_PORT"
964G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200965G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200966
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200967if [ -n "${OPENSSL_LEGACY:-}" ]; then
968 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
969 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
970fi
971
Hanno Becker58e9dc32018-08-17 15:53:21 +0100972if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200973 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
974fi
975
Hanno Becker58e9dc32018-08-17 15:53:21 +0100976if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200977 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200978fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100979
Gilles Peskine62469d92017-05-10 10:13:59 +0200980# Allow SHA-1, because many of our test certificates use it
981P_SRV="$P_SRV allow_sha1=1"
982P_CLI="$P_CLI allow_sha1=1"
983
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200984# Also pick a unique name for intermediate files
985SRV_OUT="srv_out.$$"
986CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200987PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200988SESSION="session.$$"
989
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200990SKIP_NEXT="NO"
991
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100992trap cleanup INT TERM HUP
993
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200994# Basic test
995
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200996# Checks that:
997# - things work with all ciphersuites active (used with config-full in all.sh)
998# - the expected (highest security) parameters are selected
999# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001000run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001001 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001002 "$P_CLI" \
1003 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001004 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001005 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001006 -s "client hello v3, signature_algorithm ext: 6" \
1007 -s "ECDHE curve: secp521r1" \
1008 -S "error" \
1009 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001010
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001011run_test "Default, DTLS" \
1012 "$P_SRV dtls=1" \
1013 "$P_CLI dtls=1" \
1014 0 \
1015 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001016 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001017
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +01001018requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1019run_test "Default (compression enabled)" \
1020 "$P_SRV debug_level=3" \
1021 "$P_CLI debug_level=3" \
1022 0 \
1023 -s "Allocating compression buffer" \
1024 -c "Allocating compression buffer" \
1025 -s "Record expansion is unknown (compression)" \
1026 -c "Record expansion is unknown (compression)" \
1027 -S "error" \
1028 -C "error"
1029
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001030# Test current time in ServerHello
1031requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001032run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001033 "$P_SRV debug_level=3" \
1034 "$P_CLI debug_level=3" \
1035 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001036 -f "check_server_hello_time" \
1037 -F "check_server_hello_time"
1038
Simon Butcher8e004102016-10-14 00:48:33 +01001039# Test for uniqueness of IVs in AEAD ciphersuites
1040run_test "Unique IV in GCM" \
1041 "$P_SRV exchanges=20 debug_level=4" \
1042 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1043 0 \
1044 -u "IV used" \
1045 -U "IV used"
1046
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001047# Tests for rc4 option
1048
Simon Butchera410af52016-05-19 22:12:18 +01001049requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001050run_test "RC4: server disabled, client enabled" \
1051 "$P_SRV" \
1052 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1053 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001054 -s "SSL - The server has no ciphersuites in common"
1055
Simon Butchera410af52016-05-19 22:12:18 +01001056requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001057run_test "RC4: server half, client enabled" \
1058 "$P_SRV arc4=1" \
1059 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1060 1 \
1061 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001062
1063run_test "RC4: server enabled, client disabled" \
1064 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1065 "$P_CLI" \
1066 1 \
1067 -s "SSL - The server has no ciphersuites in common"
1068
1069run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001070 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001071 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1072 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001073 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001074 -S "SSL - The server has no ciphersuites in common"
1075
Hanno Beckerd26bb202018-08-17 09:54:10 +01001076# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1077
1078requires_gnutls
1079requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1080run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1081 "$G_SRV"\
1082 "$P_CLI force_version=tls1_1" \
1083 0
1084
1085requires_gnutls
1086requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1087run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1088 "$G_SRV"\
1089 "$P_CLI force_version=tls1" \
1090 0
1091
Gilles Peskinebc70a182017-05-09 15:59:24 +02001092# Tests for SHA-1 support
1093
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001094requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001095run_test "SHA-1 forbidden by default in server certificate" \
1096 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1097 "$P_CLI debug_level=2 allow_sha1=0" \
1098 1 \
1099 -c "The certificate is signed with an unacceptable hash"
1100
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001101requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1102run_test "SHA-1 forbidden by default in server certificate" \
1103 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1104 "$P_CLI debug_level=2 allow_sha1=0" \
1105 0
1106
Gilles Peskinebc70a182017-05-09 15:59:24 +02001107run_test "SHA-1 explicitly allowed in server certificate" \
1108 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1109 "$P_CLI allow_sha1=1" \
1110 0
1111
1112run_test "SHA-256 allowed by default in server certificate" \
1113 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1114 "$P_CLI allow_sha1=0" \
1115 0
1116
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001117requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001118run_test "SHA-1 forbidden by default in client certificate" \
1119 "$P_SRV auth_mode=required allow_sha1=0" \
1120 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1121 1 \
1122 -s "The certificate is signed with an unacceptable hash"
1123
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001124requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1125run_test "SHA-1 forbidden 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-sha1.crt" \
1128 0
1129
Gilles Peskinebc70a182017-05-09 15:59:24 +02001130run_test "SHA-1 explicitly allowed in client certificate" \
1131 "$P_SRV auth_mode=required allow_sha1=1" \
1132 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1133 0
1134
1135run_test "SHA-256 allowed by default in client certificate" \
1136 "$P_SRV auth_mode=required allow_sha1=0" \
1137 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1138 0
1139
Hanno Becker7ae8a762018-08-14 15:43:35 +01001140# Tests for datagram packing
1141run_test "DTLS: multiple records in same datagram, client and server" \
1142 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1143 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1144 0 \
1145 -c "next record in same datagram" \
1146 -s "next record in same datagram"
1147
1148run_test "DTLS: multiple records in same datagram, client only" \
1149 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1150 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1151 0 \
1152 -s "next record in same datagram" \
1153 -C "next record in same datagram"
1154
1155run_test "DTLS: multiple records in same datagram, server only" \
1156 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1157 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1158 0 \
1159 -S "next record in same datagram" \
1160 -c "next record in same datagram"
1161
1162run_test "DTLS: multiple records in same datagram, neither client nor server" \
1163 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1164 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1165 0 \
1166 -S "next record in same datagram" \
1167 -C "next record in same datagram"
1168
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001169# Tests for Truncated HMAC extension
1170
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001171run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001172 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001173 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001174 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001175 -s "dumping 'expected mac' (20 bytes)" \
1176 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001177
Hanno Becker32c55012017-11-10 08:42:54 +00001178requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001179run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001180 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001181 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001182 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001183 -s "dumping 'expected mac' (20 bytes)" \
1184 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001185
Hanno Becker32c55012017-11-10 08:42:54 +00001186requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001187run_test "Truncated HMAC: client enabled, server default" \
1188 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001189 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001190 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001191 -s "dumping 'expected mac' (20 bytes)" \
1192 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001193
Hanno Becker32c55012017-11-10 08:42:54 +00001194requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001195run_test "Truncated HMAC: client enabled, server disabled" \
1196 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001197 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001198 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001199 -s "dumping 'expected mac' (20 bytes)" \
1200 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001201
Hanno Becker32c55012017-11-10 08:42:54 +00001202requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001203run_test "Truncated HMAC: client disabled, server enabled" \
1204 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001205 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001206 0 \
1207 -s "dumping 'expected mac' (20 bytes)" \
1208 -S "dumping 'expected mac' (10 bytes)"
1209
1210requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001211run_test "Truncated HMAC: client enabled, server enabled" \
1212 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001213 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001214 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001215 -S "dumping 'expected mac' (20 bytes)" \
1216 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001217
Hanno Becker4c4f4102017-11-10 09:16:05 +00001218run_test "Truncated HMAC, DTLS: client default, server default" \
1219 "$P_SRV dtls=1 debug_level=4" \
1220 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1221 0 \
1222 -s "dumping 'expected mac' (20 bytes)" \
1223 -S "dumping 'expected mac' (10 bytes)"
1224
1225requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1226run_test "Truncated HMAC, DTLS: client disabled, server default" \
1227 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001228 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001229 0 \
1230 -s "dumping 'expected mac' (20 bytes)" \
1231 -S "dumping 'expected mac' (10 bytes)"
1232
1233requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1234run_test "Truncated HMAC, DTLS: client enabled, server default" \
1235 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001236 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001237 0 \
1238 -s "dumping 'expected mac' (20 bytes)" \
1239 -S "dumping 'expected mac' (10 bytes)"
1240
1241requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1242run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1243 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001244 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001245 0 \
1246 -s "dumping 'expected mac' (20 bytes)" \
1247 -S "dumping 'expected mac' (10 bytes)"
1248
1249requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1250run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1251 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001252 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001253 0 \
1254 -s "dumping 'expected mac' (20 bytes)" \
1255 -S "dumping 'expected mac' (10 bytes)"
1256
1257requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1258run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1259 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001260 "$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 +01001261 0 \
1262 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001263 -s "dumping 'expected mac' (10 bytes)"
1264
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001265# Tests for Encrypt-then-MAC extension
1266
1267run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001268 "$P_SRV debug_level=3 \
1269 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001270 "$P_CLI debug_level=3" \
1271 0 \
1272 -c "client hello, adding encrypt_then_mac extension" \
1273 -s "found encrypt then mac extension" \
1274 -s "server hello, adding encrypt then mac extension" \
1275 -c "found encrypt_then_mac extension" \
1276 -c "using encrypt then mac" \
1277 -s "using encrypt then mac"
1278
1279run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001280 "$P_SRV debug_level=3 etm=0 \
1281 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001282 "$P_CLI debug_level=3 etm=1" \
1283 0 \
1284 -c "client hello, adding encrypt_then_mac extension" \
1285 -s "found encrypt then mac extension" \
1286 -S "server hello, adding encrypt then mac extension" \
1287 -C "found encrypt_then_mac extension" \
1288 -C "using encrypt then mac" \
1289 -S "using encrypt then mac"
1290
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001291run_test "Encrypt then MAC: client enabled, aead cipher" \
1292 "$P_SRV debug_level=3 etm=1 \
1293 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1294 "$P_CLI debug_level=3 etm=1" \
1295 0 \
1296 -c "client hello, adding encrypt_then_mac extension" \
1297 -s "found encrypt then mac extension" \
1298 -S "server hello, adding encrypt then mac extension" \
1299 -C "found encrypt_then_mac extension" \
1300 -C "using encrypt then mac" \
1301 -S "using encrypt then mac"
1302
1303run_test "Encrypt then MAC: client enabled, stream cipher" \
1304 "$P_SRV debug_level=3 etm=1 \
1305 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001306 "$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 +01001307 0 \
1308 -c "client hello, adding encrypt_then_mac extension" \
1309 -s "found encrypt then mac extension" \
1310 -S "server hello, adding encrypt then mac extension" \
1311 -C "found encrypt_then_mac extension" \
1312 -C "using encrypt then mac" \
1313 -S "using encrypt then mac"
1314
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001315run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001316 "$P_SRV debug_level=3 etm=1 \
1317 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001318 "$P_CLI debug_level=3 etm=0" \
1319 0 \
1320 -C "client hello, adding encrypt_then_mac extension" \
1321 -S "found encrypt then mac extension" \
1322 -S "server hello, adding encrypt then mac extension" \
1323 -C "found encrypt_then_mac extension" \
1324 -C "using encrypt then mac" \
1325 -S "using encrypt then mac"
1326
Janos Follathe2681a42016-03-07 15:57:05 +00001327requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001328run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001329 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001330 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001331 "$P_CLI debug_level=3 force_version=ssl3" \
1332 0 \
1333 -C "client hello, adding encrypt_then_mac extension" \
1334 -S "found encrypt then mac extension" \
1335 -S "server hello, adding encrypt then mac extension" \
1336 -C "found encrypt_then_mac extension" \
1337 -C "using encrypt then mac" \
1338 -S "using encrypt then mac"
1339
Janos Follathe2681a42016-03-07 15:57:05 +00001340requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001341run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001342 "$P_SRV debug_level=3 force_version=ssl3 \
1343 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001344 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001345 0 \
1346 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001347 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001348 -S "server hello, adding encrypt then mac extension" \
1349 -C "found encrypt_then_mac extension" \
1350 -C "using encrypt then mac" \
1351 -S "using encrypt then mac"
1352
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001353# Tests for Extended Master Secret extension
1354
1355run_test "Extended Master Secret: default" \
1356 "$P_SRV debug_level=3" \
1357 "$P_CLI debug_level=3" \
1358 0 \
1359 -c "client hello, adding extended_master_secret extension" \
1360 -s "found extended master secret extension" \
1361 -s "server hello, adding extended master secret extension" \
1362 -c "found extended_master_secret extension" \
1363 -c "using extended master secret" \
1364 -s "using extended master secret"
1365
1366run_test "Extended Master Secret: client enabled, server disabled" \
1367 "$P_SRV debug_level=3 extended_ms=0" \
1368 "$P_CLI debug_level=3 extended_ms=1" \
1369 0 \
1370 -c "client hello, adding extended_master_secret extension" \
1371 -s "found extended master secret extension" \
1372 -S "server hello, adding extended master secret extension" \
1373 -C "found extended_master_secret extension" \
1374 -C "using extended master secret" \
1375 -S "using extended master secret"
1376
1377run_test "Extended Master Secret: client disabled, server enabled" \
1378 "$P_SRV debug_level=3 extended_ms=1" \
1379 "$P_CLI debug_level=3 extended_ms=0" \
1380 0 \
1381 -C "client hello, adding extended_master_secret extension" \
1382 -S "found extended master secret extension" \
1383 -S "server hello, adding extended master secret extension" \
1384 -C "found extended_master_secret extension" \
1385 -C "using extended master secret" \
1386 -S "using extended master secret"
1387
Janos Follathe2681a42016-03-07 15:57:05 +00001388requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001389run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001390 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001391 "$P_CLI debug_level=3 force_version=ssl3" \
1392 0 \
1393 -C "client hello, adding extended_master_secret extension" \
1394 -S "found extended master secret extension" \
1395 -S "server hello, adding extended master secret extension" \
1396 -C "found extended_master_secret extension" \
1397 -C "using extended master secret" \
1398 -S "using extended master secret"
1399
Janos Follathe2681a42016-03-07 15:57:05 +00001400requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001401run_test "Extended Master Secret: client enabled, server SSLv3" \
1402 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001403 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001404 0 \
1405 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001406 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001407 -S "server hello, adding extended master secret extension" \
1408 -C "found extended_master_secret extension" \
1409 -C "using extended master secret" \
1410 -S "using extended master secret"
1411
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001412# Tests for FALLBACK_SCSV
1413
1414run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001415 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001416 "$P_CLI debug_level=3 force_version=tls1_1" \
1417 0 \
1418 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001419 -S "received FALLBACK_SCSV" \
1420 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001421 -C "is a fatal alert message (msg 86)"
1422
1423run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001424 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001425 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1426 0 \
1427 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001428 -S "received FALLBACK_SCSV" \
1429 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001430 -C "is a fatal alert message (msg 86)"
1431
1432run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001433 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001434 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001435 1 \
1436 -c "adding FALLBACK_SCSV" \
1437 -s "received FALLBACK_SCSV" \
1438 -s "inapropriate fallback" \
1439 -c "is a fatal alert message (msg 86)"
1440
1441run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001442 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001443 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001444 0 \
1445 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001446 -s "received FALLBACK_SCSV" \
1447 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001448 -C "is a fatal alert message (msg 86)"
1449
1450requires_openssl_with_fallback_scsv
1451run_test "Fallback SCSV: default, openssl server" \
1452 "$O_SRV" \
1453 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1454 0 \
1455 -C "adding FALLBACK_SCSV" \
1456 -C "is a fatal alert message (msg 86)"
1457
1458requires_openssl_with_fallback_scsv
1459run_test "Fallback SCSV: enabled, openssl server" \
1460 "$O_SRV" \
1461 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1462 1 \
1463 -c "adding FALLBACK_SCSV" \
1464 -c "is a fatal alert message (msg 86)"
1465
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001466requires_openssl_with_fallback_scsv
1467run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001468 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001469 "$O_CLI -tls1_1" \
1470 0 \
1471 -S "received FALLBACK_SCSV" \
1472 -S "inapropriate fallback"
1473
1474requires_openssl_with_fallback_scsv
1475run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001476 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001477 "$O_CLI -tls1_1 -fallback_scsv" \
1478 1 \
1479 -s "received FALLBACK_SCSV" \
1480 -s "inapropriate fallback"
1481
1482requires_openssl_with_fallback_scsv
1483run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001484 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001485 "$O_CLI -fallback_scsv" \
1486 0 \
1487 -s "received FALLBACK_SCSV" \
1488 -S "inapropriate fallback"
1489
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001490# Test sending and receiving empty application data records
1491
1492run_test "Encrypt then MAC: empty application data record" \
1493 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1494 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1495 0 \
1496 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1497 -s "dumping 'input payload after decrypt' (0 bytes)" \
1498 -c "0 bytes written in 1 fragments"
1499
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001500run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001501 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1502 "$P_CLI auth_mode=none etm=0 request_size=0" \
1503 0 \
1504 -s "dumping 'input payload after decrypt' (0 bytes)" \
1505 -c "0 bytes written in 1 fragments"
1506
1507run_test "Encrypt then MAC, DTLS: empty application data record" \
1508 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1509 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1510 0 \
1511 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1512 -s "dumping 'input payload after decrypt' (0 bytes)" \
1513 -c "0 bytes written in 1 fragments"
1514
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001515run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001516 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1517 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1518 0 \
1519 -s "dumping 'input payload after decrypt' (0 bytes)" \
1520 -c "0 bytes written in 1 fragments"
1521
Gilles Peskined50177f2017-05-16 17:53:03 +02001522## ClientHello generated with
1523## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1524## then manually twiddling the ciphersuite list.
1525## The ClientHello content is spelled out below as a hex string as
1526## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1527## The expected response is an inappropriate_fallback alert.
1528requires_openssl_with_fallback_scsv
1529run_test "Fallback SCSV: beginning of list" \
1530 "$P_SRV debug_level=2" \
1531 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1532 0 \
1533 -s "received FALLBACK_SCSV" \
1534 -s "inapropriate fallback"
1535
1536requires_openssl_with_fallback_scsv
1537run_test "Fallback SCSV: end of list" \
1538 "$P_SRV debug_level=2" \
1539 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1540 0 \
1541 -s "received FALLBACK_SCSV" \
1542 -s "inapropriate fallback"
1543
1544## Here the expected response is a valid ServerHello prefix, up to the random.
1545requires_openssl_with_fallback_scsv
1546run_test "Fallback SCSV: not in list" \
1547 "$P_SRV debug_level=2" \
1548 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1549 0 \
1550 -S "received FALLBACK_SCSV" \
1551 -S "inapropriate fallback"
1552
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001553# Tests for CBC 1/n-1 record splitting
1554
1555run_test "CBC Record splitting: TLS 1.2, no splitting" \
1556 "$P_SRV" \
1557 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1558 request_size=123 force_version=tls1_2" \
1559 0 \
1560 -s "Read from client: 123 bytes read" \
1561 -S "Read from client: 1 bytes read" \
1562 -S "122 bytes read"
1563
1564run_test "CBC Record splitting: TLS 1.1, no splitting" \
1565 "$P_SRV" \
1566 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1567 request_size=123 force_version=tls1_1" \
1568 0 \
1569 -s "Read from client: 123 bytes read" \
1570 -S "Read from client: 1 bytes read" \
1571 -S "122 bytes read"
1572
1573run_test "CBC Record splitting: TLS 1.0, splitting" \
1574 "$P_SRV" \
1575 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1576 request_size=123 force_version=tls1" \
1577 0 \
1578 -S "Read from client: 123 bytes read" \
1579 -s "Read from client: 1 bytes read" \
1580 -s "122 bytes read"
1581
Janos Follathe2681a42016-03-07 15:57:05 +00001582requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001583run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001584 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001585 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1586 request_size=123 force_version=ssl3" \
1587 0 \
1588 -S "Read from client: 123 bytes read" \
1589 -s "Read from client: 1 bytes read" \
1590 -s "122 bytes read"
1591
1592run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001593 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001594 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1595 request_size=123 force_version=tls1" \
1596 0 \
1597 -s "Read from client: 123 bytes read" \
1598 -S "Read from client: 1 bytes read" \
1599 -S "122 bytes read"
1600
1601run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1602 "$P_SRV" \
1603 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1604 request_size=123 force_version=tls1 recsplit=0" \
1605 0 \
1606 -s "Read from client: 123 bytes read" \
1607 -S "Read from client: 1 bytes read" \
1608 -S "122 bytes read"
1609
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001610run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1611 "$P_SRV nbio=2" \
1612 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1613 request_size=123 force_version=tls1" \
1614 0 \
1615 -S "Read from client: 123 bytes read" \
1616 -s "Read from client: 1 bytes read" \
1617 -s "122 bytes read"
1618
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001619# Tests for Session Tickets
1620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001621run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001622 "$P_SRV debug_level=3 tickets=1" \
1623 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001624 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001625 -c "client hello, adding session ticket extension" \
1626 -s "found session ticket extension" \
1627 -s "server hello, adding session ticket extension" \
1628 -c "found session_ticket extension" \
1629 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001630 -S "session successfully restored from cache" \
1631 -s "session successfully restored from ticket" \
1632 -s "a session has been resumed" \
1633 -c "a session has been resumed"
1634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001635run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001636 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1637 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001638 0 \
1639 -c "client hello, adding session ticket extension" \
1640 -s "found session ticket extension" \
1641 -s "server hello, adding session ticket extension" \
1642 -c "found session_ticket extension" \
1643 -c "parse new session ticket" \
1644 -S "session successfully restored from cache" \
1645 -s "session successfully restored from ticket" \
1646 -s "a session has been resumed" \
1647 -c "a session has been resumed"
1648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001649run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001650 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1651 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001652 0 \
1653 -c "client hello, adding session ticket extension" \
1654 -s "found session ticket extension" \
1655 -s "server hello, adding session ticket extension" \
1656 -c "found session_ticket extension" \
1657 -c "parse new session ticket" \
1658 -S "session successfully restored from cache" \
1659 -S "session successfully restored from ticket" \
1660 -S "a session has been resumed" \
1661 -C "a session has been resumed"
1662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001663run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001664 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001665 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001666 0 \
1667 -c "client hello, adding session ticket extension" \
1668 -c "found session_ticket extension" \
1669 -c "parse new session ticket" \
1670 -c "a session has been resumed"
1671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001672run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001673 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001674 "( $O_CLI -sess_out $SESSION; \
1675 $O_CLI -sess_in $SESSION; \
1676 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001677 0 \
1678 -s "found session ticket extension" \
1679 -s "server hello, adding session ticket extension" \
1680 -S "session successfully restored from cache" \
1681 -s "session successfully restored from ticket" \
1682 -s "a session has been resumed"
1683
Hanno Becker1d739932018-08-21 13:55:22 +01001684# Tests for Session Tickets with DTLS
1685
1686run_test "Session resume using tickets, DTLS: basic" \
1687 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001688 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001689 0 \
1690 -c "client hello, adding session ticket extension" \
1691 -s "found session ticket extension" \
1692 -s "server hello, adding session ticket extension" \
1693 -c "found session_ticket extension" \
1694 -c "parse new session ticket" \
1695 -S "session successfully restored from cache" \
1696 -s "session successfully restored from ticket" \
1697 -s "a session has been resumed" \
1698 -c "a session has been resumed"
1699
1700run_test "Session resume using tickets, DTLS: cache disabled" \
1701 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001702 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001703 0 \
1704 -c "client hello, adding session ticket extension" \
1705 -s "found session ticket extension" \
1706 -s "server hello, adding session ticket extension" \
1707 -c "found session_ticket extension" \
1708 -c "parse new session ticket" \
1709 -S "session successfully restored from cache" \
1710 -s "session successfully restored from ticket" \
1711 -s "a session has been resumed" \
1712 -c "a session has been resumed"
1713
1714run_test "Session resume using tickets, DTLS: timeout" \
1715 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001716 "$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 +01001717 0 \
1718 -c "client hello, adding session ticket extension" \
1719 -s "found session ticket extension" \
1720 -s "server hello, adding session ticket extension" \
1721 -c "found session_ticket extension" \
1722 -c "parse new session ticket" \
1723 -S "session successfully restored from cache" \
1724 -S "session successfully restored from ticket" \
1725 -S "a session has been resumed" \
1726 -C "a session has been resumed"
1727
1728run_test "Session resume using tickets, DTLS: openssl server" \
1729 "$O_SRV -dtls1" \
1730 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1731 0 \
1732 -c "client hello, adding session ticket extension" \
1733 -c "found session_ticket extension" \
1734 -c "parse new session ticket" \
1735 -c "a session has been resumed"
1736
1737run_test "Session resume using tickets, DTLS: openssl client" \
1738 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1739 "( $O_CLI -dtls1 -sess_out $SESSION; \
1740 $O_CLI -dtls1 -sess_in $SESSION; \
1741 rm -f $SESSION )" \
1742 0 \
1743 -s "found session ticket extension" \
1744 -s "server hello, adding session ticket extension" \
1745 -S "session successfully restored from cache" \
1746 -s "session successfully restored from ticket" \
1747 -s "a session has been resumed"
1748
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001749# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001751run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001752 "$P_SRV debug_level=3 tickets=0" \
1753 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001754 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001755 -c "client hello, adding session ticket extension" \
1756 -s "found session ticket extension" \
1757 -S "server hello, adding session ticket extension" \
1758 -C "found session_ticket extension" \
1759 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001760 -s "session successfully restored from cache" \
1761 -S "session successfully restored from ticket" \
1762 -s "a session has been resumed" \
1763 -c "a session has been resumed"
1764
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001765run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001766 "$P_SRV debug_level=3 tickets=1" \
1767 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001768 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001769 -C "client hello, adding session ticket extension" \
1770 -S "found session ticket extension" \
1771 -S "server hello, adding session ticket extension" \
1772 -C "found session_ticket extension" \
1773 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001774 -s "session successfully restored from cache" \
1775 -S "session successfully restored from ticket" \
1776 -s "a session has been resumed" \
1777 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001779run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001780 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1781 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001782 0 \
1783 -S "session successfully restored from cache" \
1784 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001785 -S "a session has been resumed" \
1786 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001788run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001789 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1790 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001791 0 \
1792 -s "session successfully restored from cache" \
1793 -S "session successfully restored from ticket" \
1794 -s "a session has been resumed" \
1795 -c "a session has been resumed"
1796
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001797run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001798 "$P_SRV debug_level=3 tickets=0" \
1799 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001800 0 \
1801 -s "session successfully restored from cache" \
1802 -S "session successfully restored from ticket" \
1803 -s "a session has been resumed" \
1804 -c "a session has been resumed"
1805
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001806run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001807 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1808 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001809 0 \
1810 -S "session successfully restored from cache" \
1811 -S "session successfully restored from ticket" \
1812 -S "a session has been resumed" \
1813 -C "a session has been resumed"
1814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001815run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001816 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1817 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001818 0 \
1819 -s "session successfully restored from cache" \
1820 -S "session successfully restored from ticket" \
1821 -s "a session has been resumed" \
1822 -c "a session has been resumed"
1823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001824run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001825 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001826 "( $O_CLI -sess_out $SESSION; \
1827 $O_CLI -sess_in $SESSION; \
1828 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001829 0 \
1830 -s "found session ticket extension" \
1831 -S "server hello, adding session ticket extension" \
1832 -s "session successfully restored from cache" \
1833 -S "session successfully restored from ticket" \
1834 -s "a session has been resumed"
1835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001836run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001837 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001838 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001839 0 \
1840 -C "found session_ticket extension" \
1841 -C "parse new session ticket" \
1842 -c "a session has been resumed"
1843
Hanno Becker1d739932018-08-21 13:55:22 +01001844# Tests for Session Resume based on session-ID and cache, DTLS
1845
1846run_test "Session resume using cache, DTLS: tickets enabled on client" \
1847 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001848 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001849 0 \
1850 -c "client hello, adding session ticket extension" \
1851 -s "found session ticket extension" \
1852 -S "server hello, adding session ticket extension" \
1853 -C "found session_ticket extension" \
1854 -C "parse new session ticket" \
1855 -s "session successfully restored from cache" \
1856 -S "session successfully restored from ticket" \
1857 -s "a session has been resumed" \
1858 -c "a session has been resumed"
1859
1860run_test "Session resume using cache, DTLS: tickets enabled on server" \
1861 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001862 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001863 0 \
1864 -C "client hello, adding session ticket extension" \
1865 -S "found session ticket extension" \
1866 -S "server hello, adding session ticket extension" \
1867 -C "found session_ticket extension" \
1868 -C "parse new session ticket" \
1869 -s "session successfully restored from cache" \
1870 -S "session successfully restored from ticket" \
1871 -s "a session has been resumed" \
1872 -c "a session has been resumed"
1873
1874run_test "Session resume using cache, DTLS: cache_max=0" \
1875 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001876 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001877 0 \
1878 -S "session successfully restored from cache" \
1879 -S "session successfully restored from ticket" \
1880 -S "a session has been resumed" \
1881 -C "a session has been resumed"
1882
1883run_test "Session resume using cache, DTLS: cache_max=1" \
1884 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001885 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001886 0 \
1887 -s "session successfully restored from cache" \
1888 -S "session successfully restored from ticket" \
1889 -s "a session has been resumed" \
1890 -c "a session has been resumed"
1891
1892run_test "Session resume using cache, DTLS: timeout > delay" \
1893 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001894 "$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 +01001895 0 \
1896 -s "session successfully restored from cache" \
1897 -S "session successfully restored from ticket" \
1898 -s "a session has been resumed" \
1899 -c "a session has been resumed"
1900
1901run_test "Session resume using cache, DTLS: timeout < delay" \
1902 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001903 "$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 +01001904 0 \
1905 -S "session successfully restored from cache" \
1906 -S "session successfully restored from ticket" \
1907 -S "a session has been resumed" \
1908 -C "a session has been resumed"
1909
1910run_test "Session resume using cache, DTLS: no timeout" \
1911 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001912 "$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 +01001913 0 \
1914 -s "session successfully restored from cache" \
1915 -S "session successfully restored from ticket" \
1916 -s "a session has been resumed" \
1917 -c "a session has been resumed"
1918
1919run_test "Session resume using cache, DTLS: openssl client" \
1920 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1921 "( $O_CLI -dtls1 -sess_out $SESSION; \
1922 $O_CLI -dtls1 -sess_in $SESSION; \
1923 rm -f $SESSION )" \
1924 0 \
1925 -s "found session ticket extension" \
1926 -S "server hello, adding session ticket extension" \
1927 -s "session successfully restored from cache" \
1928 -S "session successfully restored from ticket" \
1929 -s "a session has been resumed"
1930
1931run_test "Session resume using cache, DTLS: openssl server" \
1932 "$O_SRV -dtls1" \
1933 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1934 0 \
1935 -C "found session_ticket extension" \
1936 -C "parse new session ticket" \
1937 -c "a session has been resumed"
1938
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001939# Tests for Max Fragment Length extension
1940
Hanno Becker4aed27e2017-09-18 15:00:34 +01001941requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001942run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001943 "$P_SRV debug_level=3" \
1944 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001945 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001946 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1947 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001948 -C "client hello, adding max_fragment_length extension" \
1949 -S "found max fragment length extension" \
1950 -S "server hello, max_fragment_length extension" \
1951 -C "found max_fragment_length extension"
1952
Hanno Becker4aed27e2017-09-18 15:00:34 +01001953requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001954run_test "Max fragment length: enabled, default, larger message" \
1955 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001956 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001957 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001958 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1959 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001960 -C "client hello, adding max_fragment_length extension" \
1961 -S "found max fragment length extension" \
1962 -S "server hello, max_fragment_length extension" \
1963 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001964 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1965 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001966 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001967
1968requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1969run_test "Max fragment length, DTLS: enabled, default, larger message" \
1970 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001971 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001972 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001973 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1974 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001975 -C "client hello, adding max_fragment_length extension" \
1976 -S "found max fragment length extension" \
1977 -S "server hello, max_fragment_length extension" \
1978 -C "found max_fragment_length extension" \
1979 -c "fragment larger than.*maximum "
1980
Angus Grattonc4dd0732018-04-11 16:28:39 +10001981# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1982# (session fragment length will be 16384 regardless of mbedtls
1983# content length configuration.)
1984
Hanno Beckerc5266962017-09-18 15:01:50 +01001985requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1986run_test "Max fragment length: disabled, larger message" \
1987 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001988 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001989 0 \
1990 -C "Maximum fragment length is 16384" \
1991 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001992 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1993 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001994 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001995
1996requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takano2e580ce2021-06-21 19:43:33 +01001997run_test "Max fragment length, DTLS: disabled, larger message" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001998 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001999 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002000 1 \
2001 -C "Maximum fragment length is 16384" \
2002 -S "Maximum fragment length is 16384" \
2003 -c "fragment larger than.*maximum "
2004
Yuto Takano0807e1d2021-07-02 10:10:49 +01002005requires_max_content_len 4096
Hanno Beckerc5266962017-09-18 15:01:50 +01002006requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002007run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002008 "$P_SRV debug_level=3" \
2009 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002010 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002011 -c "Maximum fragment length is 4096" \
2012 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002013 -c "client hello, adding max_fragment_length extension" \
2014 -s "found max fragment length extension" \
2015 -s "server hello, max_fragment_length extension" \
2016 -c "found max_fragment_length extension"
2017
Yuto Takano0807e1d2021-07-02 10:10:49 +01002018requires_max_content_len 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002019requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002020run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002021 "$P_SRV debug_level=3 max_frag_len=4096" \
2022 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002023 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002024 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002025 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002026 -C "client hello, adding max_fragment_length extension" \
2027 -S "found max fragment length extension" \
2028 -S "server hello, max_fragment_length extension" \
2029 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002030
Yuto Takano0807e1d2021-07-02 10:10:49 +01002031requires_max_content_len 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002032requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002033requires_gnutls
2034run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002035 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002036 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002037 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002038 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002039 -c "client hello, adding max_fragment_length extension" \
2040 -c "found max_fragment_length extension"
2041
Yuto Takano0807e1d2021-07-02 10:10:49 +01002042requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002043requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002044run_test "Max fragment length: client, message just fits" \
2045 "$P_SRV debug_level=3" \
2046 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
2047 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002048 -c "Maximum fragment length is 2048" \
2049 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002050 -c "client hello, adding max_fragment_length extension" \
2051 -s "found max fragment length extension" \
2052 -s "server hello, max_fragment_length extension" \
2053 -c "found max_fragment_length extension" \
2054 -c "2048 bytes written in 1 fragments" \
2055 -s "2048 bytes read"
2056
Yuto Takano0807e1d2021-07-02 10:10:49 +01002057requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002058requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002059run_test "Max fragment length: client, larger message" \
2060 "$P_SRV debug_level=3" \
2061 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2062 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002063 -c "Maximum fragment length is 2048" \
2064 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002065 -c "client hello, adding max_fragment_length extension" \
2066 -s "found max fragment length extension" \
2067 -s "server hello, max_fragment_length extension" \
2068 -c "found max_fragment_length extension" \
2069 -c "2345 bytes written in 2 fragments" \
2070 -s "2048 bytes read" \
2071 -s "297 bytes read"
2072
Yuto Takano0807e1d2021-07-02 10:10:49 +01002073requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002074requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002075run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002076 "$P_SRV debug_level=3 dtls=1" \
2077 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2078 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002079 -c "Maximum fragment length is 2048" \
2080 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002081 -c "client hello, adding max_fragment_length extension" \
2082 -s "found max fragment length extension" \
2083 -s "server hello, max_fragment_length extension" \
2084 -c "found max_fragment_length extension" \
2085 -c "fragment larger than.*maximum"
2086
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002087# Tests for renegotiation
2088
Hanno Becker6a243642017-10-12 15:18:45 +01002089# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002090run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002091 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002092 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002093 0 \
2094 -C "client hello, adding renegotiation extension" \
2095 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2096 -S "found renegotiation extension" \
2097 -s "server hello, secure renegotiation extension" \
2098 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002099 -C "=> renegotiate" \
2100 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002101 -S "write hello request"
2102
Hanno Becker6a243642017-10-12 15:18:45 +01002103requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002104run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002105 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002106 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002107 0 \
2108 -c "client hello, adding renegotiation extension" \
2109 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2110 -s "found renegotiation extension" \
2111 -s "server hello, secure renegotiation extension" \
2112 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002113 -c "=> renegotiate" \
2114 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002115 -S "write hello request"
2116
Hanno Becker6a243642017-10-12 15:18:45 +01002117requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002118run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002119 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002120 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002121 0 \
2122 -c "client hello, adding renegotiation extension" \
2123 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2124 -s "found renegotiation extension" \
2125 -s "server hello, secure renegotiation extension" \
2126 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002127 -c "=> renegotiate" \
2128 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002129 -s "write hello request"
2130
Janos Follathb0f148c2017-10-05 12:29:42 +01002131# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2132# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2133# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002134requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002135run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2136 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2137 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2138 0 \
2139 -c "client hello, adding renegotiation extension" \
2140 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2141 -s "found renegotiation extension" \
2142 -s "server hello, secure renegotiation extension" \
2143 -c "found renegotiation extension" \
2144 -c "=> renegotiate" \
2145 -s "=> renegotiate" \
2146 -S "write hello request" \
2147 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2148
2149# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2150# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2151# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002152requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002153run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2154 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2155 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2156 0 \
2157 -c "client hello, adding renegotiation extension" \
2158 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2159 -s "found renegotiation extension" \
2160 -s "server hello, secure renegotiation extension" \
2161 -c "found renegotiation extension" \
2162 -c "=> renegotiate" \
2163 -s "=> renegotiate" \
2164 -s "write hello request" \
2165 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2166
Hanno Becker6a243642017-10-12 15:18:45 +01002167requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002168run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002169 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002170 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002171 0 \
2172 -c "client hello, adding renegotiation extension" \
2173 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2174 -s "found renegotiation extension" \
2175 -s "server hello, secure renegotiation extension" \
2176 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002177 -c "=> renegotiate" \
2178 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002179 -s "write hello request"
2180
Hanno Becker6a243642017-10-12 15:18:45 +01002181requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002182run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002183 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002184 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002185 1 \
2186 -c "client hello, adding renegotiation extension" \
2187 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2188 -S "found renegotiation extension" \
2189 -s "server hello, secure renegotiation extension" \
2190 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002191 -c "=> renegotiate" \
2192 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002193 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002194 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002195 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002196
Hanno Becker6a243642017-10-12 15:18:45 +01002197requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002198run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002199 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002200 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002201 0 \
2202 -C "client hello, adding renegotiation extension" \
2203 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2204 -S "found renegotiation extension" \
2205 -s "server hello, secure renegotiation extension" \
2206 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002207 -C "=> renegotiate" \
2208 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002209 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002210 -S "SSL - An unexpected message was received from our peer" \
2211 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002212
Hanno Becker6a243642017-10-12 15:18:45 +01002213requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002214run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002215 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002216 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002217 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002218 0 \
2219 -C "client hello, adding renegotiation extension" \
2220 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2221 -S "found renegotiation extension" \
2222 -s "server hello, secure renegotiation extension" \
2223 -c "found renegotiation extension" \
2224 -C "=> renegotiate" \
2225 -S "=> renegotiate" \
2226 -s "write hello request" \
2227 -S "SSL - An unexpected message was received from our peer" \
2228 -S "failed"
2229
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002230# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002231requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002232run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002233 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002234 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002235 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002236 0 \
2237 -C "client hello, adding renegotiation extension" \
2238 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2239 -S "found renegotiation extension" \
2240 -s "server hello, secure renegotiation extension" \
2241 -c "found renegotiation extension" \
2242 -C "=> renegotiate" \
2243 -S "=> renegotiate" \
2244 -s "write hello request" \
2245 -S "SSL - An unexpected message was received from our peer" \
2246 -S "failed"
2247
Hanno Becker6a243642017-10-12 15:18:45 +01002248requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002249run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002250 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002251 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002252 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002253 0 \
2254 -C "client hello, adding renegotiation extension" \
2255 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2256 -S "found renegotiation extension" \
2257 -s "server hello, secure renegotiation extension" \
2258 -c "found renegotiation extension" \
2259 -C "=> renegotiate" \
2260 -S "=> renegotiate" \
2261 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002262 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002263
Hanno Becker6a243642017-10-12 15:18:45 +01002264requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002265run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002266 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002267 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002268 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002269 0 \
2270 -c "client hello, adding renegotiation extension" \
2271 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2272 -s "found renegotiation extension" \
2273 -s "server hello, secure renegotiation extension" \
2274 -c "found renegotiation extension" \
2275 -c "=> renegotiate" \
2276 -s "=> renegotiate" \
2277 -s "write hello request" \
2278 -S "SSL - An unexpected message was received from our peer" \
2279 -S "failed"
2280
Hanno Becker6a243642017-10-12 15:18:45 +01002281requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002282run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002283 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002284 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2285 0 \
2286 -C "client hello, adding renegotiation extension" \
2287 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2288 -S "found renegotiation extension" \
2289 -s "server hello, secure renegotiation extension" \
2290 -c "found renegotiation extension" \
2291 -S "record counter limit reached: renegotiate" \
2292 -C "=> renegotiate" \
2293 -S "=> renegotiate" \
2294 -S "write hello request" \
2295 -S "SSL - An unexpected message was received from our peer" \
2296 -S "failed"
2297
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002298# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002299requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002300run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002301 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002302 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002303 0 \
2304 -c "client hello, adding renegotiation extension" \
2305 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2306 -s "found renegotiation extension" \
2307 -s "server hello, secure renegotiation extension" \
2308 -c "found renegotiation extension" \
2309 -s "record counter limit reached: renegotiate" \
2310 -c "=> renegotiate" \
2311 -s "=> renegotiate" \
2312 -s "write hello request" \
2313 -S "SSL - An unexpected message was received from our peer" \
2314 -S "failed"
2315
Hanno Becker6a243642017-10-12 15:18:45 +01002316requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002317run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002318 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002319 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002320 0 \
2321 -c "client hello, adding renegotiation extension" \
2322 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2323 -s "found renegotiation extension" \
2324 -s "server hello, secure renegotiation extension" \
2325 -c "found renegotiation extension" \
2326 -s "record counter limit reached: renegotiate" \
2327 -c "=> renegotiate" \
2328 -s "=> renegotiate" \
2329 -s "write hello request" \
2330 -S "SSL - An unexpected message was received from our peer" \
2331 -S "failed"
2332
Hanno Becker6a243642017-10-12 15:18:45 +01002333requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002334run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002335 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002336 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2337 0 \
2338 -C "client hello, adding renegotiation extension" \
2339 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2340 -S "found renegotiation extension" \
2341 -s "server hello, secure renegotiation extension" \
2342 -c "found renegotiation extension" \
2343 -S "record counter limit reached: renegotiate" \
2344 -C "=> renegotiate" \
2345 -S "=> renegotiate" \
2346 -S "write hello request" \
2347 -S "SSL - An unexpected message was received from our peer" \
2348 -S "failed"
2349
Hanno Becker6a243642017-10-12 15:18:45 +01002350requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002351run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002352 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002353 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002354 0 \
2355 -c "client hello, adding renegotiation extension" \
2356 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2357 -s "found renegotiation extension" \
2358 -s "server hello, secure renegotiation extension" \
2359 -c "found renegotiation extension" \
2360 -c "=> renegotiate" \
2361 -s "=> renegotiate" \
2362 -S "write hello request"
2363
Hanno Becker6a243642017-10-12 15:18:45 +01002364requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002365run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002366 "$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 +02002367 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002368 0 \
2369 -c "client hello, adding renegotiation extension" \
2370 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2371 -s "found renegotiation extension" \
2372 -s "server hello, secure renegotiation extension" \
2373 -c "found renegotiation extension" \
2374 -c "=> renegotiate" \
2375 -s "=> renegotiate" \
2376 -s "write hello request"
2377
Hanno Becker6a243642017-10-12 15:18:45 +01002378requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002379run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002380 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002381 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002382 0 \
2383 -c "client hello, adding renegotiation extension" \
2384 -c "found renegotiation extension" \
2385 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002386 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002387 -C "error" \
2388 -c "HTTP/1.0 200 [Oo][Kk]"
2389
Paul Bakker539d9722015-02-08 16:18:35 +01002390requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002391requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002392run_test "Renegotiation: gnutls server strict, client-initiated" \
2393 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002394 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002395 0 \
2396 -c "client hello, adding renegotiation extension" \
2397 -c "found renegotiation extension" \
2398 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002399 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002400 -C "error" \
2401 -c "HTTP/1.0 200 [Oo][Kk]"
2402
Paul Bakker539d9722015-02-08 16:18:35 +01002403requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002404requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002405run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2406 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2407 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2408 1 \
2409 -c "client hello, adding renegotiation extension" \
2410 -C "found renegotiation extension" \
2411 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002412 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002413 -c "error" \
2414 -C "HTTP/1.0 200 [Oo][Kk]"
2415
Paul Bakker539d9722015-02-08 16:18:35 +01002416requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002417requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002418run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2419 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2420 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2421 allow_legacy=0" \
2422 1 \
2423 -c "client hello, adding renegotiation extension" \
2424 -C "found renegotiation extension" \
2425 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002426 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002427 -c "error" \
2428 -C "HTTP/1.0 200 [Oo][Kk]"
2429
Paul Bakker539d9722015-02-08 16:18:35 +01002430requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002431requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002432run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2433 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2434 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2435 allow_legacy=1" \
2436 0 \
2437 -c "client hello, adding renegotiation extension" \
2438 -C "found renegotiation extension" \
2439 -c "=> renegotiate" \
2440 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002441 -C "error" \
2442 -c "HTTP/1.0 200 [Oo][Kk]"
2443
Hanno Becker6a243642017-10-12 15:18:45 +01002444requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002445run_test "Renegotiation: DTLS, client-initiated" \
2446 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2447 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2448 0 \
2449 -c "client hello, adding renegotiation extension" \
2450 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2451 -s "found renegotiation extension" \
2452 -s "server hello, secure renegotiation extension" \
2453 -c "found renegotiation extension" \
2454 -c "=> renegotiate" \
2455 -s "=> renegotiate" \
2456 -S "write hello request"
2457
Hanno Becker6a243642017-10-12 15:18:45 +01002458requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002459run_test "Renegotiation: DTLS, server-initiated" \
2460 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002461 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2462 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002463 0 \
2464 -c "client hello, adding renegotiation extension" \
2465 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2466 -s "found renegotiation extension" \
2467 -s "server hello, secure renegotiation extension" \
2468 -c "found renegotiation extension" \
2469 -c "=> renegotiate" \
2470 -s "=> renegotiate" \
2471 -s "write hello request"
2472
Hanno Becker6a243642017-10-12 15:18:45 +01002473requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002474run_test "Renegotiation: DTLS, renego_period overflow" \
2475 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2476 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2477 0 \
2478 -c "client hello, adding renegotiation extension" \
2479 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2480 -s "found renegotiation extension" \
2481 -s "server hello, secure renegotiation extension" \
2482 -s "record counter limit reached: renegotiate" \
2483 -c "=> renegotiate" \
2484 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002485 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002486
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002487requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002488requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002489run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2490 "$G_SRV -u --mtu 4096" \
2491 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2492 0 \
2493 -c "client hello, adding renegotiation extension" \
2494 -c "found renegotiation extension" \
2495 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002496 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002497 -C "error" \
2498 -s "Extra-header:"
2499
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002500# Test for the "secure renegotation" extension only (no actual renegotiation)
2501
Paul Bakker539d9722015-02-08 16:18:35 +01002502requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002503run_test "Renego ext: gnutls server strict, client default" \
2504 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2505 "$P_CLI debug_level=3" \
2506 0 \
2507 -c "found renegotiation extension" \
2508 -C "error" \
2509 -c "HTTP/1.0 200 [Oo][Kk]"
2510
Paul Bakker539d9722015-02-08 16:18:35 +01002511requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002512run_test "Renego ext: gnutls server unsafe, client default" \
2513 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2514 "$P_CLI debug_level=3" \
2515 0 \
2516 -C "found renegotiation extension" \
2517 -C "error" \
2518 -c "HTTP/1.0 200 [Oo][Kk]"
2519
Paul Bakker539d9722015-02-08 16:18:35 +01002520requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002521run_test "Renego ext: gnutls server unsafe, client break legacy" \
2522 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2523 "$P_CLI debug_level=3 allow_legacy=-1" \
2524 1 \
2525 -C "found renegotiation extension" \
2526 -c "error" \
2527 -C "HTTP/1.0 200 [Oo][Kk]"
2528
Paul Bakker539d9722015-02-08 16:18:35 +01002529requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002530run_test "Renego ext: gnutls client strict, server default" \
2531 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002532 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002533 0 \
2534 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2535 -s "server hello, secure renegotiation extension"
2536
Paul Bakker539d9722015-02-08 16:18:35 +01002537requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002538run_test "Renego ext: gnutls client unsafe, server default" \
2539 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002540 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002541 0 \
2542 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2543 -S "server hello, secure renegotiation extension"
2544
Paul Bakker539d9722015-02-08 16:18:35 +01002545requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002546run_test "Renego ext: gnutls client unsafe, server break legacy" \
2547 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002548 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002549 1 \
2550 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2551 -S "server hello, secure renegotiation extension"
2552
Janos Follath0b242342016-02-17 10:11:21 +00002553# Tests for silently dropping trailing extra bytes in .der certificates
2554
2555requires_gnutls
2556run_test "DER format: no trailing bytes" \
2557 "$P_SRV crt_file=data_files/server5-der0.crt \
2558 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002559 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002560 0 \
2561 -c "Handshake was completed" \
2562
2563requires_gnutls
2564run_test "DER format: with a trailing zero byte" \
2565 "$P_SRV crt_file=data_files/server5-der1a.crt \
2566 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002567 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002568 0 \
2569 -c "Handshake was completed" \
2570
2571requires_gnutls
2572run_test "DER format: with a trailing random byte" \
2573 "$P_SRV crt_file=data_files/server5-der1b.crt \
2574 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002575 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002576 0 \
2577 -c "Handshake was completed" \
2578
2579requires_gnutls
2580run_test "DER format: with 2 trailing random bytes" \
2581 "$P_SRV crt_file=data_files/server5-der2.crt \
2582 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002583 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002584 0 \
2585 -c "Handshake was completed" \
2586
2587requires_gnutls
2588run_test "DER format: with 4 trailing random bytes" \
2589 "$P_SRV crt_file=data_files/server5-der4.crt \
2590 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002591 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002592 0 \
2593 -c "Handshake was completed" \
2594
2595requires_gnutls
2596run_test "DER format: with 8 trailing random bytes" \
2597 "$P_SRV crt_file=data_files/server5-der8.crt \
2598 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002599 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002600 0 \
2601 -c "Handshake was completed" \
2602
2603requires_gnutls
2604run_test "DER format: with 9 trailing random bytes" \
2605 "$P_SRV crt_file=data_files/server5-der9.crt \
2606 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002607 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002608 0 \
2609 -c "Handshake was completed" \
2610
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002611# Tests for auth_mode
2612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002613run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002614 "$P_SRV crt_file=data_files/server5-badsign.crt \
2615 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002616 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002617 1 \
2618 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002619 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002620 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002621 -c "X509 - Certificate verification failed"
2622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002623run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002624 "$P_SRV crt_file=data_files/server5-badsign.crt \
2625 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002626 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002627 0 \
2628 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002629 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002630 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002631 -C "X509 - Certificate verification failed"
2632
Hanno Beckere6706e62017-05-15 16:05:15 +01002633run_test "Authentication: server goodcert, client optional, no trusted CA" \
2634 "$P_SRV" \
2635 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2636 0 \
2637 -c "x509_verify_cert() returned" \
2638 -c "! The certificate is not correctly signed by the trusted CA" \
2639 -c "! Certificate verification flags"\
2640 -C "! mbedtls_ssl_handshake returned" \
2641 -C "X509 - Certificate verification failed" \
2642 -C "SSL - No CA Chain is set, but required to operate"
2643
2644run_test "Authentication: server goodcert, client required, no trusted CA" \
2645 "$P_SRV" \
2646 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2647 1 \
2648 -c "x509_verify_cert() returned" \
2649 -c "! The certificate is not correctly signed by the trusted CA" \
2650 -c "! Certificate verification flags"\
2651 -c "! mbedtls_ssl_handshake returned" \
2652 -c "SSL - No CA Chain is set, but required to operate"
2653
2654# The purpose of the next two tests is to test the client's behaviour when receiving a server
2655# certificate with an unsupported elliptic curve. This should usually not happen because
2656# the client informs the server about the supported curves - it does, though, in the
2657# corner case of a static ECDH suite, because the server doesn't check the curve on that
2658# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2659# different means to have the server ignoring the client's supported curve list.
2660
2661requires_config_enabled MBEDTLS_ECP_C
2662run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2663 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2664 crt_file=data_files/server5.ku-ka.crt" \
2665 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2666 1 \
2667 -c "bad certificate (EC key curve)"\
2668 -c "! Certificate verification flags"\
2669 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2670
2671requires_config_enabled MBEDTLS_ECP_C
2672run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2673 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2674 crt_file=data_files/server5.ku-ka.crt" \
2675 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2676 1 \
2677 -c "bad certificate (EC key curve)"\
2678 -c "! Certificate verification flags"\
2679 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002681run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002682 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002683 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002684 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002685 0 \
2686 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002687 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002688 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002689 -C "X509 - Certificate verification failed"
2690
Simon Butcher99000142016-10-13 17:21:01 +01002691run_test "Authentication: client SHA256, server required" \
2692 "$P_SRV auth_mode=required" \
2693 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2694 key_file=data_files/server6.key \
2695 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2696 0 \
2697 -c "Supported Signature Algorithm found: 4," \
2698 -c "Supported Signature Algorithm found: 5,"
2699
2700run_test "Authentication: client SHA384, server required" \
2701 "$P_SRV auth_mode=required" \
2702 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2703 key_file=data_files/server6.key \
2704 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2705 0 \
2706 -c "Supported Signature Algorithm found: 4," \
2707 -c "Supported Signature Algorithm found: 5,"
2708
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002709requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2710run_test "Authentication: client has no cert, server required (SSLv3)" \
2711 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2712 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2713 key_file=data_files/server5.key" \
2714 1 \
2715 -S "skip write certificate request" \
2716 -C "skip parse certificate request" \
2717 -c "got a certificate request" \
2718 -c "got no certificate to send" \
2719 -S "x509_verify_cert() returned" \
2720 -s "client has no certificate" \
2721 -s "! mbedtls_ssl_handshake returned" \
2722 -c "! mbedtls_ssl_handshake returned" \
2723 -s "No client certification received from the client, but required by the authentication mode"
2724
2725run_test "Authentication: client has no cert, server required (TLS)" \
2726 "$P_SRV debug_level=3 auth_mode=required" \
2727 "$P_CLI debug_level=3 crt_file=none \
2728 key_file=data_files/server5.key" \
2729 1 \
2730 -S "skip write certificate request" \
2731 -C "skip parse certificate request" \
2732 -c "got a certificate request" \
2733 -c "= write certificate$" \
2734 -C "skip write certificate$" \
2735 -S "x509_verify_cert() returned" \
2736 -s "client has no certificate" \
2737 -s "! mbedtls_ssl_handshake returned" \
2738 -c "! mbedtls_ssl_handshake returned" \
2739 -s "No client certification received from the client, but required by the authentication mode"
2740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002741run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002742 "$P_SRV debug_level=3 auth_mode=required" \
2743 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002744 key_file=data_files/server5.key" \
2745 1 \
2746 -S "skip write certificate request" \
2747 -C "skip parse certificate request" \
2748 -c "got a certificate request" \
2749 -C "skip write certificate" \
2750 -C "skip write certificate verify" \
2751 -S "skip parse certificate verify" \
2752 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002753 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002754 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002755 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002756 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002757 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002758# We don't check that the client receives the alert because it might
2759# detect that its write end of the connection is closed and abort
2760# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002761
Janos Follath89baba22017-04-10 14:34:35 +01002762run_test "Authentication: client cert not trusted, server required" \
2763 "$P_SRV debug_level=3 auth_mode=required" \
2764 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2765 key_file=data_files/server5.key" \
2766 1 \
2767 -S "skip write certificate request" \
2768 -C "skip parse certificate request" \
2769 -c "got a certificate request" \
2770 -C "skip write certificate" \
2771 -C "skip write certificate verify" \
2772 -S "skip parse certificate verify" \
2773 -s "x509_verify_cert() returned" \
2774 -s "! The certificate is not correctly signed by the trusted CA" \
2775 -s "! mbedtls_ssl_handshake returned" \
2776 -c "! mbedtls_ssl_handshake returned" \
2777 -s "X509 - Certificate verification failed"
2778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002779run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002780 "$P_SRV debug_level=3 auth_mode=optional" \
2781 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002782 key_file=data_files/server5.key" \
2783 0 \
2784 -S "skip write certificate request" \
2785 -C "skip parse certificate request" \
2786 -c "got a certificate request" \
2787 -C "skip write certificate" \
2788 -C "skip write certificate verify" \
2789 -S "skip parse certificate verify" \
2790 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002791 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002792 -S "! mbedtls_ssl_handshake returned" \
2793 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002794 -S "X509 - Certificate verification failed"
2795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002796run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002797 "$P_SRV debug_level=3 auth_mode=none" \
2798 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002799 key_file=data_files/server5.key" \
2800 0 \
2801 -s "skip write certificate request" \
2802 -C "skip parse certificate request" \
2803 -c "got no certificate request" \
2804 -c "skip write certificate" \
2805 -c "skip write certificate verify" \
2806 -s "skip parse certificate verify" \
2807 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002808 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002809 -S "! mbedtls_ssl_handshake returned" \
2810 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002811 -S "X509 - Certificate verification failed"
2812
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002813run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002814 "$P_SRV debug_level=3 auth_mode=optional" \
2815 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002816 0 \
2817 -S "skip write certificate request" \
2818 -C "skip parse certificate request" \
2819 -c "got a certificate request" \
2820 -C "skip write certificate$" \
2821 -C "got no certificate to send" \
2822 -S "SSLv3 client has no certificate" \
2823 -c "skip write certificate verify" \
2824 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002825 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002826 -S "! mbedtls_ssl_handshake returned" \
2827 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002828 -S "X509 - Certificate verification failed"
2829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002830run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002831 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002832 "$O_CLI" \
2833 0 \
2834 -S "skip write certificate request" \
2835 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002836 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002837 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002838 -S "X509 - Certificate verification failed"
2839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002840run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002841 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002842 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002843 0 \
2844 -C "skip parse certificate request" \
2845 -c "got a certificate request" \
2846 -C "skip write certificate$" \
2847 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002848 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002849
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002850run_test "Authentication: client no cert, openssl server required" \
2851 "$O_SRV -Verify 10" \
2852 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2853 1 \
2854 -C "skip parse certificate request" \
2855 -c "got a certificate request" \
2856 -C "skip write certificate$" \
2857 -c "skip write certificate verify" \
2858 -c "! mbedtls_ssl_handshake returned"
2859
Janos Follathe2681a42016-03-07 15:57:05 +00002860requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002861run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002862 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002863 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002864 0 \
2865 -S "skip write certificate request" \
2866 -C "skip parse certificate request" \
2867 -c "got a certificate request" \
2868 -C "skip write certificate$" \
2869 -c "skip write certificate verify" \
2870 -c "got no certificate to send" \
2871 -s "SSLv3 client has no certificate" \
2872 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002873 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002874 -S "! mbedtls_ssl_handshake returned" \
2875 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002876 -S "X509 - Certificate verification failed"
2877
Yuto Takano8df2d252021-07-02 13:05:15 +01002878# This script assumes that MBEDTLS_X509_MAX_INTERMEDIATE_CA has its default
2879# value, defined here as MAX_IM_CA. Some test cases will be skipped if the
2880# library is configured with a different value.
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002881
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002882MAX_IM_CA='8'
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002883
Yuto Takano8df2d252021-07-02 13:05:15 +01002884# The tests for the max_int tests can pass with any number higher than MAX_IM_CA
2885# because only a chain of MAX_IM_CA length is tested. Equally, the max_int+1
2886# tests can pass with any number less than MAX_IM_CA. However, stricter preconditions
2887# are in place so that the semantics are consistent with the test description.
Yuto Takanoe153ca22021-06-21 20:07:12 +01002888requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2889requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002890requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002891run_test "Authentication: server max_int chain, client default" \
2892 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2893 key_file=data_files/dir-maxpath/09.key" \
2894 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2895 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002896 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002897
Yuto Takanod8a50292021-06-22 06:08:11 +01002898requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2899requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002900requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002901run_test "Authentication: server max_int+1 chain, client default" \
2902 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2903 key_file=data_files/dir-maxpath/10.key" \
2904 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2905 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002906 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002907
Yuto Takanod8a50292021-06-22 06:08:11 +01002908requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2909requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002910requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002911run_test "Authentication: server max_int+1 chain, client optional" \
2912 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2913 key_file=data_files/dir-maxpath/10.key" \
2914 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2915 auth_mode=optional" \
2916 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002917 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002918
Yuto Takanod8a50292021-06-22 06:08:11 +01002919requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2920requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002921requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002922run_test "Authentication: server max_int+1 chain, client none" \
2923 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2924 key_file=data_files/dir-maxpath/10.key" \
2925 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2926 auth_mode=none" \
2927 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002928 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002929
Yuto Takanod8a50292021-06-22 06:08:11 +01002930requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2931requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002932requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002933run_test "Authentication: client max_int+1 chain, server default" \
2934 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2935 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2936 key_file=data_files/dir-maxpath/10.key" \
2937 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002938 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002939
Yuto Takanod8a50292021-06-22 06:08:11 +01002940requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2941requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002942requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002943run_test "Authentication: client max_int+1 chain, server optional" \
2944 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2945 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2946 key_file=data_files/dir-maxpath/10.key" \
2947 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002948 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002949
Yuto Takanod8a50292021-06-22 06:08:11 +01002950requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2951requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002952requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002953run_test "Authentication: client max_int+1 chain, server required" \
2954 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2955 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2956 key_file=data_files/dir-maxpath/10.key" \
2957 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002958 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002959
Yuto Takanoe153ca22021-06-21 20:07:12 +01002960requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2961requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002962requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002963run_test "Authentication: client max_int chain, server required" \
2964 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2965 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2966 key_file=data_files/dir-maxpath/09.key" \
2967 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002968 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002969
Janos Follath89baba22017-04-10 14:34:35 +01002970# Tests for CA list in CertificateRequest messages
2971
2972run_test "Authentication: send CA list in CertificateRequest (default)" \
2973 "$P_SRV debug_level=3 auth_mode=required" \
2974 "$P_CLI crt_file=data_files/server6.crt \
2975 key_file=data_files/server6.key" \
2976 0 \
2977 -s "requested DN"
2978
2979run_test "Authentication: do not send CA list in CertificateRequest" \
2980 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2981 "$P_CLI crt_file=data_files/server6.crt \
2982 key_file=data_files/server6.key" \
2983 0 \
2984 -S "requested DN"
2985
2986run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2987 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2988 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2989 key_file=data_files/server5.key" \
2990 1 \
2991 -S "requested DN" \
2992 -s "x509_verify_cert() returned" \
2993 -s "! The certificate is not correctly signed by the trusted CA" \
2994 -s "! mbedtls_ssl_handshake returned" \
2995 -c "! mbedtls_ssl_handshake returned" \
2996 -s "X509 - Certificate verification failed"
2997
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002998# Tests for certificate selection based on SHA verson
2999
3000run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
3001 "$P_SRV crt_file=data_files/server5.crt \
3002 key_file=data_files/server5.key \
3003 crt_file2=data_files/server5-sha1.crt \
3004 key_file2=data_files/server5.key" \
3005 "$P_CLI force_version=tls1_2" \
3006 0 \
3007 -c "signed using.*ECDSA with SHA256" \
3008 -C "signed using.*ECDSA with SHA1"
3009
3010run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
3011 "$P_SRV crt_file=data_files/server5.crt \
3012 key_file=data_files/server5.key \
3013 crt_file2=data_files/server5-sha1.crt \
3014 key_file2=data_files/server5.key" \
3015 "$P_CLI force_version=tls1_1" \
3016 0 \
3017 -C "signed using.*ECDSA with SHA256" \
3018 -c "signed using.*ECDSA with SHA1"
3019
3020run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
3021 "$P_SRV crt_file=data_files/server5.crt \
3022 key_file=data_files/server5.key \
3023 crt_file2=data_files/server5-sha1.crt \
3024 key_file2=data_files/server5.key" \
3025 "$P_CLI force_version=tls1" \
3026 0 \
3027 -C "signed using.*ECDSA with SHA256" \
3028 -c "signed using.*ECDSA with SHA1"
3029
3030run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
3031 "$P_SRV crt_file=data_files/server5.crt \
3032 key_file=data_files/server5.key \
3033 crt_file2=data_files/server6.crt \
3034 key_file2=data_files/server6.key" \
3035 "$P_CLI force_version=tls1_1" \
3036 0 \
3037 -c "serial number.*09" \
3038 -c "signed using.*ECDSA with SHA256" \
3039 -C "signed using.*ECDSA with SHA1"
3040
3041run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
3042 "$P_SRV crt_file=data_files/server6.crt \
3043 key_file=data_files/server6.key \
3044 crt_file2=data_files/server5.crt \
3045 key_file2=data_files/server5.key" \
3046 "$P_CLI force_version=tls1_1" \
3047 0 \
3048 -c "serial number.*0A" \
3049 -c "signed using.*ECDSA with SHA256" \
3050 -C "signed using.*ECDSA with SHA1"
3051
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003052# tests for SNI
3053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003054run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003055 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003056 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003057 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003058 0 \
3059 -S "parse ServerName extension" \
3060 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3061 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003063run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003064 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003065 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003066 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 +02003067 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003068 0 \
3069 -s "parse ServerName extension" \
3070 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3071 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003072
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003073run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003074 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003075 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003076 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 +02003077 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003078 0 \
3079 -s "parse ServerName extension" \
3080 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3081 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003083run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003084 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003085 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003086 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 +02003087 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003088 1 \
3089 -s "parse ServerName extension" \
3090 -s "ssl_sni_wrapper() returned" \
3091 -s "mbedtls_ssl_handshake returned" \
3092 -c "mbedtls_ssl_handshake returned" \
3093 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003094
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003095run_test "SNI: client auth no override: optional" \
3096 "$P_SRV debug_level=3 auth_mode=optional \
3097 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3098 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3099 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003100 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003101 -S "skip write certificate request" \
3102 -C "skip parse certificate request" \
3103 -c "got a certificate request" \
3104 -C "skip write certificate" \
3105 -C "skip write certificate verify" \
3106 -S "skip parse certificate verify"
3107
3108run_test "SNI: client auth override: none -> optional" \
3109 "$P_SRV debug_level=3 auth_mode=none \
3110 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3111 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3112 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003113 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003114 -S "skip write certificate request" \
3115 -C "skip parse certificate request" \
3116 -c "got a certificate request" \
3117 -C "skip write certificate" \
3118 -C "skip write certificate verify" \
3119 -S "skip parse certificate verify"
3120
3121run_test "SNI: client auth override: optional -> none" \
3122 "$P_SRV debug_level=3 auth_mode=optional \
3123 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3124 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3125 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003126 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003127 -s "skip write certificate request" \
3128 -C "skip parse certificate request" \
3129 -c "got no certificate request" \
3130 -c "skip write certificate" \
3131 -c "skip write certificate verify" \
3132 -s "skip parse certificate verify"
3133
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003134run_test "SNI: CA no override" \
3135 "$P_SRV debug_level=3 auth_mode=optional \
3136 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3137 ca_file=data_files/test-ca.crt \
3138 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3139 "$P_CLI debug_level=3 server_name=localhost \
3140 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3141 1 \
3142 -S "skip write certificate request" \
3143 -C "skip parse certificate request" \
3144 -c "got a certificate request" \
3145 -C "skip write certificate" \
3146 -C "skip write certificate verify" \
3147 -S "skip parse certificate verify" \
3148 -s "x509_verify_cert() returned" \
3149 -s "! The certificate is not correctly signed by the trusted CA" \
3150 -S "The certificate has been revoked (is on a CRL)"
3151
3152run_test "SNI: CA override" \
3153 "$P_SRV debug_level=3 auth_mode=optional \
3154 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3155 ca_file=data_files/test-ca.crt \
3156 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3157 "$P_CLI debug_level=3 server_name=localhost \
3158 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3159 0 \
3160 -S "skip write certificate request" \
3161 -C "skip parse certificate request" \
3162 -c "got a certificate request" \
3163 -C "skip write certificate" \
3164 -C "skip write certificate verify" \
3165 -S "skip parse certificate verify" \
3166 -S "x509_verify_cert() returned" \
3167 -S "! The certificate is not correctly signed by the trusted CA" \
3168 -S "The certificate has been revoked (is on a CRL)"
3169
3170run_test "SNI: CA override with CRL" \
3171 "$P_SRV debug_level=3 auth_mode=optional \
3172 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3173 ca_file=data_files/test-ca.crt \
3174 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3175 "$P_CLI debug_level=3 server_name=localhost \
3176 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3177 1 \
3178 -S "skip write certificate request" \
3179 -C "skip parse certificate request" \
3180 -c "got a certificate request" \
3181 -C "skip write certificate" \
3182 -C "skip write certificate verify" \
3183 -S "skip parse certificate verify" \
3184 -s "x509_verify_cert() returned" \
3185 -S "! The certificate is not correctly signed by the trusted CA" \
3186 -s "The certificate has been revoked (is on a CRL)"
3187
Andres AG1a834452016-12-07 10:01:30 +00003188# Tests for SNI and DTLS
3189
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003190run_test "SNI: DTLS, no SNI callback" \
3191 "$P_SRV debug_level=3 dtls=1 \
3192 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3193 "$P_CLI server_name=localhost dtls=1" \
3194 0 \
3195 -S "parse ServerName extension" \
3196 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3197 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3198
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003199run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003200 "$P_SRV debug_level=3 dtls=1 \
3201 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3202 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3203 "$P_CLI server_name=localhost dtls=1" \
3204 0 \
3205 -s "parse ServerName extension" \
3206 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3207 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3208
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003209run_test "SNI: DTLS, matching cert 2" \
3210 "$P_SRV debug_level=3 dtls=1 \
3211 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3212 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3213 "$P_CLI server_name=polarssl.example dtls=1" \
3214 0 \
3215 -s "parse ServerName extension" \
3216 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3217 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3218
3219run_test "SNI: DTLS, no matching cert" \
3220 "$P_SRV debug_level=3 dtls=1 \
3221 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3222 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3223 "$P_CLI server_name=nonesuch.example dtls=1" \
3224 1 \
3225 -s "parse ServerName extension" \
3226 -s "ssl_sni_wrapper() returned" \
3227 -s "mbedtls_ssl_handshake returned" \
3228 -c "mbedtls_ssl_handshake returned" \
3229 -c "SSL - A fatal alert message was received from our peer"
3230
3231run_test "SNI: DTLS, client auth no override: optional" \
3232 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3233 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3234 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3235 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3236 0 \
3237 -S "skip write certificate request" \
3238 -C "skip parse certificate request" \
3239 -c "got a certificate request" \
3240 -C "skip write certificate" \
3241 -C "skip write certificate verify" \
3242 -S "skip parse certificate verify"
3243
3244run_test "SNI: DTLS, client auth override: none -> optional" \
3245 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3246 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3247 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3248 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3249 0 \
3250 -S "skip write certificate request" \
3251 -C "skip parse certificate request" \
3252 -c "got a certificate request" \
3253 -C "skip write certificate" \
3254 -C "skip write certificate verify" \
3255 -S "skip parse certificate verify"
3256
3257run_test "SNI: DTLS, client auth override: optional -> none" \
3258 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3259 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3260 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3261 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3262 0 \
3263 -s "skip write certificate request" \
3264 -C "skip parse certificate request" \
3265 -c "got no certificate request" \
3266 -c "skip write certificate" \
3267 -c "skip write certificate verify" \
3268 -s "skip parse certificate verify"
3269
3270run_test "SNI: DTLS, CA no override" \
3271 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3272 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3273 ca_file=data_files/test-ca.crt \
3274 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3275 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3276 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3277 1 \
3278 -S "skip write certificate request" \
3279 -C "skip parse certificate request" \
3280 -c "got a certificate request" \
3281 -C "skip write certificate" \
3282 -C "skip write certificate verify" \
3283 -S "skip parse certificate verify" \
3284 -s "x509_verify_cert() returned" \
3285 -s "! The certificate is not correctly signed by the trusted CA" \
3286 -S "The certificate has been revoked (is on a CRL)"
3287
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003288run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003289 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3290 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3291 ca_file=data_files/test-ca.crt \
3292 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3293 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3294 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3295 0 \
3296 -S "skip write certificate request" \
3297 -C "skip parse certificate request" \
3298 -c "got a certificate request" \
3299 -C "skip write certificate" \
3300 -C "skip write certificate verify" \
3301 -S "skip parse certificate verify" \
3302 -S "x509_verify_cert() returned" \
3303 -S "! The certificate is not correctly signed by the trusted CA" \
3304 -S "The certificate has been revoked (is on a CRL)"
3305
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003306run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003307 "$P_SRV debug_level=3 auth_mode=optional \
3308 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3309 ca_file=data_files/test-ca.crt \
3310 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3311 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3312 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3313 1 \
3314 -S "skip write certificate request" \
3315 -C "skip parse certificate request" \
3316 -c "got a certificate request" \
3317 -C "skip write certificate" \
3318 -C "skip write certificate verify" \
3319 -S "skip parse certificate verify" \
3320 -s "x509_verify_cert() returned" \
3321 -S "! The certificate is not correctly signed by the trusted CA" \
3322 -s "The certificate has been revoked (is on a CRL)"
3323
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003324# Tests for non-blocking I/O: exercise a variety of handshake flows
3325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003326run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003327 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3328 "$P_CLI nbio=2 tickets=0" \
3329 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003330 -S "mbedtls_ssl_handshake returned" \
3331 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003332 -c "Read from server: .* bytes read"
3333
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003334run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003335 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3336 "$P_CLI nbio=2 tickets=0" \
3337 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003338 -S "mbedtls_ssl_handshake returned" \
3339 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003340 -c "Read from server: .* bytes read"
3341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003342run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003343 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3344 "$P_CLI nbio=2 tickets=1" \
3345 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003346 -S "mbedtls_ssl_handshake returned" \
3347 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003348 -c "Read from server: .* bytes read"
3349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003350run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003351 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3352 "$P_CLI nbio=2 tickets=1" \
3353 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003354 -S "mbedtls_ssl_handshake returned" \
3355 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003356 -c "Read from server: .* bytes read"
3357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003358run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003359 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3360 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3361 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003362 -S "mbedtls_ssl_handshake returned" \
3363 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003364 -c "Read from server: .* bytes read"
3365
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003366run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003367 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3368 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3369 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003370 -S "mbedtls_ssl_handshake returned" \
3371 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003372 -c "Read from server: .* bytes read"
3373
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003374run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003375 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3376 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3377 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003378 -S "mbedtls_ssl_handshake returned" \
3379 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003380 -c "Read from server: .* bytes read"
3381
Hanno Becker00076712017-11-15 16:39:08 +00003382# Tests for event-driven I/O: exercise a variety of handshake flows
3383
3384run_test "Event-driven I/O: basic handshake" \
3385 "$P_SRV event=1 tickets=0 auth_mode=none" \
3386 "$P_CLI event=1 tickets=0" \
3387 0 \
3388 -S "mbedtls_ssl_handshake returned" \
3389 -C "mbedtls_ssl_handshake returned" \
3390 -c "Read from server: .* bytes read"
3391
3392run_test "Event-driven I/O: client auth" \
3393 "$P_SRV event=1 tickets=0 auth_mode=required" \
3394 "$P_CLI event=1 tickets=0" \
3395 0 \
3396 -S "mbedtls_ssl_handshake returned" \
3397 -C "mbedtls_ssl_handshake returned" \
3398 -c "Read from server: .* bytes read"
3399
3400run_test "Event-driven I/O: ticket" \
3401 "$P_SRV event=1 tickets=1 auth_mode=none" \
3402 "$P_CLI event=1 tickets=1" \
3403 0 \
3404 -S "mbedtls_ssl_handshake returned" \
3405 -C "mbedtls_ssl_handshake returned" \
3406 -c "Read from server: .* bytes read"
3407
3408run_test "Event-driven I/O: ticket + client auth" \
3409 "$P_SRV event=1 tickets=1 auth_mode=required" \
3410 "$P_CLI event=1 tickets=1" \
3411 0 \
3412 -S "mbedtls_ssl_handshake returned" \
3413 -C "mbedtls_ssl_handshake returned" \
3414 -c "Read from server: .* bytes read"
3415
3416run_test "Event-driven I/O: ticket + client auth + resume" \
3417 "$P_SRV event=1 tickets=1 auth_mode=required" \
3418 "$P_CLI event=1 tickets=1 reconnect=1" \
3419 0 \
3420 -S "mbedtls_ssl_handshake returned" \
3421 -C "mbedtls_ssl_handshake returned" \
3422 -c "Read from server: .* bytes read"
3423
3424run_test "Event-driven I/O: ticket + resume" \
3425 "$P_SRV event=1 tickets=1 auth_mode=none" \
3426 "$P_CLI event=1 tickets=1 reconnect=1" \
3427 0 \
3428 -S "mbedtls_ssl_handshake returned" \
3429 -C "mbedtls_ssl_handshake returned" \
3430 -c "Read from server: .* bytes read"
3431
3432run_test "Event-driven I/O: session-id resume" \
3433 "$P_SRV event=1 tickets=0 auth_mode=none" \
3434 "$P_CLI event=1 tickets=0 reconnect=1" \
3435 0 \
3436 -S "mbedtls_ssl_handshake returned" \
3437 -C "mbedtls_ssl_handshake returned" \
3438 -c "Read from server: .* bytes read"
3439
Hanno Becker6a33f592018-03-13 11:38:46 +00003440run_test "Event-driven I/O, DTLS: basic handshake" \
3441 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3442 "$P_CLI dtls=1 event=1 tickets=0" \
3443 0 \
3444 -c "Read from server: .* bytes read"
3445
3446run_test "Event-driven I/O, DTLS: client auth" \
3447 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3448 "$P_CLI dtls=1 event=1 tickets=0" \
3449 0 \
3450 -c "Read from server: .* bytes read"
3451
3452run_test "Event-driven I/O, DTLS: ticket" \
3453 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3454 "$P_CLI dtls=1 event=1 tickets=1" \
3455 0 \
3456 -c "Read from server: .* bytes read"
3457
3458run_test "Event-driven I/O, DTLS: ticket + client auth" \
3459 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3460 "$P_CLI dtls=1 event=1 tickets=1" \
3461 0 \
3462 -c "Read from server: .* bytes read"
3463
3464run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3465 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003466 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003467 0 \
3468 -c "Read from server: .* bytes read"
3469
3470run_test "Event-driven I/O, DTLS: ticket + resume" \
3471 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003472 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003473 0 \
3474 -c "Read from server: .* bytes read"
3475
3476run_test "Event-driven I/O, DTLS: session-id resume" \
3477 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003478 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003479 0 \
3480 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003481
3482# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3483# During session resumption, the client will send its ApplicationData record
3484# within the same datagram as the Finished messages. In this situation, the
3485# server MUST NOT idle on the underlying transport after handshake completion,
3486# because the ApplicationData request has already been queued internally.
3487run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003488 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003489 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003490 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003491 0 \
3492 -c "Read from server: .* bytes read"
3493
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003494# Tests for version negotiation
3495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003496run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003497 "$P_SRV" \
3498 "$P_CLI" \
3499 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003500 -S "mbedtls_ssl_handshake returned" \
3501 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003502 -s "Protocol is TLSv1.2" \
3503 -c "Protocol is TLSv1.2"
3504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003505run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003506 "$P_SRV" \
3507 "$P_CLI max_version=tls1_1" \
3508 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003509 -S "mbedtls_ssl_handshake returned" \
3510 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003511 -s "Protocol is TLSv1.1" \
3512 -c "Protocol is TLSv1.1"
3513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003514run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003515 "$P_SRV max_version=tls1_1" \
3516 "$P_CLI" \
3517 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003518 -S "mbedtls_ssl_handshake returned" \
3519 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003520 -s "Protocol is TLSv1.1" \
3521 -c "Protocol is TLSv1.1"
3522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003523run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003524 "$P_SRV max_version=tls1_1" \
3525 "$P_CLI max_version=tls1_1" \
3526 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003527 -S "mbedtls_ssl_handshake returned" \
3528 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003529 -s "Protocol is TLSv1.1" \
3530 -c "Protocol is TLSv1.1"
3531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003532run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003533 "$P_SRV min_version=tls1_1" \
3534 "$P_CLI max_version=tls1_1" \
3535 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003536 -S "mbedtls_ssl_handshake returned" \
3537 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003538 -s "Protocol is TLSv1.1" \
3539 -c "Protocol is TLSv1.1"
3540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003541run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003542 "$P_SRV max_version=tls1_1" \
3543 "$P_CLI min_version=tls1_1" \
3544 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003545 -S "mbedtls_ssl_handshake returned" \
3546 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003547 -s "Protocol is TLSv1.1" \
3548 -c "Protocol is TLSv1.1"
3549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003550run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003551 "$P_SRV max_version=tls1_1" \
3552 "$P_CLI min_version=tls1_2" \
3553 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003554 -s "mbedtls_ssl_handshake returned" \
3555 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003556 -c "SSL - Handshake protocol not within min/max boundaries"
3557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003558run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003559 "$P_SRV min_version=tls1_2" \
3560 "$P_CLI max_version=tls1_1" \
3561 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003562 -s "mbedtls_ssl_handshake returned" \
3563 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003564 -s "SSL - Handshake protocol not within min/max boundaries"
3565
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003566# Tests for ALPN extension
3567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003568run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003569 "$P_SRV debug_level=3" \
3570 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003571 0 \
3572 -C "client hello, adding alpn extension" \
3573 -S "found alpn extension" \
3574 -C "got an alert message, type: \\[2:120]" \
3575 -S "server hello, adding alpn extension" \
3576 -C "found alpn extension " \
3577 -C "Application Layer Protocol is" \
3578 -S "Application Layer Protocol is"
3579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003580run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003581 "$P_SRV debug_level=3" \
3582 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003583 0 \
3584 -c "client hello, adding alpn extension" \
3585 -s "found alpn extension" \
3586 -C "got an alert message, type: \\[2:120]" \
3587 -S "server hello, adding alpn extension" \
3588 -C "found alpn extension " \
3589 -c "Application Layer Protocol is (none)" \
3590 -S "Application Layer Protocol is"
3591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003592run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003593 "$P_SRV debug_level=3 alpn=abc,1234" \
3594 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003595 0 \
3596 -C "client hello, adding alpn extension" \
3597 -S "found alpn extension" \
3598 -C "got an alert message, type: \\[2:120]" \
3599 -S "server hello, adding alpn extension" \
3600 -C "found alpn extension " \
3601 -C "Application Layer Protocol is" \
3602 -s "Application Layer Protocol is (none)"
3603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003604run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003605 "$P_SRV debug_level=3 alpn=abc,1234" \
3606 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003607 0 \
3608 -c "client hello, adding alpn extension" \
3609 -s "found alpn extension" \
3610 -C "got an alert message, type: \\[2:120]" \
3611 -s "server hello, adding alpn extension" \
3612 -c "found alpn extension" \
3613 -c "Application Layer Protocol is abc" \
3614 -s "Application Layer Protocol is abc"
3615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003616run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003617 "$P_SRV debug_level=3 alpn=abc,1234" \
3618 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003619 0 \
3620 -c "client hello, adding alpn extension" \
3621 -s "found alpn extension" \
3622 -C "got an alert message, type: \\[2:120]" \
3623 -s "server hello, adding alpn extension" \
3624 -c "found alpn extension" \
3625 -c "Application Layer Protocol is abc" \
3626 -s "Application Layer Protocol is abc"
3627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003628run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003629 "$P_SRV debug_level=3 alpn=abc,1234" \
3630 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003631 0 \
3632 -c "client hello, adding alpn extension" \
3633 -s "found alpn extension" \
3634 -C "got an alert message, type: \\[2:120]" \
3635 -s "server hello, adding alpn extension" \
3636 -c "found alpn extension" \
3637 -c "Application Layer Protocol is 1234" \
3638 -s "Application Layer Protocol is 1234"
3639
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003640run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003641 "$P_SRV debug_level=3 alpn=abc,123" \
3642 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003643 1 \
3644 -c "client hello, adding alpn extension" \
3645 -s "found alpn extension" \
3646 -c "got an alert message, type: \\[2:120]" \
3647 -S "server hello, adding alpn extension" \
3648 -C "found alpn extension" \
3649 -C "Application Layer Protocol is 1234" \
3650 -S "Application Layer Protocol is 1234"
3651
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003652
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003653# Tests for keyUsage in leaf certificates, part 1:
3654# server-side certificate/suite selection
3655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003656run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003657 "$P_SRV key_file=data_files/server2.key \
3658 crt_file=data_files/server2.ku-ds.crt" \
3659 "$P_CLI" \
3660 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003661 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003662
3663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003664run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003665 "$P_SRV key_file=data_files/server2.key \
3666 crt_file=data_files/server2.ku-ke.crt" \
3667 "$P_CLI" \
3668 0 \
3669 -c "Ciphersuite is TLS-RSA-WITH-"
3670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003671run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003672 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003673 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003674 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003675 1 \
3676 -C "Ciphersuite is "
3677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003678run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003679 "$P_SRV key_file=data_files/server5.key \
3680 crt_file=data_files/server5.ku-ds.crt" \
3681 "$P_CLI" \
3682 0 \
3683 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3684
3685
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003686run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003687 "$P_SRV key_file=data_files/server5.key \
3688 crt_file=data_files/server5.ku-ka.crt" \
3689 "$P_CLI" \
3690 0 \
3691 -c "Ciphersuite is TLS-ECDH-"
3692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003693run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003694 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003695 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003696 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003697 1 \
3698 -C "Ciphersuite is "
3699
3700# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003701# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003703run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003704 "$O_SRV -key data_files/server2.key \
3705 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003706 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003707 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3708 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003709 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003710 -C "Processing of the Certificate handshake message failed" \
3711 -c "Ciphersuite is TLS-"
3712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003713run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003714 "$O_SRV -key data_files/server2.key \
3715 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003716 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003717 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3718 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003719 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003720 -C "Processing of the Certificate handshake message failed" \
3721 -c "Ciphersuite is TLS-"
3722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003723run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003724 "$O_SRV -key data_files/server2.key \
3725 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003726 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003727 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3728 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003729 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003730 -C "Processing of the Certificate handshake message failed" \
3731 -c "Ciphersuite is TLS-"
3732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003733run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003734 "$O_SRV -key data_files/server2.key \
3735 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003736 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003737 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3738 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003739 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003740 -c "Processing of the Certificate handshake message failed" \
3741 -C "Ciphersuite is TLS-"
3742
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003743run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3744 "$O_SRV -key data_files/server2.key \
3745 -cert data_files/server2.ku-ke.crt" \
3746 "$P_CLI debug_level=1 auth_mode=optional \
3747 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3748 0 \
3749 -c "bad certificate (usage extensions)" \
3750 -C "Processing of the Certificate handshake message failed" \
3751 -c "Ciphersuite is TLS-" \
3752 -c "! Usage does not match the keyUsage extension"
3753
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003754run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003755 "$O_SRV -key data_files/server2.key \
3756 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003757 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003758 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3759 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003760 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003761 -C "Processing of the Certificate handshake message failed" \
3762 -c "Ciphersuite is TLS-"
3763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003764run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003765 "$O_SRV -key data_files/server2.key \
3766 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003767 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003768 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3769 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003770 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003771 -c "Processing of the Certificate handshake message failed" \
3772 -C "Ciphersuite is TLS-"
3773
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003774run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3775 "$O_SRV -key data_files/server2.key \
3776 -cert data_files/server2.ku-ds.crt" \
3777 "$P_CLI debug_level=1 auth_mode=optional \
3778 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3779 0 \
3780 -c "bad certificate (usage extensions)" \
3781 -C "Processing of the Certificate handshake message failed" \
3782 -c "Ciphersuite is TLS-" \
3783 -c "! Usage does not match the keyUsage extension"
3784
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003785# Tests for keyUsage in leaf certificates, part 3:
3786# server-side checking of client cert
3787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003788run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003789 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003790 "$O_CLI -key data_files/server2.key \
3791 -cert data_files/server2.ku-ds.crt" \
3792 0 \
3793 -S "bad certificate (usage extensions)" \
3794 -S "Processing of the Certificate handshake message failed"
3795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003796run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003797 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003798 "$O_CLI -key data_files/server2.key \
3799 -cert data_files/server2.ku-ke.crt" \
3800 0 \
3801 -s "bad certificate (usage extensions)" \
3802 -S "Processing of the Certificate handshake message failed"
3803
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003804run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003805 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003806 "$O_CLI -key data_files/server2.key \
3807 -cert data_files/server2.ku-ke.crt" \
3808 1 \
3809 -s "bad certificate (usage extensions)" \
3810 -s "Processing of the Certificate handshake message failed"
3811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003812run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003813 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003814 "$O_CLI -key data_files/server5.key \
3815 -cert data_files/server5.ku-ds.crt" \
3816 0 \
3817 -S "bad certificate (usage extensions)" \
3818 -S "Processing of the Certificate handshake message failed"
3819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003820run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003821 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003822 "$O_CLI -key data_files/server5.key \
3823 -cert data_files/server5.ku-ka.crt" \
3824 0 \
3825 -s "bad certificate (usage extensions)" \
3826 -S "Processing of the Certificate handshake message failed"
3827
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003828# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003830run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003831 "$P_SRV key_file=data_files/server5.key \
3832 crt_file=data_files/server5.eku-srv.crt" \
3833 "$P_CLI" \
3834 0
3835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003836run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003837 "$P_SRV key_file=data_files/server5.key \
3838 crt_file=data_files/server5.eku-srv.crt" \
3839 "$P_CLI" \
3840 0
3841
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003842run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003843 "$P_SRV key_file=data_files/server5.key \
3844 crt_file=data_files/server5.eku-cs_any.crt" \
3845 "$P_CLI" \
3846 0
3847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003848run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003849 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003850 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003851 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003852 1
3853
3854# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003856run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003857 "$O_SRV -key data_files/server5.key \
3858 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003859 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003860 0 \
3861 -C "bad certificate (usage extensions)" \
3862 -C "Processing of the Certificate handshake message failed" \
3863 -c "Ciphersuite is TLS-"
3864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003865run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003866 "$O_SRV -key data_files/server5.key \
3867 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003868 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003869 0 \
3870 -C "bad certificate (usage extensions)" \
3871 -C "Processing of the Certificate handshake message failed" \
3872 -c "Ciphersuite is TLS-"
3873
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003874run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003875 "$O_SRV -key data_files/server5.key \
3876 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003877 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003878 0 \
3879 -C "bad certificate (usage extensions)" \
3880 -C "Processing of the Certificate handshake message failed" \
3881 -c "Ciphersuite is TLS-"
3882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003883run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003884 "$O_SRV -key data_files/server5.key \
3885 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003886 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003887 1 \
3888 -c "bad certificate (usage extensions)" \
3889 -c "Processing of the Certificate handshake message failed" \
3890 -C "Ciphersuite is TLS-"
3891
3892# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3893
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003894run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003895 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003896 "$O_CLI -key data_files/server5.key \
3897 -cert data_files/server5.eku-cli.crt" \
3898 0 \
3899 -S "bad certificate (usage extensions)" \
3900 -S "Processing of the Certificate handshake message failed"
3901
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003902run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003903 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003904 "$O_CLI -key data_files/server5.key \
3905 -cert data_files/server5.eku-srv_cli.crt" \
3906 0 \
3907 -S "bad certificate (usage extensions)" \
3908 -S "Processing of the Certificate handshake message failed"
3909
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003910run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003911 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003912 "$O_CLI -key data_files/server5.key \
3913 -cert data_files/server5.eku-cs_any.crt" \
3914 0 \
3915 -S "bad certificate (usage extensions)" \
3916 -S "Processing of the Certificate handshake message failed"
3917
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003918run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003919 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003920 "$O_CLI -key data_files/server5.key \
3921 -cert data_files/server5.eku-cs.crt" \
3922 0 \
3923 -s "bad certificate (usage extensions)" \
3924 -S "Processing of the Certificate handshake message failed"
3925
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003926run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003927 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003928 "$O_CLI -key data_files/server5.key \
3929 -cert data_files/server5.eku-cs.crt" \
3930 1 \
3931 -s "bad certificate (usage extensions)" \
3932 -s "Processing of the Certificate handshake message failed"
3933
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003934# Tests for DHM parameters loading
3935
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003936run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003937 "$P_SRV" \
3938 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3939 debug_level=3" \
3940 0 \
3941 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003942 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003943
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003944run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003945 "$P_SRV dhm_file=data_files/dhparams.pem" \
3946 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3947 debug_level=3" \
3948 0 \
3949 -c "value of 'DHM: P ' (1024 bits)" \
3950 -c "value of 'DHM: G ' (2 bits)"
3951
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003952# Tests for DHM client-side size checking
3953
3954run_test "DHM size: server default, client default, OK" \
3955 "$P_SRV" \
3956 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3957 debug_level=1" \
3958 0 \
3959 -C "DHM prime too short:"
3960
3961run_test "DHM size: server default, client 2048, OK" \
3962 "$P_SRV" \
3963 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3964 debug_level=1 dhmlen=2048" \
3965 0 \
3966 -C "DHM prime too short:"
3967
3968run_test "DHM size: server 1024, client default, OK" \
3969 "$P_SRV dhm_file=data_files/dhparams.pem" \
3970 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3971 debug_level=1" \
3972 0 \
3973 -C "DHM prime too short:"
3974
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01003975run_test "DHM size: server 999, client 999, OK" \
3976 "$P_SRV dhm_file=data_files/dh.999.pem" \
3977 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3978 debug_level=1 dhmlen=999" \
3979 0 \
3980 -C "DHM prime too short:"
3981
3982run_test "DHM size: server 1000, client 1000, OK" \
3983 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3984 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3985 debug_level=1 dhmlen=1000" \
3986 0 \
3987 -C "DHM prime too short:"
3988
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003989run_test "DHM size: server 1000, client default, rejected" \
3990 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3991 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3992 debug_level=1" \
3993 1 \
3994 -c "DHM prime too short:"
3995
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01003996run_test "DHM size: server 1000, client 1001, rejected" \
3997 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3998 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3999 debug_level=1 dhmlen=1001" \
4000 1 \
4001 -c "DHM prime too short:"
4002
4003run_test "DHM size: server 999, client 1000, rejected" \
4004 "$P_SRV dhm_file=data_files/dh.999.pem" \
4005 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4006 debug_level=1 dhmlen=1000" \
4007 1 \
4008 -c "DHM prime too short:"
4009
4010run_test "DHM size: server 998, client 999, rejected" \
4011 "$P_SRV dhm_file=data_files/dh.998.pem" \
4012 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4013 debug_level=1 dhmlen=999" \
4014 1 \
4015 -c "DHM prime too short:"
4016
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004017run_test "DHM size: server default, client 2049, rejected" \
4018 "$P_SRV" \
4019 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4020 debug_level=1 dhmlen=2049" \
4021 1 \
4022 -c "DHM prime too short:"
4023
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004024# Tests for PSK callback
4025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004026run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004027 "$P_SRV psk=abc123 psk_identity=foo" \
4028 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4029 psk_identity=foo psk=abc123" \
4030 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004031 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004032 -S "SSL - Unknown identity received" \
4033 -S "SSL - Verification of the message MAC failed"
4034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004035run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004036 "$P_SRV" \
4037 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4038 psk_identity=foo psk=abc123" \
4039 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004040 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004041 -S "SSL - Unknown identity received" \
4042 -S "SSL - Verification of the message MAC failed"
4043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004044run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004045 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
4046 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4047 psk_identity=foo psk=abc123" \
4048 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004049 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004050 -s "SSL - Unknown identity received" \
4051 -S "SSL - Verification of the message MAC failed"
4052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004053run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004054 "$P_SRV psk_list=abc,dead,def,beef" \
4055 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4056 psk_identity=abc psk=dead" \
4057 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004058 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004059 -S "SSL - Unknown identity received" \
4060 -S "SSL - Verification of the message MAC failed"
4061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004062run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004063 "$P_SRV psk_list=abc,dead,def,beef" \
4064 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4065 psk_identity=def psk=beef" \
4066 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004067 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004068 -S "SSL - Unknown identity received" \
4069 -S "SSL - Verification of the message MAC failed"
4070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004071run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004072 "$P_SRV psk_list=abc,dead,def,beef" \
4073 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4074 psk_identity=ghi psk=beef" \
4075 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004076 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004077 -s "SSL - Unknown identity received" \
4078 -S "SSL - Verification of the message MAC failed"
4079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004080run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004081 "$P_SRV psk_list=abc,dead,def,beef" \
4082 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4083 psk_identity=abc psk=beef" \
4084 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004085 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004086 -S "SSL - Unknown identity received" \
4087 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004088
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004089# Tests for EC J-PAKE
4090
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004091requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004092run_test "ECJPAKE: client not configured" \
4093 "$P_SRV debug_level=3" \
4094 "$P_CLI debug_level=3" \
4095 0 \
4096 -C "add ciphersuite: c0ff" \
4097 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004098 -S "found ecjpake kkpp extension" \
4099 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004100 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004101 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004102 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004103 -S "None of the common ciphersuites is usable"
4104
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004105requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004106run_test "ECJPAKE: server not configured" \
4107 "$P_SRV debug_level=3" \
4108 "$P_CLI debug_level=3 ecjpake_pw=bla \
4109 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4110 1 \
4111 -c "add ciphersuite: c0ff" \
4112 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004113 -s "found ecjpake kkpp extension" \
4114 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004115 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004116 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004117 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004118 -s "None of the common ciphersuites is usable"
4119
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004120requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004121run_test "ECJPAKE: working, TLS" \
4122 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4123 "$P_CLI debug_level=3 ecjpake_pw=bla \
4124 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004125 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004126 -c "add ciphersuite: c0ff" \
4127 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004128 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004129 -s "found ecjpake kkpp extension" \
4130 -S "skip ecjpake kkpp extension" \
4131 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004132 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004133 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004134 -S "None of the common ciphersuites is usable" \
4135 -S "SSL - Verification of the message MAC failed"
4136
Janos Follath74537a62016-09-02 13:45:28 +01004137server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004138requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004139run_test "ECJPAKE: password mismatch, TLS" \
4140 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4141 "$P_CLI debug_level=3 ecjpake_pw=bad \
4142 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4143 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004144 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004145 -s "SSL - Verification of the message MAC failed"
4146
Dave Rodgmancee9e922021-06-29 19:05:34 +01004147requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004148run_test "ECJPAKE: working, DTLS" \
4149 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4150 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4151 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4152 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004153 -c "re-using cached ecjpake parameters" \
4154 -S "SSL - Verification of the message MAC failed"
4155
Dave Rodgmancee9e922021-06-29 19:05:34 +01004156requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004157run_test "ECJPAKE: working, DTLS, no cookie" \
4158 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4159 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4160 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4161 0 \
4162 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004163 -S "SSL - Verification of the message MAC failed"
4164
Janos Follath74537a62016-09-02 13:45:28 +01004165server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004166requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004167run_test "ECJPAKE: password mismatch, DTLS" \
4168 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4169 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4170 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4171 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004172 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004173 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004174
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004175# for tests with configs/config-thread.h
Dave Rodgmancee9e922021-06-29 19:05:34 +01004176requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004177run_test "ECJPAKE: working, DTLS, nolog" \
4178 "$P_SRV dtls=1 ecjpake_pw=bla" \
4179 "$P_CLI dtls=1 ecjpake_pw=bla \
4180 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4181 0
4182
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004183# Tests for ciphersuites per version
4184
Janos Follathe2681a42016-03-07 15:57:05 +00004185requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004186requires_config_enabled MBEDTLS_CAMELLIA_C
4187requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004188run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004189 "$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 +02004190 "$P_CLI force_version=ssl3" \
4191 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004192 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004193
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004194requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4195requires_config_enabled MBEDTLS_CAMELLIA_C
4196requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004197run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004198 "$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 +01004199 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004200 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004201 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004202
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004203requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4204requires_config_enabled MBEDTLS_CAMELLIA_C
4205requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004206run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004207 "$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 +02004208 "$P_CLI force_version=tls1_1" \
4209 0 \
4210 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4211
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004212requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4213requires_config_enabled MBEDTLS_CAMELLIA_C
4214requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004215run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004216 "$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 +02004217 "$P_CLI force_version=tls1_2" \
4218 0 \
4219 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4220
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004221# Test for ClientHello without extensions
4222
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004223requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004224run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004225 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004226 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004227 0 \
4228 -s "dumping 'client hello extensions' (0 bytes)"
4229
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004230# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004231
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004232run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004233 "$P_SRV" \
4234 "$P_CLI request_size=100" \
4235 0 \
4236 -s "Read from client: 100 bytes read$"
4237
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004238run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004239 "$P_SRV" \
4240 "$P_CLI request_size=500" \
4241 0 \
4242 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004243
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004244# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004245
Janos Follathe2681a42016-03-07 15:57:05 +00004246requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004247run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004248 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004249 "$P_CLI request_size=1 force_version=ssl3 \
4250 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4251 0 \
4252 -s "Read from client: 1 bytes read"
4253
Janos Follathe2681a42016-03-07 15:57:05 +00004254requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004255run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004256 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004257 "$P_CLI request_size=1 force_version=ssl3 \
4258 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4259 0 \
4260 -s "Read from client: 1 bytes read"
4261
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004262run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004263 "$P_SRV" \
4264 "$P_CLI request_size=1 force_version=tls1 \
4265 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4266 0 \
4267 -s "Read from client: 1 bytes read"
4268
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004269run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004270 "$P_SRV" \
4271 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4272 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4273 0 \
4274 -s "Read from client: 1 bytes read"
4275
Hanno Becker32c55012017-11-10 08:42:54 +00004276requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004277run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004278 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004279 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004280 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004281 0 \
4282 -s "Read from client: 1 bytes read"
4283
Hanno Becker32c55012017-11-10 08:42:54 +00004284requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004285run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004286 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004287 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004288 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004289 0 \
4290 -s "Read from client: 1 bytes read"
4291
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004292run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004293 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004294 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004295 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4296 0 \
4297 -s "Read from client: 1 bytes read"
4298
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004299run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004300 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4301 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004302 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004303 0 \
4304 -s "Read from client: 1 bytes read"
4305
4306requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004307run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004308 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004309 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004310 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004311 0 \
4312 -s "Read from client: 1 bytes read"
4313
Hanno Becker8501f982017-11-10 08:59:04 +00004314requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004315run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004316 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4317 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4318 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004319 0 \
4320 -s "Read from client: 1 bytes read"
4321
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004322run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004323 "$P_SRV" \
4324 "$P_CLI request_size=1 force_version=tls1_1 \
4325 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4326 0 \
4327 -s "Read from client: 1 bytes read"
4328
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004329run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004330 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004331 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004332 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004333 0 \
4334 -s "Read from client: 1 bytes read"
4335
4336requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004337run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004338 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004339 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004340 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004341 0 \
4342 -s "Read from client: 1 bytes read"
4343
4344requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004345run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004346 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004347 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004348 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004349 0 \
4350 -s "Read from client: 1 bytes read"
4351
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004352run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004353 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004354 "$P_CLI request_size=1 force_version=tls1_1 \
4355 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4356 0 \
4357 -s "Read from client: 1 bytes read"
4358
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004359run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004360 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004361 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004362 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004363 0 \
4364 -s "Read from client: 1 bytes read"
4365
Hanno Becker8501f982017-11-10 08:59:04 +00004366requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004367run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004368 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004369 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004370 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004371 0 \
4372 -s "Read from client: 1 bytes read"
4373
Hanno Becker32c55012017-11-10 08:42:54 +00004374requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004375run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004376 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004377 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004378 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004379 0 \
4380 -s "Read from client: 1 bytes read"
4381
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004382run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004383 "$P_SRV" \
4384 "$P_CLI request_size=1 force_version=tls1_2 \
4385 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4386 0 \
4387 -s "Read from client: 1 bytes read"
4388
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004389run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004390 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004391 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004392 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004393 0 \
4394 -s "Read from client: 1 bytes read"
4395
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004396run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004397 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004398 "$P_CLI request_size=1 force_version=tls1_2 \
4399 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004400 0 \
4401 -s "Read from client: 1 bytes read"
4402
Hanno Becker32c55012017-11-10 08:42:54 +00004403requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004404run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004405 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004406 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004407 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004408 0 \
4409 -s "Read from client: 1 bytes read"
4410
Hanno Becker8501f982017-11-10 08:59:04 +00004411requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004412run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004413 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004414 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004415 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004416 0 \
4417 -s "Read from client: 1 bytes read"
4418
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004419run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004420 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004421 "$P_CLI request_size=1 force_version=tls1_2 \
4422 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4423 0 \
4424 -s "Read from client: 1 bytes read"
4425
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004426run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004427 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004428 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004429 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004430 0 \
4431 -s "Read from client: 1 bytes read"
4432
Hanno Becker32c55012017-11-10 08:42:54 +00004433requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004434run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004435 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004436 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004437 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004438 0 \
4439 -s "Read from client: 1 bytes read"
4440
Hanno Becker8501f982017-11-10 08:59:04 +00004441requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004442run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004443 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004444 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004445 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004446 0 \
4447 -s "Read from client: 1 bytes read"
4448
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004449run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004450 "$P_SRV" \
4451 "$P_CLI request_size=1 force_version=tls1_2 \
4452 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4453 0 \
4454 -s "Read from client: 1 bytes read"
4455
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004456run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004457 "$P_SRV" \
4458 "$P_CLI request_size=1 force_version=tls1_2 \
4459 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4460 0 \
4461 -s "Read from client: 1 bytes read"
4462
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004463# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004464
4465requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004466run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004467 "$P_SRV dtls=1 force_version=dtls1" \
4468 "$P_CLI dtls=1 request_size=1 \
4469 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4470 0 \
4471 -s "Read from client: 1 bytes read"
4472
4473requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004474run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004475 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4476 "$P_CLI dtls=1 request_size=1 \
4477 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4478 0 \
4479 -s "Read from client: 1 bytes read"
4480
4481requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4482requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004483run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004484 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4485 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004486 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4487 0 \
4488 -s "Read from client: 1 bytes read"
4489
4490requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4491requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004492run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004493 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004494 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004495 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004496 0 \
4497 -s "Read from client: 1 bytes read"
4498
4499requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004500run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004501 "$P_SRV dtls=1 force_version=dtls1_2" \
4502 "$P_CLI dtls=1 request_size=1 \
4503 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4504 0 \
4505 -s "Read from client: 1 bytes read"
4506
4507requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004508run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004509 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004510 "$P_CLI dtls=1 request_size=1 \
4511 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4512 0 \
4513 -s "Read from client: 1 bytes read"
4514
4515requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4516requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004517run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004518 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004519 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004520 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004521 0 \
4522 -s "Read from client: 1 bytes read"
4523
4524requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4525requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004526run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004527 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004528 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004529 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004530 0 \
4531 -s "Read from client: 1 bytes read"
4532
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004533# Tests for small server packets
4534
4535requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4536run_test "Small server packet SSLv3 BlockCipher" \
4537 "$P_SRV response_size=1 min_version=ssl3" \
4538 "$P_CLI force_version=ssl3 \
4539 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4540 0 \
4541 -c "Read from server: 1 bytes read"
4542
4543requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4544run_test "Small server packet SSLv3 StreamCipher" \
4545 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4546 "$P_CLI force_version=ssl3 \
4547 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4548 0 \
4549 -c "Read from server: 1 bytes read"
4550
4551run_test "Small server packet TLS 1.0 BlockCipher" \
4552 "$P_SRV response_size=1" \
4553 "$P_CLI force_version=tls1 \
4554 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4555 0 \
4556 -c "Read from server: 1 bytes read"
4557
4558run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4559 "$P_SRV response_size=1" \
4560 "$P_CLI force_version=tls1 etm=0 \
4561 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4562 0 \
4563 -c "Read from server: 1 bytes read"
4564
4565requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4566run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4567 "$P_SRV response_size=1 trunc_hmac=1" \
4568 "$P_CLI force_version=tls1 \
4569 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4570 0 \
4571 -c "Read from server: 1 bytes read"
4572
4573requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4574run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4575 "$P_SRV response_size=1 trunc_hmac=1" \
4576 "$P_CLI force_version=tls1 \
4577 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4578 0 \
4579 -c "Read from server: 1 bytes read"
4580
4581run_test "Small server packet TLS 1.0 StreamCipher" \
4582 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4583 "$P_CLI force_version=tls1 \
4584 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4585 0 \
4586 -c "Read from server: 1 bytes read"
4587
4588run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4589 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4590 "$P_CLI force_version=tls1 \
4591 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4592 0 \
4593 -c "Read from server: 1 bytes read"
4594
4595requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4596run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4597 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4598 "$P_CLI force_version=tls1 \
4599 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4600 0 \
4601 -c "Read from server: 1 bytes read"
4602
4603requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4604run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4605 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4606 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4607 trunc_hmac=1 etm=0" \
4608 0 \
4609 -c "Read from server: 1 bytes read"
4610
4611run_test "Small server packet TLS 1.1 BlockCipher" \
4612 "$P_SRV response_size=1" \
4613 "$P_CLI force_version=tls1_1 \
4614 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4615 0 \
4616 -c "Read from server: 1 bytes read"
4617
4618run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4619 "$P_SRV response_size=1" \
4620 "$P_CLI force_version=tls1_1 \
4621 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4622 0 \
4623 -c "Read from server: 1 bytes read"
4624
4625requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4626run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4627 "$P_SRV response_size=1 trunc_hmac=1" \
4628 "$P_CLI force_version=tls1_1 \
4629 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4630 0 \
4631 -c "Read from server: 1 bytes read"
4632
4633requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4634run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4635 "$P_SRV response_size=1 trunc_hmac=1" \
4636 "$P_CLI force_version=tls1_1 \
4637 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4638 0 \
4639 -c "Read from server: 1 bytes read"
4640
4641run_test "Small server packet TLS 1.1 StreamCipher" \
4642 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4643 "$P_CLI force_version=tls1_1 \
4644 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4645 0 \
4646 -c "Read from server: 1 bytes read"
4647
4648run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4649 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4650 "$P_CLI force_version=tls1_1 \
4651 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4652 0 \
4653 -c "Read from server: 1 bytes read"
4654
4655requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4656run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4657 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4658 "$P_CLI force_version=tls1_1 \
4659 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4660 0 \
4661 -c "Read from server: 1 bytes read"
4662
4663requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4664run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4665 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4666 "$P_CLI force_version=tls1_1 \
4667 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4668 0 \
4669 -c "Read from server: 1 bytes read"
4670
4671run_test "Small server packet TLS 1.2 BlockCipher" \
4672 "$P_SRV response_size=1" \
4673 "$P_CLI force_version=tls1_2 \
4674 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4675 0 \
4676 -c "Read from server: 1 bytes read"
4677
4678run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4679 "$P_SRV response_size=1" \
4680 "$P_CLI force_version=tls1_2 \
4681 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4682 0 \
4683 -c "Read from server: 1 bytes read"
4684
4685run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4686 "$P_SRV response_size=1" \
4687 "$P_CLI force_version=tls1_2 \
4688 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4689 0 \
4690 -c "Read from server: 1 bytes read"
4691
4692requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4693run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4694 "$P_SRV response_size=1 trunc_hmac=1" \
4695 "$P_CLI force_version=tls1_2 \
4696 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4697 0 \
4698 -c "Read from server: 1 bytes read"
4699
4700requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4701run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4702 "$P_SRV response_size=1 trunc_hmac=1" \
4703 "$P_CLI force_version=tls1_2 \
4704 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4705 0 \
4706 -c "Read from server: 1 bytes read"
4707
4708run_test "Small server packet TLS 1.2 StreamCipher" \
4709 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4710 "$P_CLI force_version=tls1_2 \
4711 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4712 0 \
4713 -c "Read from server: 1 bytes read"
4714
4715run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4716 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4717 "$P_CLI force_version=tls1_2 \
4718 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4719 0 \
4720 -c "Read from server: 1 bytes read"
4721
4722requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4723run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4724 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4725 "$P_CLI force_version=tls1_2 \
4726 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4727 0 \
4728 -c "Read from server: 1 bytes read"
4729
4730requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4731run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4732 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4733 "$P_CLI force_version=tls1_2 \
4734 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4735 0 \
4736 -c "Read from server: 1 bytes read"
4737
4738run_test "Small server packet TLS 1.2 AEAD" \
4739 "$P_SRV response_size=1" \
4740 "$P_CLI force_version=tls1_2 \
4741 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4742 0 \
4743 -c "Read from server: 1 bytes read"
4744
4745run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4746 "$P_SRV response_size=1" \
4747 "$P_CLI force_version=tls1_2 \
4748 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4749 0 \
4750 -c "Read from server: 1 bytes read"
4751
4752# Tests for small server packets in DTLS
4753
4754requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4755run_test "Small server packet DTLS 1.0" \
4756 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4757 "$P_CLI dtls=1 \
4758 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4759 0 \
4760 -c "Read from server: 1 bytes read"
4761
4762requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4763run_test "Small server packet DTLS 1.0, without EtM" \
4764 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4765 "$P_CLI dtls=1 \
4766 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4767 0 \
4768 -c "Read from server: 1 bytes read"
4769
4770requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4771requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4772run_test "Small server packet DTLS 1.0, truncated hmac" \
4773 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4774 "$P_CLI dtls=1 trunc_hmac=1 \
4775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4776 0 \
4777 -c "Read from server: 1 bytes read"
4778
4779requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4780requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4781run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4782 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4783 "$P_CLI dtls=1 \
4784 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4785 0 \
4786 -c "Read from server: 1 bytes read"
4787
4788requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4789run_test "Small server packet DTLS 1.2" \
4790 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4791 "$P_CLI dtls=1 \
4792 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4793 0 \
4794 -c "Read from server: 1 bytes read"
4795
4796requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4797run_test "Small server packet DTLS 1.2, without EtM" \
4798 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4799 "$P_CLI dtls=1 \
4800 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4801 0 \
4802 -c "Read from server: 1 bytes read"
4803
4804requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4805requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4806run_test "Small server packet DTLS 1.2, truncated hmac" \
4807 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4808 "$P_CLI dtls=1 \
4809 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4810 0 \
4811 -c "Read from server: 1 bytes read"
4812
4813requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4814requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4815run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4816 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4817 "$P_CLI dtls=1 \
4818 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4819 0 \
4820 -c "Read from server: 1 bytes read"
4821
Janos Follath00efff72016-05-06 13:48:23 +01004822# A test for extensions in SSLv3
4823
4824requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4825run_test "SSLv3 with extensions, server side" \
4826 "$P_SRV min_version=ssl3 debug_level=3" \
4827 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4828 0 \
4829 -S "dumping 'client hello extensions'" \
4830 -S "server hello, total extension length:"
4831
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004832# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004833
Angus Grattonc4dd0732018-04-11 16:28:39 +10004834# How many fragments do we expect to write $1 bytes?
4835fragments_for_write() {
4836 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4837}
4838
Janos Follathe2681a42016-03-07 15:57:05 +00004839requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004840run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004841 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004842 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004843 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4844 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004845 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4846 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004847
Janos Follathe2681a42016-03-07 15:57:05 +00004848requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004849run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004850 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004851 "$P_CLI request_size=16384 force_version=ssl3 \
4852 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4853 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004854 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4855 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004856
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004857run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004858 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004859 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004860 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4861 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004862 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4863 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004864
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004865run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004866 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004867 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4868 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4869 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004870 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004871
Hanno Becker32c55012017-11-10 08:42:54 +00004872requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004873run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004874 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004875 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004876 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004877 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004878 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4879 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004880
Hanno Becker32c55012017-11-10 08:42:54 +00004881requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004882run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004883 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004884 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004885 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004886 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004887 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004888
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004889run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004890 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004891 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004892 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4893 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004894 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004895
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004896run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004897 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4898 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004899 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004900 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004901 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004902
4903requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004904run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004905 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004906 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004907 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004908 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004909 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004910
Hanno Becker278fc7a2017-11-10 09:16:28 +00004911requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004912run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004913 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004914 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004915 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004916 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004917 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4918 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004919
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004920run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004921 "$P_SRV" \
4922 "$P_CLI request_size=16384 force_version=tls1_1 \
4923 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4924 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004925 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4926 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004927
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004928run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004929 "$P_SRV" \
4930 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4931 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004932 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004933 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004934
Hanno Becker32c55012017-11-10 08:42:54 +00004935requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004936run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004937 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004938 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004939 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004940 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004941 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004942
Hanno Becker32c55012017-11-10 08:42:54 +00004943requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004944run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004945 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004946 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004947 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004948 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004949 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004950
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004951run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004952 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4953 "$P_CLI request_size=16384 force_version=tls1_1 \
4954 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4955 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004956 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4957 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004958
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004959run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004960 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004961 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004962 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004963 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004964 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4965 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004966
Hanno Becker278fc7a2017-11-10 09:16:28 +00004967requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004968run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004969 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004970 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004971 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004972 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004973 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004974
Hanno Becker278fc7a2017-11-10 09:16:28 +00004975requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004976run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004977 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004978 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004979 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004980 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004981 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4982 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004983
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004984run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004985 "$P_SRV" \
4986 "$P_CLI request_size=16384 force_version=tls1_2 \
4987 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4988 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004989 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4990 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004991
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004992run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004993 "$P_SRV" \
4994 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4995 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4996 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004997 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004998
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004999run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005000 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005001 "$P_CLI request_size=16384 force_version=tls1_2 \
5002 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005003 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005004 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5005 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005006
Hanno Becker32c55012017-11-10 08:42:54 +00005007requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005008run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005009 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005010 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005011 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005012 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005013 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005014
Hanno Becker278fc7a2017-11-10 09:16:28 +00005015requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005016run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005017 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005018 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005019 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005020 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005021 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5022 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005023
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005024run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005025 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005026 "$P_CLI request_size=16384 force_version=tls1_2 \
5027 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5028 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005029 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5030 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005031
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005032run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005033 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005034 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005035 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5036 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005037 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005038
Hanno Becker32c55012017-11-10 08:42:54 +00005039requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005040run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005041 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005042 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005043 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005044 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005045 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005046
Hanno Becker278fc7a2017-11-10 09:16:28 +00005047requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005048run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005049 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005050 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005051 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005052 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005053 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5054 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005055
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005056run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005057 "$P_SRV" \
5058 "$P_CLI request_size=16384 force_version=tls1_2 \
5059 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5060 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005061 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5062 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005063
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005064run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005065 "$P_SRV" \
5066 "$P_CLI request_size=16384 force_version=tls1_2 \
5067 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5068 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005069 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5070 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005071
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005072# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005073requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5074run_test "Large server packet SSLv3 StreamCipher" \
5075 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5076 "$P_CLI force_version=ssl3 \
5077 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5078 0 \
5079 -c "Read from server: 16384 bytes read"
5080
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04005081# Checking next 4 tests logs for 1n-1 split against BEAST too
5082requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5083run_test "Large server packet SSLv3 BlockCipher" \
5084 "$P_SRV response_size=16384 min_version=ssl3" \
5085 "$P_CLI force_version=ssl3 recsplit=0 \
5086 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5087 0 \
5088 -c "Read from server: 1 bytes read"\
5089 -c "16383 bytes read"\
5090 -C "Read from server: 16384 bytes read"
5091
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005092run_test "Large server packet TLS 1.0 BlockCipher" \
5093 "$P_SRV response_size=16384" \
5094 "$P_CLI force_version=tls1 recsplit=0 \
5095 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5096 0 \
5097 -c "Read from server: 1 bytes read"\
5098 -c "16383 bytes read"\
5099 -C "Read from server: 16384 bytes read"
5100
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005101run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5102 "$P_SRV response_size=16384" \
5103 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5104 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5105 0 \
5106 -c "Read from server: 1 bytes read"\
5107 -c "16383 bytes read"\
5108 -C "Read from server: 16384 bytes read"
5109
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005110requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5111run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5112 "$P_SRV response_size=16384" \
5113 "$P_CLI force_version=tls1 recsplit=0 \
5114 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5115 trunc_hmac=1" \
5116 0 \
5117 -c "Read from server: 1 bytes read"\
5118 -c "16383 bytes read"\
5119 -C "Read from server: 16384 bytes read"
5120
5121requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5122run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5123 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5124 "$P_CLI force_version=tls1 \
5125 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5126 trunc_hmac=1" \
5127 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005128 -s "16384 bytes written in 1 fragments" \
5129 -c "Read from server: 16384 bytes read"
5130
5131run_test "Large server packet TLS 1.0 StreamCipher" \
5132 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5133 "$P_CLI force_version=tls1 \
5134 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5135 0 \
5136 -s "16384 bytes written in 1 fragments" \
5137 -c "Read from server: 16384 bytes read"
5138
5139run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5140 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5141 "$P_CLI force_version=tls1 \
5142 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5143 0 \
5144 -s "16384 bytes written in 1 fragments" \
5145 -c "Read from server: 16384 bytes read"
5146
5147requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5148run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5149 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5150 "$P_CLI force_version=tls1 \
5151 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5152 0 \
5153 -s "16384 bytes written in 1 fragments" \
5154 -c "Read from server: 16384 bytes read"
5155
5156requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5157run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5158 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5159 "$P_CLI force_version=tls1 \
5160 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5161 0 \
5162 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005163 -c "Read from server: 16384 bytes read"
5164
5165run_test "Large server packet TLS 1.1 BlockCipher" \
5166 "$P_SRV response_size=16384" \
5167 "$P_CLI force_version=tls1_1 \
5168 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
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 BlockCipher, without EtM" \
5173 "$P_SRV response_size=16384" \
5174 "$P_CLI force_version=tls1_1 etm=0 \
5175 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005176 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005177 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005178 -c "Read from server: 16384 bytes read"
5179
5180requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5181run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5182 "$P_SRV response_size=16384" \
5183 "$P_CLI force_version=tls1_1 \
5184 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5185 trunc_hmac=1" \
5186 0 \
5187 -c "Read from server: 16384 bytes read"
5188
5189requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005190run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5191 "$P_SRV response_size=16384 trunc_hmac=1" \
5192 "$P_CLI force_version=tls1_1 \
5193 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5194 0 \
5195 -s "16384 bytes written in 1 fragments" \
5196 -c "Read from server: 16384 bytes read"
5197
5198run_test "Large server packet TLS 1.1 StreamCipher" \
5199 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5200 "$P_CLI force_version=tls1_1 \
5201 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5202 0 \
5203 -c "Read from server: 16384 bytes read"
5204
5205run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5206 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5207 "$P_CLI force_version=tls1_1 \
5208 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5209 0 \
5210 -s "16384 bytes written in 1 fragments" \
5211 -c "Read from server: 16384 bytes read"
5212
5213requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005214run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5215 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5216 "$P_CLI force_version=tls1_1 \
5217 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5218 trunc_hmac=1" \
5219 0 \
5220 -c "Read from server: 16384 bytes read"
5221
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005222run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5223 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5224 "$P_CLI force_version=tls1_1 \
5225 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5226 0 \
5227 -s "16384 bytes written in 1 fragments" \
5228 -c "Read from server: 16384 bytes read"
5229
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005230run_test "Large server packet TLS 1.2 BlockCipher" \
5231 "$P_SRV response_size=16384" \
5232 "$P_CLI force_version=tls1_2 \
5233 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5234 0 \
5235 -c "Read from server: 16384 bytes read"
5236
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005237run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5238 "$P_SRV response_size=16384" \
5239 "$P_CLI force_version=tls1_2 etm=0 \
5240 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5241 0 \
5242 -s "16384 bytes written in 1 fragments" \
5243 -c "Read from server: 16384 bytes read"
5244
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005245run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5246 "$P_SRV response_size=16384" \
5247 "$P_CLI force_version=tls1_2 \
5248 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5249 0 \
5250 -c "Read from server: 16384 bytes read"
5251
5252requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5253run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5254 "$P_SRV response_size=16384" \
5255 "$P_CLI force_version=tls1_2 \
5256 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5257 trunc_hmac=1" \
5258 0 \
5259 -c "Read from server: 16384 bytes read"
5260
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005261run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5262 "$P_SRV response_size=16384 trunc_hmac=1" \
5263 "$P_CLI force_version=tls1_2 \
5264 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5265 0 \
5266 -s "16384 bytes written in 1 fragments" \
5267 -c "Read from server: 16384 bytes read"
5268
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005269run_test "Large server packet TLS 1.2 StreamCipher" \
5270 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5271 "$P_CLI force_version=tls1_2 \
5272 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5273 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005274 -s "16384 bytes written in 1 fragments" \
5275 -c "Read from server: 16384 bytes read"
5276
5277run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5278 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5279 "$P_CLI force_version=tls1_2 \
5280 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5281 0 \
5282 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005283 -c "Read from server: 16384 bytes read"
5284
5285requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5286run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5287 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5288 "$P_CLI force_version=tls1_2 \
5289 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5290 trunc_hmac=1" \
5291 0 \
5292 -c "Read from server: 16384 bytes read"
5293
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005294requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5295run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5296 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5297 "$P_CLI force_version=tls1_2 \
5298 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5299 0 \
5300 -s "16384 bytes written in 1 fragments" \
5301 -c "Read from server: 16384 bytes read"
5302
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005303run_test "Large server packet TLS 1.2 AEAD" \
5304 "$P_SRV response_size=16384" \
5305 "$P_CLI force_version=tls1_2 \
5306 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5307 0 \
5308 -c "Read from server: 16384 bytes read"
5309
5310run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5311 "$P_SRV response_size=16384" \
5312 "$P_CLI force_version=tls1_2 \
5313 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5314 0 \
5315 -c "Read from server: 16384 bytes read"
5316
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005317# Tests for restartable ECC
5318
5319requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5320run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005321 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005322 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005323 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005324 debug_level=1" \
5325 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005326 -C "x509_verify_cert.*4b00" \
5327 -C "mbedtls_pk_verify.*4b00" \
5328 -C "mbedtls_ecdh_make_public.*4b00" \
5329 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005330
5331requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5332run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005333 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005334 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005335 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005336 debug_level=1 ec_max_ops=0" \
5337 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005338 -C "x509_verify_cert.*4b00" \
5339 -C "mbedtls_pk_verify.*4b00" \
5340 -C "mbedtls_ecdh_make_public.*4b00" \
5341 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005342
5343requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5344run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005345 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005346 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005347 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005348 debug_level=1 ec_max_ops=65535" \
5349 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005350 -C "x509_verify_cert.*4b00" \
5351 -C "mbedtls_pk_verify.*4b00" \
5352 -C "mbedtls_ecdh_make_public.*4b00" \
5353 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005354
5355requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5356run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005357 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005358 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005359 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005360 debug_level=1 ec_max_ops=1000" \
5361 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005362 -c "x509_verify_cert.*4b00" \
5363 -c "mbedtls_pk_verify.*4b00" \
5364 -c "mbedtls_ecdh_make_public.*4b00" \
5365 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005366
5367requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005368run_test "EC restart: TLS, max_ops=1000, badsign" \
5369 "$P_SRV auth_mode=required \
5370 crt_file=data_files/server5-badsign.crt \
5371 key_file=data_files/server5.key" \
5372 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5373 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5374 debug_level=1 ec_max_ops=1000" \
5375 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005376 -c "x509_verify_cert.*4b00" \
5377 -C "mbedtls_pk_verify.*4b00" \
5378 -C "mbedtls_ecdh_make_public.*4b00" \
5379 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005380 -c "! The certificate is not correctly signed by the trusted CA" \
5381 -c "! mbedtls_ssl_handshake returned" \
5382 -c "X509 - Certificate verification failed"
5383
5384requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5385run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5386 "$P_SRV auth_mode=required \
5387 crt_file=data_files/server5-badsign.crt \
5388 key_file=data_files/server5.key" \
5389 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5390 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5391 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5392 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005393 -c "x509_verify_cert.*4b00" \
5394 -c "mbedtls_pk_verify.*4b00" \
5395 -c "mbedtls_ecdh_make_public.*4b00" \
5396 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005397 -c "! The certificate is not correctly signed by the trusted CA" \
5398 -C "! mbedtls_ssl_handshake returned" \
5399 -C "X509 - Certificate verification failed"
5400
5401requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5402run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5403 "$P_SRV auth_mode=required \
5404 crt_file=data_files/server5-badsign.crt \
5405 key_file=data_files/server5.key" \
5406 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5407 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5408 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5409 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005410 -C "x509_verify_cert.*4b00" \
5411 -c "mbedtls_pk_verify.*4b00" \
5412 -c "mbedtls_ecdh_make_public.*4b00" \
5413 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005414 -C "! The certificate is not correctly signed by the trusted CA" \
5415 -C "! mbedtls_ssl_handshake returned" \
5416 -C "X509 - Certificate verification failed"
5417
5418requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005419run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005420 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005421 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005422 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005423 dtls=1 debug_level=1 ec_max_ops=1000" \
5424 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005425 -c "x509_verify_cert.*4b00" \
5426 -c "mbedtls_pk_verify.*4b00" \
5427 -c "mbedtls_ecdh_make_public.*4b00" \
5428 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005429
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005430requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5431run_test "EC restart: TLS, max_ops=1000 no client auth" \
5432 "$P_SRV" \
5433 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5434 debug_level=1 ec_max_ops=1000" \
5435 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005436 -c "x509_verify_cert.*4b00" \
5437 -c "mbedtls_pk_verify.*4b00" \
5438 -c "mbedtls_ecdh_make_public.*4b00" \
5439 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005440
5441requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5442run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5443 "$P_SRV psk=abc123" \
5444 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5445 psk=abc123 debug_level=1 ec_max_ops=1000" \
5446 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005447 -C "x509_verify_cert.*4b00" \
5448 -C "mbedtls_pk_verify.*4b00" \
5449 -C "mbedtls_ecdh_make_public.*4b00" \
5450 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005451
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005452# Tests of asynchronous private key support in SSL
5453
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005454requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005455run_test "SSL async private: sign, delay=0" \
5456 "$P_SRV \
5457 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005458 "$P_CLI" \
5459 0 \
5460 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005461 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005462
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005463requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005464run_test "SSL async private: sign, delay=1" \
5465 "$P_SRV \
5466 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005467 "$P_CLI" \
5468 0 \
5469 -s "Async sign callback: using key slot " \
5470 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005471 -s "Async resume (slot [0-9]): sign done, status=0"
5472
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005473requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5474run_test "SSL async private: sign, delay=2" \
5475 "$P_SRV \
5476 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5477 "$P_CLI" \
5478 0 \
5479 -s "Async sign callback: using key slot " \
5480 -U "Async sign callback: using key slot " \
5481 -s "Async resume (slot [0-9]): call 1 more times." \
5482 -s "Async resume (slot [0-9]): call 0 more times." \
5483 -s "Async resume (slot [0-9]): sign done, status=0"
5484
Gilles Peskined3268832018-04-26 06:23:59 +02005485# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5486# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5487requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5488requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5489run_test "SSL async private: sign, RSA, TLS 1.1" \
5490 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5491 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5492 "$P_CLI force_version=tls1_1" \
5493 0 \
5494 -s "Async sign callback: using key slot " \
5495 -s "Async resume (slot [0-9]): sign done, status=0"
5496
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005497requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005498run_test "SSL async private: sign, SNI" \
5499 "$P_SRV debug_level=3 \
5500 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5501 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5502 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5503 "$P_CLI server_name=polarssl.example" \
5504 0 \
5505 -s "Async sign callback: using key slot " \
5506 -s "Async resume (slot [0-9]): sign done, status=0" \
5507 -s "parse ServerName extension" \
5508 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5509 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5510
5511requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005512run_test "SSL async private: decrypt, delay=0" \
5513 "$P_SRV \
5514 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5515 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5516 0 \
5517 -s "Async decrypt callback: using key slot " \
5518 -s "Async resume (slot [0-9]): decrypt done, status=0"
5519
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005520requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005521run_test "SSL async private: decrypt, delay=1" \
5522 "$P_SRV \
5523 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5524 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5525 0 \
5526 -s "Async decrypt callback: using key slot " \
5527 -s "Async resume (slot [0-9]): call 0 more times." \
5528 -s "Async resume (slot [0-9]): decrypt done, status=0"
5529
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005530requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005531run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5532 "$P_SRV psk=abc123 \
5533 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5534 "$P_CLI psk=abc123 \
5535 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5536 0 \
5537 -s "Async decrypt callback: using key slot " \
5538 -s "Async resume (slot [0-9]): decrypt done, status=0"
5539
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005540requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005541run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5542 "$P_SRV psk=abc123 \
5543 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5544 "$P_CLI psk=abc123 \
5545 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5546 0 \
5547 -s "Async decrypt callback: using key slot " \
5548 -s "Async resume (slot [0-9]): call 0 more times." \
5549 -s "Async resume (slot [0-9]): decrypt done, status=0"
5550
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005551requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005552run_test "SSL async private: sign callback not present" \
5553 "$P_SRV \
5554 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5555 "$P_CLI; [ \$? -eq 1 ] &&
5556 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5557 0 \
5558 -S "Async sign callback" \
5559 -s "! mbedtls_ssl_handshake returned" \
5560 -s "The own private key or pre-shared key is not set, but needed" \
5561 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5562 -s "Successful connection"
5563
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005564requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005565run_test "SSL async private: decrypt callback not present" \
5566 "$P_SRV debug_level=1 \
5567 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5568 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5569 [ \$? -eq 1 ] && $P_CLI" \
5570 0 \
5571 -S "Async decrypt callback" \
5572 -s "! mbedtls_ssl_handshake returned" \
5573 -s "got no RSA private key" \
5574 -s "Async resume (slot [0-9]): sign done, status=0" \
5575 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005576
5577# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005578requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005579run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005580 "$P_SRV \
5581 async_operations=s async_private_delay1=1 \
5582 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5583 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005584 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5585 0 \
5586 -s "Async sign callback: using key slot 0," \
5587 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005588 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005589
5590# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005591requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005592run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005593 "$P_SRV \
5594 async_operations=s async_private_delay2=1 \
5595 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5596 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005597 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5598 0 \
5599 -s "Async sign callback: using key slot 0," \
5600 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005601 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005602
5603# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005604requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005605run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005606 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005607 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005608 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5609 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005610 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5611 0 \
5612 -s "Async sign callback: using key slot 1," \
5613 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005614 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005615
5616# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005617requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005618run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005619 "$P_SRV \
5620 async_operations=s async_private_delay1=1 \
5621 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5622 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005623 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5624 0 \
5625 -s "Async sign callback: no key matches this certificate."
5626
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005627requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005628run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005629 "$P_SRV \
5630 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5631 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005632 "$P_CLI" \
5633 1 \
5634 -s "Async sign callback: injected error" \
5635 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005636 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005637 -s "! mbedtls_ssl_handshake returned"
5638
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005639requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005640run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005641 "$P_SRV \
5642 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5643 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005644 "$P_CLI" \
5645 1 \
5646 -s "Async sign callback: using key slot " \
5647 -S "Async resume" \
5648 -s "Async cancel"
5649
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005650requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005651run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005652 "$P_SRV \
5653 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5654 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005655 "$P_CLI" \
5656 1 \
5657 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005658 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005659 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005660 -s "! mbedtls_ssl_handshake returned"
5661
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005662requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005663run_test "SSL async private: decrypt, error in start" \
5664 "$P_SRV \
5665 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5666 async_private_error=1" \
5667 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5668 1 \
5669 -s "Async decrypt callback: injected error" \
5670 -S "Async resume" \
5671 -S "Async cancel" \
5672 -s "! mbedtls_ssl_handshake returned"
5673
5674requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5675run_test "SSL async private: decrypt, cancel after start" \
5676 "$P_SRV \
5677 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5678 async_private_error=2" \
5679 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5680 1 \
5681 -s "Async decrypt callback: using key slot " \
5682 -S "Async resume" \
5683 -s "Async cancel"
5684
5685requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5686run_test "SSL async private: decrypt, error in resume" \
5687 "$P_SRV \
5688 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5689 async_private_error=3" \
5690 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5691 1 \
5692 -s "Async decrypt callback: using key slot " \
5693 -s "Async resume callback: decrypt done but injected error" \
5694 -S "Async cancel" \
5695 -s "! mbedtls_ssl_handshake returned"
5696
5697requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005698run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005699 "$P_SRV \
5700 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5701 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005702 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5703 0 \
5704 -s "Async cancel" \
5705 -s "! mbedtls_ssl_handshake returned" \
5706 -s "Async resume" \
5707 -s "Successful connection"
5708
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005709requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005710run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005711 "$P_SRV \
5712 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5713 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005714 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5715 0 \
5716 -s "! mbedtls_ssl_handshake returned" \
5717 -s "Async resume" \
5718 -s "Successful connection"
5719
5720# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005721requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005722run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005723 "$P_SRV \
5724 async_operations=s async_private_delay1=1 async_private_error=-2 \
5725 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5726 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005727 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5728 [ \$? -eq 1 ] &&
5729 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5730 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005731 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005732 -S "Async resume" \
5733 -s "Async cancel" \
5734 -s "! mbedtls_ssl_handshake returned" \
5735 -s "Async sign callback: no key matches this certificate." \
5736 -s "Successful connection"
5737
5738# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005739requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005740run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005741 "$P_SRV \
5742 async_operations=s async_private_delay1=1 async_private_error=-3 \
5743 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5744 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005745 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5746 [ \$? -eq 1 ] &&
5747 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5748 0 \
5749 -s "Async resume" \
5750 -s "! mbedtls_ssl_handshake returned" \
5751 -s "Async sign callback: no key matches this certificate." \
5752 -s "Successful connection"
5753
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005754requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005755requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005756run_test "SSL async private: renegotiation: client-initiated; sign" \
5757 "$P_SRV \
5758 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005759 exchanges=2 renegotiation=1" \
5760 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5761 0 \
5762 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005763 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005764
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005765requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005766requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005767run_test "SSL async private: renegotiation: server-initiated; sign" \
5768 "$P_SRV \
5769 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005770 exchanges=2 renegotiation=1 renegotiate=1" \
5771 "$P_CLI exchanges=2 renegotiation=1" \
5772 0 \
5773 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005774 -s "Async resume (slot [0-9]): sign done, status=0"
5775
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005776requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005777requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5778run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5779 "$P_SRV \
5780 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5781 exchanges=2 renegotiation=1" \
5782 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5783 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5784 0 \
5785 -s "Async decrypt callback: using key slot " \
5786 -s "Async resume (slot [0-9]): decrypt done, status=0"
5787
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005788requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005789requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5790run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5791 "$P_SRV \
5792 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5793 exchanges=2 renegotiation=1 renegotiate=1" \
5794 "$P_CLI exchanges=2 renegotiation=1 \
5795 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5796 0 \
5797 -s "Async decrypt callback: using key slot " \
5798 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005799
Ron Eldor58093c82018-06-28 13:22:05 +03005800# Tests for ECC extensions (rfc 4492)
5801
Ron Eldor643df7c2018-06-28 16:17:00 +03005802requires_config_enabled MBEDTLS_AES_C
5803requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5804requires_config_enabled MBEDTLS_SHA256_C
5805requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005806run_test "Force a non ECC ciphersuite in the client side" \
5807 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005808 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005809 0 \
5810 -C "client hello, adding supported_elliptic_curves extension" \
5811 -C "client hello, adding supported_point_formats extension" \
5812 -S "found supported elliptic curves extension" \
5813 -S "found supported point formats extension"
5814
Ron Eldor643df7c2018-06-28 16:17:00 +03005815requires_config_enabled MBEDTLS_AES_C
5816requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5817requires_config_enabled MBEDTLS_SHA256_C
5818requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005819run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005820 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005821 "$P_CLI debug_level=3" \
5822 0 \
5823 -C "found supported_point_formats extension" \
5824 -S "server hello, supported_point_formats extension"
5825
Ron Eldor643df7c2018-06-28 16:17:00 +03005826requires_config_enabled MBEDTLS_AES_C
5827requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5828requires_config_enabled MBEDTLS_SHA256_C
5829requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005830run_test "Force an ECC ciphersuite in the client side" \
5831 "$P_SRV debug_level=3" \
5832 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5833 0 \
5834 -c "client hello, adding supported_elliptic_curves extension" \
5835 -c "client hello, adding supported_point_formats extension" \
5836 -s "found supported elliptic curves extension" \
5837 -s "found supported point formats extension"
5838
Ron Eldor643df7c2018-06-28 16:17:00 +03005839requires_config_enabled MBEDTLS_AES_C
5840requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5841requires_config_enabled MBEDTLS_SHA256_C
5842requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005843run_test "Force an ECC ciphersuite in the server side" \
5844 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5845 "$P_CLI debug_level=3" \
5846 0 \
5847 -c "found supported_point_formats extension" \
5848 -s "server hello, supported_point_formats extension"
5849
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005850# Tests for DTLS HelloVerifyRequest
5851
5852run_test "DTLS cookie: enabled" \
5853 "$P_SRV dtls=1 debug_level=2" \
5854 "$P_CLI dtls=1 debug_level=2" \
5855 0 \
5856 -s "cookie verification failed" \
5857 -s "cookie verification passed" \
5858 -S "cookie verification skipped" \
5859 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005860 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005861 -S "SSL - The requested feature is not available"
5862
5863run_test "DTLS cookie: disabled" \
5864 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5865 "$P_CLI dtls=1 debug_level=2" \
5866 0 \
5867 -S "cookie verification failed" \
5868 -S "cookie verification passed" \
5869 -s "cookie verification skipped" \
5870 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005871 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005872 -S "SSL - The requested feature is not available"
5873
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005874run_test "DTLS cookie: default (failing)" \
5875 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5876 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5877 1 \
5878 -s "cookie verification failed" \
5879 -S "cookie verification passed" \
5880 -S "cookie verification skipped" \
5881 -C "received hello verify request" \
5882 -S "hello verification requested" \
5883 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005884
5885requires_ipv6
5886run_test "DTLS cookie: enabled, IPv6" \
5887 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5888 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5889 0 \
5890 -s "cookie verification failed" \
5891 -s "cookie verification passed" \
5892 -S "cookie verification skipped" \
5893 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005894 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005895 -S "SSL - The requested feature is not available"
5896
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005897run_test "DTLS cookie: enabled, nbio" \
5898 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5899 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5900 0 \
5901 -s "cookie verification failed" \
5902 -s "cookie verification passed" \
5903 -S "cookie verification skipped" \
5904 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005905 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005906 -S "SSL - The requested feature is not available"
5907
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005908# Tests for client reconnecting from the same port with DTLS
5909
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005910not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005911run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005912 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5913 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005914 0 \
5915 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005916 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005917 -S "Client initiated reconnection from same port"
5918
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005919not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005920run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005921 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5922 "$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 +02005923 0 \
5924 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005925 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005926 -s "Client initiated reconnection from same port"
5927
Paul Bakker362689d2016-05-13 10:33:25 +01005928not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5929run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005930 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5931 "$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 +02005932 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005933 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005934 -s "Client initiated reconnection from same port"
5935
Paul Bakker362689d2016-05-13 10:33:25 +01005936only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5937run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5938 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5939 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5940 0 \
5941 -S "The operation timed out" \
5942 -s "Client initiated reconnection from same port"
5943
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005944run_test "DTLS client reconnect from same port: no cookies" \
5945 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005946 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5947 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005948 -s "The operation timed out" \
5949 -S "Client initiated reconnection from same port"
5950
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005951run_test "DTLS client reconnect from same port: attacker-injected" \
5952 -p "$P_PXY inject_clihlo=1" \
5953 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5954 "$P_CLI dtls=1 exchanges=2" \
5955 0 \
5956 -s "possible client reconnect from the same port" \
5957 -S "Client initiated reconnection from same port"
5958
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005959# Tests for various cases of client authentication with DTLS
5960# (focused on handshake flows and message parsing)
5961
5962run_test "DTLS client auth: required" \
5963 "$P_SRV dtls=1 auth_mode=required" \
5964 "$P_CLI dtls=1" \
5965 0 \
5966 -s "Verifying peer X.509 certificate... ok"
5967
5968run_test "DTLS client auth: optional, client has no cert" \
5969 "$P_SRV dtls=1 auth_mode=optional" \
5970 "$P_CLI dtls=1 crt_file=none key_file=none" \
5971 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005972 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005973
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005974run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005975 "$P_SRV dtls=1 auth_mode=none" \
5976 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5977 0 \
5978 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005979 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005980
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005981run_test "DTLS wrong PSK: badmac alert" \
5982 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5983 "$P_CLI dtls=1 psk=abc124" \
5984 1 \
5985 -s "SSL - Verification of the message MAC failed" \
5986 -c "SSL - A fatal alert message was received from our peer"
5987
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005988# Tests for receiving fragmented handshake messages with DTLS
5989
5990requires_gnutls
5991run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5992 "$G_SRV -u --mtu 2048 -a" \
5993 "$P_CLI dtls=1 debug_level=2" \
5994 0 \
5995 -C "found fragmented DTLS handshake message" \
5996 -C "error"
5997
5998requires_gnutls
5999run_test "DTLS reassembly: some fragmentation (gnutls server)" \
6000 "$G_SRV -u --mtu 512" \
6001 "$P_CLI dtls=1 debug_level=2" \
6002 0 \
6003 -c "found fragmented DTLS handshake message" \
6004 -C "error"
6005
6006requires_gnutls
6007run_test "DTLS reassembly: more fragmentation (gnutls server)" \
6008 "$G_SRV -u --mtu 128" \
6009 "$P_CLI dtls=1 debug_level=2" \
6010 0 \
6011 -c "found fragmented DTLS handshake message" \
6012 -C "error"
6013
6014requires_gnutls
6015run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
6016 "$G_SRV -u --mtu 128" \
6017 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6018 0 \
6019 -c "found fragmented DTLS handshake message" \
6020 -C "error"
6021
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006022requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006023requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006024run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
6025 "$G_SRV -u --mtu 256" \
6026 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
6027 0 \
6028 -c "found fragmented DTLS handshake message" \
6029 -c "client hello, adding renegotiation extension" \
6030 -c "found renegotiation extension" \
6031 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006032 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006033 -C "error" \
6034 -s "Extra-header:"
6035
6036requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006037requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006038run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
6039 "$G_SRV -u --mtu 256" \
6040 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
6041 0 \
6042 -c "found fragmented DTLS handshake message" \
6043 -c "client hello, adding renegotiation extension" \
6044 -c "found renegotiation extension" \
6045 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006046 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006047 -C "error" \
6048 -s "Extra-header:"
6049
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006050run_test "DTLS reassembly: no fragmentation (openssl server)" \
6051 "$O_SRV -dtls1 -mtu 2048" \
6052 "$P_CLI dtls=1 debug_level=2" \
6053 0 \
6054 -C "found fragmented DTLS handshake message" \
6055 -C "error"
6056
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006057run_test "DTLS reassembly: some fragmentation (openssl server)" \
6058 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006059 "$P_CLI dtls=1 debug_level=2" \
6060 0 \
6061 -c "found fragmented DTLS handshake message" \
6062 -C "error"
6063
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006064run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006065 "$O_SRV -dtls1 -mtu 256" \
6066 "$P_CLI dtls=1 debug_level=2" \
6067 0 \
6068 -c "found fragmented DTLS handshake message" \
6069 -C "error"
6070
6071run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6072 "$O_SRV -dtls1 -mtu 256" \
6073 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6074 0 \
6075 -c "found fragmented DTLS handshake message" \
6076 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006077
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006078# Tests for sending fragmented handshake messages with DTLS
6079#
6080# Use client auth when we need the client to send large messages,
6081# and use large cert chains on both sides too (the long chains we have all use
6082# both RSA and ECDSA, but ideally we should have long chains with either).
6083# Sizes reached (UDP payload):
6084# - 2037B for server certificate
6085# - 1542B for client certificate
6086# - 1013B for newsessionticket
6087# - all others below 512B
6088# All those tests assume MAX_CONTENT_LEN is at least 2048
6089
6090requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6091requires_config_enabled MBEDTLS_RSA_C
6092requires_config_enabled MBEDTLS_ECDSA_C
6093requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6094run_test "DTLS fragmenting: none (for reference)" \
6095 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6096 crt_file=data_files/server7_int-ca.crt \
6097 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006098 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006099 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006100 "$P_CLI dtls=1 debug_level=2 \
6101 crt_file=data_files/server8_int-ca2.crt \
6102 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006103 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006104 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006105 0 \
6106 -S "found fragmented DTLS handshake message" \
6107 -C "found fragmented DTLS handshake message" \
6108 -C "error"
6109
6110requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6111requires_config_enabled MBEDTLS_RSA_C
6112requires_config_enabled MBEDTLS_ECDSA_C
6113requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006114run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006115 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6116 crt_file=data_files/server7_int-ca.crt \
6117 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006118 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006119 max_frag_len=1024" \
6120 "$P_CLI dtls=1 debug_level=2 \
6121 crt_file=data_files/server8_int-ca2.crt \
6122 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006123 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006124 max_frag_len=2048" \
6125 0 \
6126 -S "found fragmented DTLS handshake message" \
6127 -c "found fragmented DTLS handshake message" \
6128 -C "error"
6129
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006130# With the MFL extension, the server has no way of forcing
6131# the client to not exceed a certain MTU; hence, the following
6132# test can't be replicated with an MTU proxy such as the one
6133# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006134requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6135requires_config_enabled MBEDTLS_RSA_C
6136requires_config_enabled MBEDTLS_ECDSA_C
6137requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006138run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006139 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6140 crt_file=data_files/server7_int-ca.crt \
6141 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006142 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006143 max_frag_len=512" \
6144 "$P_CLI dtls=1 debug_level=2 \
6145 crt_file=data_files/server8_int-ca2.crt \
6146 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006147 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006148 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006149 0 \
6150 -S "found fragmented DTLS handshake message" \
6151 -c "found fragmented DTLS handshake message" \
6152 -C "error"
6153
6154requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6155requires_config_enabled MBEDTLS_RSA_C
6156requires_config_enabled MBEDTLS_ECDSA_C
6157requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006158run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006159 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6160 crt_file=data_files/server7_int-ca.crt \
6161 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006162 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006163 max_frag_len=2048" \
6164 "$P_CLI dtls=1 debug_level=2 \
6165 crt_file=data_files/server8_int-ca2.crt \
6166 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006167 hs_timeout=2500-60000 \
6168 max_frag_len=1024" \
6169 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006170 -S "found fragmented DTLS handshake message" \
6171 -c "found fragmented DTLS handshake message" \
6172 -C "error"
6173
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006174# While not required by the standard defining the MFL extension
6175# (according to which it only applies to records, not to datagrams),
6176# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6177# as otherwise there wouldn't be any means to communicate MTU restrictions
6178# to the peer.
6179# The next test checks that no datagrams significantly larger than the
6180# negotiated MFL are sent.
6181requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6182requires_config_enabled MBEDTLS_RSA_C
6183requires_config_enabled MBEDTLS_ECDSA_C
6184requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6185run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006186 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006187 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6188 crt_file=data_files/server7_int-ca.crt \
6189 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006190 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006191 max_frag_len=2048" \
6192 "$P_CLI dtls=1 debug_level=2 \
6193 crt_file=data_files/server8_int-ca2.crt \
6194 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006195 hs_timeout=2500-60000 \
6196 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006197 0 \
6198 -S "found fragmented DTLS handshake message" \
6199 -c "found fragmented DTLS handshake message" \
6200 -C "error"
6201
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006202requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6203requires_config_enabled MBEDTLS_RSA_C
6204requires_config_enabled MBEDTLS_ECDSA_C
6205requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006206run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006207 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6208 crt_file=data_files/server7_int-ca.crt \
6209 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006210 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006211 max_frag_len=2048" \
6212 "$P_CLI dtls=1 debug_level=2 \
6213 crt_file=data_files/server8_int-ca2.crt \
6214 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006215 hs_timeout=2500-60000 \
6216 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006217 0 \
6218 -s "found fragmented DTLS handshake message" \
6219 -c "found fragmented DTLS handshake message" \
6220 -C "error"
6221
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006222# While not required by the standard defining the MFL extension
6223# (according to which it only applies to records, not to datagrams),
6224# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6225# as otherwise there wouldn't be any means to communicate MTU restrictions
6226# to the peer.
6227# The next test checks that no datagrams significantly larger than the
6228# negotiated MFL are sent.
6229requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6230requires_config_enabled MBEDTLS_RSA_C
6231requires_config_enabled MBEDTLS_ECDSA_C
6232requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6233run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006234 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006235 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6236 crt_file=data_files/server7_int-ca.crt \
6237 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006238 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006239 max_frag_len=2048" \
6240 "$P_CLI dtls=1 debug_level=2 \
6241 crt_file=data_files/server8_int-ca2.crt \
6242 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006243 hs_timeout=2500-60000 \
6244 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006245 0 \
6246 -s "found fragmented DTLS handshake message" \
6247 -c "found fragmented DTLS handshake message" \
6248 -C "error"
6249
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006250requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6251requires_config_enabled MBEDTLS_RSA_C
6252requires_config_enabled MBEDTLS_ECDSA_C
6253run_test "DTLS fragmenting: none (for reference) (MTU)" \
6254 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6255 crt_file=data_files/server7_int-ca.crt \
6256 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006257 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006258 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006259 "$P_CLI dtls=1 debug_level=2 \
6260 crt_file=data_files/server8_int-ca2.crt \
6261 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006262 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006263 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006264 0 \
6265 -S "found fragmented DTLS handshake message" \
6266 -C "found fragmented DTLS handshake message" \
6267 -C "error"
6268
6269requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6270requires_config_enabled MBEDTLS_RSA_C
6271requires_config_enabled MBEDTLS_ECDSA_C
6272run_test "DTLS fragmenting: client (MTU)" \
6273 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6274 crt_file=data_files/server7_int-ca.crt \
6275 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006276 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006277 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006278 "$P_CLI dtls=1 debug_level=2 \
6279 crt_file=data_files/server8_int-ca2.crt \
6280 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006281 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006282 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006283 0 \
6284 -s "found fragmented DTLS handshake message" \
6285 -C "found fragmented DTLS handshake message" \
6286 -C "error"
6287
6288requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6289requires_config_enabled MBEDTLS_RSA_C
6290requires_config_enabled MBEDTLS_ECDSA_C
6291run_test "DTLS fragmenting: server (MTU)" \
6292 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6293 crt_file=data_files/server7_int-ca.crt \
6294 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006295 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006296 mtu=512" \
6297 "$P_CLI dtls=1 debug_level=2 \
6298 crt_file=data_files/server8_int-ca2.crt \
6299 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006300 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006301 mtu=2048" \
6302 0 \
6303 -S "found fragmented DTLS handshake message" \
6304 -c "found fragmented DTLS handshake message" \
6305 -C "error"
6306
6307requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6308requires_config_enabled MBEDTLS_RSA_C
6309requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006310run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006311 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006312 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6313 crt_file=data_files/server7_int-ca.crt \
6314 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006315 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006316 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006317 "$P_CLI dtls=1 debug_level=2 \
6318 crt_file=data_files/server8_int-ca2.crt \
6319 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006320 hs_timeout=2500-60000 \
6321 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006322 0 \
6323 -s "found fragmented DTLS handshake message" \
6324 -c "found fragmented DTLS handshake message" \
6325 -C "error"
6326
Andrzej Kurek77826052018-10-11 07:34:08 -04006327# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006328requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6329requires_config_enabled MBEDTLS_RSA_C
6330requires_config_enabled MBEDTLS_ECDSA_C
6331requires_config_enabled MBEDTLS_SHA256_C
6332requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6333requires_config_enabled MBEDTLS_AES_C
6334requires_config_enabled MBEDTLS_GCM_C
6335run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006336 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006337 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6338 crt_file=data_files/server7_int-ca.crt \
6339 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006340 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006341 mtu=512" \
6342 "$P_CLI dtls=1 debug_level=2 \
6343 crt_file=data_files/server8_int-ca2.crt \
6344 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006345 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6346 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006347 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006348 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006349 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006350 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006351 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006352
Andrzej Kurek7311c782018-10-11 06:49:41 -04006353# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006354# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006355# The ratio of max/min timeout should ideally equal 4 to accept two
6356# retransmissions, but in some cases (like both the server and client using
6357# fragmentation and auto-reduction) an extra retransmission might occur,
6358# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006359not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +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 -04006363requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6364requires_config_enabled MBEDTLS_AES_C
6365requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006366run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6367 -p "$P_PXY mtu=508" \
6368 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6369 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006370 key_file=data_files/server7.key \
6371 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006372 "$P_CLI dtls=1 debug_level=2 \
6373 crt_file=data_files/server8_int-ca2.crt \
6374 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006375 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6376 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006377 0 \
6378 -s "found fragmented DTLS handshake message" \
6379 -c "found fragmented DTLS handshake message" \
6380 -C "error"
6381
Andrzej Kurek77826052018-10-11 07:34:08 -04006382# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006383only_with_valgrind
6384requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6385requires_config_enabled MBEDTLS_RSA_C
6386requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006387requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6388requires_config_enabled MBEDTLS_AES_C
6389requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006390run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6391 -p "$P_PXY mtu=508" \
6392 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6393 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006394 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006395 hs_timeout=250-10000" \
6396 "$P_CLI dtls=1 debug_level=2 \
6397 crt_file=data_files/server8_int-ca2.crt \
6398 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006399 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006400 hs_timeout=250-10000" \
6401 0 \
6402 -s "found fragmented DTLS handshake message" \
6403 -c "found fragmented DTLS handshake message" \
6404 -C "error"
6405
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006406# 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 +02006407# OTOH the client might resend if the server is to slow to reset after sending
6408# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006409not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006410requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6411requires_config_enabled MBEDTLS_RSA_C
6412requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006413run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006414 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006415 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6416 crt_file=data_files/server7_int-ca.crt \
6417 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006418 hs_timeout=10000-60000 \
6419 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006420 "$P_CLI dtls=1 debug_level=2 \
6421 crt_file=data_files/server8_int-ca2.crt \
6422 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006423 hs_timeout=10000-60000 \
6424 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006425 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006426 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006427 -s "found fragmented DTLS handshake message" \
6428 -c "found fragmented DTLS handshake message" \
6429 -C "error"
6430
Andrzej Kurek77826052018-10-11 07:34:08 -04006431# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006432# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6433# OTOH the client might resend if the server is to slow to reset after sending
6434# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006435not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006436requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6437requires_config_enabled MBEDTLS_RSA_C
6438requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006439requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6440requires_config_enabled MBEDTLS_AES_C
6441requires_config_enabled MBEDTLS_GCM_C
6442run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006443 -p "$P_PXY mtu=512" \
6444 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6445 crt_file=data_files/server7_int-ca.crt \
6446 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006447 hs_timeout=10000-60000 \
6448 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006449 "$P_CLI dtls=1 debug_level=2 \
6450 crt_file=data_files/server8_int-ca2.crt \
6451 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006452 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6453 hs_timeout=10000-60000 \
6454 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006455 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006456 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006457 -s "found fragmented DTLS handshake message" \
6458 -c "found fragmented DTLS handshake message" \
6459 -C "error"
6460
Andrzej Kurek7311c782018-10-11 06:49:41 -04006461not_with_valgrind # spurious autoreduction due to timeout
6462requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6463requires_config_enabled MBEDTLS_RSA_C
6464requires_config_enabled MBEDTLS_ECDSA_C
6465run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006466 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006467 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6468 crt_file=data_files/server7_int-ca.crt \
6469 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006470 hs_timeout=10000-60000 \
6471 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006472 "$P_CLI dtls=1 debug_level=2 \
6473 crt_file=data_files/server8_int-ca2.crt \
6474 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006475 hs_timeout=10000-60000 \
6476 mtu=1024 nbio=2" \
6477 0 \
6478 -S "autoreduction" \
6479 -s "found fragmented DTLS handshake message" \
6480 -c "found fragmented DTLS handshake message" \
6481 -C "error"
6482
Andrzej Kurek77826052018-10-11 07:34:08 -04006483# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006484not_with_valgrind # spurious autoreduction due to timeout
6485requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6486requires_config_enabled MBEDTLS_RSA_C
6487requires_config_enabled MBEDTLS_ECDSA_C
6488requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6489requires_config_enabled MBEDTLS_AES_C
6490requires_config_enabled MBEDTLS_GCM_C
6491run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6492 -p "$P_PXY mtu=512" \
6493 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6494 crt_file=data_files/server7_int-ca.crt \
6495 key_file=data_files/server7.key \
6496 hs_timeout=10000-60000 \
6497 mtu=512 nbio=2" \
6498 "$P_CLI dtls=1 debug_level=2 \
6499 crt_file=data_files/server8_int-ca2.crt \
6500 key_file=data_files/server8.key \
6501 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6502 hs_timeout=10000-60000 \
6503 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006504 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006505 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006506 -s "found fragmented DTLS handshake message" \
6507 -c "found fragmented DTLS handshake message" \
6508 -C "error"
6509
Andrzej Kurek77826052018-10-11 07:34:08 -04006510# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006511# This ensures things still work after session_reset().
6512# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006513# Since we don't support reading fragmented ClientHello yet,
6514# up the MTU to 1450 (larger than ClientHello with session ticket,
6515# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006516# An autoreduction on the client-side might happen if the server is
6517# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006518# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006519# resumed listening, which would result in a spurious autoreduction.
6520not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006521requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6522requires_config_enabled MBEDTLS_RSA_C
6523requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006524requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6525requires_config_enabled MBEDTLS_AES_C
6526requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006527run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6528 -p "$P_PXY mtu=1450" \
6529 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6530 crt_file=data_files/server7_int-ca.crt \
6531 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006532 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006533 mtu=1450" \
6534 "$P_CLI dtls=1 debug_level=2 \
6535 crt_file=data_files/server8_int-ca2.crt \
6536 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006537 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006538 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006539 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006540 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006541 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006542 -s "found fragmented DTLS handshake message" \
6543 -c "found fragmented DTLS handshake message" \
6544 -C "error"
6545
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006546# An autoreduction on the client-side might happen if the server is
6547# slow to reset, therefore omitting '-C "autoreduction"' below.
6548not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006549requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6550requires_config_enabled MBEDTLS_RSA_C
6551requires_config_enabled MBEDTLS_ECDSA_C
6552requires_config_enabled MBEDTLS_SHA256_C
6553requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6554requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6555requires_config_enabled MBEDTLS_CHACHAPOLY_C
6556run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6557 -p "$P_PXY mtu=512" \
6558 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6559 crt_file=data_files/server7_int-ca.crt \
6560 key_file=data_files/server7.key \
6561 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006562 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006563 mtu=512" \
6564 "$P_CLI dtls=1 debug_level=2 \
6565 crt_file=data_files/server8_int-ca2.crt \
6566 key_file=data_files/server8.key \
6567 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006568 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006569 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006570 mtu=512" \
6571 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006572 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006573 -s "found fragmented DTLS handshake message" \
6574 -c "found fragmented DTLS handshake message" \
6575 -C "error"
6576
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006577# An autoreduction on the client-side might happen if the server is
6578# slow to reset, therefore omitting '-C "autoreduction"' below.
6579not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006580requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6581requires_config_enabled MBEDTLS_RSA_C
6582requires_config_enabled MBEDTLS_ECDSA_C
6583requires_config_enabled MBEDTLS_SHA256_C
6584requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6585requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6586requires_config_enabled MBEDTLS_AES_C
6587requires_config_enabled MBEDTLS_GCM_C
6588run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6589 -p "$P_PXY mtu=512" \
6590 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6591 crt_file=data_files/server7_int-ca.crt \
6592 key_file=data_files/server7.key \
6593 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006594 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006595 mtu=512" \
6596 "$P_CLI dtls=1 debug_level=2 \
6597 crt_file=data_files/server8_int-ca2.crt \
6598 key_file=data_files/server8.key \
6599 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006600 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006601 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006602 mtu=512" \
6603 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006604 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006605 -s "found fragmented DTLS handshake message" \
6606 -c "found fragmented DTLS handshake message" \
6607 -C "error"
6608
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006609# An autoreduction on the client-side might happen if the server is
6610# slow to reset, therefore omitting '-C "autoreduction"' below.
6611not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006612requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6613requires_config_enabled MBEDTLS_RSA_C
6614requires_config_enabled MBEDTLS_ECDSA_C
6615requires_config_enabled MBEDTLS_SHA256_C
6616requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6617requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6618requires_config_enabled MBEDTLS_AES_C
6619requires_config_enabled MBEDTLS_CCM_C
6620run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006621 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006622 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6623 crt_file=data_files/server7_int-ca.crt \
6624 key_file=data_files/server7.key \
6625 exchanges=2 renegotiation=1 \
6626 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006627 hs_timeout=10000-60000 \
6628 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006629 "$P_CLI dtls=1 debug_level=2 \
6630 crt_file=data_files/server8_int-ca2.crt \
6631 key_file=data_files/server8.key \
6632 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006633 hs_timeout=10000-60000 \
6634 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006635 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006636 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006637 -s "found fragmented DTLS handshake message" \
6638 -c "found fragmented DTLS handshake message" \
6639 -C "error"
6640
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006641# An autoreduction on the client-side might happen if the server is
6642# slow to reset, therefore omitting '-C "autoreduction"' below.
6643not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006644requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6645requires_config_enabled MBEDTLS_RSA_C
6646requires_config_enabled MBEDTLS_ECDSA_C
6647requires_config_enabled MBEDTLS_SHA256_C
6648requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6649requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6650requires_config_enabled MBEDTLS_AES_C
6651requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6652requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6653run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006654 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006655 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6656 crt_file=data_files/server7_int-ca.crt \
6657 key_file=data_files/server7.key \
6658 exchanges=2 renegotiation=1 \
6659 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006660 hs_timeout=10000-60000 \
6661 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006662 "$P_CLI dtls=1 debug_level=2 \
6663 crt_file=data_files/server8_int-ca2.crt \
6664 key_file=data_files/server8.key \
6665 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006666 hs_timeout=10000-60000 \
6667 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006668 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006669 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006670 -s "found fragmented DTLS handshake message" \
6671 -c "found fragmented DTLS handshake message" \
6672 -C "error"
6673
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006674# An autoreduction on the client-side might happen if the server is
6675# slow to reset, therefore omitting '-C "autoreduction"' below.
6676not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006677requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6678requires_config_enabled MBEDTLS_RSA_C
6679requires_config_enabled MBEDTLS_ECDSA_C
6680requires_config_enabled MBEDTLS_SHA256_C
6681requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6682requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6683requires_config_enabled MBEDTLS_AES_C
6684requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6685run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006686 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006687 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6688 crt_file=data_files/server7_int-ca.crt \
6689 key_file=data_files/server7.key \
6690 exchanges=2 renegotiation=1 \
6691 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006692 hs_timeout=10000-60000 \
6693 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006694 "$P_CLI dtls=1 debug_level=2 \
6695 crt_file=data_files/server8_int-ca2.crt \
6696 key_file=data_files/server8.key \
6697 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006698 hs_timeout=10000-60000 \
6699 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006700 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006701 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006702 -s "found fragmented DTLS handshake message" \
6703 -c "found fragmented DTLS handshake message" \
6704 -C "error"
6705
Andrzej Kurek77826052018-10-11 07:34:08 -04006706# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006707requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6708requires_config_enabled MBEDTLS_RSA_C
6709requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006710requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6711requires_config_enabled MBEDTLS_AES_C
6712requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006713client_needs_more_time 2
6714run_test "DTLS fragmenting: proxy MTU + 3d" \
6715 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006716 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006717 crt_file=data_files/server7_int-ca.crt \
6718 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006719 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006720 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006721 crt_file=data_files/server8_int-ca2.crt \
6722 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006723 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006724 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006725 0 \
6726 -s "found fragmented DTLS handshake message" \
6727 -c "found fragmented DTLS handshake message" \
6728 -C "error"
6729
Andrzej Kurek77826052018-10-11 07:34:08 -04006730# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006731requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6732requires_config_enabled MBEDTLS_RSA_C
6733requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006734requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6735requires_config_enabled MBEDTLS_AES_C
6736requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006737client_needs_more_time 2
6738run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6739 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6740 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6741 crt_file=data_files/server7_int-ca.crt \
6742 key_file=data_files/server7.key \
6743 hs_timeout=250-10000 mtu=512 nbio=2" \
6744 "$P_CLI dtls=1 debug_level=2 \
6745 crt_file=data_files/server8_int-ca2.crt \
6746 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006747 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006748 hs_timeout=250-10000 mtu=512 nbio=2" \
6749 0 \
6750 -s "found fragmented DTLS handshake message" \
6751 -c "found fragmented DTLS handshake message" \
6752 -C "error"
6753
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006754# interop tests for DTLS fragmentating with reliable connection
6755#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006756# here and below we just want to test that the we fragment in a way that
6757# pleases other implementations, so we don't need the peer to fragment
6758requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6759requires_config_enabled MBEDTLS_RSA_C
6760requires_config_enabled MBEDTLS_ECDSA_C
6761requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006762requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006763run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6764 "$G_SRV -u" \
6765 "$P_CLI dtls=1 debug_level=2 \
6766 crt_file=data_files/server8_int-ca2.crt \
6767 key_file=data_files/server8.key \
6768 mtu=512 force_version=dtls1_2" \
6769 0 \
6770 -c "fragmenting handshake message" \
6771 -C "error"
6772
6773requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6774requires_config_enabled MBEDTLS_RSA_C
6775requires_config_enabled MBEDTLS_ECDSA_C
6776requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006777requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006778run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6779 "$G_SRV -u" \
6780 "$P_CLI dtls=1 debug_level=2 \
6781 crt_file=data_files/server8_int-ca2.crt \
6782 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006783 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006784 0 \
6785 -c "fragmenting handshake message" \
6786 -C "error"
6787
Hanno Beckerb9a00862018-08-28 10:20:22 +01006788# We use --insecure for the GnuTLS client because it expects
6789# the hostname / IP it connects to to be the name used in the
6790# certificate obtained from the server. Here, however, it
6791# connects to 127.0.0.1 while our test certificates use 'localhost'
6792# as the server name in the certificate. This will make the
6793# certifiate validation fail, but passing --insecure makes
6794# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006795requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6796requires_config_enabled MBEDTLS_RSA_C
6797requires_config_enabled MBEDTLS_ECDSA_C
6798requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006799requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006800requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006801run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006802 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006803 crt_file=data_files/server7_int-ca.crt \
6804 key_file=data_files/server7.key \
6805 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006806 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006807 0 \
6808 -s "fragmenting handshake message"
6809
Hanno Beckerb9a00862018-08-28 10:20:22 +01006810# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006811requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6812requires_config_enabled MBEDTLS_RSA_C
6813requires_config_enabled MBEDTLS_ECDSA_C
6814requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006815requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006816requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006817run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006818 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006819 crt_file=data_files/server7_int-ca.crt \
6820 key_file=data_files/server7.key \
6821 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006822 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006823 0 \
6824 -s "fragmenting handshake message"
6825
6826requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6827requires_config_enabled MBEDTLS_RSA_C
6828requires_config_enabled MBEDTLS_ECDSA_C
6829requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6830run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6831 "$O_SRV -dtls1_2 -verify 10" \
6832 "$P_CLI dtls=1 debug_level=2 \
6833 crt_file=data_files/server8_int-ca2.crt \
6834 key_file=data_files/server8.key \
6835 mtu=512 force_version=dtls1_2" \
6836 0 \
6837 -c "fragmenting handshake message" \
6838 -C "error"
6839
6840requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6841requires_config_enabled MBEDTLS_RSA_C
6842requires_config_enabled MBEDTLS_ECDSA_C
6843requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6844run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6845 "$O_SRV -dtls1 -verify 10" \
6846 "$P_CLI dtls=1 debug_level=2 \
6847 crt_file=data_files/server8_int-ca2.crt \
6848 key_file=data_files/server8.key \
6849 mtu=512 force_version=dtls1" \
6850 0 \
6851 -c "fragmenting handshake message" \
6852 -C "error"
6853
6854requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6855requires_config_enabled MBEDTLS_RSA_C
6856requires_config_enabled MBEDTLS_ECDSA_C
6857requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6858run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6859 "$P_SRV dtls=1 debug_level=2 \
6860 crt_file=data_files/server7_int-ca.crt \
6861 key_file=data_files/server7.key \
6862 mtu=512 force_version=dtls1_2" \
6863 "$O_CLI -dtls1_2" \
6864 0 \
6865 -s "fragmenting handshake message"
6866
6867requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6868requires_config_enabled MBEDTLS_RSA_C
6869requires_config_enabled MBEDTLS_ECDSA_C
6870requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6871run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6872 "$P_SRV dtls=1 debug_level=2 \
6873 crt_file=data_files/server7_int-ca.crt \
6874 key_file=data_files/server7.key \
6875 mtu=512 force_version=dtls1" \
6876 "$O_CLI -dtls1" \
6877 0 \
6878 -s "fragmenting handshake message"
6879
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006880# interop tests for DTLS fragmentating with unreliable connection
6881#
6882# again we just want to test that the we fragment in a way that
6883# pleases other implementations, so we don't need the peer to fragment
6884requires_gnutls_next
6885requires_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_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006889client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006890run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6891 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6892 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006893 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006894 crt_file=data_files/server8_int-ca2.crt \
6895 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006896 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006897 0 \
6898 -c "fragmenting handshake message" \
6899 -C "error"
6900
6901requires_gnutls_next
6902requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6903requires_config_enabled MBEDTLS_RSA_C
6904requires_config_enabled MBEDTLS_ECDSA_C
6905requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006906client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006907run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6908 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6909 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006910 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006911 crt_file=data_files/server8_int-ca2.crt \
6912 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006913 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006914 0 \
6915 -c "fragmenting handshake message" \
6916 -C "error"
6917
k-stachowiakabb843e2019-02-18 16:14:03 +01006918requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006919requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6920requires_config_enabled MBEDTLS_RSA_C
6921requires_config_enabled MBEDTLS_ECDSA_C
6922requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6923client_needs_more_time 4
6924run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6925 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6926 "$P_SRV dtls=1 debug_level=2 \
6927 crt_file=data_files/server7_int-ca.crt \
6928 key_file=data_files/server7.key \
6929 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006930 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006931 0 \
6932 -s "fragmenting handshake message"
6933
k-stachowiakabb843e2019-02-18 16:14:03 +01006934requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006935requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6936requires_config_enabled MBEDTLS_RSA_C
6937requires_config_enabled MBEDTLS_ECDSA_C
6938requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6939client_needs_more_time 4
6940run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6941 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6942 "$P_SRV dtls=1 debug_level=2 \
6943 crt_file=data_files/server7_int-ca.crt \
6944 key_file=data_files/server7.key \
6945 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006946 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006947 0 \
6948 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006949
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006950## Interop test with OpenSSL might trigger a bug in recent versions (including
6951## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006952## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006953## They should be re-enabled once a fixed version of OpenSSL is available
6954## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006955skip_next_test
6956requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6957requires_config_enabled MBEDTLS_RSA_C
6958requires_config_enabled MBEDTLS_ECDSA_C
6959requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6960client_needs_more_time 4
6961run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6962 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6963 "$O_SRV -dtls1_2 -verify 10" \
6964 "$P_CLI dtls=1 debug_level=2 \
6965 crt_file=data_files/server8_int-ca2.crt \
6966 key_file=data_files/server8.key \
6967 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6968 0 \
6969 -c "fragmenting handshake message" \
6970 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006971
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006972skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006973requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6974requires_config_enabled MBEDTLS_RSA_C
6975requires_config_enabled MBEDTLS_ECDSA_C
6976requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006977client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006978run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6979 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006980 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006981 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006982 crt_file=data_files/server8_int-ca2.crt \
6983 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006984 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006985 0 \
6986 -c "fragmenting handshake message" \
6987 -C "error"
6988
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006989skip_next_test
6990requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6991requires_config_enabled MBEDTLS_RSA_C
6992requires_config_enabled MBEDTLS_ECDSA_C
6993requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6994client_needs_more_time 4
6995run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6996 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6997 "$P_SRV dtls=1 debug_level=2 \
6998 crt_file=data_files/server7_int-ca.crt \
6999 key_file=data_files/server7.key \
7000 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7001 "$O_CLI -dtls1_2" \
7002 0 \
7003 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007004
7005# -nbio is added to prevent s_client from blocking in case of duplicated
7006# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007007skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007008requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7009requires_config_enabled MBEDTLS_RSA_C
7010requires_config_enabled MBEDTLS_ECDSA_C
7011requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007012client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007013run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
7014 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007015 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007016 crt_file=data_files/server7_int-ca.crt \
7017 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007018 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007019 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007020 0 \
7021 -s "fragmenting handshake message"
7022
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007023# Tests for specific things with "unreliable" UDP connection
7024
7025not_with_valgrind # spurious resend due to timeout
7026run_test "DTLS proxy: reference" \
7027 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007028 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
7029 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007030 0 \
7031 -C "replayed record" \
7032 -S "replayed record" \
7033 -C "record from another epoch" \
7034 -S "record from another epoch" \
7035 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007036 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007037 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007038 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007039 -c "HTTP/1.0 200 OK"
7040
7041not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007042run_test "DTLS proxy: duplicate every packet" \
7043 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007044 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
7045 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007046 0 \
7047 -c "replayed record" \
7048 -s "replayed record" \
7049 -c "record from another epoch" \
7050 -s "record from another epoch" \
7051 -S "resend" \
7052 -s "Extra-header:" \
7053 -c "HTTP/1.0 200 OK"
7054
7055run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7056 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007057 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7058 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007059 0 \
7060 -c "replayed record" \
7061 -S "replayed record" \
7062 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007063 -s "record from another epoch" \
7064 -c "resend" \
7065 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007066 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007067 -c "HTTP/1.0 200 OK"
7068
7069run_test "DTLS proxy: multiple records in same datagram" \
7070 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007071 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7072 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007073 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007074 -c "next record in same datagram" \
7075 -s "next record in same datagram"
7076
7077run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7078 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007079 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7080 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007081 0 \
7082 -c "next record in same datagram" \
7083 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007084
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007085run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7086 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007087 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7088 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007089 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007090 -c "discarding invalid record (mac)" \
7091 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007092 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007093 -c "HTTP/1.0 200 OK" \
7094 -S "too many records with bad MAC" \
7095 -S "Verification of the message MAC failed"
7096
7097run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
7098 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007099 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7100 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007101 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007102 -C "discarding invalid record (mac)" \
7103 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007104 -S "Extra-header:" \
7105 -C "HTTP/1.0 200 OK" \
7106 -s "too many records with bad MAC" \
7107 -s "Verification of the message MAC failed"
7108
7109run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7110 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007111 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7112 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007113 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007114 -c "discarding invalid record (mac)" \
7115 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007116 -s "Extra-header:" \
7117 -c "HTTP/1.0 200 OK" \
7118 -S "too many records with bad MAC" \
7119 -S "Verification of the message MAC failed"
7120
7121run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7122 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007123 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7124 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007125 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007126 -c "discarding invalid record (mac)" \
7127 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007128 -s "Extra-header:" \
7129 -c "HTTP/1.0 200 OK" \
7130 -s "too many records with bad MAC" \
7131 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007132
7133run_test "DTLS proxy: delay ChangeCipherSpec" \
7134 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007135 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7136 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007137 0 \
7138 -c "record from another epoch" \
7139 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007140 -s "Extra-header:" \
7141 -c "HTTP/1.0 200 OK"
7142
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007143# Tests for reordering support with DTLS
7144
Hanno Becker56cdfd12018-08-17 13:42:15 +01007145run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7146 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007147 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7148 hs_timeout=2500-60000" \
7149 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7150 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007151 0 \
7152 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007153 -c "Next handshake message has been buffered - load"\
7154 -S "Buffering HS message" \
7155 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007156 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007157 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007158 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007159 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007160
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007161run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7162 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007163 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7164 hs_timeout=2500-60000" \
7165 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7166 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007167 0 \
7168 -c "Buffering HS message" \
7169 -c "found fragmented DTLS handshake message"\
7170 -c "Next handshake message 1 not or only partially bufffered" \
7171 -c "Next handshake message has been buffered - load"\
7172 -S "Buffering HS message" \
7173 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007174 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007175 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007176 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007177 -S "Remember CCS message"
7178
Hanno Beckera1adcca2018-08-24 14:41:07 +01007179# The client buffers the ServerKeyExchange before receiving the fragmented
7180# Certificate message; at the time of writing, together these are aroudn 1200b
7181# in size, so that the bound below ensures that the certificate can be reassembled
7182# while keeping the ServerKeyExchange.
7183requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7184run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007185 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007186 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7187 hs_timeout=2500-60000" \
7188 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7189 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007190 0 \
7191 -c "Buffering HS message" \
7192 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007193 -C "attempt to make space by freeing buffered messages" \
7194 -S "Buffering HS message" \
7195 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007196 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007197 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007198 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007199 -S "Remember CCS message"
7200
7201# The size constraints ensure that the delayed certificate message can't
7202# be reassembled while keeping the ServerKeyExchange message, but it can
7203# when dropping it first.
7204requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7205requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7206run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7207 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007208 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7209 hs_timeout=2500-60000" \
7210 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7211 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007212 0 \
7213 -c "Buffering HS message" \
7214 -c "attempt to make space by freeing buffered future messages" \
7215 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007216 -S "Buffering HS message" \
7217 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007218 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007219 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007220 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007221 -S "Remember CCS message"
7222
Hanno Becker56cdfd12018-08-17 13:42:15 +01007223run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7224 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007225 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7226 hs_timeout=2500-60000" \
7227 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7228 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007229 0 \
7230 -C "Buffering HS message" \
7231 -C "Next handshake message has been buffered - load"\
7232 -s "Buffering HS message" \
7233 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007234 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007235 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007236 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007237 -S "Remember CCS message"
7238
7239run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7240 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007241 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7242 hs_timeout=2500-60000" \
7243 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7244 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007245 0 \
7246 -C "Buffering HS message" \
7247 -C "Next handshake message has been buffered - load"\
7248 -S "Buffering HS message" \
7249 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007250 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007251 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007252 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007253 -S "Remember CCS message"
7254
7255run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7256 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007257 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7258 hs_timeout=2500-60000" \
7259 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7260 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007261 0 \
7262 -C "Buffering HS message" \
7263 -C "Next handshake message has been buffered - load"\
7264 -S "Buffering HS message" \
7265 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007266 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007267 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007268 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007269 -s "Remember CCS message"
7270
Hanno Beckera1adcca2018-08-24 14:41:07 +01007271run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007272 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007273 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7274 hs_timeout=2500-60000" \
7275 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7276 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007277 0 \
7278 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007279 -s "Found buffered record from current epoch - load" \
7280 -c "Buffer record from epoch 1" \
7281 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007282
Hanno Beckera1adcca2018-08-24 14:41:07 +01007283# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7284# from the server are delayed, so that the encrypted Finished message
7285# is received and buffered. When the fragmented NewSessionTicket comes
7286# in afterwards, the encrypted Finished message must be freed in order
7287# to make space for the NewSessionTicket to be reassembled.
7288# This works only in very particular circumstances:
7289# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7290# of the NewSessionTicket, but small enough to also allow buffering of
7291# the encrypted Finished message.
7292# - The MTU setting on the server must be so small that the NewSessionTicket
7293# needs to be fragmented.
7294# - All messages sent by the server must be small enough to be either sent
7295# without fragmentation or be reassembled within the bounds of
7296# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7297# handshake, omitting CRTs.
7298requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7299requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7300run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7301 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7302 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7303 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7304 0 \
7305 -s "Buffer record from epoch 1" \
7306 -s "Found buffered record from current epoch - load" \
7307 -c "Buffer record from epoch 1" \
7308 -C "Found buffered record from current epoch - load" \
7309 -c "Enough space available after freeing future epoch record"
7310
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007311# Tests for "randomly unreliable connection": try a variety of flows and peers
7312
7313client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007314run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7315 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007316 "$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 +02007317 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007318 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007319 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7320 0 \
7321 -s "Extra-header:" \
7322 -c "HTTP/1.0 200 OK"
7323
Janos Follath74537a62016-09-02 13:45:28 +01007324client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007325run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7326 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007327 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7328 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007329 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7330 0 \
7331 -s "Extra-header:" \
7332 -c "HTTP/1.0 200 OK"
7333
Janos Follath74537a62016-09-02 13:45:28 +01007334client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007335run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7336 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007337 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7338 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007339 0 \
7340 -s "Extra-header:" \
7341 -c "HTTP/1.0 200 OK"
7342
Janos Follath74537a62016-09-02 13:45:28 +01007343client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007344run_test "DTLS proxy: 3d, FS, client auth" \
7345 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007346 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7347 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007348 0 \
7349 -s "Extra-header:" \
7350 -c "HTTP/1.0 200 OK"
7351
Janos Follath74537a62016-09-02 13:45:28 +01007352client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007353run_test "DTLS proxy: 3d, FS, ticket" \
7354 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007355 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7356 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007357 0 \
7358 -s "Extra-header:" \
7359 -c "HTTP/1.0 200 OK"
7360
Janos Follath74537a62016-09-02 13:45:28 +01007361client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007362run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7363 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007364 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7365 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007366 0 \
7367 -s "Extra-header:" \
7368 -c "HTTP/1.0 200 OK"
7369
Janos Follath74537a62016-09-02 13:45:28 +01007370client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007371run_test "DTLS proxy: 3d, max handshake, nbio" \
7372 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007373 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007374 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007375 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007376 0 \
7377 -s "Extra-header:" \
7378 -c "HTTP/1.0 200 OK"
7379
Janos Follath74537a62016-09-02 13:45:28 +01007380client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007381run_test "DTLS proxy: 3d, min handshake, resumption" \
7382 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007383 "$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 +02007384 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007385 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007386 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007387 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7388 0 \
7389 -s "a session has been resumed" \
7390 -c "a session has been resumed" \
7391 -s "Extra-header:" \
7392 -c "HTTP/1.0 200 OK"
7393
Janos Follath74537a62016-09-02 13:45:28 +01007394client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007395run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7396 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007397 "$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 +02007398 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007399 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007400 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007401 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7402 0 \
7403 -s "a session has been resumed" \
7404 -c "a session has been resumed" \
7405 -s "Extra-header:" \
7406 -c "HTTP/1.0 200 OK"
7407
Janos Follath74537a62016-09-02 13:45:28 +01007408client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007409requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007410run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007411 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007412 "$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 +02007413 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007414 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007415 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007416 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7417 0 \
7418 -c "=> renegotiate" \
7419 -s "=> renegotiate" \
7420 -s "Extra-header:" \
7421 -c "HTTP/1.0 200 OK"
7422
Janos Follath74537a62016-09-02 13:45:28 +01007423client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007424requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007425run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7426 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007427 "$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 +02007428 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007429 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007430 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007431 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7432 0 \
7433 -c "=> renegotiate" \
7434 -s "=> renegotiate" \
7435 -s "Extra-header:" \
7436 -c "HTTP/1.0 200 OK"
7437
Janos Follath74537a62016-09-02 13:45:28 +01007438client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007439requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007440run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007441 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007442 "$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 +02007443 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007444 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007445 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007446 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007447 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7448 0 \
7449 -c "=> renegotiate" \
7450 -s "=> renegotiate" \
7451 -s "Extra-header:" \
7452 -c "HTTP/1.0 200 OK"
7453
Janos Follath74537a62016-09-02 13:45:28 +01007454client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007455requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007456run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007457 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007458 "$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 +02007459 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007460 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007461 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007462 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007463 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7464 0 \
7465 -c "=> renegotiate" \
7466 -s "=> renegotiate" \
7467 -s "Extra-header:" \
7468 -c "HTTP/1.0 200 OK"
7469
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007470## Interop tests with OpenSSL might trigger a bug in recent versions (including
7471## all versions installed on the CI machines), reported here:
7472## Bug report: https://github.com/openssl/openssl/issues/6902
7473## They should be re-enabled once a fixed version of OpenSSL is available
7474## (this should happen in some 1.1.1_ release according to the ticket).
7475skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007476client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007477not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007478run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007479 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7480 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007481 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007482 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007483 -c "HTTP/1.0 200 OK"
7484
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007485skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007486client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007487not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007488run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7489 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7490 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007491 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007492 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007493 -c "HTTP/1.0 200 OK"
7494
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007495skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007496client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007497not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007498run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7499 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7500 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007501 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007502 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007503 -c "HTTP/1.0 200 OK"
7504
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007505requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007506client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007507not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007508run_test "DTLS proxy: 3d, gnutls server" \
7509 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7510 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007511 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007512 0 \
7513 -s "Extra-header:" \
7514 -c "Extra-header:"
7515
k-stachowiakabb843e2019-02-18 16:14:03 +01007516requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007517client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007518not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007519run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7520 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007521 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007522 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007523 0 \
7524 -s "Extra-header:" \
7525 -c "Extra-header:"
7526
k-stachowiakabb843e2019-02-18 16:14:03 +01007527requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007528client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007529not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007530run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7531 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007532 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007533 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007534 0 \
7535 -s "Extra-header:" \
7536 -c "Extra-header:"
7537
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007538# Final report
7539
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007540echo "------------------------------------------------------------------------"
7541
7542if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007543 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007544else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007545 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007546fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007547PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007548echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007549
7550exit $FAILS