blob: 764e607cdc13e3da8c0ede7b34a8ed0a64193246 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Bence Szépkútia2947ac2020-08-19 16:37:36 +02005# Copyright The Mbed TLS Contributors
Bence Szépkútif744bd72020-06-05 13:02:18 +02006# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7#
8# This file is provided under the Apache License 2.0, or the
9# GNU General Public License v2.0 or later.
10#
11# **********
12# Apache License 2.0:
Bence Szépkúti51b41d52020-05-26 01:54:15 +020013#
14# Licensed under the Apache License, Version 2.0 (the "License"); you may
15# not use this file except in compliance with the License.
16# You may obtain a copy of the License at
17#
18# http://www.apache.org/licenses/LICENSE-2.0
19#
20# Unless required by applicable law or agreed to in writing, software
21# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23# See the License for the specific language governing permissions and
24# limitations under the License.
25#
Bence Szépkútif744bd72020-06-05 13:02:18 +020026# **********
27#
28# **********
29# GNU General Public License v2.0 or later:
30#
31# This program is free software; you can redistribute it and/or modify
32# it under the terms of the GNU General Public License as published by
33# the Free Software Foundation; either version 2 of the License, or
34# (at your option) any later version.
35#
36# This program is distributed in the hope that it will be useful,
37# but WITHOUT ANY WARRANTY; without even the implied warranty of
38# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39# GNU General Public License for more details.
40#
41# You should have received a copy of the GNU General Public License along
42# with this program; if not, write to the Free Software Foundation, Inc.,
43# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
44#
45# **********
46#
Simon Butcher58eddef2016-05-19 23:43:11 +010047# Purpose
48#
49# Executes tests to prove various TLS/SSL options and extensions.
50#
51# The goal is not to cover every ciphersuite/version, but instead to cover
52# specific options (max fragment length, truncated hmac, etc) or procedures
53# (session resumption from cache or ticket, renego, etc).
54#
55# The tests assume a build with default options, with exceptions expressed
56# with a dependency. The tests focus on functionality and do not consider
57# performance.
58#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010059
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010060set -u
61
Jaeden Ameroa258ccd2019-07-03 13:51:04 +010062# Limit the size of each log to 10 GiB, in case of failures with this script
63# where it may output seemingly unlimited length error logs.
64ulimit -f 20971520
65
Angus Grattonc4dd0732018-04-11 16:28:39 +100066if cd $( dirname $0 ); then :; else
67 echo "cd $( dirname $0 ) failed" >&2
68 exit 1
69fi
70
Antonin Décimod5f47592019-01-23 15:24:37 +010071# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010072: ${P_SRV:=../programs/ssl/ssl_server2}
73: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020074: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010075: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020076: ${GNUTLS_CLI:=gnutls-cli}
77: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020078: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010079
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020080O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010081O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020082G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010083G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020084TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010085
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020086# alternative versions of OpenSSL and GnuTLS (no default path)
87
88if [ -n "${OPENSSL_LEGACY:-}" ]; then
89 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
90 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
91else
92 O_LEGACY_SRV=false
93 O_LEGACY_CLI=false
94fi
95
Hanno Becker58e9dc32018-08-17 15:53:21 +010096if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020097 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
98else
99 G_NEXT_SRV=false
100fi
101
Hanno Becker58e9dc32018-08-17 15:53:21 +0100102if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200103 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
104else
105 G_NEXT_CLI=false
106fi
107
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100108TESTS=0
109FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200110SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100111
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000112CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +0200113
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100114MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100115FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200116EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100117
Paul Bakkere20310a2016-05-10 11:18:17 +0100118SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +0100119RUN_TEST_NUMBER=''
120
Paul Bakkeracaac852016-05-10 11:47:13 +0100121PRESERVE_LOGS=0
122
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200123# Pick a "unique" server port in the range 10000-19999, and a proxy
124# port which is this plus 10000. Each port number may be independently
125# overridden by a command line option.
126SRV_PORT=$(($$ % 10000 + 10000))
127PXY_PORT=$((SRV_PORT + 10000))
128
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100129print_usage() {
130 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100131 printf " -h|--help\tPrint this help.\n"
132 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200133 printf " -f|--filter\tOnly matching tests are executed (substring or BRE)\n"
134 printf " -e|--exclude\tMatching tests are excluded (substring or BRE)\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100135 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100136 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100137 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200138 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
139 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100140 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100141}
142
143get_options() {
144 while [ $# -gt 0 ]; do
145 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100146 -f|--filter)
147 shift; FILTER=$1
148 ;;
149 -e|--exclude)
150 shift; EXCLUDE=$1
151 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100152 -m|--memcheck)
153 MEMCHECK=1
154 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100155 -n|--number)
156 shift; RUN_TEST_NUMBER=$1
157 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100158 -s|--show-numbers)
159 SHOW_TEST_NUMBER=1
160 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100161 -p|--preserve-logs)
162 PRESERVE_LOGS=1
163 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200164 --port)
165 shift; SRV_PORT=$1
166 ;;
167 --proxy-port)
168 shift; PXY_PORT=$1
169 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100170 --seed)
171 shift; SEED="$1"
172 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100173 -h|--help)
174 print_usage
175 exit 0
176 ;;
177 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200178 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100179 print_usage
180 exit 1
181 ;;
182 esac
183 shift
184 done
185}
186
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200187# Read boolean configuration options from config.h for easy and quick
188# testing. Skip non-boolean options (with something other than spaces
189# and a comment after "#define SYMBOL"). The variable contains a
190# space-separated list of symbols.
191CONFIGS_ENABLED=" $(<"$CONFIG_H" \
192 sed -n 's!^ *#define *\([A-Za-z][0-9A-Z_a-z]*\) *\(/*\)*!\1!p' |
193 tr '\n' ' ')"
194
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100195# Skip next test; use this macro to skip tests which are legitimate
196# in theory and expected to be re-introduced at some point, but
197# aren't expected to succeed at the moment due to problems outside
198# our control (such as bugs in other TLS implementations).
199skip_next_test() {
200 SKIP_NEXT="YES"
201}
202
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100203# skip next test if the flag is not enabled in config.h
204requires_config_enabled() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200205 case $CONFIGS_ENABLED in
206 *" $1 "*) :;;
207 *) SKIP_NEXT="YES";;
208 esac
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100209}
210
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200211# skip next test if the flag is enabled in config.h
212requires_config_disabled() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200213 case $CONFIGS_ENABLED in
214 *" $1 "*) SKIP_NEXT="YES";;
215 esac
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200216}
217
Hanno Becker7c48dd12018-08-28 16:09:22 +0100218get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100219 # This function uses the query_config command line option to query the
220 # required Mbed TLS compile time configuration from the ssl_server2
221 # program. The command will always return a success value if the
222 # configuration is defined and the value will be printed to stdout.
223 #
224 # Note that if the configuration is not defined or is defined to nothing,
225 # the output of this function will be an empty string.
226 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100227}
228
229requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100230 VAL="$( get_config_value_or_default "$1" )"
231 if [ -z "$VAL" ]; then
232 # Should never happen
233 echo "Mbed TLS configuration $1 is not defined"
234 exit 1
235 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100236 SKIP_NEXT="YES"
237 fi
238}
239
240requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100241 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100242 if [ -z "$VAL" ]; then
243 # Should never happen
244 echo "Mbed TLS configuration $1 is not defined"
245 exit 1
246 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100247 SKIP_NEXT="YES"
248 fi
249}
250
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200251# skip next test if OpenSSL doesn't support FALLBACK_SCSV
252requires_openssl_with_fallback_scsv() {
253 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
254 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
255 then
256 OPENSSL_HAS_FBSCSV="YES"
257 else
258 OPENSSL_HAS_FBSCSV="NO"
259 fi
260 fi
261 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
262 SKIP_NEXT="YES"
263 fi
264}
265
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200266# skip next test if GnuTLS isn't available
267requires_gnutls() {
268 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200269 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200270 GNUTLS_AVAILABLE="YES"
271 else
272 GNUTLS_AVAILABLE="NO"
273 fi
274 fi
275 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
276 SKIP_NEXT="YES"
277 fi
278}
279
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200280# skip next test if GnuTLS-next isn't available
281requires_gnutls_next() {
282 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
283 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
284 GNUTLS_NEXT_AVAILABLE="YES"
285 else
286 GNUTLS_NEXT_AVAILABLE="NO"
287 fi
288 fi
289 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
290 SKIP_NEXT="YES"
291 fi
292}
293
294# skip next test if OpenSSL-legacy isn't available
295requires_openssl_legacy() {
296 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
297 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
298 OPENSSL_LEGACY_AVAILABLE="YES"
299 else
300 OPENSSL_LEGACY_AVAILABLE="NO"
301 fi
302 fi
303 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
304 SKIP_NEXT="YES"
305 fi
306}
307
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200308# skip next test if IPv6 isn't available on this host
309requires_ipv6() {
310 if [ -z "${HAS_IPV6:-}" ]; then
311 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
312 SRV_PID=$!
313 sleep 1
314 kill $SRV_PID >/dev/null 2>&1
315 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
316 HAS_IPV6="NO"
317 else
318 HAS_IPV6="YES"
319 fi
320 rm -r $SRV_OUT
321 fi
322
323 if [ "$HAS_IPV6" = "NO" ]; then
324 SKIP_NEXT="YES"
325 fi
326}
327
Andrzej Kurekb4593462018-10-11 08:43:30 -0400328# skip next test if it's i686 or uname is not available
329requires_not_i686() {
330 if [ -z "${IS_I686:-}" ]; then
331 IS_I686="YES"
332 if which "uname" >/dev/null 2>&1; then
333 if [ -z "$(uname -a | grep i686)" ]; then
334 IS_I686="NO"
335 fi
336 fi
337 fi
338 if [ "$IS_I686" = "YES" ]; then
339 SKIP_NEXT="YES"
340 fi
341}
342
Angus Grattonc4dd0732018-04-11 16:28:39 +1000343# Calculate the input & output maximum content lengths set in the config
Yuto Takanobbf657a2021-06-22 07:16:40 +0100344MAX_CONTENT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_MAX_CONTENT_LEN" )
345MAX_IN_LEN=$( get_config_value_or_default "MBEDTLS_SSL_IN_CONTENT_LEN" )
346MAX_OUT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_OUT_CONTENT_LEN" )
Angus Grattonc4dd0732018-04-11 16:28:39 +1000347
Yuto Takano2e580ce2021-06-21 19:43:33 +0100348# Calculate the maximum content length that fits both
Angus Grattonc4dd0732018-04-11 16:28:39 +1000349if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
350 MAX_CONTENT_LEN="$MAX_IN_LEN"
351fi
352if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
353 MAX_CONTENT_LEN="$MAX_OUT_LEN"
354fi
355
356# skip the next test if the SSL output buffer is less than 16KB
357requires_full_size_output_buffer() {
358 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
359 SKIP_NEXT="YES"
360 fi
361}
362
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200363# skip the next test if valgrind is in use
364not_with_valgrind() {
365 if [ "$MEMCHECK" -gt 0 ]; then
366 SKIP_NEXT="YES"
367 fi
368}
369
Paul Bakker362689d2016-05-13 10:33:25 +0100370# skip the next test if valgrind is NOT in use
371only_with_valgrind() {
372 if [ "$MEMCHECK" -eq 0 ]; then
373 SKIP_NEXT="YES"
374 fi
375}
376
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200377# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100378client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200379 CLI_DELAY_FACTOR=$1
380}
381
Janos Follath74537a62016-09-02 13:45:28 +0100382# wait for the given seconds after the client finished in the next test
383server_needs_more_time() {
384 SRV_DELAY_SECONDS=$1
385}
386
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100387# print_name <name>
388print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100389 TESTS=$(( $TESTS + 1 ))
390 LINE=""
391
392 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
393 LINE="$TESTS "
394 fi
395
396 LINE="$LINE$1"
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200397 printf "%s " "$LINE"
Paul Bakkere20310a2016-05-10 11:18:17 +0100398 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100399 for i in `seq 1 $LEN`; do printf '.'; done
400 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100401
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100402}
403
404# fail <message>
405fail() {
406 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100407 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100408
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200409 mv $SRV_OUT o-srv-${TESTS}.log
410 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200411 if [ -n "$PXY_CMD" ]; then
412 mv $PXY_OUT o-pxy-${TESTS}.log
413 fi
414 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100415
Manuel Pégourié-Gonnarde63fc6d2020-06-08 11:49:05 +0200416 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200417 echo " ! server output:"
418 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200419 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200420 echo " ! client output:"
421 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200422 if [ -n "$PXY_CMD" ]; then
423 echo " ! ========================================================"
424 echo " ! proxy output:"
425 cat o-pxy-${TESTS}.log
426 fi
427 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200428 fi
429
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200430 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100431}
432
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100433# is_polar <cmd_line>
434is_polar() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200435 case "$1" in
436 *ssl_client2*) true;;
437 *ssl_server2*) true;;
438 *) false;;
439 esac
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100440}
441
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200442# openssl s_server doesn't have -www with DTLS
443check_osrv_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200444 case "$SRV_CMD" in
445 *s_server*-dtls*)
446 NEEDS_INPUT=1
447 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )";;
448 *) NEEDS_INPUT=0;;
449 esac
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200450}
451
452# provide input to commands that need it
453provide_input() {
454 if [ $NEEDS_INPUT -eq 0 ]; then
455 return
456 fi
457
458 while true; do
459 echo "HTTP/1.0 200 OK"
460 sleep 1
461 done
462}
463
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100464# has_mem_err <log_file_name>
465has_mem_err() {
466 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
467 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
468 then
469 return 1 # false: does not have errors
470 else
471 return 0 # true: has errors
472 fi
473}
474
Unknown43dc0d62019-09-02 10:42:57 -0400475# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100476if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400477 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100478 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200479 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100480 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200481 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100482 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200483 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100484 # Make a tight loop, server normally takes less than 1s to start.
485 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
486 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400487 echo "$3 START TIMEOUT"
488 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100489 break
490 fi
491 # Linux and *BSD support decimal arguments to sleep. On other
492 # OSes this may be a tight loop.
493 sleep 0.1 2>/dev/null || true
494 done
495 }
496else
Unknown43dc0d62019-09-02 10:42:57 -0400497 echo "Warning: lsof not available, wait_app_start = sleep"
498 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200499 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100500 }
501fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200502
Unknown43dc0d62019-09-02 10:42:57 -0400503# Wait for server process $2 to be listening on port $1.
504wait_server_start() {
505 wait_app_start $1 $2 "SERVER" $SRV_OUT
506}
507
508# Wait for proxy process $2 to be listening on port $1.
509wait_proxy_start() {
510 wait_app_start $1 $2 "PROXY" $PXY_OUT
511}
512
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100513# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100514# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100515# acceptable bounds
516check_server_hello_time() {
517 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100518 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100519 # Get the Unix timestamp for now
520 CUR_TIME=$(date +'%s')
521 THRESHOLD_IN_SECS=300
522
523 # Check if the ServerHello time was printed
524 if [ -z "$SERVER_HELLO_TIME" ]; then
525 return 1
526 fi
527
528 # Check the time in ServerHello is within acceptable bounds
529 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
530 # The time in ServerHello is at least 5 minutes before now
531 return 1
532 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100533 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100534 return 1
535 else
536 return 0
537 fi
538}
539
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200540# wait for client to terminate and set CLI_EXIT
541# must be called right after starting the client
542wait_client_done() {
543 CLI_PID=$!
544
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200545 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
546 CLI_DELAY_FACTOR=1
547
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200548 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200549 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200550
551 wait $CLI_PID
552 CLI_EXIT=$?
553
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200554 kill $DOG_PID >/dev/null 2>&1
555 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200556
557 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100558
559 sleep $SRV_DELAY_SECONDS
560 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200561}
562
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200563# check if the given command uses dtls and sets global variable DTLS
564detect_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200565 case "$1" in
566 *dtls=1*|-dtls|-u) DTLS=1;;
567 *) DTLS=0;;
568 esac
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200569}
570
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200571# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100572# Options: -s pattern pattern that must be present in server output
573# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100574# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100575# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100576# -S pattern pattern that must be absent in server output
577# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100578# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100579# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100580run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100581 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200582 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100583
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200584 if is_excluded "$NAME"; then
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200585 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100586 return
587 fi
588
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100589 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100590
Paul Bakkerb7584a52016-05-10 10:50:43 +0100591 # Do we only run numbered tests?
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200592 if [ -n "$RUN_TEST_NUMBER" ]; then
593 case ",$RUN_TEST_NUMBER," in
594 *",$TESTS,"*) :;;
595 *) SKIP_NEXT="YES";;
596 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100597 fi
598
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200599 # should we skip?
600 if [ "X$SKIP_NEXT" = "XYES" ]; then
601 SKIP_NEXT="NO"
602 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200603 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200604 return
605 fi
606
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200607 # does this test use a proxy?
608 if [ "X$1" = "X-p" ]; then
609 PXY_CMD="$2"
610 shift 2
611 else
612 PXY_CMD=""
613 fi
614
615 # get commands and client output
616 SRV_CMD="$1"
617 CLI_CMD="$2"
618 CLI_EXPECT="$3"
619 shift 3
620
Hanno Becker7a11e722019-05-10 14:38:42 +0100621 # Check if test uses files
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200622 case "$SRV_CMD $CLI_CMD" in
623 *data_files/*)
624 requires_config_enabled MBEDTLS_FS_IO;;
625 esac
Hanno Becker7a11e722019-05-10 14:38:42 +0100626
627 # should we skip?
628 if [ "X$SKIP_NEXT" = "XYES" ]; then
629 SKIP_NEXT="NO"
630 echo "SKIP"
631 SKIPS=$(( $SKIPS + 1 ))
632 return
633 fi
634
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200635 # update DTLS variable
636 detect_dtls "$SRV_CMD"
637
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200638 # if the test uses DTLS but no custom proxy, add a simple proxy
639 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200640 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200641 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200642 case " $SRV_CMD " in
643 *' server_addr=::1 '*)
644 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
645 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200646 fi
647
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200648 # fix client port
649 if [ -n "$PXY_CMD" ]; then
650 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
651 else
652 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
653 fi
654
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100655 # prepend valgrind to our commands if active
656 if [ "$MEMCHECK" -gt 0 ]; then
657 if is_polar "$SRV_CMD"; then
658 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
659 fi
660 if is_polar "$CLI_CMD"; then
661 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
662 fi
663 fi
664
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200665 TIMES_LEFT=2
666 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200667 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200668
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200669 # run the commands
670 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda1919ad2020-07-27 09:45:32 +0200671 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200672 $PXY_CMD >> $PXY_OUT 2>&1 &
673 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400674 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200675 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200676
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200677 check_osrv_dtls
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200678 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200679 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
680 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100681 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200682
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200683 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200684 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
685 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100686
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100687 sleep 0.05
688
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200689 # terminate the server (and the proxy)
690 kill $SRV_PID
691 wait $SRV_PID
Gilles Peskine634fe272021-02-02 23:29:03 +0100692 SRV_RET=$?
Hanno Beckerd82d8462017-05-29 21:37:46 +0100693
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200694 if [ -n "$PXY_CMD" ]; then
695 kill $PXY_PID >/dev/null 2>&1
696 wait $PXY_PID
697 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100698
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200699 # retry only on timeouts
700 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
701 printf "RETRY "
702 else
703 TIMES_LEFT=0
704 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200705 done
706
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100707 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200708 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100709 # expected client exit to incorrectly succeed in case of catastrophic
710 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100711 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200712 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100713 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100714 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100715 return
716 fi
717 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100718 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200719 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100720 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100721 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100722 return
723 fi
724 fi
725
Gilles Peskine2cf44b62021-02-09 21:01:33 +0100726 # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
727 # exit with status 0 when interrupted by a signal, and we don't really
728 # care anyway), in case e.g. the server reports a memory leak.
729 if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then
Gilles Peskine634fe272021-02-02 23:29:03 +0100730 fail "Server exited with status $SRV_RET"
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100731 return
732 fi
733
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100734 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100735 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
736 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100737 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200738 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100739 return
740 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100741
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100742 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200743 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100744 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100745 while [ $# -gt 0 ]
746 do
747 case $1 in
748 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100749 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 +0100750 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100751 return
752 fi
753 ;;
754
755 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100756 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 +0100757 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100758 return
759 fi
760 ;;
761
762 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100763 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 +0100764 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100765 return
766 fi
767 ;;
768
769 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100770 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 +0100771 fail "pattern '$2' MUST NOT be present in the Client output"
772 return
773 fi
774 ;;
775
776 # The filtering in the following two options (-u and -U) do the following
777 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100778 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100779 # - keep one of each non-unique line
780 # - count how many lines remain
781 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
782 # if there were no duplicates.
783 "-U")
784 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
785 fail "lines following pattern '$2' must be unique in Server output"
786 return
787 fi
788 ;;
789
790 "-u")
791 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
792 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100793 return
794 fi
795 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100796 "-F")
797 if ! $2 "$SRV_OUT"; then
798 fail "function call to '$2' failed on Server output"
799 return
800 fi
801 ;;
802 "-f")
803 if ! $2 "$CLI_OUT"; then
804 fail "function call to '$2' failed on Client output"
805 return
806 fi
807 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100808
809 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200810 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100811 exit 1
812 esac
813 shift 2
814 done
815
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100816 # check valgrind's results
817 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200818 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100819 fail "Server has memory errors"
820 return
821 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200822 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100823 fail "Client has memory errors"
824 return
825 fi
826 fi
827
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100828 # if we're here, everything is ok
829 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100830 if [ "$PRESERVE_LOGS" -gt 0 ]; then
831 mv $SRV_OUT o-srv-${TESTS}.log
832 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100833 if [ -n "$PXY_CMD" ]; then
834 mv $PXY_OUT o-pxy-${TESTS}.log
835 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100836 fi
837
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200838 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100839}
840
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100841cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200842 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200843 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
844 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
845 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
846 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100847 exit 1
848}
849
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100850#
851# MAIN
852#
853
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100854get_options "$@"
855
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200856# Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell
857# patterns rather than regular expressions, use a case statement instead
858# of calling grep. To keep the optimizer simple, it is incomplete and only
859# detects simple cases: plain substring, everything, nothing.
860#
861# As an exception, the character '.' is treated as an ordinary character
862# if it is the only special character in the string. This is because it's
863# rare to need "any one character", but needing a literal '.' is common
864# (e.g. '-f "DTLS 1.2"').
865need_grep=
866case "$FILTER" in
867 '^$') simple_filter=;;
868 '.*') simple_filter='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200869 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200870 need_grep=1;;
871 *) # No regexp or shell-pattern special character
872 simple_filter="*$FILTER*";;
873esac
874case "$EXCLUDE" in
875 '^$') simple_exclude=;;
876 '.*') simple_exclude='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200877 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200878 need_grep=1;;
879 *) # No regexp or shell-pattern special character
880 simple_exclude="*$EXCLUDE*";;
881esac
882if [ -n "$need_grep" ]; then
883 is_excluded () {
884 ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE"
885 }
886else
887 is_excluded () {
888 case "$1" in
889 $simple_exclude) true;;
890 $simple_filter) false;;
891 *) true;;
892 esac
893 }
894fi
895
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100896# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100897P_SRV_BIN="${P_SRV%%[ ]*}"
898P_CLI_BIN="${P_CLI%%[ ]*}"
899P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100900if [ ! -x "$P_SRV_BIN" ]; then
901 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100902 exit 1
903fi
Hanno Becker17c04932017-10-10 14:44:53 +0100904if [ ! -x "$P_CLI_BIN" ]; then
905 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100906 exit 1
907fi
Hanno Becker17c04932017-10-10 14:44:53 +0100908if [ ! -x "$P_PXY_BIN" ]; then
909 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200910 exit 1
911fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100912if [ "$MEMCHECK" -gt 0 ]; then
913 if which valgrind >/dev/null 2>&1; then :; else
914 echo "Memcheck not possible. Valgrind not found"
915 exit 1
916 fi
917fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100918if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
919 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100920 exit 1
921fi
922
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200923# used by watchdog
924MAIN_PID="$$"
925
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100926# We use somewhat arbitrary delays for tests:
927# - how long do we wait for the server to start (when lsof not available)?
928# - how long do we allow for the client to finish?
929# (not to check performance, just to avoid waiting indefinitely)
930# Things are slower with valgrind, so give extra time here.
931#
932# Note: without lsof, there is a trade-off between the running time of this
933# script and the risk of spurious errors because we didn't wait long enough.
934# The watchdog delay on the other hand doesn't affect normal running time of
935# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200936if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100937 START_DELAY=6
938 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200939else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100940 START_DELAY=2
941 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200942fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100943
944# some particular tests need more time:
945# - for the client, we multiply the usual watchdog limit by a factor
946# - for the server, we sleep for a number of seconds after the client exits
947# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200948CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100949SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200950
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200951# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000952# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200953P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
954P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100955P_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 +0200956O_SRV="$O_SRV -accept $SRV_PORT"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200957O_CLI="$O_CLI -connect localhost:+SRV_PORT"
958G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200959G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200960
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200961if [ -n "${OPENSSL_LEGACY:-}" ]; then
962 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
963 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
964fi
965
Hanno Becker58e9dc32018-08-17 15:53:21 +0100966if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200967 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
968fi
969
Hanno Becker58e9dc32018-08-17 15:53:21 +0100970if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200971 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200972fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100973
Gilles Peskine62469d92017-05-10 10:13:59 +0200974# Allow SHA-1, because many of our test certificates use it
975P_SRV="$P_SRV allow_sha1=1"
976P_CLI="$P_CLI allow_sha1=1"
977
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200978# Also pick a unique name for intermediate files
979SRV_OUT="srv_out.$$"
980CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200981PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200982SESSION="session.$$"
983
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200984SKIP_NEXT="NO"
985
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100986trap cleanup INT TERM HUP
987
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200988# Basic test
989
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200990# Checks that:
991# - things work with all ciphersuites active (used with config-full in all.sh)
992# - the expected (highest security) parameters are selected
993# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200994run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200995 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200996 "$P_CLI" \
997 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200998 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200999 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001000 -s "client hello v3, signature_algorithm ext: 6" \
1001 -s "ECDHE curve: secp521r1" \
1002 -S "error" \
1003 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001004
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001005run_test "Default, DTLS" \
1006 "$P_SRV dtls=1" \
1007 "$P_CLI dtls=1" \
1008 0 \
1009 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001010 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001011
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +01001012requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1013run_test "Default (compression enabled)" \
1014 "$P_SRV debug_level=3" \
1015 "$P_CLI debug_level=3" \
1016 0 \
1017 -s "Allocating compression buffer" \
1018 -c "Allocating compression buffer" \
1019 -s "Record expansion is unknown (compression)" \
1020 -c "Record expansion is unknown (compression)" \
1021 -S "error" \
1022 -C "error"
1023
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001024# Test current time in ServerHello
1025requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001026run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001027 "$P_SRV debug_level=3" \
1028 "$P_CLI debug_level=3" \
1029 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001030 -f "check_server_hello_time" \
1031 -F "check_server_hello_time"
1032
Simon Butcher8e004102016-10-14 00:48:33 +01001033# Test for uniqueness of IVs in AEAD ciphersuites
1034run_test "Unique IV in GCM" \
1035 "$P_SRV exchanges=20 debug_level=4" \
1036 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1037 0 \
1038 -u "IV used" \
1039 -U "IV used"
1040
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001041# Tests for rc4 option
1042
Simon Butchera410af52016-05-19 22:12:18 +01001043requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001044run_test "RC4: server disabled, client enabled" \
1045 "$P_SRV" \
1046 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1047 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001048 -s "SSL - The server has no ciphersuites in common"
1049
Simon Butchera410af52016-05-19 22:12:18 +01001050requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001051run_test "RC4: server half, client enabled" \
1052 "$P_SRV arc4=1" \
1053 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1054 1 \
1055 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001056
1057run_test "RC4: server enabled, client disabled" \
1058 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1059 "$P_CLI" \
1060 1 \
1061 -s "SSL - The server has no ciphersuites in common"
1062
1063run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001064 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001065 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1066 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001067 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001068 -S "SSL - The server has no ciphersuites in common"
1069
Hanno Beckerd26bb202018-08-17 09:54:10 +01001070# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1071
1072requires_gnutls
1073requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1074run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1075 "$G_SRV"\
1076 "$P_CLI force_version=tls1_1" \
1077 0
1078
1079requires_gnutls
1080requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1081run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1082 "$G_SRV"\
1083 "$P_CLI force_version=tls1" \
1084 0
1085
Gilles Peskinebc70a182017-05-09 15:59:24 +02001086# Tests for SHA-1 support
1087
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001088requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001089run_test "SHA-1 forbidden by default in server certificate" \
1090 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1091 "$P_CLI debug_level=2 allow_sha1=0" \
1092 1 \
1093 -c "The certificate is signed with an unacceptable hash"
1094
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001095requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1096run_test "SHA-1 forbidden by default in server certificate" \
1097 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1098 "$P_CLI debug_level=2 allow_sha1=0" \
1099 0
1100
Gilles Peskinebc70a182017-05-09 15:59:24 +02001101run_test "SHA-1 explicitly allowed in server certificate" \
1102 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1103 "$P_CLI allow_sha1=1" \
1104 0
1105
1106run_test "SHA-256 allowed by default in server certificate" \
1107 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1108 "$P_CLI allow_sha1=0" \
1109 0
1110
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001111requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001112run_test "SHA-1 forbidden by default in client certificate" \
1113 "$P_SRV auth_mode=required allow_sha1=0" \
1114 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1115 1 \
1116 -s "The certificate is signed with an unacceptable hash"
1117
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001118requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1119run_test "SHA-1 forbidden by default in client certificate" \
1120 "$P_SRV auth_mode=required allow_sha1=0" \
1121 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1122 0
1123
Gilles Peskinebc70a182017-05-09 15:59:24 +02001124run_test "SHA-1 explicitly allowed in client certificate" \
1125 "$P_SRV auth_mode=required allow_sha1=1" \
1126 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1127 0
1128
1129run_test "SHA-256 allowed by default in client certificate" \
1130 "$P_SRV auth_mode=required allow_sha1=0" \
1131 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1132 0
1133
Hanno Becker7ae8a762018-08-14 15:43:35 +01001134# Tests for datagram packing
1135run_test "DTLS: multiple records in same datagram, client and server" \
1136 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1137 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1138 0 \
1139 -c "next record in same datagram" \
1140 -s "next record in same datagram"
1141
1142run_test "DTLS: multiple records in same datagram, client only" \
1143 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1144 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1145 0 \
1146 -s "next record in same datagram" \
1147 -C "next record in same datagram"
1148
1149run_test "DTLS: multiple records in same datagram, server only" \
1150 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1151 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1152 0 \
1153 -S "next record in same datagram" \
1154 -c "next record in same datagram"
1155
1156run_test "DTLS: multiple records in same datagram, neither client nor server" \
1157 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1158 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1159 0 \
1160 -S "next record in same datagram" \
1161 -C "next record in same datagram"
1162
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001163# Tests for Truncated HMAC extension
1164
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001165run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001166 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001167 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001168 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001169 -s "dumping 'expected mac' (20 bytes)" \
1170 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001171
Hanno Becker32c55012017-11-10 08:42:54 +00001172requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001173run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001174 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001175 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001176 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001177 -s "dumping 'expected mac' (20 bytes)" \
1178 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001179
Hanno Becker32c55012017-11-10 08:42:54 +00001180requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001181run_test "Truncated HMAC: client enabled, server default" \
1182 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001183 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001184 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001185 -s "dumping 'expected mac' (20 bytes)" \
1186 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001187
Hanno Becker32c55012017-11-10 08:42:54 +00001188requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001189run_test "Truncated HMAC: client enabled, server disabled" \
1190 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001191 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001192 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001193 -s "dumping 'expected mac' (20 bytes)" \
1194 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001195
Hanno Becker32c55012017-11-10 08:42:54 +00001196requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001197run_test "Truncated HMAC: client disabled, server enabled" \
1198 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001199 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001200 0 \
1201 -s "dumping 'expected mac' (20 bytes)" \
1202 -S "dumping 'expected mac' (10 bytes)"
1203
1204requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001205run_test "Truncated HMAC: client enabled, server enabled" \
1206 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001207 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001208 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001209 -S "dumping 'expected mac' (20 bytes)" \
1210 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001211
Hanno Becker4c4f4102017-11-10 09:16:05 +00001212run_test "Truncated HMAC, DTLS: client default, server default" \
1213 "$P_SRV dtls=1 debug_level=4" \
1214 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1215 0 \
1216 -s "dumping 'expected mac' (20 bytes)" \
1217 -S "dumping 'expected mac' (10 bytes)"
1218
1219requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1220run_test "Truncated HMAC, DTLS: client disabled, server default" \
1221 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001222 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001223 0 \
1224 -s "dumping 'expected mac' (20 bytes)" \
1225 -S "dumping 'expected mac' (10 bytes)"
1226
1227requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1228run_test "Truncated HMAC, DTLS: client enabled, server default" \
1229 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001230 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001231 0 \
1232 -s "dumping 'expected mac' (20 bytes)" \
1233 -S "dumping 'expected mac' (10 bytes)"
1234
1235requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1236run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1237 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001238 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001239 0 \
1240 -s "dumping 'expected mac' (20 bytes)" \
1241 -S "dumping 'expected mac' (10 bytes)"
1242
1243requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1244run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1245 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001246 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001247 0 \
1248 -s "dumping 'expected mac' (20 bytes)" \
1249 -S "dumping 'expected mac' (10 bytes)"
1250
1251requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1252run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1253 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001254 "$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 +01001255 0 \
1256 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001257 -s "dumping 'expected mac' (10 bytes)"
1258
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001259# Tests for Encrypt-then-MAC extension
1260
1261run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001262 "$P_SRV debug_level=3 \
1263 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001264 "$P_CLI debug_level=3" \
1265 0 \
1266 -c "client hello, adding encrypt_then_mac extension" \
1267 -s "found encrypt then mac extension" \
1268 -s "server hello, adding encrypt then mac extension" \
1269 -c "found encrypt_then_mac extension" \
1270 -c "using encrypt then mac" \
1271 -s "using encrypt then mac"
1272
1273run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001274 "$P_SRV debug_level=3 etm=0 \
1275 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001276 "$P_CLI debug_level=3 etm=1" \
1277 0 \
1278 -c "client hello, adding encrypt_then_mac extension" \
1279 -s "found encrypt then mac extension" \
1280 -S "server hello, adding encrypt then mac extension" \
1281 -C "found encrypt_then_mac extension" \
1282 -C "using encrypt then mac" \
1283 -S "using encrypt then mac"
1284
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001285run_test "Encrypt then MAC: client enabled, aead cipher" \
1286 "$P_SRV debug_level=3 etm=1 \
1287 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1288 "$P_CLI debug_level=3 etm=1" \
1289 0 \
1290 -c "client hello, adding encrypt_then_mac extension" \
1291 -s "found encrypt then mac extension" \
1292 -S "server hello, adding encrypt then mac extension" \
1293 -C "found encrypt_then_mac extension" \
1294 -C "using encrypt then mac" \
1295 -S "using encrypt then mac"
1296
1297run_test "Encrypt then MAC: client enabled, stream cipher" \
1298 "$P_SRV debug_level=3 etm=1 \
1299 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001300 "$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 +01001301 0 \
1302 -c "client hello, adding encrypt_then_mac extension" \
1303 -s "found encrypt then mac extension" \
1304 -S "server hello, adding encrypt then mac extension" \
1305 -C "found encrypt_then_mac extension" \
1306 -C "using encrypt then mac" \
1307 -S "using encrypt then mac"
1308
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001309run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001310 "$P_SRV debug_level=3 etm=1 \
1311 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001312 "$P_CLI debug_level=3 etm=0" \
1313 0 \
1314 -C "client hello, adding encrypt_then_mac extension" \
1315 -S "found encrypt then mac extension" \
1316 -S "server hello, adding encrypt then mac extension" \
1317 -C "found encrypt_then_mac extension" \
1318 -C "using encrypt then mac" \
1319 -S "using encrypt then mac"
1320
Janos Follathe2681a42016-03-07 15:57:05 +00001321requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001322run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001323 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001324 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001325 "$P_CLI debug_level=3 force_version=ssl3" \
1326 0 \
1327 -C "client hello, adding encrypt_then_mac extension" \
1328 -S "found encrypt then mac extension" \
1329 -S "server hello, adding encrypt then mac extension" \
1330 -C "found encrypt_then_mac extension" \
1331 -C "using encrypt then mac" \
1332 -S "using encrypt then mac"
1333
Janos Follathe2681a42016-03-07 15:57:05 +00001334requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001335run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001336 "$P_SRV debug_level=3 force_version=ssl3 \
1337 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001338 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001339 0 \
1340 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001341 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001342 -S "server hello, adding encrypt then mac extension" \
1343 -C "found encrypt_then_mac extension" \
1344 -C "using encrypt then mac" \
1345 -S "using encrypt then mac"
1346
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001347# Tests for Extended Master Secret extension
1348
1349run_test "Extended Master Secret: default" \
1350 "$P_SRV debug_level=3" \
1351 "$P_CLI debug_level=3" \
1352 0 \
1353 -c "client hello, adding extended_master_secret extension" \
1354 -s "found extended master secret extension" \
1355 -s "server hello, adding extended master secret extension" \
1356 -c "found extended_master_secret extension" \
1357 -c "using extended master secret" \
1358 -s "using extended master secret"
1359
1360run_test "Extended Master Secret: client enabled, server disabled" \
1361 "$P_SRV debug_level=3 extended_ms=0" \
1362 "$P_CLI debug_level=3 extended_ms=1" \
1363 0 \
1364 -c "client hello, adding extended_master_secret extension" \
1365 -s "found extended master secret extension" \
1366 -S "server hello, adding extended master secret extension" \
1367 -C "found extended_master_secret extension" \
1368 -C "using extended master secret" \
1369 -S "using extended master secret"
1370
1371run_test "Extended Master Secret: client disabled, server enabled" \
1372 "$P_SRV debug_level=3 extended_ms=1" \
1373 "$P_CLI debug_level=3 extended_ms=0" \
1374 0 \
1375 -C "client hello, adding extended_master_secret extension" \
1376 -S "found extended master secret extension" \
1377 -S "server hello, adding extended master secret extension" \
1378 -C "found extended_master_secret extension" \
1379 -C "using extended master secret" \
1380 -S "using extended master secret"
1381
Janos Follathe2681a42016-03-07 15:57:05 +00001382requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001383run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001384 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001385 "$P_CLI debug_level=3 force_version=ssl3" \
1386 0 \
1387 -C "client hello, adding extended_master_secret extension" \
1388 -S "found extended master secret extension" \
1389 -S "server hello, adding extended master secret extension" \
1390 -C "found extended_master_secret extension" \
1391 -C "using extended master secret" \
1392 -S "using extended master secret"
1393
Janos Follathe2681a42016-03-07 15:57:05 +00001394requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001395run_test "Extended Master Secret: client enabled, server SSLv3" \
1396 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001397 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001398 0 \
1399 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001400 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001401 -S "server hello, adding extended master secret extension" \
1402 -C "found extended_master_secret extension" \
1403 -C "using extended master secret" \
1404 -S "using extended master secret"
1405
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001406# Tests for FALLBACK_SCSV
1407
1408run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001409 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001410 "$P_CLI debug_level=3 force_version=tls1_1" \
1411 0 \
1412 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001413 -S "received FALLBACK_SCSV" \
1414 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001415 -C "is a fatal alert message (msg 86)"
1416
1417run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001418 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001419 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1420 0 \
1421 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001422 -S "received FALLBACK_SCSV" \
1423 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001424 -C "is a fatal alert message (msg 86)"
1425
1426run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001427 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001428 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001429 1 \
1430 -c "adding FALLBACK_SCSV" \
1431 -s "received FALLBACK_SCSV" \
1432 -s "inapropriate fallback" \
1433 -c "is a fatal alert message (msg 86)"
1434
1435run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001436 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001437 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001438 0 \
1439 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001440 -s "received FALLBACK_SCSV" \
1441 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001442 -C "is a fatal alert message (msg 86)"
1443
1444requires_openssl_with_fallback_scsv
1445run_test "Fallback SCSV: default, openssl server" \
1446 "$O_SRV" \
1447 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1448 0 \
1449 -C "adding FALLBACK_SCSV" \
1450 -C "is a fatal alert message (msg 86)"
1451
1452requires_openssl_with_fallback_scsv
1453run_test "Fallback SCSV: enabled, openssl server" \
1454 "$O_SRV" \
1455 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1456 1 \
1457 -c "adding FALLBACK_SCSV" \
1458 -c "is a fatal alert message (msg 86)"
1459
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001460requires_openssl_with_fallback_scsv
1461run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001462 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001463 "$O_CLI -tls1_1" \
1464 0 \
1465 -S "received FALLBACK_SCSV" \
1466 -S "inapropriate fallback"
1467
1468requires_openssl_with_fallback_scsv
1469run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001470 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001471 "$O_CLI -tls1_1 -fallback_scsv" \
1472 1 \
1473 -s "received FALLBACK_SCSV" \
1474 -s "inapropriate fallback"
1475
1476requires_openssl_with_fallback_scsv
1477run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001478 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001479 "$O_CLI -fallback_scsv" \
1480 0 \
1481 -s "received FALLBACK_SCSV" \
1482 -S "inapropriate fallback"
1483
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001484# Test sending and receiving empty application data records
1485
1486run_test "Encrypt then MAC: empty application data record" \
1487 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1488 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1489 0 \
1490 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1491 -s "dumping 'input payload after decrypt' (0 bytes)" \
1492 -c "0 bytes written in 1 fragments"
1493
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001494run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001495 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1496 "$P_CLI auth_mode=none etm=0 request_size=0" \
1497 0 \
1498 -s "dumping 'input payload after decrypt' (0 bytes)" \
1499 -c "0 bytes written in 1 fragments"
1500
1501run_test "Encrypt then MAC, DTLS: empty application data record" \
1502 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1503 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1504 0 \
1505 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1506 -s "dumping 'input payload after decrypt' (0 bytes)" \
1507 -c "0 bytes written in 1 fragments"
1508
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001509run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001510 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1511 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1512 0 \
1513 -s "dumping 'input payload after decrypt' (0 bytes)" \
1514 -c "0 bytes written in 1 fragments"
1515
Gilles Peskined50177f2017-05-16 17:53:03 +02001516## ClientHello generated with
1517## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1518## then manually twiddling the ciphersuite list.
1519## The ClientHello content is spelled out below as a hex string as
1520## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1521## The expected response is an inappropriate_fallback alert.
1522requires_openssl_with_fallback_scsv
1523run_test "Fallback SCSV: beginning of list" \
1524 "$P_SRV debug_level=2" \
1525 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1526 0 \
1527 -s "received FALLBACK_SCSV" \
1528 -s "inapropriate fallback"
1529
1530requires_openssl_with_fallback_scsv
1531run_test "Fallback SCSV: end of list" \
1532 "$P_SRV debug_level=2" \
1533 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1534 0 \
1535 -s "received FALLBACK_SCSV" \
1536 -s "inapropriate fallback"
1537
1538## Here the expected response is a valid ServerHello prefix, up to the random.
1539requires_openssl_with_fallback_scsv
1540run_test "Fallback SCSV: not in list" \
1541 "$P_SRV debug_level=2" \
1542 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1543 0 \
1544 -S "received FALLBACK_SCSV" \
1545 -S "inapropriate fallback"
1546
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001547# Tests for CBC 1/n-1 record splitting
1548
1549run_test "CBC Record splitting: TLS 1.2, no splitting" \
1550 "$P_SRV" \
1551 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1552 request_size=123 force_version=tls1_2" \
1553 0 \
1554 -s "Read from client: 123 bytes read" \
1555 -S "Read from client: 1 bytes read" \
1556 -S "122 bytes read"
1557
1558run_test "CBC Record splitting: TLS 1.1, no splitting" \
1559 "$P_SRV" \
1560 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1561 request_size=123 force_version=tls1_1" \
1562 0 \
1563 -s "Read from client: 123 bytes read" \
1564 -S "Read from client: 1 bytes read" \
1565 -S "122 bytes read"
1566
1567run_test "CBC Record splitting: TLS 1.0, splitting" \
1568 "$P_SRV" \
1569 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1570 request_size=123 force_version=tls1" \
1571 0 \
1572 -S "Read from client: 123 bytes read" \
1573 -s "Read from client: 1 bytes read" \
1574 -s "122 bytes read"
1575
Janos Follathe2681a42016-03-07 15:57:05 +00001576requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001577run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001578 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001579 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1580 request_size=123 force_version=ssl3" \
1581 0 \
1582 -S "Read from client: 123 bytes read" \
1583 -s "Read from client: 1 bytes read" \
1584 -s "122 bytes read"
1585
1586run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001587 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001588 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1589 request_size=123 force_version=tls1" \
1590 0 \
1591 -s "Read from client: 123 bytes read" \
1592 -S "Read from client: 1 bytes read" \
1593 -S "122 bytes read"
1594
1595run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1596 "$P_SRV" \
1597 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1598 request_size=123 force_version=tls1 recsplit=0" \
1599 0 \
1600 -s "Read from client: 123 bytes read" \
1601 -S "Read from client: 1 bytes read" \
1602 -S "122 bytes read"
1603
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001604run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1605 "$P_SRV nbio=2" \
1606 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1607 request_size=123 force_version=tls1" \
1608 0 \
1609 -S "Read from client: 123 bytes read" \
1610 -s "Read from client: 1 bytes read" \
1611 -s "122 bytes read"
1612
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001613# Tests for Session Tickets
1614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001615run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001616 "$P_SRV debug_level=3 tickets=1" \
1617 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001618 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001619 -c "client hello, adding session ticket extension" \
1620 -s "found session ticket extension" \
1621 -s "server hello, adding session ticket extension" \
1622 -c "found session_ticket extension" \
1623 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001624 -S "session successfully restored from cache" \
1625 -s "session successfully restored from ticket" \
1626 -s "a session has been resumed" \
1627 -c "a session has been resumed"
1628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001629run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001630 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1631 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001632 0 \
1633 -c "client hello, adding session ticket extension" \
1634 -s "found session ticket extension" \
1635 -s "server hello, adding session ticket extension" \
1636 -c "found session_ticket extension" \
1637 -c "parse new session ticket" \
1638 -S "session successfully restored from cache" \
1639 -s "session successfully restored from ticket" \
1640 -s "a session has been resumed" \
1641 -c "a session has been resumed"
1642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001643run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001644 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1645 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001646 0 \
1647 -c "client hello, adding session ticket extension" \
1648 -s "found session ticket extension" \
1649 -s "server hello, adding session ticket extension" \
1650 -c "found session_ticket extension" \
1651 -c "parse new session ticket" \
1652 -S "session successfully restored from cache" \
1653 -S "session successfully restored from ticket" \
1654 -S "a session has been resumed" \
1655 -C "a session has been resumed"
1656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001657run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001658 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001659 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001660 0 \
1661 -c "client hello, adding session ticket extension" \
1662 -c "found session_ticket extension" \
1663 -c "parse new session ticket" \
1664 -c "a session has been resumed"
1665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001666run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001667 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001668 "( $O_CLI -sess_out $SESSION; \
1669 $O_CLI -sess_in $SESSION; \
1670 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001671 0 \
1672 -s "found session ticket extension" \
1673 -s "server hello, adding session ticket extension" \
1674 -S "session successfully restored from cache" \
1675 -s "session successfully restored from ticket" \
1676 -s "a session has been resumed"
1677
Hanno Becker1d739932018-08-21 13:55:22 +01001678# Tests for Session Tickets with DTLS
1679
1680run_test "Session resume using tickets, DTLS: basic" \
1681 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001682 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001683 0 \
1684 -c "client hello, adding session ticket extension" \
1685 -s "found session ticket extension" \
1686 -s "server hello, adding session ticket extension" \
1687 -c "found session_ticket extension" \
1688 -c "parse new session ticket" \
1689 -S "session successfully restored from cache" \
1690 -s "session successfully restored from ticket" \
1691 -s "a session has been resumed" \
1692 -c "a session has been resumed"
1693
1694run_test "Session resume using tickets, DTLS: cache disabled" \
1695 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001696 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001697 0 \
1698 -c "client hello, adding session ticket extension" \
1699 -s "found session ticket extension" \
1700 -s "server hello, adding session ticket extension" \
1701 -c "found session_ticket extension" \
1702 -c "parse new session ticket" \
1703 -S "session successfully restored from cache" \
1704 -s "session successfully restored from ticket" \
1705 -s "a session has been resumed" \
1706 -c "a session has been resumed"
1707
1708run_test "Session resume using tickets, DTLS: timeout" \
1709 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001710 "$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 +01001711 0 \
1712 -c "client hello, adding session ticket extension" \
1713 -s "found session ticket extension" \
1714 -s "server hello, adding session ticket extension" \
1715 -c "found session_ticket extension" \
1716 -c "parse new session ticket" \
1717 -S "session successfully restored from cache" \
1718 -S "session successfully restored from ticket" \
1719 -S "a session has been resumed" \
1720 -C "a session has been resumed"
1721
1722run_test "Session resume using tickets, DTLS: openssl server" \
1723 "$O_SRV -dtls1" \
1724 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1725 0 \
1726 -c "client hello, adding session ticket extension" \
1727 -c "found session_ticket extension" \
1728 -c "parse new session ticket" \
1729 -c "a session has been resumed"
1730
1731run_test "Session resume using tickets, DTLS: openssl client" \
1732 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1733 "( $O_CLI -dtls1 -sess_out $SESSION; \
1734 $O_CLI -dtls1 -sess_in $SESSION; \
1735 rm -f $SESSION )" \
1736 0 \
1737 -s "found session ticket extension" \
1738 -s "server hello, adding session ticket extension" \
1739 -S "session successfully restored from cache" \
1740 -s "session successfully restored from ticket" \
1741 -s "a session has been resumed"
1742
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001743# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001745run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001746 "$P_SRV debug_level=3 tickets=0" \
1747 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001748 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001749 -c "client hello, adding session ticket extension" \
1750 -s "found session ticket extension" \
1751 -S "server hello, adding session ticket extension" \
1752 -C "found session_ticket extension" \
1753 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001754 -s "session successfully restored from cache" \
1755 -S "session successfully restored from ticket" \
1756 -s "a session has been resumed" \
1757 -c "a session has been resumed"
1758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001759run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001760 "$P_SRV debug_level=3 tickets=1" \
1761 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001762 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001763 -C "client hello, adding session ticket extension" \
1764 -S "found session ticket extension" \
1765 -S "server hello, adding session ticket extension" \
1766 -C "found session_ticket extension" \
1767 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001768 -s "session successfully restored from cache" \
1769 -S "session successfully restored from ticket" \
1770 -s "a session has been resumed" \
1771 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001773run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001774 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1775 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001776 0 \
1777 -S "session successfully restored from cache" \
1778 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001779 -S "a session has been resumed" \
1780 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001781
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001782run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001783 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1784 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001785 0 \
1786 -s "session successfully restored from cache" \
1787 -S "session successfully restored from ticket" \
1788 -s "a session has been resumed" \
1789 -c "a session has been resumed"
1790
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001791run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001792 "$P_SRV debug_level=3 tickets=0" \
1793 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001794 0 \
1795 -s "session successfully restored from cache" \
1796 -S "session successfully restored from ticket" \
1797 -s "a session has been resumed" \
1798 -c "a session has been resumed"
1799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001800run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001801 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1802 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001803 0 \
1804 -S "session successfully restored from cache" \
1805 -S "session successfully restored from ticket" \
1806 -S "a session has been resumed" \
1807 -C "a session has been resumed"
1808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001809run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001810 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1811 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001812 0 \
1813 -s "session successfully restored from cache" \
1814 -S "session successfully restored from ticket" \
1815 -s "a session has been resumed" \
1816 -c "a session has been resumed"
1817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001818run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001819 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001820 "( $O_CLI -sess_out $SESSION; \
1821 $O_CLI -sess_in $SESSION; \
1822 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001823 0 \
1824 -s "found session ticket extension" \
1825 -S "server hello, adding session ticket extension" \
1826 -s "session successfully restored from cache" \
1827 -S "session successfully restored from ticket" \
1828 -s "a session has been resumed"
1829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001830run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001831 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001832 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001833 0 \
1834 -C "found session_ticket extension" \
1835 -C "parse new session ticket" \
1836 -c "a session has been resumed"
1837
Hanno Becker1d739932018-08-21 13:55:22 +01001838# Tests for Session Resume based on session-ID and cache, DTLS
1839
1840run_test "Session resume using cache, DTLS: tickets enabled on client" \
1841 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001842 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001843 0 \
1844 -c "client hello, adding session ticket extension" \
1845 -s "found session ticket extension" \
1846 -S "server hello, adding session ticket extension" \
1847 -C "found session_ticket extension" \
1848 -C "parse new session ticket" \
1849 -s "session successfully restored from cache" \
1850 -S "session successfully restored from ticket" \
1851 -s "a session has been resumed" \
1852 -c "a session has been resumed"
1853
1854run_test "Session resume using cache, DTLS: tickets enabled on server" \
1855 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001856 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001857 0 \
1858 -C "client hello, adding session ticket extension" \
1859 -S "found session ticket extension" \
1860 -S "server hello, adding session ticket extension" \
1861 -C "found session_ticket extension" \
1862 -C "parse new session ticket" \
1863 -s "session successfully restored from cache" \
1864 -S "session successfully restored from ticket" \
1865 -s "a session has been resumed" \
1866 -c "a session has been resumed"
1867
1868run_test "Session resume using cache, DTLS: cache_max=0" \
1869 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001870 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001871 0 \
1872 -S "session successfully restored from cache" \
1873 -S "session successfully restored from ticket" \
1874 -S "a session has been resumed" \
1875 -C "a session has been resumed"
1876
1877run_test "Session resume using cache, DTLS: cache_max=1" \
1878 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001879 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001880 0 \
1881 -s "session successfully restored from cache" \
1882 -S "session successfully restored from ticket" \
1883 -s "a session has been resumed" \
1884 -c "a session has been resumed"
1885
1886run_test "Session resume using cache, DTLS: timeout > delay" \
1887 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001888 "$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 +01001889 0 \
1890 -s "session successfully restored from cache" \
1891 -S "session successfully restored from ticket" \
1892 -s "a session has been resumed" \
1893 -c "a session has been resumed"
1894
1895run_test "Session resume using cache, DTLS: timeout < delay" \
1896 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001897 "$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 +01001898 0 \
1899 -S "session successfully restored from cache" \
1900 -S "session successfully restored from ticket" \
1901 -S "a session has been resumed" \
1902 -C "a session has been resumed"
1903
1904run_test "Session resume using cache, DTLS: no timeout" \
1905 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001906 "$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 +01001907 0 \
1908 -s "session successfully restored from cache" \
1909 -S "session successfully restored from ticket" \
1910 -s "a session has been resumed" \
1911 -c "a session has been resumed"
1912
1913run_test "Session resume using cache, DTLS: openssl client" \
1914 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1915 "( $O_CLI -dtls1 -sess_out $SESSION; \
1916 $O_CLI -dtls1 -sess_in $SESSION; \
1917 rm -f $SESSION )" \
1918 0 \
1919 -s "found session ticket extension" \
1920 -S "server hello, adding session ticket extension" \
1921 -s "session successfully restored from cache" \
1922 -S "session successfully restored from ticket" \
1923 -s "a session has been resumed"
1924
1925run_test "Session resume using cache, DTLS: openssl server" \
1926 "$O_SRV -dtls1" \
1927 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1928 0 \
1929 -C "found session_ticket extension" \
1930 -C "parse new session ticket" \
1931 -c "a session has been resumed"
1932
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001933# Tests for Max Fragment Length extension
1934
Angus Grattonc4dd0732018-04-11 16:28:39 +10001935if [ $MAX_CONTENT_LEN -ne 16384 ]; then
Yuto Takano2e580ce2021-06-21 19:43:33 +01001936 echo "Using non-default maximum content length $MAX_CONTENT_LEN instead of 16384 "
Angus Grattonc4dd0732018-04-11 16:28:39 +10001937fi
1938
Hanno Becker4aed27e2017-09-18 15:00:34 +01001939requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001940run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001941 "$P_SRV debug_level=3" \
1942 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001943 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001944 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1945 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001946 -C "client hello, adding max_fragment_length extension" \
1947 -S "found max fragment length extension" \
1948 -S "server hello, max_fragment_length extension" \
1949 -C "found max_fragment_length extension"
1950
Hanno Becker4aed27e2017-09-18 15:00:34 +01001951requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001952run_test "Max fragment length: enabled, default, larger message" \
1953 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001954 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001955 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001956 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1957 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001958 -C "client hello, adding max_fragment_length extension" \
1959 -S "found max fragment length extension" \
1960 -S "server hello, max_fragment_length extension" \
1961 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001962 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1963 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001964 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001965
1966requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1967run_test "Max fragment length, DTLS: enabled, default, larger message" \
1968 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001969 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001970 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001971 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1972 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001973 -C "client hello, adding max_fragment_length extension" \
1974 -S "found max fragment length extension" \
1975 -S "server hello, max_fragment_length extension" \
1976 -C "found max_fragment_length extension" \
1977 -c "fragment larger than.*maximum "
1978
Angus Grattonc4dd0732018-04-11 16:28:39 +10001979# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1980# (session fragment length will be 16384 regardless of mbedtls
1981# content length configuration.)
1982
Hanno Beckerc5266962017-09-18 15:01:50 +01001983requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1984run_test "Max fragment length: disabled, larger message" \
1985 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001986 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001987 0 \
1988 -C "Maximum fragment length is 16384" \
1989 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001990 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1991 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001992 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001993
1994requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takano2e580ce2021-06-21 19:43:33 +01001995run_test "Max fragment length, DTLS: disabled, larger message" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001996 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001997 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001998 1 \
1999 -C "Maximum fragment length is 16384" \
2000 -S "Maximum fragment length is 16384" \
2001 -c "fragment larger than.*maximum "
2002
Yuto Takano2e580ce2021-06-21 19:43:33 +01002003# Make sure it was compiled with lengths over 4096
2004requires_config_value_at_least "MBEDTLS_SSL_IN_CONTENT_LEN" 4096
2005requires_config_value_at_least "MBEDTLS_SSL_OUT_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 Takano2e580ce2021-06-21 19:43:33 +01002018requires_config_value_at_least "MBEDTLS_SSL_IN_CONTENT_LEN" 4096
2019requires_config_value_at_least "MBEDTLS_SSL_OUT_CONTENT_LEN" 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002020requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002021run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002022 "$P_SRV debug_level=3 max_frag_len=4096" \
2023 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002024 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002025 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002026 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002027 -C "client hello, adding max_fragment_length extension" \
2028 -S "found max fragment length extension" \
2029 -S "server hello, max_fragment_length extension" \
2030 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002031
Yuto Takano2e580ce2021-06-21 19:43:33 +01002032requires_config_value_at_least "MBEDTLS_SSL_IN_CONTENT_LEN" 4096
2033requires_config_value_at_least "MBEDTLS_SSL_OUT_CONTENT_LEN" 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002034requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002035requires_gnutls
2036run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002037 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002038 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002039 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002040 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002041 -c "client hello, adding max_fragment_length extension" \
2042 -c "found max_fragment_length extension"
2043
Yuto Takano2e580ce2021-06-21 19:43:33 +01002044requires_config_value_at_least "MBEDTLS_SSL_IN_CONTENT_LEN" 2048
2045requires_config_value_at_least "MBEDTLS_SSL_OUT_CONTENT_LEN" 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002046requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002047run_test "Max fragment length: client, message just fits" \
2048 "$P_SRV debug_level=3" \
2049 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
2050 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002051 -c "Maximum fragment length is 2048" \
2052 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002053 -c "client hello, adding max_fragment_length extension" \
2054 -s "found max fragment length extension" \
2055 -s "server hello, max_fragment_length extension" \
2056 -c "found max_fragment_length extension" \
2057 -c "2048 bytes written in 1 fragments" \
2058 -s "2048 bytes read"
2059
Yuto Takano2e580ce2021-06-21 19:43:33 +01002060requires_config_value_at_least "MBEDTLS_SSL_IN_CONTENT_LEN" 2048
2061requires_config_value_at_least "MBEDTLS_SSL_OUT_CONTENT_LEN" 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002062requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002063run_test "Max fragment length: client, larger message" \
2064 "$P_SRV debug_level=3" \
2065 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2066 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002067 -c "Maximum fragment length is 2048" \
2068 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002069 -c "client hello, adding max_fragment_length extension" \
2070 -s "found max fragment length extension" \
2071 -s "server hello, max_fragment_length extension" \
2072 -c "found max_fragment_length extension" \
2073 -c "2345 bytes written in 2 fragments" \
2074 -s "2048 bytes read" \
2075 -s "297 bytes read"
2076
Yuto Takano2e580ce2021-06-21 19:43:33 +01002077requires_config_value_at_least "MBEDTLS_SSL_IN_CONTENT_LEN" 2048
2078requires_config_value_at_least "MBEDTLS_SSL_OUT_CONTENT_LEN" 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002079requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002080run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002081 "$P_SRV debug_level=3 dtls=1" \
2082 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2083 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002084 -c "Maximum fragment length is 2048" \
2085 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002086 -c "client hello, adding max_fragment_length extension" \
2087 -s "found max fragment length extension" \
2088 -s "server hello, max_fragment_length extension" \
2089 -c "found max_fragment_length extension" \
2090 -c "fragment larger than.*maximum"
2091
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002092# Tests for renegotiation
2093
Hanno Becker6a243642017-10-12 15:18:45 +01002094# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002095run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002096 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002097 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002098 0 \
2099 -C "client hello, adding renegotiation extension" \
2100 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2101 -S "found renegotiation extension" \
2102 -s "server hello, secure renegotiation extension" \
2103 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002104 -C "=> renegotiate" \
2105 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002106 -S "write hello request"
2107
Hanno Becker6a243642017-10-12 15:18:45 +01002108requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002109run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002110 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002111 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002112 0 \
2113 -c "client hello, adding renegotiation extension" \
2114 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2115 -s "found renegotiation extension" \
2116 -s "server hello, secure renegotiation extension" \
2117 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002118 -c "=> renegotiate" \
2119 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002120 -S "write hello request"
2121
Hanno Becker6a243642017-10-12 15:18:45 +01002122requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002123run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002124 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002125 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002126 0 \
2127 -c "client hello, adding renegotiation extension" \
2128 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2129 -s "found renegotiation extension" \
2130 -s "server hello, secure renegotiation extension" \
2131 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002132 -c "=> renegotiate" \
2133 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002134 -s "write hello request"
2135
Janos Follathb0f148c2017-10-05 12:29:42 +01002136# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2137# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2138# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002139requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002140run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2141 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2142 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2143 0 \
2144 -c "client hello, adding renegotiation extension" \
2145 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2146 -s "found renegotiation extension" \
2147 -s "server hello, secure renegotiation extension" \
2148 -c "found renegotiation extension" \
2149 -c "=> renegotiate" \
2150 -s "=> renegotiate" \
2151 -S "write hello request" \
2152 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2153
2154# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2155# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2156# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002157requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002158run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2159 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2160 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2161 0 \
2162 -c "client hello, adding renegotiation extension" \
2163 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2164 -s "found renegotiation extension" \
2165 -s "server hello, secure renegotiation extension" \
2166 -c "found renegotiation extension" \
2167 -c "=> renegotiate" \
2168 -s "=> renegotiate" \
2169 -s "write hello request" \
2170 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2171
Hanno Becker6a243642017-10-12 15:18:45 +01002172requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002173run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002174 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002175 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002176 0 \
2177 -c "client hello, adding renegotiation extension" \
2178 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2179 -s "found renegotiation extension" \
2180 -s "server hello, secure renegotiation extension" \
2181 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002182 -c "=> renegotiate" \
2183 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002184 -s "write hello request"
2185
Hanno Becker6a243642017-10-12 15:18:45 +01002186requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002187run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002188 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002189 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002190 1 \
2191 -c "client hello, adding renegotiation extension" \
2192 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2193 -S "found renegotiation extension" \
2194 -s "server hello, secure renegotiation extension" \
2195 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002196 -c "=> renegotiate" \
2197 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002198 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002199 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002200 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002201
Hanno Becker6a243642017-10-12 15:18:45 +01002202requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002203run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002204 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002205 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002206 0 \
2207 -C "client hello, adding renegotiation extension" \
2208 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2209 -S "found renegotiation extension" \
2210 -s "server hello, secure renegotiation extension" \
2211 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002212 -C "=> renegotiate" \
2213 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002214 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002215 -S "SSL - An unexpected message was received from our peer" \
2216 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002217
Hanno Becker6a243642017-10-12 15:18:45 +01002218requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002219run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002220 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002221 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002222 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002223 0 \
2224 -C "client hello, adding renegotiation extension" \
2225 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2226 -S "found renegotiation extension" \
2227 -s "server hello, secure renegotiation extension" \
2228 -c "found renegotiation extension" \
2229 -C "=> renegotiate" \
2230 -S "=> renegotiate" \
2231 -s "write hello request" \
2232 -S "SSL - An unexpected message was received from our peer" \
2233 -S "failed"
2234
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002235# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002236requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002237run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002238 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002239 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002240 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002241 0 \
2242 -C "client hello, adding renegotiation extension" \
2243 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2244 -S "found renegotiation extension" \
2245 -s "server hello, secure renegotiation extension" \
2246 -c "found renegotiation extension" \
2247 -C "=> renegotiate" \
2248 -S "=> renegotiate" \
2249 -s "write hello request" \
2250 -S "SSL - An unexpected message was received from our peer" \
2251 -S "failed"
2252
Hanno Becker6a243642017-10-12 15:18:45 +01002253requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002254run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002255 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002256 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002257 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002258 0 \
2259 -C "client hello, adding renegotiation extension" \
2260 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2261 -S "found renegotiation extension" \
2262 -s "server hello, secure renegotiation extension" \
2263 -c "found renegotiation extension" \
2264 -C "=> renegotiate" \
2265 -S "=> renegotiate" \
2266 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002267 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002268
Hanno Becker6a243642017-10-12 15:18:45 +01002269requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002270run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002271 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002272 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002273 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002274 0 \
2275 -c "client hello, adding renegotiation extension" \
2276 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2277 -s "found renegotiation extension" \
2278 -s "server hello, secure renegotiation extension" \
2279 -c "found renegotiation extension" \
2280 -c "=> renegotiate" \
2281 -s "=> renegotiate" \
2282 -s "write hello request" \
2283 -S "SSL - An unexpected message was received from our peer" \
2284 -S "failed"
2285
Hanno Becker6a243642017-10-12 15:18:45 +01002286requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002287run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002288 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002289 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2290 0 \
2291 -C "client hello, adding renegotiation extension" \
2292 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2293 -S "found renegotiation extension" \
2294 -s "server hello, secure renegotiation extension" \
2295 -c "found renegotiation extension" \
2296 -S "record counter limit reached: renegotiate" \
2297 -C "=> renegotiate" \
2298 -S "=> renegotiate" \
2299 -S "write hello request" \
2300 -S "SSL - An unexpected message was received from our peer" \
2301 -S "failed"
2302
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002303# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002304requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002305run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002306 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002307 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002308 0 \
2309 -c "client hello, adding renegotiation extension" \
2310 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2311 -s "found renegotiation extension" \
2312 -s "server hello, secure renegotiation extension" \
2313 -c "found renegotiation extension" \
2314 -s "record counter limit reached: renegotiate" \
2315 -c "=> renegotiate" \
2316 -s "=> renegotiate" \
2317 -s "write hello request" \
2318 -S "SSL - An unexpected message was received from our peer" \
2319 -S "failed"
2320
Hanno Becker6a243642017-10-12 15:18:45 +01002321requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002322run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002323 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002324 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002325 0 \
2326 -c "client hello, adding renegotiation extension" \
2327 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2328 -s "found renegotiation extension" \
2329 -s "server hello, secure renegotiation extension" \
2330 -c "found renegotiation extension" \
2331 -s "record counter limit reached: renegotiate" \
2332 -c "=> renegotiate" \
2333 -s "=> renegotiate" \
2334 -s "write hello request" \
2335 -S "SSL - An unexpected message was received from our peer" \
2336 -S "failed"
2337
Hanno Becker6a243642017-10-12 15:18:45 +01002338requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002339run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002340 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002341 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2342 0 \
2343 -C "client hello, adding renegotiation extension" \
2344 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2345 -S "found renegotiation extension" \
2346 -s "server hello, secure renegotiation extension" \
2347 -c "found renegotiation extension" \
2348 -S "record counter limit reached: renegotiate" \
2349 -C "=> renegotiate" \
2350 -S "=> renegotiate" \
2351 -S "write hello request" \
2352 -S "SSL - An unexpected message was received from our peer" \
2353 -S "failed"
2354
Hanno Becker6a243642017-10-12 15:18:45 +01002355requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002356run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002357 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002358 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002359 0 \
2360 -c "client hello, adding renegotiation extension" \
2361 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2362 -s "found renegotiation extension" \
2363 -s "server hello, secure renegotiation extension" \
2364 -c "found renegotiation extension" \
2365 -c "=> renegotiate" \
2366 -s "=> renegotiate" \
2367 -S "write hello request"
2368
Hanno Becker6a243642017-10-12 15:18:45 +01002369requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002370run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002371 "$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 +02002372 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002373 0 \
2374 -c "client hello, adding renegotiation extension" \
2375 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2376 -s "found renegotiation extension" \
2377 -s "server hello, secure renegotiation extension" \
2378 -c "found renegotiation extension" \
2379 -c "=> renegotiate" \
2380 -s "=> renegotiate" \
2381 -s "write hello request"
2382
Hanno Becker6a243642017-10-12 15:18:45 +01002383requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002384run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002385 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002386 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002387 0 \
2388 -c "client hello, adding renegotiation extension" \
2389 -c "found renegotiation extension" \
2390 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002391 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002392 -C "error" \
2393 -c "HTTP/1.0 200 [Oo][Kk]"
2394
Paul Bakker539d9722015-02-08 16:18:35 +01002395requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002396requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002397run_test "Renegotiation: gnutls server strict, client-initiated" \
2398 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002399 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002400 0 \
2401 -c "client hello, adding renegotiation extension" \
2402 -c "found renegotiation extension" \
2403 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002404 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002405 -C "error" \
2406 -c "HTTP/1.0 200 [Oo][Kk]"
2407
Paul Bakker539d9722015-02-08 16:18:35 +01002408requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002409requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002410run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2411 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2412 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2413 1 \
2414 -c "client hello, adding renegotiation extension" \
2415 -C "found renegotiation extension" \
2416 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002417 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002418 -c "error" \
2419 -C "HTTP/1.0 200 [Oo][Kk]"
2420
Paul Bakker539d9722015-02-08 16:18:35 +01002421requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002422requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002423run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2424 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2425 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2426 allow_legacy=0" \
2427 1 \
2428 -c "client hello, adding renegotiation extension" \
2429 -C "found renegotiation extension" \
2430 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002431 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002432 -c "error" \
2433 -C "HTTP/1.0 200 [Oo][Kk]"
2434
Paul Bakker539d9722015-02-08 16:18:35 +01002435requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002436requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002437run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2438 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2439 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2440 allow_legacy=1" \
2441 0 \
2442 -c "client hello, adding renegotiation extension" \
2443 -C "found renegotiation extension" \
2444 -c "=> renegotiate" \
2445 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002446 -C "error" \
2447 -c "HTTP/1.0 200 [Oo][Kk]"
2448
Hanno Becker6a243642017-10-12 15:18:45 +01002449requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002450run_test "Renegotiation: DTLS, client-initiated" \
2451 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2452 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2453 0 \
2454 -c "client hello, adding renegotiation extension" \
2455 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2456 -s "found renegotiation extension" \
2457 -s "server hello, secure renegotiation extension" \
2458 -c "found renegotiation extension" \
2459 -c "=> renegotiate" \
2460 -s "=> renegotiate" \
2461 -S "write hello request"
2462
Hanno Becker6a243642017-10-12 15:18:45 +01002463requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002464run_test "Renegotiation: DTLS, server-initiated" \
2465 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002466 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2467 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002468 0 \
2469 -c "client hello, adding renegotiation extension" \
2470 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2471 -s "found renegotiation extension" \
2472 -s "server hello, secure renegotiation extension" \
2473 -c "found renegotiation extension" \
2474 -c "=> renegotiate" \
2475 -s "=> renegotiate" \
2476 -s "write hello request"
2477
Hanno Becker6a243642017-10-12 15:18:45 +01002478requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002479run_test "Renegotiation: DTLS, renego_period overflow" \
2480 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2481 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2482 0 \
2483 -c "client hello, adding renegotiation extension" \
2484 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2485 -s "found renegotiation extension" \
2486 -s "server hello, secure renegotiation extension" \
2487 -s "record counter limit reached: renegotiate" \
2488 -c "=> renegotiate" \
2489 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002490 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002491
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002492requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002493requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002494run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2495 "$G_SRV -u --mtu 4096" \
2496 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2497 0 \
2498 -c "client hello, adding renegotiation extension" \
2499 -c "found renegotiation extension" \
2500 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002501 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002502 -C "error" \
2503 -s "Extra-header:"
2504
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002505# Test for the "secure renegotation" extension only (no actual renegotiation)
2506
Paul Bakker539d9722015-02-08 16:18:35 +01002507requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002508run_test "Renego ext: gnutls server strict, client default" \
2509 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2510 "$P_CLI debug_level=3" \
2511 0 \
2512 -c "found renegotiation extension" \
2513 -C "error" \
2514 -c "HTTP/1.0 200 [Oo][Kk]"
2515
Paul Bakker539d9722015-02-08 16:18:35 +01002516requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002517run_test "Renego ext: gnutls server unsafe, client default" \
2518 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2519 "$P_CLI debug_level=3" \
2520 0 \
2521 -C "found renegotiation extension" \
2522 -C "error" \
2523 -c "HTTP/1.0 200 [Oo][Kk]"
2524
Paul Bakker539d9722015-02-08 16:18:35 +01002525requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002526run_test "Renego ext: gnutls server unsafe, client break legacy" \
2527 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2528 "$P_CLI debug_level=3 allow_legacy=-1" \
2529 1 \
2530 -C "found renegotiation extension" \
2531 -c "error" \
2532 -C "HTTP/1.0 200 [Oo][Kk]"
2533
Paul Bakker539d9722015-02-08 16:18:35 +01002534requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002535run_test "Renego ext: gnutls client strict, server default" \
2536 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002537 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002538 0 \
2539 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2540 -s "server hello, secure renegotiation extension"
2541
Paul Bakker539d9722015-02-08 16:18:35 +01002542requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002543run_test "Renego ext: gnutls client unsafe, server default" \
2544 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002545 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002546 0 \
2547 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2548 -S "server hello, secure renegotiation extension"
2549
Paul Bakker539d9722015-02-08 16:18:35 +01002550requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002551run_test "Renego ext: gnutls client unsafe, server break legacy" \
2552 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002553 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002554 1 \
2555 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2556 -S "server hello, secure renegotiation extension"
2557
Janos Follath0b242342016-02-17 10:11:21 +00002558# Tests for silently dropping trailing extra bytes in .der certificates
2559
2560requires_gnutls
2561run_test "DER format: no trailing bytes" \
2562 "$P_SRV crt_file=data_files/server5-der0.crt \
2563 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002564 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002565 0 \
2566 -c "Handshake was completed" \
2567
2568requires_gnutls
2569run_test "DER format: with a trailing zero byte" \
2570 "$P_SRV crt_file=data_files/server5-der1a.crt \
2571 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002572 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002573 0 \
2574 -c "Handshake was completed" \
2575
2576requires_gnutls
2577run_test "DER format: with a trailing random byte" \
2578 "$P_SRV crt_file=data_files/server5-der1b.crt \
2579 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002580 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002581 0 \
2582 -c "Handshake was completed" \
2583
2584requires_gnutls
2585run_test "DER format: with 2 trailing random bytes" \
2586 "$P_SRV crt_file=data_files/server5-der2.crt \
2587 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002588 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002589 0 \
2590 -c "Handshake was completed" \
2591
2592requires_gnutls
2593run_test "DER format: with 4 trailing random bytes" \
2594 "$P_SRV crt_file=data_files/server5-der4.crt \
2595 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002596 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002597 0 \
2598 -c "Handshake was completed" \
2599
2600requires_gnutls
2601run_test "DER format: with 8 trailing random bytes" \
2602 "$P_SRV crt_file=data_files/server5-der8.crt \
2603 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002604 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002605 0 \
2606 -c "Handshake was completed" \
2607
2608requires_gnutls
2609run_test "DER format: with 9 trailing random bytes" \
2610 "$P_SRV crt_file=data_files/server5-der9.crt \
2611 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002612 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002613 0 \
2614 -c "Handshake was completed" \
2615
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002616# Tests for auth_mode
2617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002618run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002619 "$P_SRV crt_file=data_files/server5-badsign.crt \
2620 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002621 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002622 1 \
2623 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002624 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002625 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002626 -c "X509 - Certificate verification failed"
2627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002628run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002629 "$P_SRV crt_file=data_files/server5-badsign.crt \
2630 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002631 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002632 0 \
2633 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002634 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002635 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002636 -C "X509 - Certificate verification failed"
2637
Hanno Beckere6706e62017-05-15 16:05:15 +01002638run_test "Authentication: server goodcert, client optional, no trusted CA" \
2639 "$P_SRV" \
2640 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2641 0 \
2642 -c "x509_verify_cert() returned" \
2643 -c "! The certificate is not correctly signed by the trusted CA" \
2644 -c "! Certificate verification flags"\
2645 -C "! mbedtls_ssl_handshake returned" \
2646 -C "X509 - Certificate verification failed" \
2647 -C "SSL - No CA Chain is set, but required to operate"
2648
2649run_test "Authentication: server goodcert, client required, no trusted CA" \
2650 "$P_SRV" \
2651 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2652 1 \
2653 -c "x509_verify_cert() returned" \
2654 -c "! The certificate is not correctly signed by the trusted CA" \
2655 -c "! Certificate verification flags"\
2656 -c "! mbedtls_ssl_handshake returned" \
2657 -c "SSL - No CA Chain is set, but required to operate"
2658
2659# The purpose of the next two tests is to test the client's behaviour when receiving a server
2660# certificate with an unsupported elliptic curve. This should usually not happen because
2661# the client informs the server about the supported curves - it does, though, in the
2662# corner case of a static ECDH suite, because the server doesn't check the curve on that
2663# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2664# different means to have the server ignoring the client's supported curve list.
2665
2666requires_config_enabled MBEDTLS_ECP_C
2667run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2668 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2669 crt_file=data_files/server5.ku-ka.crt" \
2670 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2671 1 \
2672 -c "bad certificate (EC key curve)"\
2673 -c "! Certificate verification flags"\
2674 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2675
2676requires_config_enabled MBEDTLS_ECP_C
2677run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2678 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2679 crt_file=data_files/server5.ku-ka.crt" \
2680 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2681 1 \
2682 -c "bad certificate (EC key curve)"\
2683 -c "! Certificate verification flags"\
2684 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2685
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002686run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002687 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002688 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002689 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002690 0 \
2691 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002692 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002693 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002694 -C "X509 - Certificate verification failed"
2695
Simon Butcher99000142016-10-13 17:21:01 +01002696run_test "Authentication: client SHA256, server required" \
2697 "$P_SRV auth_mode=required" \
2698 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2699 key_file=data_files/server6.key \
2700 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2701 0 \
2702 -c "Supported Signature Algorithm found: 4," \
2703 -c "Supported Signature Algorithm found: 5,"
2704
2705run_test "Authentication: client SHA384, server required" \
2706 "$P_SRV auth_mode=required" \
2707 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2708 key_file=data_files/server6.key \
2709 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2710 0 \
2711 -c "Supported Signature Algorithm found: 4," \
2712 -c "Supported Signature Algorithm found: 5,"
2713
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002714requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2715run_test "Authentication: client has no cert, server required (SSLv3)" \
2716 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2717 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2718 key_file=data_files/server5.key" \
2719 1 \
2720 -S "skip write certificate request" \
2721 -C "skip parse certificate request" \
2722 -c "got a certificate request" \
2723 -c "got no certificate to send" \
2724 -S "x509_verify_cert() returned" \
2725 -s "client has no certificate" \
2726 -s "! mbedtls_ssl_handshake returned" \
2727 -c "! mbedtls_ssl_handshake returned" \
2728 -s "No client certification received from the client, but required by the authentication mode"
2729
2730run_test "Authentication: client has no cert, server required (TLS)" \
2731 "$P_SRV debug_level=3 auth_mode=required" \
2732 "$P_CLI debug_level=3 crt_file=none \
2733 key_file=data_files/server5.key" \
2734 1 \
2735 -S "skip write certificate request" \
2736 -C "skip parse certificate request" \
2737 -c "got a certificate request" \
2738 -c "= write certificate$" \
2739 -C "skip write certificate$" \
2740 -S "x509_verify_cert() returned" \
2741 -s "client has no certificate" \
2742 -s "! mbedtls_ssl_handshake returned" \
2743 -c "! mbedtls_ssl_handshake returned" \
2744 -s "No client certification received from the client, but required by the authentication mode"
2745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002746run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002747 "$P_SRV debug_level=3 auth_mode=required" \
2748 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002749 key_file=data_files/server5.key" \
2750 1 \
2751 -S "skip write certificate request" \
2752 -C "skip parse certificate request" \
2753 -c "got a certificate request" \
2754 -C "skip write certificate" \
2755 -C "skip write certificate verify" \
2756 -S "skip parse certificate verify" \
2757 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002758 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002759 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002760 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002761 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002762 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002763# We don't check that the client receives the alert because it might
2764# detect that its write end of the connection is closed and abort
2765# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002766
Janos Follath89baba22017-04-10 14:34:35 +01002767run_test "Authentication: client cert not trusted, server required" \
2768 "$P_SRV debug_level=3 auth_mode=required" \
2769 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2770 key_file=data_files/server5.key" \
2771 1 \
2772 -S "skip write certificate request" \
2773 -C "skip parse certificate request" \
2774 -c "got a certificate request" \
2775 -C "skip write certificate" \
2776 -C "skip write certificate verify" \
2777 -S "skip parse certificate verify" \
2778 -s "x509_verify_cert() returned" \
2779 -s "! The certificate is not correctly signed by the trusted CA" \
2780 -s "! mbedtls_ssl_handshake returned" \
2781 -c "! mbedtls_ssl_handshake returned" \
2782 -s "X509 - Certificate verification failed"
2783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002784run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002785 "$P_SRV debug_level=3 auth_mode=optional" \
2786 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002787 key_file=data_files/server5.key" \
2788 0 \
2789 -S "skip write certificate request" \
2790 -C "skip parse certificate request" \
2791 -c "got a certificate request" \
2792 -C "skip write certificate" \
2793 -C "skip write certificate verify" \
2794 -S "skip parse certificate verify" \
2795 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002796 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002797 -S "! mbedtls_ssl_handshake returned" \
2798 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002799 -S "X509 - Certificate verification failed"
2800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002801run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002802 "$P_SRV debug_level=3 auth_mode=none" \
2803 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002804 key_file=data_files/server5.key" \
2805 0 \
2806 -s "skip write certificate request" \
2807 -C "skip parse certificate request" \
2808 -c "got no certificate request" \
2809 -c "skip write certificate" \
2810 -c "skip write certificate verify" \
2811 -s "skip parse certificate verify" \
2812 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002813 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002814 -S "! mbedtls_ssl_handshake returned" \
2815 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002816 -S "X509 - Certificate verification failed"
2817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002818run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002819 "$P_SRV debug_level=3 auth_mode=optional" \
2820 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002821 0 \
2822 -S "skip write certificate request" \
2823 -C "skip parse certificate request" \
2824 -c "got a certificate request" \
2825 -C "skip write certificate$" \
2826 -C "got no certificate to send" \
2827 -S "SSLv3 client has no certificate" \
2828 -c "skip write certificate verify" \
2829 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002830 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002831 -S "! mbedtls_ssl_handshake returned" \
2832 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002833 -S "X509 - Certificate verification failed"
2834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002835run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002836 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002837 "$O_CLI" \
2838 0 \
2839 -S "skip write certificate request" \
2840 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002841 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002842 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002843 -S "X509 - Certificate verification failed"
2844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002845run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002846 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002847 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002848 0 \
2849 -C "skip parse certificate request" \
2850 -c "got a certificate request" \
2851 -C "skip write certificate$" \
2852 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002853 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002854
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002855run_test "Authentication: client no cert, openssl server required" \
2856 "$O_SRV -Verify 10" \
2857 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2858 1 \
2859 -C "skip parse certificate request" \
2860 -c "got a certificate request" \
2861 -C "skip write certificate$" \
2862 -c "skip write certificate verify" \
2863 -c "! mbedtls_ssl_handshake returned"
2864
Janos Follathe2681a42016-03-07 15:57:05 +00002865requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002866run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002867 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002868 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002869 0 \
2870 -S "skip write certificate request" \
2871 -C "skip parse certificate request" \
2872 -c "got a certificate request" \
2873 -C "skip write certificate$" \
2874 -c "skip write certificate verify" \
2875 -c "got no certificate to send" \
2876 -s "SSLv3 client has no certificate" \
2877 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002878 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002879 -S "! mbedtls_ssl_handshake returned" \
2880 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002881 -S "X509 - Certificate verification failed"
2882
Yuto Takanoe153ca22021-06-21 20:07:12 +01002883# config.h contains a value for MBEDTLS_X509_MAX_INTERMEDIATE_CA that is
2884# different from the script's assumed default value (below).
2885# Relevant tests are skipped if they do not match.
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002886
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002887MAX_IM_CA='8'
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002888
Yuto Takanoe153ca22021-06-21 20:07:12 +01002889requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2890requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002891requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002892run_test "Authentication: server max_int chain, client default" \
2893 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2894 key_file=data_files/dir-maxpath/09.key" \
2895 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2896 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002897 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002898
Yuto Takanod8a50292021-06-22 06:08:11 +01002899requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2900requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002901requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002902run_test "Authentication: server max_int+1 chain, client default" \
2903 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2904 key_file=data_files/dir-maxpath/10.key" \
2905 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2906 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002907 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002908
Yuto Takanod8a50292021-06-22 06:08:11 +01002909requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2910requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002911requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002912run_test "Authentication: server max_int+1 chain, client optional" \
2913 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2914 key_file=data_files/dir-maxpath/10.key" \
2915 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2916 auth_mode=optional" \
2917 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002918 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002919
Yuto Takanod8a50292021-06-22 06:08:11 +01002920requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2921requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002922requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002923run_test "Authentication: server max_int+1 chain, client none" \
2924 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2925 key_file=data_files/dir-maxpath/10.key" \
2926 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2927 auth_mode=none" \
2928 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002929 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002930
Yuto Takanod8a50292021-06-22 06:08:11 +01002931requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2932requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002933requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002934run_test "Authentication: client max_int+1 chain, server default" \
2935 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2936 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2937 key_file=data_files/dir-maxpath/10.key" \
2938 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002939 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002940
Yuto Takanod8a50292021-06-22 06:08:11 +01002941requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2942requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002943requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002944run_test "Authentication: client max_int+1 chain, server optional" \
2945 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2946 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2947 key_file=data_files/dir-maxpath/10.key" \
2948 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002949 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002950
Yuto Takanod8a50292021-06-22 06:08:11 +01002951requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2952requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002953requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002954run_test "Authentication: client max_int+1 chain, server required" \
2955 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2956 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2957 key_file=data_files/dir-maxpath/10.key" \
2958 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002959 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002960
Yuto Takanoe153ca22021-06-21 20:07:12 +01002961requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2962requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002963requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002964run_test "Authentication: client max_int chain, server required" \
2965 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2966 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2967 key_file=data_files/dir-maxpath/09.key" \
2968 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002969 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002970
Janos Follath89baba22017-04-10 14:34:35 +01002971# Tests for CA list in CertificateRequest messages
2972
2973run_test "Authentication: send CA list in CertificateRequest (default)" \
2974 "$P_SRV debug_level=3 auth_mode=required" \
2975 "$P_CLI crt_file=data_files/server6.crt \
2976 key_file=data_files/server6.key" \
2977 0 \
2978 -s "requested DN"
2979
2980run_test "Authentication: do not send CA list in CertificateRequest" \
2981 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2982 "$P_CLI crt_file=data_files/server6.crt \
2983 key_file=data_files/server6.key" \
2984 0 \
2985 -S "requested DN"
2986
2987run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2988 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2989 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2990 key_file=data_files/server5.key" \
2991 1 \
2992 -S "requested DN" \
2993 -s "x509_verify_cert() returned" \
2994 -s "! The certificate is not correctly signed by the trusted CA" \
2995 -s "! mbedtls_ssl_handshake returned" \
2996 -c "! mbedtls_ssl_handshake returned" \
2997 -s "X509 - Certificate verification failed"
2998
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002999# Tests for certificate selection based on SHA verson
3000
3001run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
3002 "$P_SRV crt_file=data_files/server5.crt \
3003 key_file=data_files/server5.key \
3004 crt_file2=data_files/server5-sha1.crt \
3005 key_file2=data_files/server5.key" \
3006 "$P_CLI force_version=tls1_2" \
3007 0 \
3008 -c "signed using.*ECDSA with SHA256" \
3009 -C "signed using.*ECDSA with SHA1"
3010
3011run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
3012 "$P_SRV crt_file=data_files/server5.crt \
3013 key_file=data_files/server5.key \
3014 crt_file2=data_files/server5-sha1.crt \
3015 key_file2=data_files/server5.key" \
3016 "$P_CLI force_version=tls1_1" \
3017 0 \
3018 -C "signed using.*ECDSA with SHA256" \
3019 -c "signed using.*ECDSA with SHA1"
3020
3021run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
3022 "$P_SRV crt_file=data_files/server5.crt \
3023 key_file=data_files/server5.key \
3024 crt_file2=data_files/server5-sha1.crt \
3025 key_file2=data_files/server5.key" \
3026 "$P_CLI force_version=tls1" \
3027 0 \
3028 -C "signed using.*ECDSA with SHA256" \
3029 -c "signed using.*ECDSA with SHA1"
3030
3031run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
3032 "$P_SRV crt_file=data_files/server5.crt \
3033 key_file=data_files/server5.key \
3034 crt_file2=data_files/server6.crt \
3035 key_file2=data_files/server6.key" \
3036 "$P_CLI force_version=tls1_1" \
3037 0 \
3038 -c "serial number.*09" \
3039 -c "signed using.*ECDSA with SHA256" \
3040 -C "signed using.*ECDSA with SHA1"
3041
3042run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
3043 "$P_SRV crt_file=data_files/server6.crt \
3044 key_file=data_files/server6.key \
3045 crt_file2=data_files/server5.crt \
3046 key_file2=data_files/server5.key" \
3047 "$P_CLI force_version=tls1_1" \
3048 0 \
3049 -c "serial number.*0A" \
3050 -c "signed using.*ECDSA with SHA256" \
3051 -C "signed using.*ECDSA with SHA1"
3052
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003053# tests for SNI
3054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003055run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003056 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003057 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003058 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003059 0 \
3060 -S "parse ServerName extension" \
3061 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3062 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003064run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003065 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003066 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003067 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 +02003068 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003069 0 \
3070 -s "parse ServerName extension" \
3071 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3072 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003074run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003075 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003076 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003077 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 +02003078 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003079 0 \
3080 -s "parse ServerName extension" \
3081 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3082 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003084run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003085 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003086 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003087 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 +02003088 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003089 1 \
3090 -s "parse ServerName extension" \
3091 -s "ssl_sni_wrapper() returned" \
3092 -s "mbedtls_ssl_handshake returned" \
3093 -c "mbedtls_ssl_handshake returned" \
3094 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003095
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003096run_test "SNI: client auth no override: optional" \
3097 "$P_SRV debug_level=3 auth_mode=optional \
3098 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3099 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3100 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003101 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003102 -S "skip write certificate request" \
3103 -C "skip parse certificate request" \
3104 -c "got a certificate request" \
3105 -C "skip write certificate" \
3106 -C "skip write certificate verify" \
3107 -S "skip parse certificate verify"
3108
3109run_test "SNI: client auth override: none -> optional" \
3110 "$P_SRV debug_level=3 auth_mode=none \
3111 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3112 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3113 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003114 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003115 -S "skip write certificate request" \
3116 -C "skip parse certificate request" \
3117 -c "got a certificate request" \
3118 -C "skip write certificate" \
3119 -C "skip write certificate verify" \
3120 -S "skip parse certificate verify"
3121
3122run_test "SNI: client auth override: optional -> none" \
3123 "$P_SRV debug_level=3 auth_mode=optional \
3124 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3125 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3126 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003127 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003128 -s "skip write certificate request" \
3129 -C "skip parse certificate request" \
3130 -c "got no certificate request" \
3131 -c "skip write certificate" \
3132 -c "skip write certificate verify" \
3133 -s "skip parse certificate verify"
3134
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003135run_test "SNI: CA no override" \
3136 "$P_SRV debug_level=3 auth_mode=optional \
3137 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3138 ca_file=data_files/test-ca.crt \
3139 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3140 "$P_CLI debug_level=3 server_name=localhost \
3141 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3142 1 \
3143 -S "skip write certificate request" \
3144 -C "skip parse certificate request" \
3145 -c "got a certificate request" \
3146 -C "skip write certificate" \
3147 -C "skip write certificate verify" \
3148 -S "skip parse certificate verify" \
3149 -s "x509_verify_cert() returned" \
3150 -s "! The certificate is not correctly signed by the trusted CA" \
3151 -S "The certificate has been revoked (is on a CRL)"
3152
3153run_test "SNI: CA override" \
3154 "$P_SRV debug_level=3 auth_mode=optional \
3155 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3156 ca_file=data_files/test-ca.crt \
3157 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3158 "$P_CLI debug_level=3 server_name=localhost \
3159 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3160 0 \
3161 -S "skip write certificate request" \
3162 -C "skip parse certificate request" \
3163 -c "got a certificate request" \
3164 -C "skip write certificate" \
3165 -C "skip write certificate verify" \
3166 -S "skip parse certificate verify" \
3167 -S "x509_verify_cert() returned" \
3168 -S "! The certificate is not correctly signed by the trusted CA" \
3169 -S "The certificate has been revoked (is on a CRL)"
3170
3171run_test "SNI: CA override with CRL" \
3172 "$P_SRV debug_level=3 auth_mode=optional \
3173 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3174 ca_file=data_files/test-ca.crt \
3175 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3176 "$P_CLI debug_level=3 server_name=localhost \
3177 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3178 1 \
3179 -S "skip write certificate request" \
3180 -C "skip parse certificate request" \
3181 -c "got a certificate request" \
3182 -C "skip write certificate" \
3183 -C "skip write certificate verify" \
3184 -S "skip parse certificate verify" \
3185 -s "x509_verify_cert() returned" \
3186 -S "! The certificate is not correctly signed by the trusted CA" \
3187 -s "The certificate has been revoked (is on a CRL)"
3188
Andres AG1a834452016-12-07 10:01:30 +00003189# Tests for SNI and DTLS
3190
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003191run_test "SNI: DTLS, no SNI callback" \
3192 "$P_SRV debug_level=3 dtls=1 \
3193 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3194 "$P_CLI server_name=localhost dtls=1" \
3195 0 \
3196 -S "parse ServerName extension" \
3197 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3198 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3199
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003200run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003201 "$P_SRV debug_level=3 dtls=1 \
3202 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3203 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3204 "$P_CLI server_name=localhost dtls=1" \
3205 0 \
3206 -s "parse ServerName extension" \
3207 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3208 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3209
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003210run_test "SNI: DTLS, matching cert 2" \
3211 "$P_SRV debug_level=3 dtls=1 \
3212 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3213 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3214 "$P_CLI server_name=polarssl.example dtls=1" \
3215 0 \
3216 -s "parse ServerName extension" \
3217 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3218 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3219
3220run_test "SNI: DTLS, no matching cert" \
3221 "$P_SRV debug_level=3 dtls=1 \
3222 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3223 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3224 "$P_CLI server_name=nonesuch.example dtls=1" \
3225 1 \
3226 -s "parse ServerName extension" \
3227 -s "ssl_sni_wrapper() returned" \
3228 -s "mbedtls_ssl_handshake returned" \
3229 -c "mbedtls_ssl_handshake returned" \
3230 -c "SSL - A fatal alert message was received from our peer"
3231
3232run_test "SNI: DTLS, client auth no override: optional" \
3233 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3234 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3235 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3236 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3237 0 \
3238 -S "skip write certificate request" \
3239 -C "skip parse certificate request" \
3240 -c "got a certificate request" \
3241 -C "skip write certificate" \
3242 -C "skip write certificate verify" \
3243 -S "skip parse certificate verify"
3244
3245run_test "SNI: DTLS, client auth override: none -> optional" \
3246 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3247 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3248 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3249 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3250 0 \
3251 -S "skip write certificate request" \
3252 -C "skip parse certificate request" \
3253 -c "got a certificate request" \
3254 -C "skip write certificate" \
3255 -C "skip write certificate verify" \
3256 -S "skip parse certificate verify"
3257
3258run_test "SNI: DTLS, client auth override: optional -> none" \
3259 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3260 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3261 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3262 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3263 0 \
3264 -s "skip write certificate request" \
3265 -C "skip parse certificate request" \
3266 -c "got no certificate request" \
3267 -c "skip write certificate" \
3268 -c "skip write certificate verify" \
3269 -s "skip parse certificate verify"
3270
3271run_test "SNI: DTLS, CA no override" \
3272 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3273 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3274 ca_file=data_files/test-ca.crt \
3275 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3276 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3277 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3278 1 \
3279 -S "skip write certificate request" \
3280 -C "skip parse certificate request" \
3281 -c "got a certificate request" \
3282 -C "skip write certificate" \
3283 -C "skip write certificate verify" \
3284 -S "skip parse certificate verify" \
3285 -s "x509_verify_cert() returned" \
3286 -s "! The certificate is not correctly signed by the trusted CA" \
3287 -S "The certificate has been revoked (is on a CRL)"
3288
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003289run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003290 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3291 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3292 ca_file=data_files/test-ca.crt \
3293 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3294 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3295 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3296 0 \
3297 -S "skip write certificate request" \
3298 -C "skip parse certificate request" \
3299 -c "got a certificate request" \
3300 -C "skip write certificate" \
3301 -C "skip write certificate verify" \
3302 -S "skip parse certificate verify" \
3303 -S "x509_verify_cert() returned" \
3304 -S "! The certificate is not correctly signed by the trusted CA" \
3305 -S "The certificate has been revoked (is on a CRL)"
3306
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003307run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003308 "$P_SRV debug_level=3 auth_mode=optional \
3309 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3310 ca_file=data_files/test-ca.crt \
3311 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3312 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3313 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3314 1 \
3315 -S "skip write certificate request" \
3316 -C "skip parse certificate request" \
3317 -c "got a certificate request" \
3318 -C "skip write certificate" \
3319 -C "skip write certificate verify" \
3320 -S "skip parse certificate verify" \
3321 -s "x509_verify_cert() returned" \
3322 -S "! The certificate is not correctly signed by the trusted CA" \
3323 -s "The certificate has been revoked (is on a CRL)"
3324
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003325# Tests for non-blocking I/O: exercise a variety of handshake flows
3326
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003327run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003328 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3329 "$P_CLI nbio=2 tickets=0" \
3330 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003331 -S "mbedtls_ssl_handshake returned" \
3332 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003333 -c "Read from server: .* bytes read"
3334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003335run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003336 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3337 "$P_CLI nbio=2 tickets=0" \
3338 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003339 -S "mbedtls_ssl_handshake returned" \
3340 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003341 -c "Read from server: .* bytes read"
3342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003343run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003344 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3345 "$P_CLI nbio=2 tickets=1" \
3346 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003347 -S "mbedtls_ssl_handshake returned" \
3348 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003349 -c "Read from server: .* bytes read"
3350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003351run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003352 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3353 "$P_CLI nbio=2 tickets=1" \
3354 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003355 -S "mbedtls_ssl_handshake returned" \
3356 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003357 -c "Read from server: .* bytes read"
3358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003359run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003360 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3361 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3362 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003363 -S "mbedtls_ssl_handshake returned" \
3364 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003365 -c "Read from server: .* bytes read"
3366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003367run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003368 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3369 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3370 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003371 -S "mbedtls_ssl_handshake returned" \
3372 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003373 -c "Read from server: .* bytes read"
3374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003375run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003376 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3377 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3378 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003379 -S "mbedtls_ssl_handshake returned" \
3380 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003381 -c "Read from server: .* bytes read"
3382
Hanno Becker00076712017-11-15 16:39:08 +00003383# Tests for event-driven I/O: exercise a variety of handshake flows
3384
3385run_test "Event-driven I/O: basic handshake" \
3386 "$P_SRV event=1 tickets=0 auth_mode=none" \
3387 "$P_CLI event=1 tickets=0" \
3388 0 \
3389 -S "mbedtls_ssl_handshake returned" \
3390 -C "mbedtls_ssl_handshake returned" \
3391 -c "Read from server: .* bytes read"
3392
3393run_test "Event-driven I/O: client auth" \
3394 "$P_SRV event=1 tickets=0 auth_mode=required" \
3395 "$P_CLI event=1 tickets=0" \
3396 0 \
3397 -S "mbedtls_ssl_handshake returned" \
3398 -C "mbedtls_ssl_handshake returned" \
3399 -c "Read from server: .* bytes read"
3400
3401run_test "Event-driven I/O: ticket" \
3402 "$P_SRV event=1 tickets=1 auth_mode=none" \
3403 "$P_CLI event=1 tickets=1" \
3404 0 \
3405 -S "mbedtls_ssl_handshake returned" \
3406 -C "mbedtls_ssl_handshake returned" \
3407 -c "Read from server: .* bytes read"
3408
3409run_test "Event-driven I/O: ticket + client auth" \
3410 "$P_SRV event=1 tickets=1 auth_mode=required" \
3411 "$P_CLI event=1 tickets=1" \
3412 0 \
3413 -S "mbedtls_ssl_handshake returned" \
3414 -C "mbedtls_ssl_handshake returned" \
3415 -c "Read from server: .* bytes read"
3416
3417run_test "Event-driven I/O: ticket + client auth + resume" \
3418 "$P_SRV event=1 tickets=1 auth_mode=required" \
3419 "$P_CLI event=1 tickets=1 reconnect=1" \
3420 0 \
3421 -S "mbedtls_ssl_handshake returned" \
3422 -C "mbedtls_ssl_handshake returned" \
3423 -c "Read from server: .* bytes read"
3424
3425run_test "Event-driven I/O: ticket + resume" \
3426 "$P_SRV event=1 tickets=1 auth_mode=none" \
3427 "$P_CLI event=1 tickets=1 reconnect=1" \
3428 0 \
3429 -S "mbedtls_ssl_handshake returned" \
3430 -C "mbedtls_ssl_handshake returned" \
3431 -c "Read from server: .* bytes read"
3432
3433run_test "Event-driven I/O: session-id resume" \
3434 "$P_SRV event=1 tickets=0 auth_mode=none" \
3435 "$P_CLI event=1 tickets=0 reconnect=1" \
3436 0 \
3437 -S "mbedtls_ssl_handshake returned" \
3438 -C "mbedtls_ssl_handshake returned" \
3439 -c "Read from server: .* bytes read"
3440
Hanno Becker6a33f592018-03-13 11:38:46 +00003441run_test "Event-driven I/O, DTLS: basic handshake" \
3442 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3443 "$P_CLI dtls=1 event=1 tickets=0" \
3444 0 \
3445 -c "Read from server: .* bytes read"
3446
3447run_test "Event-driven I/O, DTLS: client auth" \
3448 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3449 "$P_CLI dtls=1 event=1 tickets=0" \
3450 0 \
3451 -c "Read from server: .* bytes read"
3452
3453run_test "Event-driven I/O, DTLS: ticket" \
3454 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3455 "$P_CLI dtls=1 event=1 tickets=1" \
3456 0 \
3457 -c "Read from server: .* bytes read"
3458
3459run_test "Event-driven I/O, DTLS: ticket + client auth" \
3460 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3461 "$P_CLI dtls=1 event=1 tickets=1" \
3462 0 \
3463 -c "Read from server: .* bytes read"
3464
3465run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3466 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003467 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003468 0 \
3469 -c "Read from server: .* bytes read"
3470
3471run_test "Event-driven I/O, DTLS: ticket + resume" \
3472 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003473 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003474 0 \
3475 -c "Read from server: .* bytes read"
3476
3477run_test "Event-driven I/O, DTLS: session-id resume" \
3478 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003479 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003480 0 \
3481 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003482
3483# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3484# During session resumption, the client will send its ApplicationData record
3485# within the same datagram as the Finished messages. In this situation, the
3486# server MUST NOT idle on the underlying transport after handshake completion,
3487# because the ApplicationData request has already been queued internally.
3488run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003489 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003490 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003491 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003492 0 \
3493 -c "Read from server: .* bytes read"
3494
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003495# Tests for version negotiation
3496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003497run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003498 "$P_SRV" \
3499 "$P_CLI" \
3500 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003501 -S "mbedtls_ssl_handshake returned" \
3502 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003503 -s "Protocol is TLSv1.2" \
3504 -c "Protocol is TLSv1.2"
3505
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003506run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003507 "$P_SRV" \
3508 "$P_CLI max_version=tls1_1" \
3509 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003510 -S "mbedtls_ssl_handshake returned" \
3511 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003512 -s "Protocol is TLSv1.1" \
3513 -c "Protocol is TLSv1.1"
3514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003515run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003516 "$P_SRV max_version=tls1_1" \
3517 "$P_CLI" \
3518 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003519 -S "mbedtls_ssl_handshake returned" \
3520 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003521 -s "Protocol is TLSv1.1" \
3522 -c "Protocol is TLSv1.1"
3523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003524run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003525 "$P_SRV max_version=tls1_1" \
3526 "$P_CLI max_version=tls1_1" \
3527 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003528 -S "mbedtls_ssl_handshake returned" \
3529 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003530 -s "Protocol is TLSv1.1" \
3531 -c "Protocol is TLSv1.1"
3532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003533run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003534 "$P_SRV min_version=tls1_1" \
3535 "$P_CLI max_version=tls1_1" \
3536 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003537 -S "mbedtls_ssl_handshake returned" \
3538 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003539 -s "Protocol is TLSv1.1" \
3540 -c "Protocol is TLSv1.1"
3541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003542run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003543 "$P_SRV max_version=tls1_1" \
3544 "$P_CLI min_version=tls1_1" \
3545 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003546 -S "mbedtls_ssl_handshake returned" \
3547 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003548 -s "Protocol is TLSv1.1" \
3549 -c "Protocol is TLSv1.1"
3550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003551run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003552 "$P_SRV max_version=tls1_1" \
3553 "$P_CLI min_version=tls1_2" \
3554 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003555 -s "mbedtls_ssl_handshake returned" \
3556 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003557 -c "SSL - Handshake protocol not within min/max boundaries"
3558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003559run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003560 "$P_SRV min_version=tls1_2" \
3561 "$P_CLI max_version=tls1_1" \
3562 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003563 -s "mbedtls_ssl_handshake returned" \
3564 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003565 -s "SSL - Handshake protocol not within min/max boundaries"
3566
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003567# Tests for ALPN extension
3568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003569run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003570 "$P_SRV debug_level=3" \
3571 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003572 0 \
3573 -C "client hello, adding alpn extension" \
3574 -S "found alpn extension" \
3575 -C "got an alert message, type: \\[2:120]" \
3576 -S "server hello, adding alpn extension" \
3577 -C "found alpn extension " \
3578 -C "Application Layer Protocol is" \
3579 -S "Application Layer Protocol is"
3580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003581run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003582 "$P_SRV debug_level=3" \
3583 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003584 0 \
3585 -c "client hello, adding alpn extension" \
3586 -s "found alpn extension" \
3587 -C "got an alert message, type: \\[2:120]" \
3588 -S "server hello, adding alpn extension" \
3589 -C "found alpn extension " \
3590 -c "Application Layer Protocol is (none)" \
3591 -S "Application Layer Protocol is"
3592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003593run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003594 "$P_SRV debug_level=3 alpn=abc,1234" \
3595 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003596 0 \
3597 -C "client hello, adding alpn extension" \
3598 -S "found alpn extension" \
3599 -C "got an alert message, type: \\[2:120]" \
3600 -S "server hello, adding alpn extension" \
3601 -C "found alpn extension " \
3602 -C "Application Layer Protocol is" \
3603 -s "Application Layer Protocol is (none)"
3604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003605run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003606 "$P_SRV debug_level=3 alpn=abc,1234" \
3607 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003608 0 \
3609 -c "client hello, adding alpn extension" \
3610 -s "found alpn extension" \
3611 -C "got an alert message, type: \\[2:120]" \
3612 -s "server hello, adding alpn extension" \
3613 -c "found alpn extension" \
3614 -c "Application Layer Protocol is abc" \
3615 -s "Application Layer Protocol is abc"
3616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003617run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003618 "$P_SRV debug_level=3 alpn=abc,1234" \
3619 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003620 0 \
3621 -c "client hello, adding alpn extension" \
3622 -s "found alpn extension" \
3623 -C "got an alert message, type: \\[2:120]" \
3624 -s "server hello, adding alpn extension" \
3625 -c "found alpn extension" \
3626 -c "Application Layer Protocol is abc" \
3627 -s "Application Layer Protocol is abc"
3628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003629run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003630 "$P_SRV debug_level=3 alpn=abc,1234" \
3631 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003632 0 \
3633 -c "client hello, adding alpn extension" \
3634 -s "found alpn extension" \
3635 -C "got an alert message, type: \\[2:120]" \
3636 -s "server hello, adding alpn extension" \
3637 -c "found alpn extension" \
3638 -c "Application Layer Protocol is 1234" \
3639 -s "Application Layer Protocol is 1234"
3640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003641run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003642 "$P_SRV debug_level=3 alpn=abc,123" \
3643 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003644 1 \
3645 -c "client hello, adding alpn extension" \
3646 -s "found alpn extension" \
3647 -c "got an alert message, type: \\[2:120]" \
3648 -S "server hello, adding alpn extension" \
3649 -C "found alpn extension" \
3650 -C "Application Layer Protocol is 1234" \
3651 -S "Application Layer Protocol is 1234"
3652
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003653
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003654# Tests for keyUsage in leaf certificates, part 1:
3655# server-side certificate/suite selection
3656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003657run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003658 "$P_SRV key_file=data_files/server2.key \
3659 crt_file=data_files/server2.ku-ds.crt" \
3660 "$P_CLI" \
3661 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003662 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003663
3664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003665run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003666 "$P_SRV key_file=data_files/server2.key \
3667 crt_file=data_files/server2.ku-ke.crt" \
3668 "$P_CLI" \
3669 0 \
3670 -c "Ciphersuite is TLS-RSA-WITH-"
3671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003672run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003673 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003674 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003675 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003676 1 \
3677 -C "Ciphersuite is "
3678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003679run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003680 "$P_SRV key_file=data_files/server5.key \
3681 crt_file=data_files/server5.ku-ds.crt" \
3682 "$P_CLI" \
3683 0 \
3684 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3685
3686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003687run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003688 "$P_SRV key_file=data_files/server5.key \
3689 crt_file=data_files/server5.ku-ka.crt" \
3690 "$P_CLI" \
3691 0 \
3692 -c "Ciphersuite is TLS-ECDH-"
3693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003694run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003695 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003696 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003697 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003698 1 \
3699 -C "Ciphersuite is "
3700
3701# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003702# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003703
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003704run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003705 "$O_SRV -key data_files/server2.key \
3706 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003707 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003708 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3709 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003710 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003711 -C "Processing of the Certificate handshake message failed" \
3712 -c "Ciphersuite is TLS-"
3713
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003714run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003715 "$O_SRV -key data_files/server2.key \
3716 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003717 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003718 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3719 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003720 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003721 -C "Processing of the Certificate handshake message failed" \
3722 -c "Ciphersuite is TLS-"
3723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003724run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003725 "$O_SRV -key data_files/server2.key \
3726 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003727 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003728 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3729 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003730 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003731 -C "Processing of the Certificate handshake message failed" \
3732 -c "Ciphersuite is TLS-"
3733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003734run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003735 "$O_SRV -key data_files/server2.key \
3736 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003737 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003738 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3739 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003740 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003741 -c "Processing of the Certificate handshake message failed" \
3742 -C "Ciphersuite is TLS-"
3743
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003744run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3745 "$O_SRV -key data_files/server2.key \
3746 -cert data_files/server2.ku-ke.crt" \
3747 "$P_CLI debug_level=1 auth_mode=optional \
3748 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3749 0 \
3750 -c "bad certificate (usage extensions)" \
3751 -C "Processing of the Certificate handshake message failed" \
3752 -c "Ciphersuite is TLS-" \
3753 -c "! Usage does not match the keyUsage extension"
3754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003755run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003756 "$O_SRV -key data_files/server2.key \
3757 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003758 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003759 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3760 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003761 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003762 -C "Processing of the Certificate handshake message failed" \
3763 -c "Ciphersuite is TLS-"
3764
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003765run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003766 "$O_SRV -key data_files/server2.key \
3767 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003768 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003769 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3770 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003771 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003772 -c "Processing of the Certificate handshake message failed" \
3773 -C "Ciphersuite is TLS-"
3774
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003775run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3776 "$O_SRV -key data_files/server2.key \
3777 -cert data_files/server2.ku-ds.crt" \
3778 "$P_CLI debug_level=1 auth_mode=optional \
3779 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3780 0 \
3781 -c "bad certificate (usage extensions)" \
3782 -C "Processing of the Certificate handshake message failed" \
3783 -c "Ciphersuite is TLS-" \
3784 -c "! Usage does not match the keyUsage extension"
3785
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003786# Tests for keyUsage in leaf certificates, part 3:
3787# server-side checking of client cert
3788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003789run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003790 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003791 "$O_CLI -key data_files/server2.key \
3792 -cert data_files/server2.ku-ds.crt" \
3793 0 \
3794 -S "bad certificate (usage extensions)" \
3795 -S "Processing of the Certificate handshake message failed"
3796
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003797run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003798 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003799 "$O_CLI -key data_files/server2.key \
3800 -cert data_files/server2.ku-ke.crt" \
3801 0 \
3802 -s "bad certificate (usage extensions)" \
3803 -S "Processing of the Certificate handshake message failed"
3804
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003805run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003806 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003807 "$O_CLI -key data_files/server2.key \
3808 -cert data_files/server2.ku-ke.crt" \
3809 1 \
3810 -s "bad certificate (usage extensions)" \
3811 -s "Processing of the Certificate handshake message failed"
3812
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003813run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003814 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003815 "$O_CLI -key data_files/server5.key \
3816 -cert data_files/server5.ku-ds.crt" \
3817 0 \
3818 -S "bad certificate (usage extensions)" \
3819 -S "Processing of the Certificate handshake message failed"
3820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003821run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003822 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003823 "$O_CLI -key data_files/server5.key \
3824 -cert data_files/server5.ku-ka.crt" \
3825 0 \
3826 -s "bad certificate (usage extensions)" \
3827 -S "Processing of the Certificate handshake message failed"
3828
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003829# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003831run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003832 "$P_SRV key_file=data_files/server5.key \
3833 crt_file=data_files/server5.eku-srv.crt" \
3834 "$P_CLI" \
3835 0
3836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003837run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003838 "$P_SRV key_file=data_files/server5.key \
3839 crt_file=data_files/server5.eku-srv.crt" \
3840 "$P_CLI" \
3841 0
3842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003843run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003844 "$P_SRV key_file=data_files/server5.key \
3845 crt_file=data_files/server5.eku-cs_any.crt" \
3846 "$P_CLI" \
3847 0
3848
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003849run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003850 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003851 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003852 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003853 1
3854
3855# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3856
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003857run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003858 "$O_SRV -key data_files/server5.key \
3859 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003860 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003861 0 \
3862 -C "bad certificate (usage extensions)" \
3863 -C "Processing of the Certificate handshake message failed" \
3864 -c "Ciphersuite is TLS-"
3865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003866run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003867 "$O_SRV -key data_files/server5.key \
3868 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003869 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003870 0 \
3871 -C "bad certificate (usage extensions)" \
3872 -C "Processing of the Certificate handshake message failed" \
3873 -c "Ciphersuite is TLS-"
3874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003875run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003876 "$O_SRV -key data_files/server5.key \
3877 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003878 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003879 0 \
3880 -C "bad certificate (usage extensions)" \
3881 -C "Processing of the Certificate handshake message failed" \
3882 -c "Ciphersuite is TLS-"
3883
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003884run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003885 "$O_SRV -key data_files/server5.key \
3886 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003887 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003888 1 \
3889 -c "bad certificate (usage extensions)" \
3890 -c "Processing of the Certificate handshake message failed" \
3891 -C "Ciphersuite is TLS-"
3892
3893# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3894
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003895run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003896 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003897 "$O_CLI -key data_files/server5.key \
3898 -cert data_files/server5.eku-cli.crt" \
3899 0 \
3900 -S "bad certificate (usage extensions)" \
3901 -S "Processing of the Certificate handshake message failed"
3902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003903run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003904 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003905 "$O_CLI -key data_files/server5.key \
3906 -cert data_files/server5.eku-srv_cli.crt" \
3907 0 \
3908 -S "bad certificate (usage extensions)" \
3909 -S "Processing of the Certificate handshake message failed"
3910
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003911run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003912 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003913 "$O_CLI -key data_files/server5.key \
3914 -cert data_files/server5.eku-cs_any.crt" \
3915 0 \
3916 -S "bad certificate (usage extensions)" \
3917 -S "Processing of the Certificate handshake message failed"
3918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003919run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003920 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003921 "$O_CLI -key data_files/server5.key \
3922 -cert data_files/server5.eku-cs.crt" \
3923 0 \
3924 -s "bad certificate (usage extensions)" \
3925 -S "Processing of the Certificate handshake message failed"
3926
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003927run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003928 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003929 "$O_CLI -key data_files/server5.key \
3930 -cert data_files/server5.eku-cs.crt" \
3931 1 \
3932 -s "bad certificate (usage extensions)" \
3933 -s "Processing of the Certificate handshake message failed"
3934
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003935# Tests for DHM parameters loading
3936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003937run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003938 "$P_SRV" \
3939 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3940 debug_level=3" \
3941 0 \
3942 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003943 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003945run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003946 "$P_SRV dhm_file=data_files/dhparams.pem" \
3947 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3948 debug_level=3" \
3949 0 \
3950 -c "value of 'DHM: P ' (1024 bits)" \
3951 -c "value of 'DHM: G ' (2 bits)"
3952
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003953# Tests for DHM client-side size checking
3954
3955run_test "DHM size: server default, client default, OK" \
3956 "$P_SRV" \
3957 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3958 debug_level=1" \
3959 0 \
3960 -C "DHM prime too short:"
3961
3962run_test "DHM size: server default, client 2048, OK" \
3963 "$P_SRV" \
3964 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3965 debug_level=1 dhmlen=2048" \
3966 0 \
3967 -C "DHM prime too short:"
3968
3969run_test "DHM size: server 1024, client default, OK" \
3970 "$P_SRV dhm_file=data_files/dhparams.pem" \
3971 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3972 debug_level=1" \
3973 0 \
3974 -C "DHM prime too short:"
3975
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01003976run_test "DHM size: server 999, client 999, OK" \
3977 "$P_SRV dhm_file=data_files/dh.999.pem" \
3978 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3979 debug_level=1 dhmlen=999" \
3980 0 \
3981 -C "DHM prime too short:"
3982
3983run_test "DHM size: server 1000, client 1000, OK" \
3984 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3985 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3986 debug_level=1 dhmlen=1000" \
3987 0 \
3988 -C "DHM prime too short:"
3989
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003990run_test "DHM size: server 1000, client default, rejected" \
3991 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3992 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3993 debug_level=1" \
3994 1 \
3995 -c "DHM prime too short:"
3996
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01003997run_test "DHM size: server 1000, client 1001, rejected" \
3998 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3999 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4000 debug_level=1 dhmlen=1001" \
4001 1 \
4002 -c "DHM prime too short:"
4003
4004run_test "DHM size: server 999, client 1000, rejected" \
4005 "$P_SRV dhm_file=data_files/dh.999.pem" \
4006 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4007 debug_level=1 dhmlen=1000" \
4008 1 \
4009 -c "DHM prime too short:"
4010
4011run_test "DHM size: server 998, client 999, rejected" \
4012 "$P_SRV dhm_file=data_files/dh.998.pem" \
4013 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4014 debug_level=1 dhmlen=999" \
4015 1 \
4016 -c "DHM prime too short:"
4017
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004018run_test "DHM size: server default, client 2049, rejected" \
4019 "$P_SRV" \
4020 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4021 debug_level=1 dhmlen=2049" \
4022 1 \
4023 -c "DHM prime too short:"
4024
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004025# Tests for PSK callback
4026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004027run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004028 "$P_SRV psk=abc123 psk_identity=foo" \
4029 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4030 psk_identity=foo psk=abc123" \
4031 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004032 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004033 -S "SSL - Unknown identity received" \
4034 -S "SSL - Verification of the message MAC failed"
4035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004036run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004037 "$P_SRV" \
4038 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4039 psk_identity=foo psk=abc123" \
4040 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004041 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004042 -S "SSL - Unknown identity received" \
4043 -S "SSL - Verification of the message MAC failed"
4044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004045run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004046 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
4047 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4048 psk_identity=foo psk=abc123" \
4049 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004050 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004051 -s "SSL - Unknown identity received" \
4052 -S "SSL - Verification of the message MAC failed"
4053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004054run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004055 "$P_SRV psk_list=abc,dead,def,beef" \
4056 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4057 psk_identity=abc psk=dead" \
4058 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004059 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004060 -S "SSL - Unknown identity received" \
4061 -S "SSL - Verification of the message MAC failed"
4062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004063run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004064 "$P_SRV psk_list=abc,dead,def,beef" \
4065 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4066 psk_identity=def psk=beef" \
4067 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004068 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004069 -S "SSL - Unknown identity received" \
4070 -S "SSL - Verification of the message MAC failed"
4071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004072run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004073 "$P_SRV psk_list=abc,dead,def,beef" \
4074 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4075 psk_identity=ghi psk=beef" \
4076 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004077 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004078 -s "SSL - Unknown identity received" \
4079 -S "SSL - Verification of the message MAC failed"
4080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004081run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004082 "$P_SRV psk_list=abc,dead,def,beef" \
4083 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4084 psk_identity=abc psk=beef" \
4085 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004086 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004087 -S "SSL - Unknown identity received" \
4088 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004089
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004090# Tests for EC J-PAKE
4091
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004092requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004093run_test "ECJPAKE: client not configured" \
4094 "$P_SRV debug_level=3" \
4095 "$P_CLI debug_level=3" \
4096 0 \
4097 -C "add ciphersuite: c0ff" \
4098 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004099 -S "found ecjpake kkpp extension" \
4100 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004101 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004102 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004103 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004104 -S "None of the common ciphersuites is usable"
4105
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004106requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004107run_test "ECJPAKE: server not configured" \
4108 "$P_SRV debug_level=3" \
4109 "$P_CLI debug_level=3 ecjpake_pw=bla \
4110 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4111 1 \
4112 -c "add ciphersuite: c0ff" \
4113 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004114 -s "found ecjpake kkpp extension" \
4115 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004116 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004117 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004118 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004119 -s "None of the common ciphersuites is usable"
4120
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004121requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004122run_test "ECJPAKE: working, TLS" \
4123 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4124 "$P_CLI debug_level=3 ecjpake_pw=bla \
4125 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004126 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004127 -c "add ciphersuite: c0ff" \
4128 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004129 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004130 -s "found ecjpake kkpp extension" \
4131 -S "skip ecjpake kkpp extension" \
4132 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004133 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004134 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004135 -S "None of the common ciphersuites is usable" \
4136 -S "SSL - Verification of the message MAC failed"
4137
Janos Follath74537a62016-09-02 13:45:28 +01004138server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004139requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004140run_test "ECJPAKE: password mismatch, TLS" \
4141 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4142 "$P_CLI debug_level=3 ecjpake_pw=bad \
4143 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4144 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004145 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004146 -s "SSL - Verification of the message MAC failed"
4147
Dave Rodgmancee9e922021-06-29 19:05:34 +01004148requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004149run_test "ECJPAKE: working, DTLS" \
4150 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4151 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4152 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4153 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004154 -c "re-using cached ecjpake parameters" \
4155 -S "SSL - Verification of the message MAC failed"
4156
Dave Rodgmancee9e922021-06-29 19:05:34 +01004157requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004158run_test "ECJPAKE: working, DTLS, no cookie" \
4159 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4160 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4161 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4162 0 \
4163 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004164 -S "SSL - Verification of the message MAC failed"
4165
Janos Follath74537a62016-09-02 13:45:28 +01004166server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004167requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004168run_test "ECJPAKE: password mismatch, DTLS" \
4169 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4170 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4171 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4172 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004173 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004174 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004175
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004176# for tests with configs/config-thread.h
Dave Rodgmancee9e922021-06-29 19:05:34 +01004177requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004178run_test "ECJPAKE: working, DTLS, nolog" \
4179 "$P_SRV dtls=1 ecjpake_pw=bla" \
4180 "$P_CLI dtls=1 ecjpake_pw=bla \
4181 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4182 0
4183
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004184# Tests for ciphersuites per version
4185
Janos Follathe2681a42016-03-07 15:57:05 +00004186requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004187requires_config_enabled MBEDTLS_CAMELLIA_C
4188requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004189run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004190 "$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 +02004191 "$P_CLI force_version=ssl3" \
4192 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004193 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004194
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004195requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4196requires_config_enabled MBEDTLS_CAMELLIA_C
4197requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004198run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004199 "$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 +01004200 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004201 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004202 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004203
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004204requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4205requires_config_enabled MBEDTLS_CAMELLIA_C
4206requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004207run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004208 "$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 +02004209 "$P_CLI force_version=tls1_1" \
4210 0 \
4211 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4212
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004213requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4214requires_config_enabled MBEDTLS_CAMELLIA_C
4215requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004216run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004217 "$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 +02004218 "$P_CLI force_version=tls1_2" \
4219 0 \
4220 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4221
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004222# Test for ClientHello without extensions
4223
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004224requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004225run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004226 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004227 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004228 0 \
4229 -s "dumping 'client hello extensions' (0 bytes)"
4230
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004231# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004232
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004233run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004234 "$P_SRV" \
4235 "$P_CLI request_size=100" \
4236 0 \
4237 -s "Read from client: 100 bytes read$"
4238
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004239run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004240 "$P_SRV" \
4241 "$P_CLI request_size=500" \
4242 0 \
4243 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004244
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004245# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004246
Janos Follathe2681a42016-03-07 15:57:05 +00004247requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004248run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004249 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004250 "$P_CLI request_size=1 force_version=ssl3 \
4251 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4252 0 \
4253 -s "Read from client: 1 bytes read"
4254
Janos Follathe2681a42016-03-07 15:57:05 +00004255requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004256run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004257 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004258 "$P_CLI request_size=1 force_version=ssl3 \
4259 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4260 0 \
4261 -s "Read from client: 1 bytes read"
4262
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004263run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004264 "$P_SRV" \
4265 "$P_CLI request_size=1 force_version=tls1 \
4266 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4267 0 \
4268 -s "Read from client: 1 bytes read"
4269
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004270run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004271 "$P_SRV" \
4272 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4273 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4274 0 \
4275 -s "Read from client: 1 bytes read"
4276
Hanno Becker32c55012017-11-10 08:42:54 +00004277requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004278run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004279 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004280 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004281 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004282 0 \
4283 -s "Read from client: 1 bytes read"
4284
Hanno Becker32c55012017-11-10 08:42:54 +00004285requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004286run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004287 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004288 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004289 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004290 0 \
4291 -s "Read from client: 1 bytes read"
4292
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004293run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004294 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004295 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004296 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4297 0 \
4298 -s "Read from client: 1 bytes read"
4299
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004300run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004301 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4302 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004303 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004304 0 \
4305 -s "Read from client: 1 bytes read"
4306
4307requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004308run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004309 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004310 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004311 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004312 0 \
4313 -s "Read from client: 1 bytes read"
4314
Hanno Becker8501f982017-11-10 08:59:04 +00004315requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004316run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004317 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4318 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4319 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004320 0 \
4321 -s "Read from client: 1 bytes read"
4322
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004323run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004324 "$P_SRV" \
4325 "$P_CLI request_size=1 force_version=tls1_1 \
4326 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4327 0 \
4328 -s "Read from client: 1 bytes read"
4329
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004330run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004331 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004332 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004333 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004334 0 \
4335 -s "Read from client: 1 bytes read"
4336
4337requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004338run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004339 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004340 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004341 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004342 0 \
4343 -s "Read from client: 1 bytes read"
4344
4345requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004346run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004347 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004348 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004349 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004350 0 \
4351 -s "Read from client: 1 bytes read"
4352
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004353run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004354 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004355 "$P_CLI request_size=1 force_version=tls1_1 \
4356 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4357 0 \
4358 -s "Read from client: 1 bytes read"
4359
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004360run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004361 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004362 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004363 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004364 0 \
4365 -s "Read from client: 1 bytes read"
4366
Hanno Becker8501f982017-11-10 08:59:04 +00004367requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004368run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004369 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004370 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004371 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004372 0 \
4373 -s "Read from client: 1 bytes read"
4374
Hanno Becker32c55012017-11-10 08:42:54 +00004375requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004376run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004377 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004378 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004379 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004380 0 \
4381 -s "Read from client: 1 bytes read"
4382
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004383run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004384 "$P_SRV" \
4385 "$P_CLI request_size=1 force_version=tls1_2 \
4386 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4387 0 \
4388 -s "Read from client: 1 bytes read"
4389
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004390run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004391 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004392 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004393 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004394 0 \
4395 -s "Read from client: 1 bytes read"
4396
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004397run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004398 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004399 "$P_CLI request_size=1 force_version=tls1_2 \
4400 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004401 0 \
4402 -s "Read from client: 1 bytes read"
4403
Hanno Becker32c55012017-11-10 08:42:54 +00004404requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004405run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004406 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004407 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004408 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004409 0 \
4410 -s "Read from client: 1 bytes read"
4411
Hanno Becker8501f982017-11-10 08:59:04 +00004412requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004413run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004414 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004415 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004416 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004417 0 \
4418 -s "Read from client: 1 bytes read"
4419
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004420run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004421 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004422 "$P_CLI request_size=1 force_version=tls1_2 \
4423 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4424 0 \
4425 -s "Read from client: 1 bytes read"
4426
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004427run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004428 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004429 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004430 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004431 0 \
4432 -s "Read from client: 1 bytes read"
4433
Hanno Becker32c55012017-11-10 08:42:54 +00004434requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004435run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004436 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004437 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004438 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004439 0 \
4440 -s "Read from client: 1 bytes read"
4441
Hanno Becker8501f982017-11-10 08:59:04 +00004442requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004443run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004444 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004445 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004446 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004447 0 \
4448 -s "Read from client: 1 bytes read"
4449
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004450run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004451 "$P_SRV" \
4452 "$P_CLI request_size=1 force_version=tls1_2 \
4453 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4454 0 \
4455 -s "Read from client: 1 bytes read"
4456
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004457run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004458 "$P_SRV" \
4459 "$P_CLI request_size=1 force_version=tls1_2 \
4460 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4461 0 \
4462 -s "Read from client: 1 bytes read"
4463
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004464# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004465
4466requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004467run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004468 "$P_SRV dtls=1 force_version=dtls1" \
4469 "$P_CLI dtls=1 request_size=1 \
4470 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4471 0 \
4472 -s "Read from client: 1 bytes read"
4473
4474requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004475run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004476 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4477 "$P_CLI dtls=1 request_size=1 \
4478 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4479 0 \
4480 -s "Read from client: 1 bytes read"
4481
4482requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4483requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004484run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004485 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4486 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004487 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4488 0 \
4489 -s "Read from client: 1 bytes read"
4490
4491requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4492requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004493run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004494 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004495 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004496 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004497 0 \
4498 -s "Read from client: 1 bytes read"
4499
4500requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004501run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004502 "$P_SRV dtls=1 force_version=dtls1_2" \
4503 "$P_CLI dtls=1 request_size=1 \
4504 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4505 0 \
4506 -s "Read from client: 1 bytes read"
4507
4508requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004509run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004510 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004511 "$P_CLI dtls=1 request_size=1 \
4512 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4513 0 \
4514 -s "Read from client: 1 bytes read"
4515
4516requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4517requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004518run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004519 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004520 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004521 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004522 0 \
4523 -s "Read from client: 1 bytes read"
4524
4525requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4526requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004527run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004528 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004529 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004530 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004531 0 \
4532 -s "Read from client: 1 bytes read"
4533
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004534# Tests for small server packets
4535
4536requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4537run_test "Small server packet SSLv3 BlockCipher" \
4538 "$P_SRV response_size=1 min_version=ssl3" \
4539 "$P_CLI force_version=ssl3 \
4540 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4541 0 \
4542 -c "Read from server: 1 bytes read"
4543
4544requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4545run_test "Small server packet SSLv3 StreamCipher" \
4546 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4547 "$P_CLI force_version=ssl3 \
4548 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4549 0 \
4550 -c "Read from server: 1 bytes read"
4551
4552run_test "Small server packet TLS 1.0 BlockCipher" \
4553 "$P_SRV response_size=1" \
4554 "$P_CLI force_version=tls1 \
4555 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4556 0 \
4557 -c "Read from server: 1 bytes read"
4558
4559run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4560 "$P_SRV response_size=1" \
4561 "$P_CLI force_version=tls1 etm=0 \
4562 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4563 0 \
4564 -c "Read from server: 1 bytes read"
4565
4566requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4567run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4568 "$P_SRV response_size=1 trunc_hmac=1" \
4569 "$P_CLI force_version=tls1 \
4570 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4571 0 \
4572 -c "Read from server: 1 bytes read"
4573
4574requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4575run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4576 "$P_SRV response_size=1 trunc_hmac=1" \
4577 "$P_CLI force_version=tls1 \
4578 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4579 0 \
4580 -c "Read from server: 1 bytes read"
4581
4582run_test "Small server packet TLS 1.0 StreamCipher" \
4583 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4584 "$P_CLI force_version=tls1 \
4585 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4586 0 \
4587 -c "Read from server: 1 bytes read"
4588
4589run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4590 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4591 "$P_CLI force_version=tls1 \
4592 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4593 0 \
4594 -c "Read from server: 1 bytes read"
4595
4596requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4597run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4598 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4599 "$P_CLI force_version=tls1 \
4600 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4601 0 \
4602 -c "Read from server: 1 bytes read"
4603
4604requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4605run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4606 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4607 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4608 trunc_hmac=1 etm=0" \
4609 0 \
4610 -c "Read from server: 1 bytes read"
4611
4612run_test "Small server packet TLS 1.1 BlockCipher" \
4613 "$P_SRV response_size=1" \
4614 "$P_CLI force_version=tls1_1 \
4615 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4616 0 \
4617 -c "Read from server: 1 bytes read"
4618
4619run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4620 "$P_SRV response_size=1" \
4621 "$P_CLI force_version=tls1_1 \
4622 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4623 0 \
4624 -c "Read from server: 1 bytes read"
4625
4626requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4627run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4628 "$P_SRV response_size=1 trunc_hmac=1" \
4629 "$P_CLI force_version=tls1_1 \
4630 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4631 0 \
4632 -c "Read from server: 1 bytes read"
4633
4634requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4635run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4636 "$P_SRV response_size=1 trunc_hmac=1" \
4637 "$P_CLI force_version=tls1_1 \
4638 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4639 0 \
4640 -c "Read from server: 1 bytes read"
4641
4642run_test "Small server packet TLS 1.1 StreamCipher" \
4643 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4644 "$P_CLI force_version=tls1_1 \
4645 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4646 0 \
4647 -c "Read from server: 1 bytes read"
4648
4649run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4650 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4651 "$P_CLI force_version=tls1_1 \
4652 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4653 0 \
4654 -c "Read from server: 1 bytes read"
4655
4656requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4657run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4658 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4659 "$P_CLI force_version=tls1_1 \
4660 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4661 0 \
4662 -c "Read from server: 1 bytes read"
4663
4664requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4665run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4666 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4667 "$P_CLI force_version=tls1_1 \
4668 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4669 0 \
4670 -c "Read from server: 1 bytes read"
4671
4672run_test "Small server packet TLS 1.2 BlockCipher" \
4673 "$P_SRV response_size=1" \
4674 "$P_CLI force_version=tls1_2 \
4675 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4676 0 \
4677 -c "Read from server: 1 bytes read"
4678
4679run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4680 "$P_SRV response_size=1" \
4681 "$P_CLI force_version=tls1_2 \
4682 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4683 0 \
4684 -c "Read from server: 1 bytes read"
4685
4686run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4687 "$P_SRV response_size=1" \
4688 "$P_CLI force_version=tls1_2 \
4689 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4690 0 \
4691 -c "Read from server: 1 bytes read"
4692
4693requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4694run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4695 "$P_SRV response_size=1 trunc_hmac=1" \
4696 "$P_CLI force_version=tls1_2 \
4697 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4698 0 \
4699 -c "Read from server: 1 bytes read"
4700
4701requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4702run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4703 "$P_SRV response_size=1 trunc_hmac=1" \
4704 "$P_CLI force_version=tls1_2 \
4705 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4706 0 \
4707 -c "Read from server: 1 bytes read"
4708
4709run_test "Small server packet TLS 1.2 StreamCipher" \
4710 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4711 "$P_CLI force_version=tls1_2 \
4712 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4713 0 \
4714 -c "Read from server: 1 bytes read"
4715
4716run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4717 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4718 "$P_CLI force_version=tls1_2 \
4719 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4720 0 \
4721 -c "Read from server: 1 bytes read"
4722
4723requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4724run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4725 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4726 "$P_CLI force_version=tls1_2 \
4727 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4728 0 \
4729 -c "Read from server: 1 bytes read"
4730
4731requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4732run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4733 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4734 "$P_CLI force_version=tls1_2 \
4735 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4736 0 \
4737 -c "Read from server: 1 bytes read"
4738
4739run_test "Small server packet TLS 1.2 AEAD" \
4740 "$P_SRV response_size=1" \
4741 "$P_CLI force_version=tls1_2 \
4742 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4743 0 \
4744 -c "Read from server: 1 bytes read"
4745
4746run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4747 "$P_SRV response_size=1" \
4748 "$P_CLI force_version=tls1_2 \
4749 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4750 0 \
4751 -c "Read from server: 1 bytes read"
4752
4753# Tests for small server packets in DTLS
4754
4755requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4756run_test "Small server packet DTLS 1.0" \
4757 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4758 "$P_CLI dtls=1 \
4759 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4760 0 \
4761 -c "Read from server: 1 bytes read"
4762
4763requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4764run_test "Small server packet DTLS 1.0, without EtM" \
4765 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4766 "$P_CLI dtls=1 \
4767 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4768 0 \
4769 -c "Read from server: 1 bytes read"
4770
4771requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4772requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4773run_test "Small server packet DTLS 1.0, truncated hmac" \
4774 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4775 "$P_CLI dtls=1 trunc_hmac=1 \
4776 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4777 0 \
4778 -c "Read from server: 1 bytes read"
4779
4780requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4781requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4782run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4783 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4784 "$P_CLI dtls=1 \
4785 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4786 0 \
4787 -c "Read from server: 1 bytes read"
4788
4789requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4790run_test "Small server packet DTLS 1.2" \
4791 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4792 "$P_CLI dtls=1 \
4793 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4794 0 \
4795 -c "Read from server: 1 bytes read"
4796
4797requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4798run_test "Small server packet DTLS 1.2, without EtM" \
4799 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4800 "$P_CLI dtls=1 \
4801 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4802 0 \
4803 -c "Read from server: 1 bytes read"
4804
4805requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4806requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4807run_test "Small server packet DTLS 1.2, truncated hmac" \
4808 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4809 "$P_CLI dtls=1 \
4810 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4811 0 \
4812 -c "Read from server: 1 bytes read"
4813
4814requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4815requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4816run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4817 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4818 "$P_CLI dtls=1 \
4819 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4820 0 \
4821 -c "Read from server: 1 bytes read"
4822
Janos Follath00efff72016-05-06 13:48:23 +01004823# A test for extensions in SSLv3
4824
4825requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4826run_test "SSLv3 with extensions, server side" \
4827 "$P_SRV min_version=ssl3 debug_level=3" \
4828 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4829 0 \
4830 -S "dumping 'client hello extensions'" \
4831 -S "server hello, total extension length:"
4832
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004833# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004834
Angus Grattonc4dd0732018-04-11 16:28:39 +10004835# How many fragments do we expect to write $1 bytes?
4836fragments_for_write() {
4837 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4838}
4839
Janos Follathe2681a42016-03-07 15:57:05 +00004840requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004841run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004842 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004843 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004844 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4845 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004846 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4847 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004848
Janos Follathe2681a42016-03-07 15:57:05 +00004849requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004850run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004851 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004852 "$P_CLI request_size=16384 force_version=ssl3 \
4853 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4854 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004855 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4856 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004857
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004858run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004859 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004860 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004861 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4862 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004863 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4864 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004865
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004866run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004867 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004868 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4869 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4870 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004871 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004872
Hanno Becker32c55012017-11-10 08:42:54 +00004873requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004874run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004875 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004876 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004877 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004878 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004879 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4880 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004881
Hanno Becker32c55012017-11-10 08:42:54 +00004882requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004883run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004884 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004885 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004886 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004887 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004888 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004889
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004890run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004891 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004892 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004893 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4894 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004895 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004896
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004897run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004898 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4899 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004900 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004901 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004902 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004903
4904requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004905run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004906 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004907 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004908 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004909 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004910 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004911
Hanno Becker278fc7a2017-11-10 09:16:28 +00004912requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004913run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004914 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004915 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004916 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004917 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004918 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4919 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004920
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004921run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004922 "$P_SRV" \
4923 "$P_CLI request_size=16384 force_version=tls1_1 \
4924 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4925 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004926 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4927 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004928
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004929run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004930 "$P_SRV" \
4931 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4932 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004933 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004934 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004935
Hanno Becker32c55012017-11-10 08:42:54 +00004936requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004937run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004938 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004939 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004940 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004941 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004942 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004943
Hanno Becker32c55012017-11-10 08:42:54 +00004944requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004945run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004946 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004947 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004948 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004949 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004950 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004951
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004952run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004953 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4954 "$P_CLI request_size=16384 force_version=tls1_1 \
4955 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4956 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004957 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4958 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004959
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004960run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004961 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004962 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004963 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004964 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004965 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4966 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004967
Hanno Becker278fc7a2017-11-10 09:16:28 +00004968requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004969run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004970 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004971 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004972 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004973 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004974 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004975
Hanno Becker278fc7a2017-11-10 09:16:28 +00004976requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004977run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004978 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004979 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004980 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004981 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004982 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4983 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004984
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004985run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004986 "$P_SRV" \
4987 "$P_CLI request_size=16384 force_version=tls1_2 \
4988 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4989 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004990 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4991 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004992
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004993run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004994 "$P_SRV" \
4995 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4996 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4997 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004998 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004999
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005000run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005001 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005002 "$P_CLI request_size=16384 force_version=tls1_2 \
5003 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005004 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005005 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5006 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005007
Hanno Becker32c55012017-11-10 08:42:54 +00005008requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005009run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005010 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005011 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005012 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005013 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005014 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005015
Hanno Becker278fc7a2017-11-10 09:16:28 +00005016requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005017run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005018 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005019 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005020 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005021 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005022 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5023 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005024
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005025run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005026 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005027 "$P_CLI request_size=16384 force_version=tls1_2 \
5028 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5029 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005030 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5031 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005032
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005033run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005034 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005035 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005036 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5037 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005038 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005039
Hanno Becker32c55012017-11-10 08:42:54 +00005040requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005041run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005042 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005043 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005044 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005045 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005046 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005047
Hanno Becker278fc7a2017-11-10 09:16:28 +00005048requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005049run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005050 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005051 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005052 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005053 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005054 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5055 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005056
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005057run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005058 "$P_SRV" \
5059 "$P_CLI request_size=16384 force_version=tls1_2 \
5060 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5061 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005062 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5063 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005064
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005065run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005066 "$P_SRV" \
5067 "$P_CLI request_size=16384 force_version=tls1_2 \
5068 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5069 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005070 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5071 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005072
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005073# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005074requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5075run_test "Large server packet SSLv3 StreamCipher" \
5076 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5077 "$P_CLI force_version=ssl3 \
5078 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5079 0 \
5080 -c "Read from server: 16384 bytes read"
5081
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04005082# Checking next 4 tests logs for 1n-1 split against BEAST too
5083requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5084run_test "Large server packet SSLv3 BlockCipher" \
5085 "$P_SRV response_size=16384 min_version=ssl3" \
5086 "$P_CLI force_version=ssl3 recsplit=0 \
5087 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5088 0 \
5089 -c "Read from server: 1 bytes read"\
5090 -c "16383 bytes read"\
5091 -C "Read from server: 16384 bytes read"
5092
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005093run_test "Large server packet TLS 1.0 BlockCipher" \
5094 "$P_SRV response_size=16384" \
5095 "$P_CLI force_version=tls1 recsplit=0 \
5096 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5097 0 \
5098 -c "Read from server: 1 bytes read"\
5099 -c "16383 bytes read"\
5100 -C "Read from server: 16384 bytes read"
5101
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005102run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5103 "$P_SRV response_size=16384" \
5104 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5105 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5106 0 \
5107 -c "Read from server: 1 bytes read"\
5108 -c "16383 bytes read"\
5109 -C "Read from server: 16384 bytes read"
5110
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005111requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5112run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5113 "$P_SRV response_size=16384" \
5114 "$P_CLI force_version=tls1 recsplit=0 \
5115 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5116 trunc_hmac=1" \
5117 0 \
5118 -c "Read from server: 1 bytes read"\
5119 -c "16383 bytes read"\
5120 -C "Read from server: 16384 bytes read"
5121
5122requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5123run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5124 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5125 "$P_CLI force_version=tls1 \
5126 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5127 trunc_hmac=1" \
5128 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005129 -s "16384 bytes written in 1 fragments" \
5130 -c "Read from server: 16384 bytes read"
5131
5132run_test "Large server packet TLS 1.0 StreamCipher" \
5133 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5134 "$P_CLI force_version=tls1 \
5135 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5136 0 \
5137 -s "16384 bytes written in 1 fragments" \
5138 -c "Read from server: 16384 bytes read"
5139
5140run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5141 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5142 "$P_CLI force_version=tls1 \
5143 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5144 0 \
5145 -s "16384 bytes written in 1 fragments" \
5146 -c "Read from server: 16384 bytes read"
5147
5148requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5149run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5150 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5151 "$P_CLI force_version=tls1 \
5152 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5153 0 \
5154 -s "16384 bytes written in 1 fragments" \
5155 -c "Read from server: 16384 bytes read"
5156
5157requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5158run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5159 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5160 "$P_CLI force_version=tls1 \
5161 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5162 0 \
5163 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005164 -c "Read from server: 16384 bytes read"
5165
5166run_test "Large server packet TLS 1.1 BlockCipher" \
5167 "$P_SRV response_size=16384" \
5168 "$P_CLI force_version=tls1_1 \
5169 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5170 0 \
5171 -c "Read from server: 16384 bytes read"
5172
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005173run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5174 "$P_SRV response_size=16384" \
5175 "$P_CLI force_version=tls1_1 etm=0 \
5176 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005177 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005178 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005179 -c "Read from server: 16384 bytes read"
5180
5181requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5182run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5183 "$P_SRV response_size=16384" \
5184 "$P_CLI force_version=tls1_1 \
5185 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5186 trunc_hmac=1" \
5187 0 \
5188 -c "Read from server: 16384 bytes read"
5189
5190requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005191run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5192 "$P_SRV response_size=16384 trunc_hmac=1" \
5193 "$P_CLI force_version=tls1_1 \
5194 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5195 0 \
5196 -s "16384 bytes written in 1 fragments" \
5197 -c "Read from server: 16384 bytes read"
5198
5199run_test "Large server packet TLS 1.1 StreamCipher" \
5200 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5201 "$P_CLI force_version=tls1_1 \
5202 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5203 0 \
5204 -c "Read from server: 16384 bytes read"
5205
5206run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5207 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5208 "$P_CLI force_version=tls1_1 \
5209 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5210 0 \
5211 -s "16384 bytes written in 1 fragments" \
5212 -c "Read from server: 16384 bytes read"
5213
5214requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005215run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5216 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5217 "$P_CLI force_version=tls1_1 \
5218 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5219 trunc_hmac=1" \
5220 0 \
5221 -c "Read from server: 16384 bytes read"
5222
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005223run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5224 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5225 "$P_CLI force_version=tls1_1 \
5226 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5227 0 \
5228 -s "16384 bytes written in 1 fragments" \
5229 -c "Read from server: 16384 bytes read"
5230
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005231run_test "Large server packet TLS 1.2 BlockCipher" \
5232 "$P_SRV response_size=16384" \
5233 "$P_CLI force_version=tls1_2 \
5234 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5235 0 \
5236 -c "Read from server: 16384 bytes read"
5237
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005238run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5239 "$P_SRV response_size=16384" \
5240 "$P_CLI force_version=tls1_2 etm=0 \
5241 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5242 0 \
5243 -s "16384 bytes written in 1 fragments" \
5244 -c "Read from server: 16384 bytes read"
5245
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005246run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5247 "$P_SRV response_size=16384" \
5248 "$P_CLI force_version=tls1_2 \
5249 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5250 0 \
5251 -c "Read from server: 16384 bytes read"
5252
5253requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5254run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5255 "$P_SRV response_size=16384" \
5256 "$P_CLI force_version=tls1_2 \
5257 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5258 trunc_hmac=1" \
5259 0 \
5260 -c "Read from server: 16384 bytes read"
5261
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005262run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5263 "$P_SRV response_size=16384 trunc_hmac=1" \
5264 "$P_CLI force_version=tls1_2 \
5265 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5266 0 \
5267 -s "16384 bytes written in 1 fragments" \
5268 -c "Read from server: 16384 bytes read"
5269
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005270run_test "Large server packet TLS 1.2 StreamCipher" \
5271 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5272 "$P_CLI force_version=tls1_2 \
5273 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5274 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005275 -s "16384 bytes written in 1 fragments" \
5276 -c "Read from server: 16384 bytes read"
5277
5278run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5279 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5280 "$P_CLI force_version=tls1_2 \
5281 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5282 0 \
5283 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005284 -c "Read from server: 16384 bytes read"
5285
5286requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5287run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5288 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5289 "$P_CLI force_version=tls1_2 \
5290 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5291 trunc_hmac=1" \
5292 0 \
5293 -c "Read from server: 16384 bytes read"
5294
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005295requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5296run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5297 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5298 "$P_CLI force_version=tls1_2 \
5299 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5300 0 \
5301 -s "16384 bytes written in 1 fragments" \
5302 -c "Read from server: 16384 bytes read"
5303
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005304run_test "Large server packet TLS 1.2 AEAD" \
5305 "$P_SRV response_size=16384" \
5306 "$P_CLI force_version=tls1_2 \
5307 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5308 0 \
5309 -c "Read from server: 16384 bytes read"
5310
5311run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5312 "$P_SRV response_size=16384" \
5313 "$P_CLI force_version=tls1_2 \
5314 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5315 0 \
5316 -c "Read from server: 16384 bytes read"
5317
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005318# Tests for restartable ECC
5319
5320requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5321run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005322 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005323 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005324 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005325 debug_level=1" \
5326 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005327 -C "x509_verify_cert.*4b00" \
5328 -C "mbedtls_pk_verify.*4b00" \
5329 -C "mbedtls_ecdh_make_public.*4b00" \
5330 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005331
5332requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5333run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005334 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005335 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005336 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005337 debug_level=1 ec_max_ops=0" \
5338 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005339 -C "x509_verify_cert.*4b00" \
5340 -C "mbedtls_pk_verify.*4b00" \
5341 -C "mbedtls_ecdh_make_public.*4b00" \
5342 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005343
5344requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5345run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005346 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005347 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005348 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005349 debug_level=1 ec_max_ops=65535" \
5350 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005351 -C "x509_verify_cert.*4b00" \
5352 -C "mbedtls_pk_verify.*4b00" \
5353 -C "mbedtls_ecdh_make_public.*4b00" \
5354 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005355
5356requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5357run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005358 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005359 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005360 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005361 debug_level=1 ec_max_ops=1000" \
5362 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005363 -c "x509_verify_cert.*4b00" \
5364 -c "mbedtls_pk_verify.*4b00" \
5365 -c "mbedtls_ecdh_make_public.*4b00" \
5366 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005367
5368requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005369run_test "EC restart: TLS, max_ops=1000, badsign" \
5370 "$P_SRV auth_mode=required \
5371 crt_file=data_files/server5-badsign.crt \
5372 key_file=data_files/server5.key" \
5373 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5374 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5375 debug_level=1 ec_max_ops=1000" \
5376 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005377 -c "x509_verify_cert.*4b00" \
5378 -C "mbedtls_pk_verify.*4b00" \
5379 -C "mbedtls_ecdh_make_public.*4b00" \
5380 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005381 -c "! The certificate is not correctly signed by the trusted CA" \
5382 -c "! mbedtls_ssl_handshake returned" \
5383 -c "X509 - Certificate verification failed"
5384
5385requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5386run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5387 "$P_SRV auth_mode=required \
5388 crt_file=data_files/server5-badsign.crt \
5389 key_file=data_files/server5.key" \
5390 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5391 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5392 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5393 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005394 -c "x509_verify_cert.*4b00" \
5395 -c "mbedtls_pk_verify.*4b00" \
5396 -c "mbedtls_ecdh_make_public.*4b00" \
5397 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005398 -c "! The certificate is not correctly signed by the trusted CA" \
5399 -C "! mbedtls_ssl_handshake returned" \
5400 -C "X509 - Certificate verification failed"
5401
5402requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5403run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5404 "$P_SRV auth_mode=required \
5405 crt_file=data_files/server5-badsign.crt \
5406 key_file=data_files/server5.key" \
5407 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5408 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5409 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5410 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005411 -C "x509_verify_cert.*4b00" \
5412 -c "mbedtls_pk_verify.*4b00" \
5413 -c "mbedtls_ecdh_make_public.*4b00" \
5414 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005415 -C "! The certificate is not correctly signed by the trusted CA" \
5416 -C "! mbedtls_ssl_handshake returned" \
5417 -C "X509 - Certificate verification failed"
5418
5419requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005420run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005421 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005422 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005423 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005424 dtls=1 debug_level=1 ec_max_ops=1000" \
5425 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005426 -c "x509_verify_cert.*4b00" \
5427 -c "mbedtls_pk_verify.*4b00" \
5428 -c "mbedtls_ecdh_make_public.*4b00" \
5429 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005430
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005431requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5432run_test "EC restart: TLS, max_ops=1000 no client auth" \
5433 "$P_SRV" \
5434 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5435 debug_level=1 ec_max_ops=1000" \
5436 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005437 -c "x509_verify_cert.*4b00" \
5438 -c "mbedtls_pk_verify.*4b00" \
5439 -c "mbedtls_ecdh_make_public.*4b00" \
5440 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005441
5442requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5443run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5444 "$P_SRV psk=abc123" \
5445 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5446 psk=abc123 debug_level=1 ec_max_ops=1000" \
5447 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005448 -C "x509_verify_cert.*4b00" \
5449 -C "mbedtls_pk_verify.*4b00" \
5450 -C "mbedtls_ecdh_make_public.*4b00" \
5451 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005452
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005453# Tests of asynchronous private key support in SSL
5454
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005455requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005456run_test "SSL async private: sign, delay=0" \
5457 "$P_SRV \
5458 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005459 "$P_CLI" \
5460 0 \
5461 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005462 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005463
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005464requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005465run_test "SSL async private: sign, delay=1" \
5466 "$P_SRV \
5467 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005468 "$P_CLI" \
5469 0 \
5470 -s "Async sign callback: using key slot " \
5471 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005472 -s "Async resume (slot [0-9]): sign done, status=0"
5473
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005474requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5475run_test "SSL async private: sign, delay=2" \
5476 "$P_SRV \
5477 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5478 "$P_CLI" \
5479 0 \
5480 -s "Async sign callback: using key slot " \
5481 -U "Async sign callback: using key slot " \
5482 -s "Async resume (slot [0-9]): call 1 more times." \
5483 -s "Async resume (slot [0-9]): call 0 more times." \
5484 -s "Async resume (slot [0-9]): sign done, status=0"
5485
Gilles Peskined3268832018-04-26 06:23:59 +02005486# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5487# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5488requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5489requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5490run_test "SSL async private: sign, RSA, TLS 1.1" \
5491 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5492 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5493 "$P_CLI force_version=tls1_1" \
5494 0 \
5495 -s "Async sign callback: using key slot " \
5496 -s "Async resume (slot [0-9]): sign done, status=0"
5497
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005498requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005499run_test "SSL async private: sign, SNI" \
5500 "$P_SRV debug_level=3 \
5501 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5502 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5503 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5504 "$P_CLI server_name=polarssl.example" \
5505 0 \
5506 -s "Async sign callback: using key slot " \
5507 -s "Async resume (slot [0-9]): sign done, status=0" \
5508 -s "parse ServerName extension" \
5509 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5510 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5511
5512requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005513run_test "SSL async private: decrypt, delay=0" \
5514 "$P_SRV \
5515 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5516 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5517 0 \
5518 -s "Async decrypt callback: using key slot " \
5519 -s "Async resume (slot [0-9]): decrypt done, status=0"
5520
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005521requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005522run_test "SSL async private: decrypt, delay=1" \
5523 "$P_SRV \
5524 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5525 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5526 0 \
5527 -s "Async decrypt callback: using key slot " \
5528 -s "Async resume (slot [0-9]): call 0 more times." \
5529 -s "Async resume (slot [0-9]): decrypt done, status=0"
5530
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005531requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005532run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5533 "$P_SRV psk=abc123 \
5534 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5535 "$P_CLI psk=abc123 \
5536 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5537 0 \
5538 -s "Async decrypt callback: using key slot " \
5539 -s "Async resume (slot [0-9]): decrypt done, status=0"
5540
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005541requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005542run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5543 "$P_SRV psk=abc123 \
5544 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5545 "$P_CLI psk=abc123 \
5546 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5547 0 \
5548 -s "Async decrypt callback: using key slot " \
5549 -s "Async resume (slot [0-9]): call 0 more times." \
5550 -s "Async resume (slot [0-9]): decrypt done, status=0"
5551
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005552requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005553run_test "SSL async private: sign callback not present" \
5554 "$P_SRV \
5555 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5556 "$P_CLI; [ \$? -eq 1 ] &&
5557 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5558 0 \
5559 -S "Async sign callback" \
5560 -s "! mbedtls_ssl_handshake returned" \
5561 -s "The own private key or pre-shared key is not set, but needed" \
5562 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5563 -s "Successful connection"
5564
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005565requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005566run_test "SSL async private: decrypt callback not present" \
5567 "$P_SRV debug_level=1 \
5568 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5569 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5570 [ \$? -eq 1 ] && $P_CLI" \
5571 0 \
5572 -S "Async decrypt callback" \
5573 -s "! mbedtls_ssl_handshake returned" \
5574 -s "got no RSA private key" \
5575 -s "Async resume (slot [0-9]): sign done, status=0" \
5576 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005577
5578# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005579requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005580run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005581 "$P_SRV \
5582 async_operations=s async_private_delay1=1 \
5583 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5584 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005585 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5586 0 \
5587 -s "Async sign callback: using key slot 0," \
5588 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005589 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005590
5591# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005592requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005593run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005594 "$P_SRV \
5595 async_operations=s async_private_delay2=1 \
5596 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5597 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005598 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5599 0 \
5600 -s "Async sign callback: using key slot 0," \
5601 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005602 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005603
5604# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005605requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005606run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005607 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005608 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005609 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5610 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005611 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5612 0 \
5613 -s "Async sign callback: using key slot 1," \
5614 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005615 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005616
5617# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005618requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005619run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005620 "$P_SRV \
5621 async_operations=s async_private_delay1=1 \
5622 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5623 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005624 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5625 0 \
5626 -s "Async sign callback: no key matches this certificate."
5627
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005628requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005629run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005630 "$P_SRV \
5631 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5632 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005633 "$P_CLI" \
5634 1 \
5635 -s "Async sign callback: injected error" \
5636 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005637 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005638 -s "! mbedtls_ssl_handshake returned"
5639
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005640requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005641run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005642 "$P_SRV \
5643 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5644 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005645 "$P_CLI" \
5646 1 \
5647 -s "Async sign callback: using key slot " \
5648 -S "Async resume" \
5649 -s "Async cancel"
5650
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005651requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005652run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005653 "$P_SRV \
5654 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5655 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005656 "$P_CLI" \
5657 1 \
5658 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005659 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005660 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005661 -s "! mbedtls_ssl_handshake returned"
5662
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005663requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005664run_test "SSL async private: decrypt, error in start" \
5665 "$P_SRV \
5666 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5667 async_private_error=1" \
5668 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5669 1 \
5670 -s "Async decrypt callback: injected error" \
5671 -S "Async resume" \
5672 -S "Async cancel" \
5673 -s "! mbedtls_ssl_handshake returned"
5674
5675requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5676run_test "SSL async private: decrypt, cancel after start" \
5677 "$P_SRV \
5678 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5679 async_private_error=2" \
5680 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5681 1 \
5682 -s "Async decrypt callback: using key slot " \
5683 -S "Async resume" \
5684 -s "Async cancel"
5685
5686requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5687run_test "SSL async private: decrypt, error in resume" \
5688 "$P_SRV \
5689 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5690 async_private_error=3" \
5691 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5692 1 \
5693 -s "Async decrypt callback: using key slot " \
5694 -s "Async resume callback: decrypt done but injected error" \
5695 -S "Async cancel" \
5696 -s "! mbedtls_ssl_handshake returned"
5697
5698requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005699run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005700 "$P_SRV \
5701 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5702 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005703 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5704 0 \
5705 -s "Async cancel" \
5706 -s "! mbedtls_ssl_handshake returned" \
5707 -s "Async resume" \
5708 -s "Successful connection"
5709
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005710requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005711run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005712 "$P_SRV \
5713 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5714 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005715 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5716 0 \
5717 -s "! mbedtls_ssl_handshake returned" \
5718 -s "Async resume" \
5719 -s "Successful connection"
5720
5721# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005722requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005723run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005724 "$P_SRV \
5725 async_operations=s async_private_delay1=1 async_private_error=-2 \
5726 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5727 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005728 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5729 [ \$? -eq 1 ] &&
5730 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5731 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005732 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005733 -S "Async resume" \
5734 -s "Async cancel" \
5735 -s "! mbedtls_ssl_handshake returned" \
5736 -s "Async sign callback: no key matches this certificate." \
5737 -s "Successful connection"
5738
5739# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005740requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005741run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005742 "$P_SRV \
5743 async_operations=s async_private_delay1=1 async_private_error=-3 \
5744 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5745 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005746 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5747 [ \$? -eq 1 ] &&
5748 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5749 0 \
5750 -s "Async resume" \
5751 -s "! mbedtls_ssl_handshake returned" \
5752 -s "Async sign callback: no key matches this certificate." \
5753 -s "Successful connection"
5754
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005755requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005756requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005757run_test "SSL async private: renegotiation: client-initiated; sign" \
5758 "$P_SRV \
5759 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005760 exchanges=2 renegotiation=1" \
5761 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5762 0 \
5763 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005764 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005765
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005766requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005767requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005768run_test "SSL async private: renegotiation: server-initiated; sign" \
5769 "$P_SRV \
5770 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005771 exchanges=2 renegotiation=1 renegotiate=1" \
5772 "$P_CLI exchanges=2 renegotiation=1" \
5773 0 \
5774 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005775 -s "Async resume (slot [0-9]): sign done, status=0"
5776
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005777requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005778requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5779run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5780 "$P_SRV \
5781 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5782 exchanges=2 renegotiation=1" \
5783 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5784 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5785 0 \
5786 -s "Async decrypt callback: using key slot " \
5787 -s "Async resume (slot [0-9]): decrypt done, status=0"
5788
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005789requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005790requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5791run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5792 "$P_SRV \
5793 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5794 exchanges=2 renegotiation=1 renegotiate=1" \
5795 "$P_CLI exchanges=2 renegotiation=1 \
5796 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5797 0 \
5798 -s "Async decrypt callback: using key slot " \
5799 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005800
Ron Eldor58093c82018-06-28 13:22:05 +03005801# Tests for ECC extensions (rfc 4492)
5802
Ron Eldor643df7c2018-06-28 16:17:00 +03005803requires_config_enabled MBEDTLS_AES_C
5804requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5805requires_config_enabled MBEDTLS_SHA256_C
5806requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005807run_test "Force a non ECC ciphersuite in the client side" \
5808 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005809 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005810 0 \
5811 -C "client hello, adding supported_elliptic_curves extension" \
5812 -C "client hello, adding supported_point_formats extension" \
5813 -S "found supported elliptic curves extension" \
5814 -S "found supported point formats extension"
5815
Ron Eldor643df7c2018-06-28 16:17:00 +03005816requires_config_enabled MBEDTLS_AES_C
5817requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5818requires_config_enabled MBEDTLS_SHA256_C
5819requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005820run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005821 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005822 "$P_CLI debug_level=3" \
5823 0 \
5824 -C "found supported_point_formats extension" \
5825 -S "server hello, supported_point_formats extension"
5826
Ron Eldor643df7c2018-06-28 16:17:00 +03005827requires_config_enabled MBEDTLS_AES_C
5828requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5829requires_config_enabled MBEDTLS_SHA256_C
5830requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005831run_test "Force an ECC ciphersuite in the client side" \
5832 "$P_SRV debug_level=3" \
5833 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5834 0 \
5835 -c "client hello, adding supported_elliptic_curves extension" \
5836 -c "client hello, adding supported_point_formats extension" \
5837 -s "found supported elliptic curves extension" \
5838 -s "found supported point formats extension"
5839
Ron Eldor643df7c2018-06-28 16:17:00 +03005840requires_config_enabled MBEDTLS_AES_C
5841requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5842requires_config_enabled MBEDTLS_SHA256_C
5843requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005844run_test "Force an ECC ciphersuite in the server side" \
5845 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5846 "$P_CLI debug_level=3" \
5847 0 \
5848 -c "found supported_point_formats extension" \
5849 -s "server hello, supported_point_formats extension"
5850
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005851# Tests for DTLS HelloVerifyRequest
5852
5853run_test "DTLS cookie: enabled" \
5854 "$P_SRV dtls=1 debug_level=2" \
5855 "$P_CLI dtls=1 debug_level=2" \
5856 0 \
5857 -s "cookie verification failed" \
5858 -s "cookie verification passed" \
5859 -S "cookie verification skipped" \
5860 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005861 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005862 -S "SSL - The requested feature is not available"
5863
5864run_test "DTLS cookie: disabled" \
5865 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5866 "$P_CLI dtls=1 debug_level=2" \
5867 0 \
5868 -S "cookie verification failed" \
5869 -S "cookie verification passed" \
5870 -s "cookie verification skipped" \
5871 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005872 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005873 -S "SSL - The requested feature is not available"
5874
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005875run_test "DTLS cookie: default (failing)" \
5876 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5877 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5878 1 \
5879 -s "cookie verification failed" \
5880 -S "cookie verification passed" \
5881 -S "cookie verification skipped" \
5882 -C "received hello verify request" \
5883 -S "hello verification requested" \
5884 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005885
5886requires_ipv6
5887run_test "DTLS cookie: enabled, IPv6" \
5888 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5889 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5890 0 \
5891 -s "cookie verification failed" \
5892 -s "cookie verification passed" \
5893 -S "cookie verification skipped" \
5894 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005895 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005896 -S "SSL - The requested feature is not available"
5897
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005898run_test "DTLS cookie: enabled, nbio" \
5899 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5900 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5901 0 \
5902 -s "cookie verification failed" \
5903 -s "cookie verification passed" \
5904 -S "cookie verification skipped" \
5905 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005906 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005907 -S "SSL - The requested feature is not available"
5908
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005909# Tests for client reconnecting from the same port with DTLS
5910
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005911not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005912run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005913 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5914 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005915 0 \
5916 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005917 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005918 -S "Client initiated reconnection from same port"
5919
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005920not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005921run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005922 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5923 "$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 +02005924 0 \
5925 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005926 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005927 -s "Client initiated reconnection from same port"
5928
Paul Bakker362689d2016-05-13 10:33:25 +01005929not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5930run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005931 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5932 "$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 +02005933 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005934 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005935 -s "Client initiated reconnection from same port"
5936
Paul Bakker362689d2016-05-13 10:33:25 +01005937only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5938run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5939 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5940 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5941 0 \
5942 -S "The operation timed out" \
5943 -s "Client initiated reconnection from same port"
5944
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005945run_test "DTLS client reconnect from same port: no cookies" \
5946 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005947 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5948 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005949 -s "The operation timed out" \
5950 -S "Client initiated reconnection from same port"
5951
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005952run_test "DTLS client reconnect from same port: attacker-injected" \
5953 -p "$P_PXY inject_clihlo=1" \
5954 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5955 "$P_CLI dtls=1 exchanges=2" \
5956 0 \
5957 -s "possible client reconnect from the same port" \
5958 -S "Client initiated reconnection from same port"
5959
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005960# Tests for various cases of client authentication with DTLS
5961# (focused on handshake flows and message parsing)
5962
5963run_test "DTLS client auth: required" \
5964 "$P_SRV dtls=1 auth_mode=required" \
5965 "$P_CLI dtls=1" \
5966 0 \
5967 -s "Verifying peer X.509 certificate... ok"
5968
5969run_test "DTLS client auth: optional, client has no cert" \
5970 "$P_SRV dtls=1 auth_mode=optional" \
5971 "$P_CLI dtls=1 crt_file=none key_file=none" \
5972 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005973 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005974
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005975run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005976 "$P_SRV dtls=1 auth_mode=none" \
5977 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5978 0 \
5979 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005980 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005981
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005982run_test "DTLS wrong PSK: badmac alert" \
5983 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5984 "$P_CLI dtls=1 psk=abc124" \
5985 1 \
5986 -s "SSL - Verification of the message MAC failed" \
5987 -c "SSL - A fatal alert message was received from our peer"
5988
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005989# Tests for receiving fragmented handshake messages with DTLS
5990
5991requires_gnutls
5992run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5993 "$G_SRV -u --mtu 2048 -a" \
5994 "$P_CLI dtls=1 debug_level=2" \
5995 0 \
5996 -C "found fragmented DTLS handshake message" \
5997 -C "error"
5998
5999requires_gnutls
6000run_test "DTLS reassembly: some fragmentation (gnutls server)" \
6001 "$G_SRV -u --mtu 512" \
6002 "$P_CLI dtls=1 debug_level=2" \
6003 0 \
6004 -c "found fragmented DTLS handshake message" \
6005 -C "error"
6006
6007requires_gnutls
6008run_test "DTLS reassembly: more fragmentation (gnutls server)" \
6009 "$G_SRV -u --mtu 128" \
6010 "$P_CLI dtls=1 debug_level=2" \
6011 0 \
6012 -c "found fragmented DTLS handshake message" \
6013 -C "error"
6014
6015requires_gnutls
6016run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
6017 "$G_SRV -u --mtu 128" \
6018 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6019 0 \
6020 -c "found fragmented DTLS handshake message" \
6021 -C "error"
6022
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006023requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006024requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006025run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
6026 "$G_SRV -u --mtu 256" \
6027 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
6028 0 \
6029 -c "found fragmented DTLS handshake message" \
6030 -c "client hello, adding renegotiation extension" \
6031 -c "found renegotiation extension" \
6032 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006033 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006034 -C "error" \
6035 -s "Extra-header:"
6036
6037requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006038requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006039run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
6040 "$G_SRV -u --mtu 256" \
6041 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
6042 0 \
6043 -c "found fragmented DTLS handshake message" \
6044 -c "client hello, adding renegotiation extension" \
6045 -c "found renegotiation extension" \
6046 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006047 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006048 -C "error" \
6049 -s "Extra-header:"
6050
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006051run_test "DTLS reassembly: no fragmentation (openssl server)" \
6052 "$O_SRV -dtls1 -mtu 2048" \
6053 "$P_CLI dtls=1 debug_level=2" \
6054 0 \
6055 -C "found fragmented DTLS handshake message" \
6056 -C "error"
6057
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006058run_test "DTLS reassembly: some fragmentation (openssl server)" \
6059 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006060 "$P_CLI dtls=1 debug_level=2" \
6061 0 \
6062 -c "found fragmented DTLS handshake message" \
6063 -C "error"
6064
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006065run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006066 "$O_SRV -dtls1 -mtu 256" \
6067 "$P_CLI dtls=1 debug_level=2" \
6068 0 \
6069 -c "found fragmented DTLS handshake message" \
6070 -C "error"
6071
6072run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6073 "$O_SRV -dtls1 -mtu 256" \
6074 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6075 0 \
6076 -c "found fragmented DTLS handshake message" \
6077 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006078
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006079# Tests for sending fragmented handshake messages with DTLS
6080#
6081# Use client auth when we need the client to send large messages,
6082# and use large cert chains on both sides too (the long chains we have all use
6083# both RSA and ECDSA, but ideally we should have long chains with either).
6084# Sizes reached (UDP payload):
6085# - 2037B for server certificate
6086# - 1542B for client certificate
6087# - 1013B for newsessionticket
6088# - all others below 512B
6089# All those tests assume MAX_CONTENT_LEN is at least 2048
6090
6091requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6092requires_config_enabled MBEDTLS_RSA_C
6093requires_config_enabled MBEDTLS_ECDSA_C
6094requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6095run_test "DTLS fragmenting: none (for reference)" \
6096 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6097 crt_file=data_files/server7_int-ca.crt \
6098 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006099 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006100 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006101 "$P_CLI dtls=1 debug_level=2 \
6102 crt_file=data_files/server8_int-ca2.crt \
6103 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006104 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006105 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006106 0 \
6107 -S "found fragmented DTLS handshake message" \
6108 -C "found fragmented DTLS handshake message" \
6109 -C "error"
6110
6111requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6112requires_config_enabled MBEDTLS_RSA_C
6113requires_config_enabled MBEDTLS_ECDSA_C
6114requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006115run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006116 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6117 crt_file=data_files/server7_int-ca.crt \
6118 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006119 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006120 max_frag_len=1024" \
6121 "$P_CLI dtls=1 debug_level=2 \
6122 crt_file=data_files/server8_int-ca2.crt \
6123 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006124 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006125 max_frag_len=2048" \
6126 0 \
6127 -S "found fragmented DTLS handshake message" \
6128 -c "found fragmented DTLS handshake message" \
6129 -C "error"
6130
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006131# With the MFL extension, the server has no way of forcing
6132# the client to not exceed a certain MTU; hence, the following
6133# test can't be replicated with an MTU proxy such as the one
6134# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006135requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6136requires_config_enabled MBEDTLS_RSA_C
6137requires_config_enabled MBEDTLS_ECDSA_C
6138requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006139run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006140 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6141 crt_file=data_files/server7_int-ca.crt \
6142 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006143 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006144 max_frag_len=512" \
6145 "$P_CLI dtls=1 debug_level=2 \
6146 crt_file=data_files/server8_int-ca2.crt \
6147 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006148 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006149 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006150 0 \
6151 -S "found fragmented DTLS handshake message" \
6152 -c "found fragmented DTLS handshake message" \
6153 -C "error"
6154
6155requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6156requires_config_enabled MBEDTLS_RSA_C
6157requires_config_enabled MBEDTLS_ECDSA_C
6158requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006159run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006160 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6161 crt_file=data_files/server7_int-ca.crt \
6162 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006163 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006164 max_frag_len=2048" \
6165 "$P_CLI dtls=1 debug_level=2 \
6166 crt_file=data_files/server8_int-ca2.crt \
6167 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006168 hs_timeout=2500-60000 \
6169 max_frag_len=1024" \
6170 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006171 -S "found fragmented DTLS handshake message" \
6172 -c "found fragmented DTLS handshake message" \
6173 -C "error"
6174
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006175# While not required by the standard defining the MFL extension
6176# (according to which it only applies to records, not to datagrams),
6177# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6178# as otherwise there wouldn't be any means to communicate MTU restrictions
6179# to the peer.
6180# The next test checks that no datagrams significantly larger than the
6181# negotiated MFL are sent.
6182requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6183requires_config_enabled MBEDTLS_RSA_C
6184requires_config_enabled MBEDTLS_ECDSA_C
6185requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6186run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006187 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006188 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6189 crt_file=data_files/server7_int-ca.crt \
6190 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006191 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006192 max_frag_len=2048" \
6193 "$P_CLI dtls=1 debug_level=2 \
6194 crt_file=data_files/server8_int-ca2.crt \
6195 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006196 hs_timeout=2500-60000 \
6197 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006198 0 \
6199 -S "found fragmented DTLS handshake message" \
6200 -c "found fragmented DTLS handshake message" \
6201 -C "error"
6202
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006203requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6204requires_config_enabled MBEDTLS_RSA_C
6205requires_config_enabled MBEDTLS_ECDSA_C
6206requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006207run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006208 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6209 crt_file=data_files/server7_int-ca.crt \
6210 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006211 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006212 max_frag_len=2048" \
6213 "$P_CLI dtls=1 debug_level=2 \
6214 crt_file=data_files/server8_int-ca2.crt \
6215 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006216 hs_timeout=2500-60000 \
6217 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006218 0 \
6219 -s "found fragmented DTLS handshake message" \
6220 -c "found fragmented DTLS handshake message" \
6221 -C "error"
6222
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006223# While not required by the standard defining the MFL extension
6224# (according to which it only applies to records, not to datagrams),
6225# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6226# as otherwise there wouldn't be any means to communicate MTU restrictions
6227# to the peer.
6228# The next test checks that no datagrams significantly larger than the
6229# negotiated MFL are sent.
6230requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6231requires_config_enabled MBEDTLS_RSA_C
6232requires_config_enabled MBEDTLS_ECDSA_C
6233requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6234run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006235 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006236 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6237 crt_file=data_files/server7_int-ca.crt \
6238 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006239 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006240 max_frag_len=2048" \
6241 "$P_CLI dtls=1 debug_level=2 \
6242 crt_file=data_files/server8_int-ca2.crt \
6243 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006244 hs_timeout=2500-60000 \
6245 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006246 0 \
6247 -s "found fragmented DTLS handshake message" \
6248 -c "found fragmented DTLS handshake message" \
6249 -C "error"
6250
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006251requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6252requires_config_enabled MBEDTLS_RSA_C
6253requires_config_enabled MBEDTLS_ECDSA_C
6254run_test "DTLS fragmenting: none (for reference) (MTU)" \
6255 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6256 crt_file=data_files/server7_int-ca.crt \
6257 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006258 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006259 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006260 "$P_CLI dtls=1 debug_level=2 \
6261 crt_file=data_files/server8_int-ca2.crt \
6262 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006263 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006264 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006265 0 \
6266 -S "found fragmented DTLS handshake message" \
6267 -C "found fragmented DTLS handshake message" \
6268 -C "error"
6269
6270requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6271requires_config_enabled MBEDTLS_RSA_C
6272requires_config_enabled MBEDTLS_ECDSA_C
6273run_test "DTLS fragmenting: client (MTU)" \
6274 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6275 crt_file=data_files/server7_int-ca.crt \
6276 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006277 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006278 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006279 "$P_CLI dtls=1 debug_level=2 \
6280 crt_file=data_files/server8_int-ca2.crt \
6281 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006282 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006283 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006284 0 \
6285 -s "found fragmented DTLS handshake message" \
6286 -C "found fragmented DTLS handshake message" \
6287 -C "error"
6288
6289requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6290requires_config_enabled MBEDTLS_RSA_C
6291requires_config_enabled MBEDTLS_ECDSA_C
6292run_test "DTLS fragmenting: server (MTU)" \
6293 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6294 crt_file=data_files/server7_int-ca.crt \
6295 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006296 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006297 mtu=512" \
6298 "$P_CLI dtls=1 debug_level=2 \
6299 crt_file=data_files/server8_int-ca2.crt \
6300 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006301 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006302 mtu=2048" \
6303 0 \
6304 -S "found fragmented DTLS handshake message" \
6305 -c "found fragmented DTLS handshake message" \
6306 -C "error"
6307
6308requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6309requires_config_enabled MBEDTLS_RSA_C
6310requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006311run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006312 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006313 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6314 crt_file=data_files/server7_int-ca.crt \
6315 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006316 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006317 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006318 "$P_CLI dtls=1 debug_level=2 \
6319 crt_file=data_files/server8_int-ca2.crt \
6320 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006321 hs_timeout=2500-60000 \
6322 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006323 0 \
6324 -s "found fragmented DTLS handshake message" \
6325 -c "found fragmented DTLS handshake message" \
6326 -C "error"
6327
Andrzej Kurek77826052018-10-11 07:34:08 -04006328# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006329requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6330requires_config_enabled MBEDTLS_RSA_C
6331requires_config_enabled MBEDTLS_ECDSA_C
6332requires_config_enabled MBEDTLS_SHA256_C
6333requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6334requires_config_enabled MBEDTLS_AES_C
6335requires_config_enabled MBEDTLS_GCM_C
6336run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006337 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006338 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6339 crt_file=data_files/server7_int-ca.crt \
6340 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006341 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006342 mtu=512" \
6343 "$P_CLI dtls=1 debug_level=2 \
6344 crt_file=data_files/server8_int-ca2.crt \
6345 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006346 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6347 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006348 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006349 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006350 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006351 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006352 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006353
Andrzej Kurek7311c782018-10-11 06:49:41 -04006354# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006355# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006356# The ratio of max/min timeout should ideally equal 4 to accept two
6357# retransmissions, but in some cases (like both the server and client using
6358# fragmentation and auto-reduction) an extra retransmission might occur,
6359# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006360not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006361requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6362requires_config_enabled MBEDTLS_RSA_C
6363requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006364requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6365requires_config_enabled MBEDTLS_AES_C
6366requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006367run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6368 -p "$P_PXY mtu=508" \
6369 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6370 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006371 key_file=data_files/server7.key \
6372 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006373 "$P_CLI dtls=1 debug_level=2 \
6374 crt_file=data_files/server8_int-ca2.crt \
6375 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006376 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6377 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006378 0 \
6379 -s "found fragmented DTLS handshake message" \
6380 -c "found fragmented DTLS handshake message" \
6381 -C "error"
6382
Andrzej Kurek77826052018-10-11 07:34:08 -04006383# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006384only_with_valgrind
6385requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6386requires_config_enabled MBEDTLS_RSA_C
6387requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006388requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6389requires_config_enabled MBEDTLS_AES_C
6390requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006391run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6392 -p "$P_PXY mtu=508" \
6393 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6394 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006395 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006396 hs_timeout=250-10000" \
6397 "$P_CLI dtls=1 debug_level=2 \
6398 crt_file=data_files/server8_int-ca2.crt \
6399 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006400 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006401 hs_timeout=250-10000" \
6402 0 \
6403 -s "found fragmented DTLS handshake message" \
6404 -c "found fragmented DTLS handshake message" \
6405 -C "error"
6406
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006407# 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 +02006408# OTOH the client might resend if the server is to slow to reset after sending
6409# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006410not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006411requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6412requires_config_enabled MBEDTLS_RSA_C
6413requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006414run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006415 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006416 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6417 crt_file=data_files/server7_int-ca.crt \
6418 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006419 hs_timeout=10000-60000 \
6420 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006421 "$P_CLI dtls=1 debug_level=2 \
6422 crt_file=data_files/server8_int-ca2.crt \
6423 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006424 hs_timeout=10000-60000 \
6425 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006426 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006427 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006428 -s "found fragmented DTLS handshake message" \
6429 -c "found fragmented DTLS handshake message" \
6430 -C "error"
6431
Andrzej Kurek77826052018-10-11 07:34:08 -04006432# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006433# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6434# OTOH the client might resend if the server is to slow to reset after sending
6435# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006436not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006437requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6438requires_config_enabled MBEDTLS_RSA_C
6439requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006440requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6441requires_config_enabled MBEDTLS_AES_C
6442requires_config_enabled MBEDTLS_GCM_C
6443run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006444 -p "$P_PXY mtu=512" \
6445 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6446 crt_file=data_files/server7_int-ca.crt \
6447 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006448 hs_timeout=10000-60000 \
6449 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006450 "$P_CLI dtls=1 debug_level=2 \
6451 crt_file=data_files/server8_int-ca2.crt \
6452 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006453 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6454 hs_timeout=10000-60000 \
6455 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006456 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006457 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006458 -s "found fragmented DTLS handshake message" \
6459 -c "found fragmented DTLS handshake message" \
6460 -C "error"
6461
Andrzej Kurek7311c782018-10-11 06:49:41 -04006462not_with_valgrind # spurious autoreduction due to timeout
6463requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6464requires_config_enabled MBEDTLS_RSA_C
6465requires_config_enabled MBEDTLS_ECDSA_C
6466run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006467 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006468 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6469 crt_file=data_files/server7_int-ca.crt \
6470 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006471 hs_timeout=10000-60000 \
6472 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006473 "$P_CLI dtls=1 debug_level=2 \
6474 crt_file=data_files/server8_int-ca2.crt \
6475 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006476 hs_timeout=10000-60000 \
6477 mtu=1024 nbio=2" \
6478 0 \
6479 -S "autoreduction" \
6480 -s "found fragmented DTLS handshake message" \
6481 -c "found fragmented DTLS handshake message" \
6482 -C "error"
6483
Andrzej Kurek77826052018-10-11 07:34:08 -04006484# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006485not_with_valgrind # spurious autoreduction due to timeout
6486requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6487requires_config_enabled MBEDTLS_RSA_C
6488requires_config_enabled MBEDTLS_ECDSA_C
6489requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6490requires_config_enabled MBEDTLS_AES_C
6491requires_config_enabled MBEDTLS_GCM_C
6492run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6493 -p "$P_PXY mtu=512" \
6494 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6495 crt_file=data_files/server7_int-ca.crt \
6496 key_file=data_files/server7.key \
6497 hs_timeout=10000-60000 \
6498 mtu=512 nbio=2" \
6499 "$P_CLI dtls=1 debug_level=2 \
6500 crt_file=data_files/server8_int-ca2.crt \
6501 key_file=data_files/server8.key \
6502 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6503 hs_timeout=10000-60000 \
6504 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006505 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006506 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006507 -s "found fragmented DTLS handshake message" \
6508 -c "found fragmented DTLS handshake message" \
6509 -C "error"
6510
Andrzej Kurek77826052018-10-11 07:34:08 -04006511# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006512# This ensures things still work after session_reset().
6513# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006514# Since we don't support reading fragmented ClientHello yet,
6515# up the MTU to 1450 (larger than ClientHello with session ticket,
6516# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006517# An autoreduction on the client-side might happen if the server is
6518# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006519# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006520# resumed listening, which would result in a spurious autoreduction.
6521not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006522requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6523requires_config_enabled MBEDTLS_RSA_C
6524requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006525requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6526requires_config_enabled MBEDTLS_AES_C
6527requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006528run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6529 -p "$P_PXY mtu=1450" \
6530 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6531 crt_file=data_files/server7_int-ca.crt \
6532 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006533 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006534 mtu=1450" \
6535 "$P_CLI dtls=1 debug_level=2 \
6536 crt_file=data_files/server8_int-ca2.crt \
6537 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006538 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006539 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006540 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006541 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006542 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006543 -s "found fragmented DTLS handshake message" \
6544 -c "found fragmented DTLS handshake message" \
6545 -C "error"
6546
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006547# An autoreduction on the client-side might happen if the server is
6548# slow to reset, therefore omitting '-C "autoreduction"' below.
6549not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006550requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6551requires_config_enabled MBEDTLS_RSA_C
6552requires_config_enabled MBEDTLS_ECDSA_C
6553requires_config_enabled MBEDTLS_SHA256_C
6554requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6555requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6556requires_config_enabled MBEDTLS_CHACHAPOLY_C
6557run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6558 -p "$P_PXY mtu=512" \
6559 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6560 crt_file=data_files/server7_int-ca.crt \
6561 key_file=data_files/server7.key \
6562 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006563 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006564 mtu=512" \
6565 "$P_CLI dtls=1 debug_level=2 \
6566 crt_file=data_files/server8_int-ca2.crt \
6567 key_file=data_files/server8.key \
6568 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006569 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006570 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006571 mtu=512" \
6572 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006573 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006574 -s "found fragmented DTLS handshake message" \
6575 -c "found fragmented DTLS handshake message" \
6576 -C "error"
6577
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006578# An autoreduction on the client-side might happen if the server is
6579# slow to reset, therefore omitting '-C "autoreduction"' below.
6580not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006581requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6582requires_config_enabled MBEDTLS_RSA_C
6583requires_config_enabled MBEDTLS_ECDSA_C
6584requires_config_enabled MBEDTLS_SHA256_C
6585requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6586requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6587requires_config_enabled MBEDTLS_AES_C
6588requires_config_enabled MBEDTLS_GCM_C
6589run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6590 -p "$P_PXY mtu=512" \
6591 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6592 crt_file=data_files/server7_int-ca.crt \
6593 key_file=data_files/server7.key \
6594 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006595 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006596 mtu=512" \
6597 "$P_CLI dtls=1 debug_level=2 \
6598 crt_file=data_files/server8_int-ca2.crt \
6599 key_file=data_files/server8.key \
6600 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006601 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006602 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006603 mtu=512" \
6604 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006605 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006606 -s "found fragmented DTLS handshake message" \
6607 -c "found fragmented DTLS handshake message" \
6608 -C "error"
6609
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006610# An autoreduction on the client-side might happen if the server is
6611# slow to reset, therefore omitting '-C "autoreduction"' below.
6612not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006613requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6614requires_config_enabled MBEDTLS_RSA_C
6615requires_config_enabled MBEDTLS_ECDSA_C
6616requires_config_enabled MBEDTLS_SHA256_C
6617requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6618requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6619requires_config_enabled MBEDTLS_AES_C
6620requires_config_enabled MBEDTLS_CCM_C
6621run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006622 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006623 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6624 crt_file=data_files/server7_int-ca.crt \
6625 key_file=data_files/server7.key \
6626 exchanges=2 renegotiation=1 \
6627 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006628 hs_timeout=10000-60000 \
6629 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006630 "$P_CLI dtls=1 debug_level=2 \
6631 crt_file=data_files/server8_int-ca2.crt \
6632 key_file=data_files/server8.key \
6633 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006634 hs_timeout=10000-60000 \
6635 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006636 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006637 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006638 -s "found fragmented DTLS handshake message" \
6639 -c "found fragmented DTLS handshake message" \
6640 -C "error"
6641
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006642# An autoreduction on the client-side might happen if the server is
6643# slow to reset, therefore omitting '-C "autoreduction"' below.
6644not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006645requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6646requires_config_enabled MBEDTLS_RSA_C
6647requires_config_enabled MBEDTLS_ECDSA_C
6648requires_config_enabled MBEDTLS_SHA256_C
6649requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6650requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6651requires_config_enabled MBEDTLS_AES_C
6652requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6653requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6654run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006655 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006656 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6657 crt_file=data_files/server7_int-ca.crt \
6658 key_file=data_files/server7.key \
6659 exchanges=2 renegotiation=1 \
6660 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006661 hs_timeout=10000-60000 \
6662 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006663 "$P_CLI dtls=1 debug_level=2 \
6664 crt_file=data_files/server8_int-ca2.crt \
6665 key_file=data_files/server8.key \
6666 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006667 hs_timeout=10000-60000 \
6668 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006669 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006670 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006671 -s "found fragmented DTLS handshake message" \
6672 -c "found fragmented DTLS handshake message" \
6673 -C "error"
6674
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006675# An autoreduction on the client-side might happen if the server is
6676# slow to reset, therefore omitting '-C "autoreduction"' below.
6677not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006678requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6679requires_config_enabled MBEDTLS_RSA_C
6680requires_config_enabled MBEDTLS_ECDSA_C
6681requires_config_enabled MBEDTLS_SHA256_C
6682requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6683requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6684requires_config_enabled MBEDTLS_AES_C
6685requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6686run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006687 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006688 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6689 crt_file=data_files/server7_int-ca.crt \
6690 key_file=data_files/server7.key \
6691 exchanges=2 renegotiation=1 \
6692 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006693 hs_timeout=10000-60000 \
6694 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006695 "$P_CLI dtls=1 debug_level=2 \
6696 crt_file=data_files/server8_int-ca2.crt \
6697 key_file=data_files/server8.key \
6698 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006699 hs_timeout=10000-60000 \
6700 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006701 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006702 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006703 -s "found fragmented DTLS handshake message" \
6704 -c "found fragmented DTLS handshake message" \
6705 -C "error"
6706
Andrzej Kurek77826052018-10-11 07:34:08 -04006707# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006708requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6709requires_config_enabled MBEDTLS_RSA_C
6710requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006711requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6712requires_config_enabled MBEDTLS_AES_C
6713requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006714client_needs_more_time 2
6715run_test "DTLS fragmenting: proxy MTU + 3d" \
6716 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006717 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006718 crt_file=data_files/server7_int-ca.crt \
6719 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006720 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006721 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006722 crt_file=data_files/server8_int-ca2.crt \
6723 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006724 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006725 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006726 0 \
6727 -s "found fragmented DTLS handshake message" \
6728 -c "found fragmented DTLS handshake message" \
6729 -C "error"
6730
Andrzej Kurek77826052018-10-11 07:34:08 -04006731# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006732requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6733requires_config_enabled MBEDTLS_RSA_C
6734requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006735requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6736requires_config_enabled MBEDTLS_AES_C
6737requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006738client_needs_more_time 2
6739run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6740 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6741 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6742 crt_file=data_files/server7_int-ca.crt \
6743 key_file=data_files/server7.key \
6744 hs_timeout=250-10000 mtu=512 nbio=2" \
6745 "$P_CLI dtls=1 debug_level=2 \
6746 crt_file=data_files/server8_int-ca2.crt \
6747 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006748 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006749 hs_timeout=250-10000 mtu=512 nbio=2" \
6750 0 \
6751 -s "found fragmented DTLS handshake message" \
6752 -c "found fragmented DTLS handshake message" \
6753 -C "error"
6754
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006755# interop tests for DTLS fragmentating with reliable connection
6756#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006757# here and below we just want to test that the we fragment in a way that
6758# pleases other implementations, so we don't need the peer to fragment
6759requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6760requires_config_enabled MBEDTLS_RSA_C
6761requires_config_enabled MBEDTLS_ECDSA_C
6762requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006763requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006764run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6765 "$G_SRV -u" \
6766 "$P_CLI dtls=1 debug_level=2 \
6767 crt_file=data_files/server8_int-ca2.crt \
6768 key_file=data_files/server8.key \
6769 mtu=512 force_version=dtls1_2" \
6770 0 \
6771 -c "fragmenting handshake message" \
6772 -C "error"
6773
6774requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6775requires_config_enabled MBEDTLS_RSA_C
6776requires_config_enabled MBEDTLS_ECDSA_C
6777requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006778requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006779run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6780 "$G_SRV -u" \
6781 "$P_CLI dtls=1 debug_level=2 \
6782 crt_file=data_files/server8_int-ca2.crt \
6783 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006784 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006785 0 \
6786 -c "fragmenting handshake message" \
6787 -C "error"
6788
Hanno Beckerb9a00862018-08-28 10:20:22 +01006789# We use --insecure for the GnuTLS client because it expects
6790# the hostname / IP it connects to to be the name used in the
6791# certificate obtained from the server. Here, however, it
6792# connects to 127.0.0.1 while our test certificates use 'localhost'
6793# as the server name in the certificate. This will make the
6794# certifiate validation fail, but passing --insecure makes
6795# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006796requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6797requires_config_enabled MBEDTLS_RSA_C
6798requires_config_enabled MBEDTLS_ECDSA_C
6799requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006800requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006801requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006802run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006803 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006804 crt_file=data_files/server7_int-ca.crt \
6805 key_file=data_files/server7.key \
6806 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006807 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006808 0 \
6809 -s "fragmenting handshake message"
6810
Hanno Beckerb9a00862018-08-28 10:20:22 +01006811# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006812requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6813requires_config_enabled MBEDTLS_RSA_C
6814requires_config_enabled MBEDTLS_ECDSA_C
6815requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006816requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006817requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006818run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006819 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006820 crt_file=data_files/server7_int-ca.crt \
6821 key_file=data_files/server7.key \
6822 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006823 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006824 0 \
6825 -s "fragmenting handshake message"
6826
6827requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6828requires_config_enabled MBEDTLS_RSA_C
6829requires_config_enabled MBEDTLS_ECDSA_C
6830requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6831run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6832 "$O_SRV -dtls1_2 -verify 10" \
6833 "$P_CLI dtls=1 debug_level=2 \
6834 crt_file=data_files/server8_int-ca2.crt \
6835 key_file=data_files/server8.key \
6836 mtu=512 force_version=dtls1_2" \
6837 0 \
6838 -c "fragmenting handshake message" \
6839 -C "error"
6840
6841requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6842requires_config_enabled MBEDTLS_RSA_C
6843requires_config_enabled MBEDTLS_ECDSA_C
6844requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6845run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6846 "$O_SRV -dtls1 -verify 10" \
6847 "$P_CLI dtls=1 debug_level=2 \
6848 crt_file=data_files/server8_int-ca2.crt \
6849 key_file=data_files/server8.key \
6850 mtu=512 force_version=dtls1" \
6851 0 \
6852 -c "fragmenting handshake message" \
6853 -C "error"
6854
6855requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6856requires_config_enabled MBEDTLS_RSA_C
6857requires_config_enabled MBEDTLS_ECDSA_C
6858requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6859run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6860 "$P_SRV dtls=1 debug_level=2 \
6861 crt_file=data_files/server7_int-ca.crt \
6862 key_file=data_files/server7.key \
6863 mtu=512 force_version=dtls1_2" \
6864 "$O_CLI -dtls1_2" \
6865 0 \
6866 -s "fragmenting handshake message"
6867
6868requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6869requires_config_enabled MBEDTLS_RSA_C
6870requires_config_enabled MBEDTLS_ECDSA_C
6871requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6872run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6873 "$P_SRV dtls=1 debug_level=2 \
6874 crt_file=data_files/server7_int-ca.crt \
6875 key_file=data_files/server7.key \
6876 mtu=512 force_version=dtls1" \
6877 "$O_CLI -dtls1" \
6878 0 \
6879 -s "fragmenting handshake message"
6880
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006881# interop tests for DTLS fragmentating with unreliable connection
6882#
6883# again we just want to test that the we fragment in a way that
6884# pleases other implementations, so we don't need the peer to fragment
6885requires_gnutls_next
6886requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6887requires_config_enabled MBEDTLS_RSA_C
6888requires_config_enabled MBEDTLS_ECDSA_C
6889requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006890client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006891run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6892 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6893 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006894 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006895 crt_file=data_files/server8_int-ca2.crt \
6896 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006897 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006898 0 \
6899 -c "fragmenting handshake message" \
6900 -C "error"
6901
6902requires_gnutls_next
6903requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6904requires_config_enabled MBEDTLS_RSA_C
6905requires_config_enabled MBEDTLS_ECDSA_C
6906requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006907client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006908run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6909 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6910 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006911 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006912 crt_file=data_files/server8_int-ca2.crt \
6913 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006914 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006915 0 \
6916 -c "fragmenting handshake message" \
6917 -C "error"
6918
k-stachowiakabb843e2019-02-18 16:14:03 +01006919requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006920requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6921requires_config_enabled MBEDTLS_RSA_C
6922requires_config_enabled MBEDTLS_ECDSA_C
6923requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6924client_needs_more_time 4
6925run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6926 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6927 "$P_SRV dtls=1 debug_level=2 \
6928 crt_file=data_files/server7_int-ca.crt \
6929 key_file=data_files/server7.key \
6930 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006931 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006932 0 \
6933 -s "fragmenting handshake message"
6934
k-stachowiakabb843e2019-02-18 16:14:03 +01006935requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006936requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6937requires_config_enabled MBEDTLS_RSA_C
6938requires_config_enabled MBEDTLS_ECDSA_C
6939requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6940client_needs_more_time 4
6941run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6942 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6943 "$P_SRV dtls=1 debug_level=2 \
6944 crt_file=data_files/server7_int-ca.crt \
6945 key_file=data_files/server7.key \
6946 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006947 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006948 0 \
6949 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006950
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006951## Interop test with OpenSSL might trigger a bug in recent versions (including
6952## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006953## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006954## They should be re-enabled once a fixed version of OpenSSL is available
6955## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006956skip_next_test
6957requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6958requires_config_enabled MBEDTLS_RSA_C
6959requires_config_enabled MBEDTLS_ECDSA_C
6960requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6961client_needs_more_time 4
6962run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6963 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6964 "$O_SRV -dtls1_2 -verify 10" \
6965 "$P_CLI dtls=1 debug_level=2 \
6966 crt_file=data_files/server8_int-ca2.crt \
6967 key_file=data_files/server8.key \
6968 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6969 0 \
6970 -c "fragmenting handshake message" \
6971 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006972
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006973skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006974requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6975requires_config_enabled MBEDTLS_RSA_C
6976requires_config_enabled MBEDTLS_ECDSA_C
6977requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006978client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006979run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6980 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006981 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006982 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006983 crt_file=data_files/server8_int-ca2.crt \
6984 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006985 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006986 0 \
6987 -c "fragmenting handshake message" \
6988 -C "error"
6989
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006990skip_next_test
6991requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6992requires_config_enabled MBEDTLS_RSA_C
6993requires_config_enabled MBEDTLS_ECDSA_C
6994requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6995client_needs_more_time 4
6996run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6997 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6998 "$P_SRV dtls=1 debug_level=2 \
6999 crt_file=data_files/server7_int-ca.crt \
7000 key_file=data_files/server7.key \
7001 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7002 "$O_CLI -dtls1_2" \
7003 0 \
7004 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007005
7006# -nbio is added to prevent s_client from blocking in case of duplicated
7007# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007008skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007009requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7010requires_config_enabled MBEDTLS_RSA_C
7011requires_config_enabled MBEDTLS_ECDSA_C
7012requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007013client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007014run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
7015 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007016 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007017 crt_file=data_files/server7_int-ca.crt \
7018 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007019 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007020 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007021 0 \
7022 -s "fragmenting handshake message"
7023
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007024# Tests for specific things with "unreliable" UDP connection
7025
7026not_with_valgrind # spurious resend due to timeout
7027run_test "DTLS proxy: reference" \
7028 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007029 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
7030 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007031 0 \
7032 -C "replayed record" \
7033 -S "replayed record" \
7034 -C "record from another epoch" \
7035 -S "record from another epoch" \
7036 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007037 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007038 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007039 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007040 -c "HTTP/1.0 200 OK"
7041
7042not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007043run_test "DTLS proxy: duplicate every packet" \
7044 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007045 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
7046 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007047 0 \
7048 -c "replayed record" \
7049 -s "replayed record" \
7050 -c "record from another epoch" \
7051 -s "record from another epoch" \
7052 -S "resend" \
7053 -s "Extra-header:" \
7054 -c "HTTP/1.0 200 OK"
7055
7056run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7057 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007058 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7059 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007060 0 \
7061 -c "replayed record" \
7062 -S "replayed record" \
7063 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007064 -s "record from another epoch" \
7065 -c "resend" \
7066 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007067 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007068 -c "HTTP/1.0 200 OK"
7069
7070run_test "DTLS proxy: multiple records in same datagram" \
7071 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007072 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7073 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007074 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007075 -c "next record in same datagram" \
7076 -s "next record in same datagram"
7077
7078run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7079 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007080 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7081 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007082 0 \
7083 -c "next record in same datagram" \
7084 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007085
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007086run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7087 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007088 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7089 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007090 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007091 -c "discarding invalid record (mac)" \
7092 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007093 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007094 -c "HTTP/1.0 200 OK" \
7095 -S "too many records with bad MAC" \
7096 -S "Verification of the message MAC failed"
7097
7098run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
7099 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007100 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7101 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007102 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007103 -C "discarding invalid record (mac)" \
7104 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007105 -S "Extra-header:" \
7106 -C "HTTP/1.0 200 OK" \
7107 -s "too many records with bad MAC" \
7108 -s "Verification of the message MAC failed"
7109
7110run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7111 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007112 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7113 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007114 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007115 -c "discarding invalid record (mac)" \
7116 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007117 -s "Extra-header:" \
7118 -c "HTTP/1.0 200 OK" \
7119 -S "too many records with bad MAC" \
7120 -S "Verification of the message MAC failed"
7121
7122run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7123 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007124 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7125 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007126 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007127 -c "discarding invalid record (mac)" \
7128 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007129 -s "Extra-header:" \
7130 -c "HTTP/1.0 200 OK" \
7131 -s "too many records with bad MAC" \
7132 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007133
7134run_test "DTLS proxy: delay ChangeCipherSpec" \
7135 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007136 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7137 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007138 0 \
7139 -c "record from another epoch" \
7140 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007141 -s "Extra-header:" \
7142 -c "HTTP/1.0 200 OK"
7143
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007144# Tests for reordering support with DTLS
7145
Hanno Becker56cdfd12018-08-17 13:42:15 +01007146run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7147 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007148 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7149 hs_timeout=2500-60000" \
7150 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7151 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007152 0 \
7153 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007154 -c "Next handshake message has been buffered - load"\
7155 -S "Buffering HS message" \
7156 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007157 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007158 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007159 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007160 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007161
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007162run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7163 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007164 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7165 hs_timeout=2500-60000" \
7166 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7167 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007168 0 \
7169 -c "Buffering HS message" \
7170 -c "found fragmented DTLS handshake message"\
7171 -c "Next handshake message 1 not or only partially bufffered" \
7172 -c "Next handshake message has been buffered - load"\
7173 -S "Buffering HS message" \
7174 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007175 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007176 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007177 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007178 -S "Remember CCS message"
7179
Hanno Beckera1adcca2018-08-24 14:41:07 +01007180# The client buffers the ServerKeyExchange before receiving the fragmented
7181# Certificate message; at the time of writing, together these are aroudn 1200b
7182# in size, so that the bound below ensures that the certificate can be reassembled
7183# while keeping the ServerKeyExchange.
7184requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7185run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007186 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007187 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7188 hs_timeout=2500-60000" \
7189 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7190 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007191 0 \
7192 -c "Buffering HS message" \
7193 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007194 -C "attempt to make space by freeing buffered messages" \
7195 -S "Buffering HS message" \
7196 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007197 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007198 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007199 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007200 -S "Remember CCS message"
7201
7202# The size constraints ensure that the delayed certificate message can't
7203# be reassembled while keeping the ServerKeyExchange message, but it can
7204# when dropping it first.
7205requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7206requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7207run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7208 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007209 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7210 hs_timeout=2500-60000" \
7211 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7212 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007213 0 \
7214 -c "Buffering HS message" \
7215 -c "attempt to make space by freeing buffered future messages" \
7216 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007217 -S "Buffering HS message" \
7218 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007219 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007220 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007221 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007222 -S "Remember CCS message"
7223
Hanno Becker56cdfd12018-08-17 13:42:15 +01007224run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7225 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007226 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7227 hs_timeout=2500-60000" \
7228 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7229 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007230 0 \
7231 -C "Buffering HS message" \
7232 -C "Next handshake message has been buffered - load"\
7233 -s "Buffering HS message" \
7234 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007235 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007236 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007237 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007238 -S "Remember CCS message"
7239
7240run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7241 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007242 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7243 hs_timeout=2500-60000" \
7244 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7245 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007246 0 \
7247 -C "Buffering HS message" \
7248 -C "Next handshake message has been buffered - load"\
7249 -S "Buffering HS message" \
7250 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007251 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007252 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007253 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007254 -S "Remember CCS message"
7255
7256run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7257 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007258 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7259 hs_timeout=2500-60000" \
7260 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7261 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007262 0 \
7263 -C "Buffering HS message" \
7264 -C "Next handshake message has been buffered - load"\
7265 -S "Buffering HS message" \
7266 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007267 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007268 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007269 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007270 -s "Remember CCS message"
7271
Hanno Beckera1adcca2018-08-24 14:41:07 +01007272run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007273 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007274 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7275 hs_timeout=2500-60000" \
7276 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7277 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007278 0 \
7279 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007280 -s "Found buffered record from current epoch - load" \
7281 -c "Buffer record from epoch 1" \
7282 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007283
Hanno Beckera1adcca2018-08-24 14:41:07 +01007284# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7285# from the server are delayed, so that the encrypted Finished message
7286# is received and buffered. When the fragmented NewSessionTicket comes
7287# in afterwards, the encrypted Finished message must be freed in order
7288# to make space for the NewSessionTicket to be reassembled.
7289# This works only in very particular circumstances:
7290# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7291# of the NewSessionTicket, but small enough to also allow buffering of
7292# the encrypted Finished message.
7293# - The MTU setting on the server must be so small that the NewSessionTicket
7294# needs to be fragmented.
7295# - All messages sent by the server must be small enough to be either sent
7296# without fragmentation or be reassembled within the bounds of
7297# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7298# handshake, omitting CRTs.
7299requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7300requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7301run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7302 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7303 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7304 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7305 0 \
7306 -s "Buffer record from epoch 1" \
7307 -s "Found buffered record from current epoch - load" \
7308 -c "Buffer record from epoch 1" \
7309 -C "Found buffered record from current epoch - load" \
7310 -c "Enough space available after freeing future epoch record"
7311
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007312# Tests for "randomly unreliable connection": try a variety of flows and peers
7313
7314client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007315run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7316 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007317 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007318 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007319 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007320 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7321 0 \
7322 -s "Extra-header:" \
7323 -c "HTTP/1.0 200 OK"
7324
Janos Follath74537a62016-09-02 13:45:28 +01007325client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007326run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7327 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007328 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7329 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007330 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7331 0 \
7332 -s "Extra-header:" \
7333 -c "HTTP/1.0 200 OK"
7334
Janos Follath74537a62016-09-02 13:45:28 +01007335client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007336run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7337 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007338 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7339 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007340 0 \
7341 -s "Extra-header:" \
7342 -c "HTTP/1.0 200 OK"
7343
Janos Follath74537a62016-09-02 13:45:28 +01007344client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007345run_test "DTLS proxy: 3d, FS, client auth" \
7346 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007347 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7348 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007349 0 \
7350 -s "Extra-header:" \
7351 -c "HTTP/1.0 200 OK"
7352
Janos Follath74537a62016-09-02 13:45:28 +01007353client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007354run_test "DTLS proxy: 3d, FS, ticket" \
7355 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007356 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7357 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007358 0 \
7359 -s "Extra-header:" \
7360 -c "HTTP/1.0 200 OK"
7361
Janos Follath74537a62016-09-02 13:45:28 +01007362client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007363run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7364 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007365 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7366 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007367 0 \
7368 -s "Extra-header:" \
7369 -c "HTTP/1.0 200 OK"
7370
Janos Follath74537a62016-09-02 13:45:28 +01007371client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007372run_test "DTLS proxy: 3d, max handshake, nbio" \
7373 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007374 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007375 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007376 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007377 0 \
7378 -s "Extra-header:" \
7379 -c "HTTP/1.0 200 OK"
7380
Janos Follath74537a62016-09-02 13:45:28 +01007381client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007382run_test "DTLS proxy: 3d, min handshake, resumption" \
7383 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007384 "$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 +02007385 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007386 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007387 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007388 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7389 0 \
7390 -s "a session has been resumed" \
7391 -c "a session has been resumed" \
7392 -s "Extra-header:" \
7393 -c "HTTP/1.0 200 OK"
7394
Janos Follath74537a62016-09-02 13:45:28 +01007395client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007396run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7397 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007398 "$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 +02007399 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007400 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007401 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007402 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7403 0 \
7404 -s "a session has been resumed" \
7405 -c "a session has been resumed" \
7406 -s "Extra-header:" \
7407 -c "HTTP/1.0 200 OK"
7408
Janos Follath74537a62016-09-02 13:45:28 +01007409client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007410requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007411run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007412 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007413 "$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 +02007414 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007415 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007416 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007417 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7418 0 \
7419 -c "=> renegotiate" \
7420 -s "=> renegotiate" \
7421 -s "Extra-header:" \
7422 -c "HTTP/1.0 200 OK"
7423
Janos Follath74537a62016-09-02 13:45:28 +01007424client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007425requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007426run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7427 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007428 "$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 +02007429 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007430 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007431 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007432 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7433 0 \
7434 -c "=> renegotiate" \
7435 -s "=> renegotiate" \
7436 -s "Extra-header:" \
7437 -c "HTTP/1.0 200 OK"
7438
Janos Follath74537a62016-09-02 13:45:28 +01007439client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007440requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007441run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007442 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007443 "$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 +02007444 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007445 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007446 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007447 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007448 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7449 0 \
7450 -c "=> renegotiate" \
7451 -s "=> renegotiate" \
7452 -s "Extra-header:" \
7453 -c "HTTP/1.0 200 OK"
7454
Janos Follath74537a62016-09-02 13:45:28 +01007455client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007456requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007457run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007458 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007459 "$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 +02007460 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007461 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007462 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007463 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007464 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7465 0 \
7466 -c "=> renegotiate" \
7467 -s "=> renegotiate" \
7468 -s "Extra-header:" \
7469 -c "HTTP/1.0 200 OK"
7470
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007471## Interop tests with OpenSSL might trigger a bug in recent versions (including
7472## all versions installed on the CI machines), reported here:
7473## Bug report: https://github.com/openssl/openssl/issues/6902
7474## They should be re-enabled once a fixed version of OpenSSL is available
7475## (this should happen in some 1.1.1_ release according to the ticket).
7476skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007477client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007478not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007479run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007480 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7481 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007482 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007483 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007484 -c "HTTP/1.0 200 OK"
7485
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007486skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007487client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007488not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007489run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7490 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7491 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007492 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007493 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007494 -c "HTTP/1.0 200 OK"
7495
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007496skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007497client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007498not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007499run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7500 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7501 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007502 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007503 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007504 -c "HTTP/1.0 200 OK"
7505
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007506requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007507client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007508not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007509run_test "DTLS proxy: 3d, gnutls server" \
7510 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7511 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007512 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007513 0 \
7514 -s "Extra-header:" \
7515 -c "Extra-header:"
7516
k-stachowiakabb843e2019-02-18 16:14:03 +01007517requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007518client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007519not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007520run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7521 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007522 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007523 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007524 0 \
7525 -s "Extra-header:" \
7526 -c "Extra-header:"
7527
k-stachowiakabb843e2019-02-18 16:14:03 +01007528requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007529client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007530not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007531run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7532 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007533 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007534 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007535 0 \
7536 -s "Extra-header:" \
7537 -c "Extra-header:"
7538
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007539# Final report
7540
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007541echo "------------------------------------------------------------------------"
7542
7543if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007544 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007545else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007546 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007547fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007548PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007549echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007550
7551exit $FAILS