blob: 9bc3b9d0f4f737f6e9430e54f10653c1475f8404 [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 Takano2e580ce2021-06-21 19:43:33 +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
Angus Grattonc4dd0732018-04-11 16:28:39 +10002899requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002900run_test "Authentication: server max_int+1 chain, client default" \
2901 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2902 key_file=data_files/dir-maxpath/10.key" \
2903 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2904 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002905 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002906
Angus Grattonc4dd0732018-04-11 16:28:39 +10002907requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002908run_test "Authentication: server max_int+1 chain, client optional" \
2909 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2910 key_file=data_files/dir-maxpath/10.key" \
2911 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2912 auth_mode=optional" \
2913 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002914 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002915
Angus Grattonc4dd0732018-04-11 16:28:39 +10002916requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002917run_test "Authentication: server max_int+1 chain, client none" \
2918 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2919 key_file=data_files/dir-maxpath/10.key" \
2920 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2921 auth_mode=none" \
2922 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002923 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002924
Angus Grattonc4dd0732018-04-11 16:28:39 +10002925requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002926run_test "Authentication: client max_int+1 chain, server default" \
2927 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2928 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2929 key_file=data_files/dir-maxpath/10.key" \
2930 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002931 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002932
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 optional" \
2935 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2936 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2937 key_file=data_files/dir-maxpath/10.key" \
2938 1 \
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
Angus Grattonc4dd0732018-04-11 16:28:39 +10002941requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002942run_test "Authentication: client max_int+1 chain, server required" \
2943 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2944 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2945 key_file=data_files/dir-maxpath/10.key" \
2946 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002947 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002948
Yuto Takanoe153ca22021-06-21 20:07:12 +01002949requires_config_value_at_least "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
2950requires_config_value_at_most "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002951requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002952run_test "Authentication: client max_int chain, server required" \
2953 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2954 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2955 key_file=data_files/dir-maxpath/09.key" \
2956 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002957 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002958
Janos Follath89baba22017-04-10 14:34:35 +01002959# Tests for CA list in CertificateRequest messages
2960
2961run_test "Authentication: send CA list in CertificateRequest (default)" \
2962 "$P_SRV debug_level=3 auth_mode=required" \
2963 "$P_CLI crt_file=data_files/server6.crt \
2964 key_file=data_files/server6.key" \
2965 0 \
2966 -s "requested DN"
2967
2968run_test "Authentication: do not send CA list in CertificateRequest" \
2969 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2970 "$P_CLI crt_file=data_files/server6.crt \
2971 key_file=data_files/server6.key" \
2972 0 \
2973 -S "requested DN"
2974
2975run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2976 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2977 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2978 key_file=data_files/server5.key" \
2979 1 \
2980 -S "requested DN" \
2981 -s "x509_verify_cert() returned" \
2982 -s "! The certificate is not correctly signed by the trusted CA" \
2983 -s "! mbedtls_ssl_handshake returned" \
2984 -c "! mbedtls_ssl_handshake returned" \
2985 -s "X509 - Certificate verification failed"
2986
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002987# Tests for certificate selection based on SHA verson
2988
2989run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2990 "$P_SRV crt_file=data_files/server5.crt \
2991 key_file=data_files/server5.key \
2992 crt_file2=data_files/server5-sha1.crt \
2993 key_file2=data_files/server5.key" \
2994 "$P_CLI force_version=tls1_2" \
2995 0 \
2996 -c "signed using.*ECDSA with SHA256" \
2997 -C "signed using.*ECDSA with SHA1"
2998
2999run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
3000 "$P_SRV crt_file=data_files/server5.crt \
3001 key_file=data_files/server5.key \
3002 crt_file2=data_files/server5-sha1.crt \
3003 key_file2=data_files/server5.key" \
3004 "$P_CLI force_version=tls1_1" \
3005 0 \
3006 -C "signed using.*ECDSA with SHA256" \
3007 -c "signed using.*ECDSA with SHA1"
3008
3009run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
3010 "$P_SRV crt_file=data_files/server5.crt \
3011 key_file=data_files/server5.key \
3012 crt_file2=data_files/server5-sha1.crt \
3013 key_file2=data_files/server5.key" \
3014 "$P_CLI force_version=tls1" \
3015 0 \
3016 -C "signed using.*ECDSA with SHA256" \
3017 -c "signed using.*ECDSA with SHA1"
3018
3019run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
3020 "$P_SRV crt_file=data_files/server5.crt \
3021 key_file=data_files/server5.key \
3022 crt_file2=data_files/server6.crt \
3023 key_file2=data_files/server6.key" \
3024 "$P_CLI force_version=tls1_1" \
3025 0 \
3026 -c "serial number.*09" \
3027 -c "signed using.*ECDSA with SHA256" \
3028 -C "signed using.*ECDSA with SHA1"
3029
3030run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
3031 "$P_SRV crt_file=data_files/server6.crt \
3032 key_file=data_files/server6.key \
3033 crt_file2=data_files/server5.crt \
3034 key_file2=data_files/server5.key" \
3035 "$P_CLI force_version=tls1_1" \
3036 0 \
3037 -c "serial number.*0A" \
3038 -c "signed using.*ECDSA with SHA256" \
3039 -C "signed using.*ECDSA with SHA1"
3040
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003041# tests for SNI
3042
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003043run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003044 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003045 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003046 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003047 0 \
3048 -S "parse ServerName extension" \
3049 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3050 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003052run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003053 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003054 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003055 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 +02003056 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003057 0 \
3058 -s "parse ServerName extension" \
3059 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3060 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003062run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003063 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003064 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003065 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 +02003066 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003067 0 \
3068 -s "parse ServerName extension" \
3069 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3070 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003072run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003073 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003074 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003075 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 +02003076 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003077 1 \
3078 -s "parse ServerName extension" \
3079 -s "ssl_sni_wrapper() returned" \
3080 -s "mbedtls_ssl_handshake returned" \
3081 -c "mbedtls_ssl_handshake returned" \
3082 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003083
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003084run_test "SNI: client auth no override: optional" \
3085 "$P_SRV debug_level=3 auth_mode=optional \
3086 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3087 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3088 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003089 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003090 -S "skip write certificate request" \
3091 -C "skip parse certificate request" \
3092 -c "got a certificate request" \
3093 -C "skip write certificate" \
3094 -C "skip write certificate verify" \
3095 -S "skip parse certificate verify"
3096
3097run_test "SNI: client auth override: none -> optional" \
3098 "$P_SRV debug_level=3 auth_mode=none \
3099 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3100 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3101 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003102 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003103 -S "skip write certificate request" \
3104 -C "skip parse certificate request" \
3105 -c "got a certificate request" \
3106 -C "skip write certificate" \
3107 -C "skip write certificate verify" \
3108 -S "skip parse certificate verify"
3109
3110run_test "SNI: client auth override: optional -> none" \
3111 "$P_SRV debug_level=3 auth_mode=optional \
3112 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3113 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3114 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003115 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003116 -s "skip write certificate request" \
3117 -C "skip parse certificate request" \
3118 -c "got no certificate request" \
3119 -c "skip write certificate" \
3120 -c "skip write certificate verify" \
3121 -s "skip parse certificate verify"
3122
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003123run_test "SNI: CA no override" \
3124 "$P_SRV debug_level=3 auth_mode=optional \
3125 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3126 ca_file=data_files/test-ca.crt \
3127 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3128 "$P_CLI debug_level=3 server_name=localhost \
3129 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3130 1 \
3131 -S "skip write certificate request" \
3132 -C "skip parse certificate request" \
3133 -c "got a certificate request" \
3134 -C "skip write certificate" \
3135 -C "skip write certificate verify" \
3136 -S "skip parse certificate verify" \
3137 -s "x509_verify_cert() returned" \
3138 -s "! The certificate is not correctly signed by the trusted CA" \
3139 -S "The certificate has been revoked (is on a CRL)"
3140
3141run_test "SNI: CA override" \
3142 "$P_SRV debug_level=3 auth_mode=optional \
3143 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3144 ca_file=data_files/test-ca.crt \
3145 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3146 "$P_CLI debug_level=3 server_name=localhost \
3147 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3148 0 \
3149 -S "skip write certificate request" \
3150 -C "skip parse certificate request" \
3151 -c "got a certificate request" \
3152 -C "skip write certificate" \
3153 -C "skip write certificate verify" \
3154 -S "skip parse certificate verify" \
3155 -S "x509_verify_cert() returned" \
3156 -S "! The certificate is not correctly signed by the trusted CA" \
3157 -S "The certificate has been revoked (is on a CRL)"
3158
3159run_test "SNI: CA override with CRL" \
3160 "$P_SRV debug_level=3 auth_mode=optional \
3161 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3162 ca_file=data_files/test-ca.crt \
3163 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3164 "$P_CLI debug_level=3 server_name=localhost \
3165 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3166 1 \
3167 -S "skip write certificate request" \
3168 -C "skip parse certificate request" \
3169 -c "got a certificate request" \
3170 -C "skip write certificate" \
3171 -C "skip write certificate verify" \
3172 -S "skip parse certificate verify" \
3173 -s "x509_verify_cert() returned" \
3174 -S "! The certificate is not correctly signed by the trusted CA" \
3175 -s "The certificate has been revoked (is on a CRL)"
3176
Andres AG1a834452016-12-07 10:01:30 +00003177# Tests for SNI and DTLS
3178
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003179run_test "SNI: DTLS, no SNI callback" \
3180 "$P_SRV debug_level=3 dtls=1 \
3181 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3182 "$P_CLI server_name=localhost dtls=1" \
3183 0 \
3184 -S "parse ServerName extension" \
3185 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3186 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3187
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003188run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003189 "$P_SRV debug_level=3 dtls=1 \
3190 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3191 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3192 "$P_CLI server_name=localhost dtls=1" \
3193 0 \
3194 -s "parse ServerName extension" \
3195 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3196 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3197
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003198run_test "SNI: DTLS, matching cert 2" \
3199 "$P_SRV debug_level=3 dtls=1 \
3200 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3201 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3202 "$P_CLI server_name=polarssl.example dtls=1" \
3203 0 \
3204 -s "parse ServerName extension" \
3205 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3206 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3207
3208run_test "SNI: DTLS, no matching cert" \
3209 "$P_SRV debug_level=3 dtls=1 \
3210 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3211 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3212 "$P_CLI server_name=nonesuch.example dtls=1" \
3213 1 \
3214 -s "parse ServerName extension" \
3215 -s "ssl_sni_wrapper() returned" \
3216 -s "mbedtls_ssl_handshake returned" \
3217 -c "mbedtls_ssl_handshake returned" \
3218 -c "SSL - A fatal alert message was received from our peer"
3219
3220run_test "SNI: DTLS, client auth no override: optional" \
3221 "$P_SRV debug_level=3 auth_mode=optional 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,-,-,-" \
3224 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3225 0 \
3226 -S "skip write certificate request" \
3227 -C "skip parse certificate request" \
3228 -c "got a certificate request" \
3229 -C "skip write certificate" \
3230 -C "skip write certificate verify" \
3231 -S "skip parse certificate verify"
3232
3233run_test "SNI: DTLS, client auth override: none -> optional" \
3234 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3235 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3236 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3237 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3238 0 \
3239 -S "skip write certificate request" \
3240 -C "skip parse certificate request" \
3241 -c "got a certificate request" \
3242 -C "skip write certificate" \
3243 -C "skip write certificate verify" \
3244 -S "skip parse certificate verify"
3245
3246run_test "SNI: DTLS, client auth override: optional -> none" \
3247 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3248 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3249 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3250 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3251 0 \
3252 -s "skip write certificate request" \
3253 -C "skip parse certificate request" \
3254 -c "got no certificate request" \
3255 -c "skip write certificate" \
3256 -c "skip write certificate verify" \
3257 -s "skip parse certificate verify"
3258
3259run_test "SNI: DTLS, CA no override" \
3260 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3261 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3262 ca_file=data_files/test-ca.crt \
3263 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3264 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3265 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3266 1 \
3267 -S "skip write certificate request" \
3268 -C "skip parse certificate request" \
3269 -c "got a certificate request" \
3270 -C "skip write certificate" \
3271 -C "skip write certificate verify" \
3272 -S "skip parse certificate verify" \
3273 -s "x509_verify_cert() returned" \
3274 -s "! The certificate is not correctly signed by the trusted CA" \
3275 -S "The certificate has been revoked (is on a CRL)"
3276
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003277run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003278 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3279 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3280 ca_file=data_files/test-ca.crt \
3281 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3282 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3283 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3284 0 \
3285 -S "skip write certificate request" \
3286 -C "skip parse certificate request" \
3287 -c "got a certificate request" \
3288 -C "skip write certificate" \
3289 -C "skip write certificate verify" \
3290 -S "skip parse certificate verify" \
3291 -S "x509_verify_cert() returned" \
3292 -S "! The certificate is not correctly signed by the trusted CA" \
3293 -S "The certificate has been revoked (is on a CRL)"
3294
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003295run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003296 "$P_SRV debug_level=3 auth_mode=optional \
3297 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3298 ca_file=data_files/test-ca.crt \
3299 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3300 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3301 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3302 1 \
3303 -S "skip write certificate request" \
3304 -C "skip parse certificate request" \
3305 -c "got a certificate request" \
3306 -C "skip write certificate" \
3307 -C "skip write certificate verify" \
3308 -S "skip parse certificate verify" \
3309 -s "x509_verify_cert() returned" \
3310 -S "! The certificate is not correctly signed by the trusted CA" \
3311 -s "The certificate has been revoked (is on a CRL)"
3312
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003313# Tests for non-blocking I/O: exercise a variety of handshake flows
3314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003315run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003316 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3317 "$P_CLI nbio=2 tickets=0" \
3318 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003319 -S "mbedtls_ssl_handshake returned" \
3320 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003321 -c "Read from server: .* bytes read"
3322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003323run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003324 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3325 "$P_CLI nbio=2 tickets=0" \
3326 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003327 -S "mbedtls_ssl_handshake returned" \
3328 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003329 -c "Read from server: .* bytes read"
3330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003331run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003332 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3333 "$P_CLI nbio=2 tickets=1" \
3334 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003335 -S "mbedtls_ssl_handshake returned" \
3336 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003337 -c "Read from server: .* bytes read"
3338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003339run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003340 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3341 "$P_CLI nbio=2 tickets=1" \
3342 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003343 -S "mbedtls_ssl_handshake returned" \
3344 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003345 -c "Read from server: .* bytes read"
3346
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003347run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003348 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3349 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3350 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003351 -S "mbedtls_ssl_handshake returned" \
3352 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003353 -c "Read from server: .* bytes read"
3354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003355run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003356 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3357 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3358 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003359 -S "mbedtls_ssl_handshake returned" \
3360 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003361 -c "Read from server: .* bytes read"
3362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003363run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003364 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3365 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3366 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003367 -S "mbedtls_ssl_handshake returned" \
3368 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003369 -c "Read from server: .* bytes read"
3370
Hanno Becker00076712017-11-15 16:39:08 +00003371# Tests for event-driven I/O: exercise a variety of handshake flows
3372
3373run_test "Event-driven I/O: basic handshake" \
3374 "$P_SRV event=1 tickets=0 auth_mode=none" \
3375 "$P_CLI event=1 tickets=0" \
3376 0 \
3377 -S "mbedtls_ssl_handshake returned" \
3378 -C "mbedtls_ssl_handshake returned" \
3379 -c "Read from server: .* bytes read"
3380
3381run_test "Event-driven I/O: client auth" \
3382 "$P_SRV event=1 tickets=0 auth_mode=required" \
3383 "$P_CLI event=1 tickets=0" \
3384 0 \
3385 -S "mbedtls_ssl_handshake returned" \
3386 -C "mbedtls_ssl_handshake returned" \
3387 -c "Read from server: .* bytes read"
3388
3389run_test "Event-driven I/O: ticket" \
3390 "$P_SRV event=1 tickets=1 auth_mode=none" \
3391 "$P_CLI event=1 tickets=1" \
3392 0 \
3393 -S "mbedtls_ssl_handshake returned" \
3394 -C "mbedtls_ssl_handshake returned" \
3395 -c "Read from server: .* bytes read"
3396
3397run_test "Event-driven I/O: ticket + client auth" \
3398 "$P_SRV event=1 tickets=1 auth_mode=required" \
3399 "$P_CLI event=1 tickets=1" \
3400 0 \
3401 -S "mbedtls_ssl_handshake returned" \
3402 -C "mbedtls_ssl_handshake returned" \
3403 -c "Read from server: .* bytes read"
3404
3405run_test "Event-driven I/O: ticket + client auth + resume" \
3406 "$P_SRV event=1 tickets=1 auth_mode=required" \
3407 "$P_CLI event=1 tickets=1 reconnect=1" \
3408 0 \
3409 -S "mbedtls_ssl_handshake returned" \
3410 -C "mbedtls_ssl_handshake returned" \
3411 -c "Read from server: .* bytes read"
3412
3413run_test "Event-driven I/O: ticket + resume" \
3414 "$P_SRV event=1 tickets=1 auth_mode=none" \
3415 "$P_CLI event=1 tickets=1 reconnect=1" \
3416 0 \
3417 -S "mbedtls_ssl_handshake returned" \
3418 -C "mbedtls_ssl_handshake returned" \
3419 -c "Read from server: .* bytes read"
3420
3421run_test "Event-driven I/O: session-id resume" \
3422 "$P_SRV event=1 tickets=0 auth_mode=none" \
3423 "$P_CLI event=1 tickets=0 reconnect=1" \
3424 0 \
3425 -S "mbedtls_ssl_handshake returned" \
3426 -C "mbedtls_ssl_handshake returned" \
3427 -c "Read from server: .* bytes read"
3428
Hanno Becker6a33f592018-03-13 11:38:46 +00003429run_test "Event-driven I/O, DTLS: basic handshake" \
3430 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3431 "$P_CLI dtls=1 event=1 tickets=0" \
3432 0 \
3433 -c "Read from server: .* bytes read"
3434
3435run_test "Event-driven I/O, DTLS: client auth" \
3436 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3437 "$P_CLI dtls=1 event=1 tickets=0" \
3438 0 \
3439 -c "Read from server: .* bytes read"
3440
3441run_test "Event-driven I/O, DTLS: ticket" \
3442 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3443 "$P_CLI dtls=1 event=1 tickets=1" \
3444 0 \
3445 -c "Read from server: .* bytes read"
3446
3447run_test "Event-driven I/O, DTLS: ticket + client auth" \
3448 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3449 "$P_CLI dtls=1 event=1 tickets=1" \
3450 0 \
3451 -c "Read from server: .* bytes read"
3452
3453run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3454 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003455 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003456 0 \
3457 -c "Read from server: .* bytes read"
3458
3459run_test "Event-driven I/O, DTLS: ticket + resume" \
3460 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003461 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003462 0 \
3463 -c "Read from server: .* bytes read"
3464
3465run_test "Event-driven I/O, DTLS: session-id resume" \
3466 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003467 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003468 0 \
3469 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003470
3471# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3472# During session resumption, the client will send its ApplicationData record
3473# within the same datagram as the Finished messages. In this situation, the
3474# server MUST NOT idle on the underlying transport after handshake completion,
3475# because the ApplicationData request has already been queued internally.
3476run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003477 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003478 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
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 Beckerbc6c1102018-03-13 11:39:40 +00003480 0 \
3481 -c "Read from server: .* bytes read"
3482
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003483# Tests for version negotiation
3484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003485run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003486 "$P_SRV" \
3487 "$P_CLI" \
3488 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003489 -S "mbedtls_ssl_handshake returned" \
3490 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003491 -s "Protocol is TLSv1.2" \
3492 -c "Protocol is TLSv1.2"
3493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003494run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003495 "$P_SRV" \
3496 "$P_CLI max_version=tls1_1" \
3497 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003498 -S "mbedtls_ssl_handshake returned" \
3499 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003500 -s "Protocol is TLSv1.1" \
3501 -c "Protocol is TLSv1.1"
3502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003503run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003504 "$P_SRV max_version=tls1_1" \
3505 "$P_CLI" \
3506 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003507 -S "mbedtls_ssl_handshake returned" \
3508 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003509 -s "Protocol is TLSv1.1" \
3510 -c "Protocol is TLSv1.1"
3511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003512run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003513 "$P_SRV max_version=tls1_1" \
3514 "$P_CLI max_version=tls1_1" \
3515 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003516 -S "mbedtls_ssl_handshake returned" \
3517 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003518 -s "Protocol is TLSv1.1" \
3519 -c "Protocol is TLSv1.1"
3520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003521run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003522 "$P_SRV min_version=tls1_1" \
3523 "$P_CLI max_version=tls1_1" \
3524 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003525 -S "mbedtls_ssl_handshake returned" \
3526 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003527 -s "Protocol is TLSv1.1" \
3528 -c "Protocol is TLSv1.1"
3529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003530run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003531 "$P_SRV max_version=tls1_1" \
3532 "$P_CLI min_version=tls1_1" \
3533 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003534 -S "mbedtls_ssl_handshake returned" \
3535 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003536 -s "Protocol is TLSv1.1" \
3537 -c "Protocol is TLSv1.1"
3538
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003539run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003540 "$P_SRV max_version=tls1_1" \
3541 "$P_CLI min_version=tls1_2" \
3542 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003543 -s "mbedtls_ssl_handshake returned" \
3544 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003545 -c "SSL - Handshake protocol not within min/max boundaries"
3546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003547run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003548 "$P_SRV min_version=tls1_2" \
3549 "$P_CLI max_version=tls1_1" \
3550 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003551 -s "mbedtls_ssl_handshake returned" \
3552 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003553 -s "SSL - Handshake protocol not within min/max boundaries"
3554
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003555# Tests for ALPN extension
3556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003557run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003558 "$P_SRV debug_level=3" \
3559 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003560 0 \
3561 -C "client hello, adding alpn extension" \
3562 -S "found alpn extension" \
3563 -C "got an alert message, type: \\[2:120]" \
3564 -S "server hello, adding alpn extension" \
3565 -C "found alpn extension " \
3566 -C "Application Layer Protocol is" \
3567 -S "Application Layer Protocol is"
3568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003569run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003570 "$P_SRV debug_level=3" \
3571 "$P_CLI debug_level=3 alpn=abc,1234" \
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 (none)" \
3579 -S "Application Layer Protocol is"
3580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003581run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003582 "$P_SRV debug_level=3 alpn=abc,1234" \
3583 "$P_CLI debug_level=3" \
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" \
3591 -s "Application Layer Protocol is (none)"
3592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003593run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003594 "$P_SRV debug_level=3 alpn=abc,1234" \
3595 "$P_CLI debug_level=3 alpn=abc,1234" \
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 abc" \
3603 -s "Application Layer Protocol is abc"
3604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003605run_test "ALPN: both, common cli2-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=1234,abc" \
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 cli1-srv2" \
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,abcde" \
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 1234" \
3627 -s "Application Layer Protocol is 1234"
3628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003629run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003630 "$P_SRV debug_level=3 alpn=abc,123" \
3631 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003632 1 \
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é-Gonnard83d8c732014-04-07 13:24:21 +02003641
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003642# Tests for keyUsage in leaf certificates, part 1:
3643# server-side certificate/suite selection
3644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003645run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003646 "$P_SRV key_file=data_files/server2.key \
3647 crt_file=data_files/server2.ku-ds.crt" \
3648 "$P_CLI" \
3649 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003650 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003651
3652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003653run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003654 "$P_SRV key_file=data_files/server2.key \
3655 crt_file=data_files/server2.ku-ke.crt" \
3656 "$P_CLI" \
3657 0 \
3658 -c "Ciphersuite is TLS-RSA-WITH-"
3659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003660run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003661 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003662 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003663 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003664 1 \
3665 -C "Ciphersuite is "
3666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003667run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003668 "$P_SRV key_file=data_files/server5.key \
3669 crt_file=data_files/server5.ku-ds.crt" \
3670 "$P_CLI" \
3671 0 \
3672 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3673
3674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003675run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003676 "$P_SRV key_file=data_files/server5.key \
3677 crt_file=data_files/server5.ku-ka.crt" \
3678 "$P_CLI" \
3679 0 \
3680 -c "Ciphersuite is TLS-ECDH-"
3681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003682run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003683 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003684 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003685 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003686 1 \
3687 -C "Ciphersuite is "
3688
3689# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003690# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003692run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003693 "$O_SRV -key data_files/server2.key \
3694 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003695 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003696 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3697 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003698 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003699 -C "Processing of the Certificate handshake message failed" \
3700 -c "Ciphersuite is TLS-"
3701
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003702run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003703 "$O_SRV -key data_files/server2.key \
3704 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003705 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003706 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3707 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003708 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003709 -C "Processing of the Certificate handshake message failed" \
3710 -c "Ciphersuite is TLS-"
3711
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003712run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003713 "$O_SRV -key data_files/server2.key \
3714 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003715 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003716 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3717 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003718 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003719 -C "Processing of the Certificate handshake message failed" \
3720 -c "Ciphersuite is TLS-"
3721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003722run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003723 "$O_SRV -key data_files/server2.key \
3724 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003725 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003726 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3727 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003728 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003729 -c "Processing of the Certificate handshake message failed" \
3730 -C "Ciphersuite is TLS-"
3731
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003732run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3733 "$O_SRV -key data_files/server2.key \
3734 -cert data_files/server2.ku-ke.crt" \
3735 "$P_CLI debug_level=1 auth_mode=optional \
3736 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3737 0 \
3738 -c "bad certificate (usage extensions)" \
3739 -C "Processing of the Certificate handshake message failed" \
3740 -c "Ciphersuite is TLS-" \
3741 -c "! Usage does not match the keyUsage extension"
3742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003743run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003744 "$O_SRV -key data_files/server2.key \
3745 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003746 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003747 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3748 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003749 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003750 -C "Processing of the Certificate handshake message failed" \
3751 -c "Ciphersuite is TLS-"
3752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003753run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003754 "$O_SRV -key data_files/server2.key \
3755 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003756 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003757 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3758 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003759 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003760 -c "Processing of the Certificate handshake message failed" \
3761 -C "Ciphersuite is TLS-"
3762
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003763run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3764 "$O_SRV -key data_files/server2.key \
3765 -cert data_files/server2.ku-ds.crt" \
3766 "$P_CLI debug_level=1 auth_mode=optional \
3767 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3768 0 \
3769 -c "bad certificate (usage extensions)" \
3770 -C "Processing of the Certificate handshake message failed" \
3771 -c "Ciphersuite is TLS-" \
3772 -c "! Usage does not match the keyUsage extension"
3773
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003774# Tests for keyUsage in leaf certificates, part 3:
3775# server-side checking of client cert
3776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003777run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003778 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003779 "$O_CLI -key data_files/server2.key \
3780 -cert data_files/server2.ku-ds.crt" \
3781 0 \
3782 -S "bad certificate (usage extensions)" \
3783 -S "Processing of the Certificate handshake message failed"
3784
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003785run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003786 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003787 "$O_CLI -key data_files/server2.key \
3788 -cert data_files/server2.ku-ke.crt" \
3789 0 \
3790 -s "bad certificate (usage extensions)" \
3791 -S "Processing of the Certificate handshake message failed"
3792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003793run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003794 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003795 "$O_CLI -key data_files/server2.key \
3796 -cert data_files/server2.ku-ke.crt" \
3797 1 \
3798 -s "bad certificate (usage extensions)" \
3799 -s "Processing of the Certificate handshake message failed"
3800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003801run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003802 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003803 "$O_CLI -key data_files/server5.key \
3804 -cert data_files/server5.ku-ds.crt" \
3805 0 \
3806 -S "bad certificate (usage extensions)" \
3807 -S "Processing of the Certificate handshake message failed"
3808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003809run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003810 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003811 "$O_CLI -key data_files/server5.key \
3812 -cert data_files/server5.ku-ka.crt" \
3813 0 \
3814 -s "bad certificate (usage extensions)" \
3815 -S "Processing of the Certificate handshake message failed"
3816
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003817# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003819run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003820 "$P_SRV key_file=data_files/server5.key \
3821 crt_file=data_files/server5.eku-srv.crt" \
3822 "$P_CLI" \
3823 0
3824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003825run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003826 "$P_SRV key_file=data_files/server5.key \
3827 crt_file=data_files/server5.eku-srv.crt" \
3828 "$P_CLI" \
3829 0
3830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003831run_test "extKeyUsage srv: codeSign,anyEKU -> 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-cs_any.crt" \
3834 "$P_CLI" \
3835 0
3836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003837run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003838 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003839 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003840 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003841 1
3842
3843# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003845run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003846 "$O_SRV -key data_files/server5.key \
3847 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003848 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003849 0 \
3850 -C "bad certificate (usage extensions)" \
3851 -C "Processing of the Certificate handshake message failed" \
3852 -c "Ciphersuite is TLS-"
3853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003854run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003855 "$O_SRV -key data_files/server5.key \
3856 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003857 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003858 0 \
3859 -C "bad certificate (usage extensions)" \
3860 -C "Processing of the Certificate handshake message failed" \
3861 -c "Ciphersuite is TLS-"
3862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003863run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003864 "$O_SRV -key data_files/server5.key \
3865 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003866 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003867 0 \
3868 -C "bad certificate (usage extensions)" \
3869 -C "Processing of the Certificate handshake message failed" \
3870 -c "Ciphersuite is TLS-"
3871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003872run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003873 "$O_SRV -key data_files/server5.key \
3874 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003875 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003876 1 \
3877 -c "bad certificate (usage extensions)" \
3878 -c "Processing of the Certificate handshake message failed" \
3879 -C "Ciphersuite is TLS-"
3880
3881# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003883run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003884 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003885 "$O_CLI -key data_files/server5.key \
3886 -cert data_files/server5.eku-cli.crt" \
3887 0 \
3888 -S "bad certificate (usage extensions)" \
3889 -S "Processing of the Certificate handshake message failed"
3890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003891run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003892 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003893 "$O_CLI -key data_files/server5.key \
3894 -cert data_files/server5.eku-srv_cli.crt" \
3895 0 \
3896 -S "bad certificate (usage extensions)" \
3897 -S "Processing of the Certificate handshake message failed"
3898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003899run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003900 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003901 "$O_CLI -key data_files/server5.key \
3902 -cert data_files/server5.eku-cs_any.crt" \
3903 0 \
3904 -S "bad certificate (usage extensions)" \
3905 -S "Processing of the Certificate handshake message failed"
3906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003907run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003908 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003909 "$O_CLI -key data_files/server5.key \
3910 -cert data_files/server5.eku-cs.crt" \
3911 0 \
3912 -s "bad certificate (usage extensions)" \
3913 -S "Processing of the Certificate handshake message failed"
3914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003915run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003916 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003917 "$O_CLI -key data_files/server5.key \
3918 -cert data_files/server5.eku-cs.crt" \
3919 1 \
3920 -s "bad certificate (usage extensions)" \
3921 -s "Processing of the Certificate handshake message failed"
3922
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003923# Tests for DHM parameters loading
3924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003925run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003926 "$P_SRV" \
3927 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3928 debug_level=3" \
3929 0 \
3930 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003931 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003933run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003934 "$P_SRV dhm_file=data_files/dhparams.pem" \
3935 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3936 debug_level=3" \
3937 0 \
3938 -c "value of 'DHM: P ' (1024 bits)" \
3939 -c "value of 'DHM: G ' (2 bits)"
3940
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003941# Tests for DHM client-side size checking
3942
3943run_test "DHM size: server default, client default, OK" \
3944 "$P_SRV" \
3945 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3946 debug_level=1" \
3947 0 \
3948 -C "DHM prime too short:"
3949
3950run_test "DHM size: server default, client 2048, OK" \
3951 "$P_SRV" \
3952 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3953 debug_level=1 dhmlen=2048" \
3954 0 \
3955 -C "DHM prime too short:"
3956
3957run_test "DHM size: server 1024, client default, OK" \
3958 "$P_SRV dhm_file=data_files/dhparams.pem" \
3959 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3960 debug_level=1" \
3961 0 \
3962 -C "DHM prime too short:"
3963
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01003964run_test "DHM size: server 999, client 999, OK" \
3965 "$P_SRV dhm_file=data_files/dh.999.pem" \
3966 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3967 debug_level=1 dhmlen=999" \
3968 0 \
3969 -C "DHM prime too short:"
3970
3971run_test "DHM size: server 1000, client 1000, OK" \
3972 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3973 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3974 debug_level=1 dhmlen=1000" \
3975 0 \
3976 -C "DHM prime too short:"
3977
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003978run_test "DHM size: server 1000, client default, rejected" \
3979 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3980 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3981 debug_level=1" \
3982 1 \
3983 -c "DHM prime too short:"
3984
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01003985run_test "DHM size: server 1000, client 1001, rejected" \
3986 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3987 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3988 debug_level=1 dhmlen=1001" \
3989 1 \
3990 -c "DHM prime too short:"
3991
3992run_test "DHM size: server 999, client 1000, rejected" \
3993 "$P_SRV dhm_file=data_files/dh.999.pem" \
3994 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3995 debug_level=1 dhmlen=1000" \
3996 1 \
3997 -c "DHM prime too short:"
3998
3999run_test "DHM size: server 998, client 999, rejected" \
4000 "$P_SRV dhm_file=data_files/dh.998.pem" \
4001 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4002 debug_level=1 dhmlen=999" \
4003 1 \
4004 -c "DHM prime too short:"
4005
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004006run_test "DHM size: server default, client 2049, rejected" \
4007 "$P_SRV" \
4008 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4009 debug_level=1 dhmlen=2049" \
4010 1 \
4011 -c "DHM prime too short:"
4012
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004013# Tests for PSK callback
4014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004015run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004016 "$P_SRV psk=abc123 psk_identity=foo" \
4017 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4018 psk_identity=foo psk=abc123" \
4019 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004020 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004021 -S "SSL - Unknown identity received" \
4022 -S "SSL - Verification of the message MAC failed"
4023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004024run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004025 "$P_SRV" \
4026 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4027 psk_identity=foo psk=abc123" \
4028 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004029 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004030 -S "SSL - Unknown identity received" \
4031 -S "SSL - Verification of the message MAC failed"
4032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004033run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004034 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
4035 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4036 psk_identity=foo psk=abc123" \
4037 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004038 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004039 -s "SSL - Unknown identity received" \
4040 -S "SSL - Verification of the message MAC failed"
4041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004042run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004043 "$P_SRV psk_list=abc,dead,def,beef" \
4044 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4045 psk_identity=abc psk=dead" \
4046 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004047 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004048 -S "SSL - Unknown identity received" \
4049 -S "SSL - Verification of the message MAC failed"
4050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004051run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004052 "$P_SRV psk_list=abc,dead,def,beef" \
4053 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4054 psk_identity=def psk=beef" \
4055 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004056 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004057 -S "SSL - Unknown identity received" \
4058 -S "SSL - Verification of the message MAC failed"
4059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004060run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004061 "$P_SRV psk_list=abc,dead,def,beef" \
4062 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4063 psk_identity=ghi psk=beef" \
4064 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004065 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004066 -s "SSL - Unknown identity received" \
4067 -S "SSL - Verification of the message MAC failed"
4068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004069run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004070 "$P_SRV psk_list=abc,dead,def,beef" \
4071 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4072 psk_identity=abc psk=beef" \
4073 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004074 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004075 -S "SSL - Unknown identity received" \
4076 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004077
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004078# Tests for EC J-PAKE
4079
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004080requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004081run_test "ECJPAKE: client not configured" \
4082 "$P_SRV debug_level=3" \
4083 "$P_CLI debug_level=3" \
4084 0 \
4085 -C "add ciphersuite: c0ff" \
4086 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004087 -S "found ecjpake kkpp extension" \
4088 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004089 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004090 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004091 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004092 -S "None of the common ciphersuites is usable"
4093
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004094requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004095run_test "ECJPAKE: server not configured" \
4096 "$P_SRV debug_level=3" \
4097 "$P_CLI debug_level=3 ecjpake_pw=bla \
4098 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4099 1 \
4100 -c "add ciphersuite: c0ff" \
4101 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004102 -s "found ecjpake kkpp extension" \
4103 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004104 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004105 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004106 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004107 -s "None of the common ciphersuites is usable"
4108
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004109requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004110run_test "ECJPAKE: working, TLS" \
4111 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4112 "$P_CLI debug_level=3 ecjpake_pw=bla \
4113 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004114 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004115 -c "add ciphersuite: c0ff" \
4116 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004117 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004118 -s "found ecjpake kkpp extension" \
4119 -S "skip ecjpake kkpp extension" \
4120 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004121 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004122 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004123 -S "None of the common ciphersuites is usable" \
4124 -S "SSL - Verification of the message MAC failed"
4125
Janos Follath74537a62016-09-02 13:45:28 +01004126server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004127requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004128run_test "ECJPAKE: password mismatch, TLS" \
4129 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4130 "$P_CLI debug_level=3 ecjpake_pw=bad \
4131 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4132 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004133 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004134 -s "SSL - Verification of the message MAC failed"
4135
Dave Rodgmancee9e922021-06-29 19:05:34 +01004136requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004137run_test "ECJPAKE: working, DTLS" \
4138 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4139 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4140 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4141 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004142 -c "re-using cached ecjpake parameters" \
4143 -S "SSL - Verification of the message MAC failed"
4144
Dave Rodgmancee9e922021-06-29 19:05:34 +01004145requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004146run_test "ECJPAKE: working, DTLS, no cookie" \
4147 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4148 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4149 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4150 0 \
4151 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004152 -S "SSL - Verification of the message MAC failed"
4153
Janos Follath74537a62016-09-02 13:45:28 +01004154server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004155requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004156run_test "ECJPAKE: password mismatch, DTLS" \
4157 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4158 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4159 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4160 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004161 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004162 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004163
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004164# for tests with configs/config-thread.h
Dave Rodgmancee9e922021-06-29 19:05:34 +01004165requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004166run_test "ECJPAKE: working, DTLS, nolog" \
4167 "$P_SRV dtls=1 ecjpake_pw=bla" \
4168 "$P_CLI dtls=1 ecjpake_pw=bla \
4169 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4170 0
4171
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004172# Tests for ciphersuites per version
4173
Janos Follathe2681a42016-03-07 15:57:05 +00004174requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004175requires_config_enabled MBEDTLS_CAMELLIA_C
4176requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004177run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004178 "$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 +02004179 "$P_CLI force_version=ssl3" \
4180 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004181 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004182
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004183requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4184requires_config_enabled MBEDTLS_CAMELLIA_C
4185requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004186run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004187 "$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 +01004188 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004189 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004190 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004191
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004192requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4193requires_config_enabled MBEDTLS_CAMELLIA_C
4194requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004195run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004196 "$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 +02004197 "$P_CLI force_version=tls1_1" \
4198 0 \
4199 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4200
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004201requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4202requires_config_enabled MBEDTLS_CAMELLIA_C
4203requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004204run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004205 "$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 +02004206 "$P_CLI force_version=tls1_2" \
4207 0 \
4208 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4209
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004210# Test for ClientHello without extensions
4211
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004212requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004213run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004214 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004215 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004216 0 \
4217 -s "dumping 'client hello extensions' (0 bytes)"
4218
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004219# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004220
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004221run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004222 "$P_SRV" \
4223 "$P_CLI request_size=100" \
4224 0 \
4225 -s "Read from client: 100 bytes read$"
4226
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004227run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004228 "$P_SRV" \
4229 "$P_CLI request_size=500" \
4230 0 \
4231 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004232
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004233# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004234
Janos Follathe2681a42016-03-07 15:57:05 +00004235requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004236run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004237 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004238 "$P_CLI request_size=1 force_version=ssl3 \
4239 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4240 0 \
4241 -s "Read from client: 1 bytes read"
4242
Janos Follathe2681a42016-03-07 15:57:05 +00004243requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004244run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004245 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004246 "$P_CLI request_size=1 force_version=ssl3 \
4247 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4248 0 \
4249 -s "Read from client: 1 bytes read"
4250
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004251run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004252 "$P_SRV" \
4253 "$P_CLI request_size=1 force_version=tls1 \
4254 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4255 0 \
4256 -s "Read from client: 1 bytes read"
4257
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004258run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004259 "$P_SRV" \
4260 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4261 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4262 0 \
4263 -s "Read from client: 1 bytes read"
4264
Hanno Becker32c55012017-11-10 08:42:54 +00004265requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004266run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004267 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004268 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004269 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004270 0 \
4271 -s "Read from client: 1 bytes read"
4272
Hanno Becker32c55012017-11-10 08:42:54 +00004273requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004274run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004275 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004276 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004277 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004278 0 \
4279 -s "Read from client: 1 bytes read"
4280
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004281run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004282 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004283 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004284 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4285 0 \
4286 -s "Read from client: 1 bytes read"
4287
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004288run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004289 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4290 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004291 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004292 0 \
4293 -s "Read from client: 1 bytes read"
4294
4295requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004296run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004297 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004298 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004299 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004300 0 \
4301 -s "Read from client: 1 bytes read"
4302
Hanno Becker8501f982017-11-10 08:59:04 +00004303requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004304run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004305 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4306 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4307 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004308 0 \
4309 -s "Read from client: 1 bytes read"
4310
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004311run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004312 "$P_SRV" \
4313 "$P_CLI request_size=1 force_version=tls1_1 \
4314 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4315 0 \
4316 -s "Read from client: 1 bytes read"
4317
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004318run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004319 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004320 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004321 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004322 0 \
4323 -s "Read from client: 1 bytes read"
4324
4325requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004326run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004327 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004328 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004329 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004330 0 \
4331 -s "Read from client: 1 bytes read"
4332
4333requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004334run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004335 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004336 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004337 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004338 0 \
4339 -s "Read from client: 1 bytes read"
4340
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004341run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004342 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004343 "$P_CLI request_size=1 force_version=tls1_1 \
4344 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4345 0 \
4346 -s "Read from client: 1 bytes read"
4347
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004348run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004349 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004350 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004351 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004352 0 \
4353 -s "Read from client: 1 bytes read"
4354
Hanno Becker8501f982017-11-10 08:59:04 +00004355requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004356run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004357 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004358 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004359 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004360 0 \
4361 -s "Read from client: 1 bytes read"
4362
Hanno Becker32c55012017-11-10 08:42:54 +00004363requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004364run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004365 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004366 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004367 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004368 0 \
4369 -s "Read from client: 1 bytes read"
4370
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004371run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004372 "$P_SRV" \
4373 "$P_CLI request_size=1 force_version=tls1_2 \
4374 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4375 0 \
4376 -s "Read from client: 1 bytes read"
4377
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004378run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004379 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004380 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004381 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004382 0 \
4383 -s "Read from client: 1 bytes read"
4384
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004385run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004386 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004387 "$P_CLI request_size=1 force_version=tls1_2 \
4388 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004389 0 \
4390 -s "Read from client: 1 bytes read"
4391
Hanno Becker32c55012017-11-10 08:42:54 +00004392requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004393run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004394 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004395 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004396 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004397 0 \
4398 -s "Read from client: 1 bytes read"
4399
Hanno Becker8501f982017-11-10 08:59:04 +00004400requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004401run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004402 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004403 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004404 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004405 0 \
4406 -s "Read from client: 1 bytes read"
4407
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004408run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004409 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004410 "$P_CLI request_size=1 force_version=tls1_2 \
4411 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4412 0 \
4413 -s "Read from client: 1 bytes read"
4414
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004415run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004416 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004417 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004418 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004419 0 \
4420 -s "Read from client: 1 bytes read"
4421
Hanno Becker32c55012017-11-10 08:42:54 +00004422requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004423run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004424 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004425 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004426 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004427 0 \
4428 -s "Read from client: 1 bytes read"
4429
Hanno Becker8501f982017-11-10 08:59:04 +00004430requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004431run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004432 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004433 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004434 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004435 0 \
4436 -s "Read from client: 1 bytes read"
4437
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004438run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004439 "$P_SRV" \
4440 "$P_CLI request_size=1 force_version=tls1_2 \
4441 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4442 0 \
4443 -s "Read from client: 1 bytes read"
4444
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004445run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004446 "$P_SRV" \
4447 "$P_CLI request_size=1 force_version=tls1_2 \
4448 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4449 0 \
4450 -s "Read from client: 1 bytes read"
4451
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004452# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004453
4454requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004455run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004456 "$P_SRV dtls=1 force_version=dtls1" \
4457 "$P_CLI dtls=1 request_size=1 \
4458 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4459 0 \
4460 -s "Read from client: 1 bytes read"
4461
4462requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004463run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004464 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4465 "$P_CLI dtls=1 request_size=1 \
4466 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4467 0 \
4468 -s "Read from client: 1 bytes read"
4469
4470requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4471requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004472run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004473 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4474 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004475 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4476 0 \
4477 -s "Read from client: 1 bytes read"
4478
4479requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4480requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004481run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004482 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004483 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004484 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004485 0 \
4486 -s "Read from client: 1 bytes read"
4487
4488requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004489run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004490 "$P_SRV dtls=1 force_version=dtls1_2" \
4491 "$P_CLI dtls=1 request_size=1 \
4492 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4493 0 \
4494 -s "Read from client: 1 bytes read"
4495
4496requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004497run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004498 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004499 "$P_CLI dtls=1 request_size=1 \
4500 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4501 0 \
4502 -s "Read from client: 1 bytes read"
4503
4504requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4505requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004506run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004507 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004508 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004509 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004510 0 \
4511 -s "Read from client: 1 bytes read"
4512
4513requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4514requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004515run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004516 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004517 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004518 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004519 0 \
4520 -s "Read from client: 1 bytes read"
4521
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004522# Tests for small server packets
4523
4524requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4525run_test "Small server packet SSLv3 BlockCipher" \
4526 "$P_SRV response_size=1 min_version=ssl3" \
4527 "$P_CLI force_version=ssl3 \
4528 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4529 0 \
4530 -c "Read from server: 1 bytes read"
4531
4532requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4533run_test "Small server packet SSLv3 StreamCipher" \
4534 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4535 "$P_CLI force_version=ssl3 \
4536 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4537 0 \
4538 -c "Read from server: 1 bytes read"
4539
4540run_test "Small server packet TLS 1.0 BlockCipher" \
4541 "$P_SRV response_size=1" \
4542 "$P_CLI force_version=tls1 \
4543 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4544 0 \
4545 -c "Read from server: 1 bytes read"
4546
4547run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4548 "$P_SRV response_size=1" \
4549 "$P_CLI force_version=tls1 etm=0 \
4550 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4551 0 \
4552 -c "Read from server: 1 bytes read"
4553
4554requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4555run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4556 "$P_SRV response_size=1 trunc_hmac=1" \
4557 "$P_CLI force_version=tls1 \
4558 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4559 0 \
4560 -c "Read from server: 1 bytes read"
4561
4562requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4563run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4564 "$P_SRV response_size=1 trunc_hmac=1" \
4565 "$P_CLI force_version=tls1 \
4566 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4567 0 \
4568 -c "Read from server: 1 bytes read"
4569
4570run_test "Small server packet TLS 1.0 StreamCipher" \
4571 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4572 "$P_CLI force_version=tls1 \
4573 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4574 0 \
4575 -c "Read from server: 1 bytes read"
4576
4577run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4578 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4579 "$P_CLI force_version=tls1 \
4580 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4581 0 \
4582 -c "Read from server: 1 bytes read"
4583
4584requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4585run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4586 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4587 "$P_CLI force_version=tls1 \
4588 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4589 0 \
4590 -c "Read from server: 1 bytes read"
4591
4592requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4593run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4594 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4595 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4596 trunc_hmac=1 etm=0" \
4597 0 \
4598 -c "Read from server: 1 bytes read"
4599
4600run_test "Small server packet TLS 1.1 BlockCipher" \
4601 "$P_SRV response_size=1" \
4602 "$P_CLI force_version=tls1_1 \
4603 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4604 0 \
4605 -c "Read from server: 1 bytes read"
4606
4607run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4608 "$P_SRV response_size=1" \
4609 "$P_CLI force_version=tls1_1 \
4610 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4611 0 \
4612 -c "Read from server: 1 bytes read"
4613
4614requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4615run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4616 "$P_SRV response_size=1 trunc_hmac=1" \
4617 "$P_CLI force_version=tls1_1 \
4618 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4619 0 \
4620 -c "Read from server: 1 bytes read"
4621
4622requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4623run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4624 "$P_SRV response_size=1 trunc_hmac=1" \
4625 "$P_CLI force_version=tls1_1 \
4626 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4627 0 \
4628 -c "Read from server: 1 bytes read"
4629
4630run_test "Small server packet TLS 1.1 StreamCipher" \
4631 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4632 "$P_CLI force_version=tls1_1 \
4633 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4634 0 \
4635 -c "Read from server: 1 bytes read"
4636
4637run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4638 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4639 "$P_CLI force_version=tls1_1 \
4640 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4641 0 \
4642 -c "Read from server: 1 bytes read"
4643
4644requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4645run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4646 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4647 "$P_CLI force_version=tls1_1 \
4648 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4649 0 \
4650 -c "Read from server: 1 bytes read"
4651
4652requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4653run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4654 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4655 "$P_CLI force_version=tls1_1 \
4656 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4657 0 \
4658 -c "Read from server: 1 bytes read"
4659
4660run_test "Small server packet TLS 1.2 BlockCipher" \
4661 "$P_SRV response_size=1" \
4662 "$P_CLI force_version=tls1_2 \
4663 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4664 0 \
4665 -c "Read from server: 1 bytes read"
4666
4667run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4668 "$P_SRV response_size=1" \
4669 "$P_CLI force_version=tls1_2 \
4670 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4671 0 \
4672 -c "Read from server: 1 bytes read"
4673
4674run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4675 "$P_SRV response_size=1" \
4676 "$P_CLI force_version=tls1_2 \
4677 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4678 0 \
4679 -c "Read from server: 1 bytes read"
4680
4681requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4682run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4683 "$P_SRV response_size=1 trunc_hmac=1" \
4684 "$P_CLI force_version=tls1_2 \
4685 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4686 0 \
4687 -c "Read from server: 1 bytes read"
4688
4689requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4690run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4691 "$P_SRV response_size=1 trunc_hmac=1" \
4692 "$P_CLI force_version=tls1_2 \
4693 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4694 0 \
4695 -c "Read from server: 1 bytes read"
4696
4697run_test "Small server packet TLS 1.2 StreamCipher" \
4698 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4699 "$P_CLI force_version=tls1_2 \
4700 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4701 0 \
4702 -c "Read from server: 1 bytes read"
4703
4704run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4705 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4706 "$P_CLI force_version=tls1_2 \
4707 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4708 0 \
4709 -c "Read from server: 1 bytes read"
4710
4711requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4712run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4713 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4714 "$P_CLI force_version=tls1_2 \
4715 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4716 0 \
4717 -c "Read from server: 1 bytes read"
4718
4719requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4720run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4721 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4722 "$P_CLI force_version=tls1_2 \
4723 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4724 0 \
4725 -c "Read from server: 1 bytes read"
4726
4727run_test "Small server packet TLS 1.2 AEAD" \
4728 "$P_SRV response_size=1" \
4729 "$P_CLI force_version=tls1_2 \
4730 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4731 0 \
4732 -c "Read from server: 1 bytes read"
4733
4734run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4735 "$P_SRV response_size=1" \
4736 "$P_CLI force_version=tls1_2 \
4737 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4738 0 \
4739 -c "Read from server: 1 bytes read"
4740
4741# Tests for small server packets in DTLS
4742
4743requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4744run_test "Small server packet DTLS 1.0" \
4745 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4746 "$P_CLI dtls=1 \
4747 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4748 0 \
4749 -c "Read from server: 1 bytes read"
4750
4751requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4752run_test "Small server packet DTLS 1.0, without EtM" \
4753 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4754 "$P_CLI dtls=1 \
4755 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4756 0 \
4757 -c "Read from server: 1 bytes read"
4758
4759requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4760requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4761run_test "Small server packet DTLS 1.0, truncated hmac" \
4762 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4763 "$P_CLI dtls=1 trunc_hmac=1 \
4764 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4765 0 \
4766 -c "Read from server: 1 bytes read"
4767
4768requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4769requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4770run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4771 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4772 "$P_CLI dtls=1 \
4773 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4774 0 \
4775 -c "Read from server: 1 bytes read"
4776
4777requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4778run_test "Small server packet DTLS 1.2" \
4779 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4780 "$P_CLI dtls=1 \
4781 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4782 0 \
4783 -c "Read from server: 1 bytes read"
4784
4785requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4786run_test "Small server packet DTLS 1.2, without EtM" \
4787 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4788 "$P_CLI dtls=1 \
4789 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4790 0 \
4791 -c "Read from server: 1 bytes read"
4792
4793requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4794requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4795run_test "Small server packet DTLS 1.2, truncated hmac" \
4796 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4797 "$P_CLI dtls=1 \
4798 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4799 0 \
4800 -c "Read from server: 1 bytes read"
4801
4802requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4803requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4804run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4805 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4806 "$P_CLI dtls=1 \
4807 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4808 0 \
4809 -c "Read from server: 1 bytes read"
4810
Janos Follath00efff72016-05-06 13:48:23 +01004811# A test for extensions in SSLv3
4812
4813requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4814run_test "SSLv3 with extensions, server side" \
4815 "$P_SRV min_version=ssl3 debug_level=3" \
4816 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4817 0 \
4818 -S "dumping 'client hello extensions'" \
4819 -S "server hello, total extension length:"
4820
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004821# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004822
Angus Grattonc4dd0732018-04-11 16:28:39 +10004823# How many fragments do we expect to write $1 bytes?
4824fragments_for_write() {
4825 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4826}
4827
Janos Follathe2681a42016-03-07 15:57:05 +00004828requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004829run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004830 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004831 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004832 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4833 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004834 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4835 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004836
Janos Follathe2681a42016-03-07 15:57:05 +00004837requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004838run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004839 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004840 "$P_CLI request_size=16384 force_version=ssl3 \
4841 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4842 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004843 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4844 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004845
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004846run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004847 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004848 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004849 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4850 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004851 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4852 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004853
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004854run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004855 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004856 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4857 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4858 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004859 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004860
Hanno Becker32c55012017-11-10 08:42:54 +00004861requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004862run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004863 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004864 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004865 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004866 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004867 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4868 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004869
Hanno Becker32c55012017-11-10 08:42:54 +00004870requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004871run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004872 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004873 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004874 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004875 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004876 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004877
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004878run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004879 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004880 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004881 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4882 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004883 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004884
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004885run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004886 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4887 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004888 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004889 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004890 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004891
4892requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004893run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004894 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004895 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004896 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004897 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004898 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004899
Hanno Becker278fc7a2017-11-10 09:16:28 +00004900requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004901run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004902 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004903 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004904 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004905 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004906 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4907 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004908
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004909run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004910 "$P_SRV" \
4911 "$P_CLI request_size=16384 force_version=tls1_1 \
4912 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4913 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004914 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4915 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004916
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004917run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004918 "$P_SRV" \
4919 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4920 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004921 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004922 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004923
Hanno Becker32c55012017-11-10 08:42:54 +00004924requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004925run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004926 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004927 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004928 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004929 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004930 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004931
Hanno Becker32c55012017-11-10 08:42:54 +00004932requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004933run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004934 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004935 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004936 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004937 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004938 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004939
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004940run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004941 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4942 "$P_CLI request_size=16384 force_version=tls1_1 \
4943 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4944 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004945 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4946 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004947
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004948run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004949 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004950 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004951 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004952 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004953 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4954 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004955
Hanno Becker278fc7a2017-11-10 09:16:28 +00004956requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004957run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004958 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004959 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004960 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004961 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004962 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004963
Hanno Becker278fc7a2017-11-10 09:16:28 +00004964requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004965run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004966 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004967 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004968 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004969 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004970 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4971 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004972
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004973run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004974 "$P_SRV" \
4975 "$P_CLI request_size=16384 force_version=tls1_2 \
4976 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4977 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004978 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4979 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004980
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004981run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004982 "$P_SRV" \
4983 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4984 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4985 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004986 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004987
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004988run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004989 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004990 "$P_CLI request_size=16384 force_version=tls1_2 \
4991 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004992 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004993 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4994 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004995
Hanno Becker32c55012017-11-10 08:42:54 +00004996requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004997run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004998 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004999 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005000 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005001 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005002 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005003
Hanno Becker278fc7a2017-11-10 09:16:28 +00005004requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005005run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005006 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005007 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005008 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005009 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005010 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5011 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005012
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005013run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005014 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005015 "$P_CLI request_size=16384 force_version=tls1_2 \
5016 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5017 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005018 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5019 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005020
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005021run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005022 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005023 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005024 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5025 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005026 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005027
Hanno Becker32c55012017-11-10 08:42:54 +00005028requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005029run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005030 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005031 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005032 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005033 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005034 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005035
Hanno Becker278fc7a2017-11-10 09:16:28 +00005036requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005037run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005038 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005039 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005040 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005041 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005042 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5043 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005044
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005045run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005046 "$P_SRV" \
5047 "$P_CLI request_size=16384 force_version=tls1_2 \
5048 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5049 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005050 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5051 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005052
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005053run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005054 "$P_SRV" \
5055 "$P_CLI request_size=16384 force_version=tls1_2 \
5056 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5057 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005058 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5059 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005060
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005061# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005062requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5063run_test "Large server packet SSLv3 StreamCipher" \
5064 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5065 "$P_CLI force_version=ssl3 \
5066 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5067 0 \
5068 -c "Read from server: 16384 bytes read"
5069
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04005070# Checking next 4 tests logs for 1n-1 split against BEAST too
5071requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5072run_test "Large server packet SSLv3 BlockCipher" \
5073 "$P_SRV response_size=16384 min_version=ssl3" \
5074 "$P_CLI force_version=ssl3 recsplit=0 \
5075 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5076 0 \
5077 -c "Read from server: 1 bytes read"\
5078 -c "16383 bytes read"\
5079 -C "Read from server: 16384 bytes read"
5080
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005081run_test "Large server packet TLS 1.0 BlockCipher" \
5082 "$P_SRV response_size=16384" \
5083 "$P_CLI force_version=tls1 recsplit=0 \
5084 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5085 0 \
5086 -c "Read from server: 1 bytes read"\
5087 -c "16383 bytes read"\
5088 -C "Read from server: 16384 bytes read"
5089
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005090run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5091 "$P_SRV response_size=16384" \
5092 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5093 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5094 0 \
5095 -c "Read from server: 1 bytes read"\
5096 -c "16383 bytes read"\
5097 -C "Read from server: 16384 bytes read"
5098
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005099requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5100run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5101 "$P_SRV response_size=16384" \
5102 "$P_CLI force_version=tls1 recsplit=0 \
5103 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5104 trunc_hmac=1" \
5105 0 \
5106 -c "Read from server: 1 bytes read"\
5107 -c "16383 bytes read"\
5108 -C "Read from server: 16384 bytes read"
5109
5110requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5111run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5112 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5113 "$P_CLI force_version=tls1 \
5114 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5115 trunc_hmac=1" \
5116 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005117 -s "16384 bytes written in 1 fragments" \
5118 -c "Read from server: 16384 bytes read"
5119
5120run_test "Large server packet TLS 1.0 StreamCipher" \
5121 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5122 "$P_CLI force_version=tls1 \
5123 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5124 0 \
5125 -s "16384 bytes written in 1 fragments" \
5126 -c "Read from server: 16384 bytes read"
5127
5128run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5129 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5130 "$P_CLI force_version=tls1 \
5131 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5132 0 \
5133 -s "16384 bytes written in 1 fragments" \
5134 -c "Read from server: 16384 bytes read"
5135
5136requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5137run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5138 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5139 "$P_CLI force_version=tls1 \
5140 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5141 0 \
5142 -s "16384 bytes written in 1 fragments" \
5143 -c "Read from server: 16384 bytes read"
5144
5145requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5146run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5147 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5148 "$P_CLI force_version=tls1 \
5149 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5150 0 \
5151 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005152 -c "Read from server: 16384 bytes read"
5153
5154run_test "Large server packet TLS 1.1 BlockCipher" \
5155 "$P_SRV response_size=16384" \
5156 "$P_CLI force_version=tls1_1 \
5157 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5158 0 \
5159 -c "Read from server: 16384 bytes read"
5160
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005161run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5162 "$P_SRV response_size=16384" \
5163 "$P_CLI force_version=tls1_1 etm=0 \
5164 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005165 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005166 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005167 -c "Read from server: 16384 bytes read"
5168
5169requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5170run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5171 "$P_SRV response_size=16384" \
5172 "$P_CLI force_version=tls1_1 \
5173 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5174 trunc_hmac=1" \
5175 0 \
5176 -c "Read from server: 16384 bytes read"
5177
5178requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005179run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5180 "$P_SRV response_size=16384 trunc_hmac=1" \
5181 "$P_CLI force_version=tls1_1 \
5182 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5183 0 \
5184 -s "16384 bytes written in 1 fragments" \
5185 -c "Read from server: 16384 bytes read"
5186
5187run_test "Large server packet TLS 1.1 StreamCipher" \
5188 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5189 "$P_CLI force_version=tls1_1 \
5190 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5191 0 \
5192 -c "Read from server: 16384 bytes read"
5193
5194run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5195 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5196 "$P_CLI force_version=tls1_1 \
5197 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5198 0 \
5199 -s "16384 bytes written in 1 fragments" \
5200 -c "Read from server: 16384 bytes read"
5201
5202requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005203run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5204 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5205 "$P_CLI force_version=tls1_1 \
5206 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5207 trunc_hmac=1" \
5208 0 \
5209 -c "Read from server: 16384 bytes read"
5210
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005211run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5212 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5213 "$P_CLI force_version=tls1_1 \
5214 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5215 0 \
5216 -s "16384 bytes written in 1 fragments" \
5217 -c "Read from server: 16384 bytes read"
5218
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005219run_test "Large server packet TLS 1.2 BlockCipher" \
5220 "$P_SRV response_size=16384" \
5221 "$P_CLI force_version=tls1_2 \
5222 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5223 0 \
5224 -c "Read from server: 16384 bytes read"
5225
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005226run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5227 "$P_SRV response_size=16384" \
5228 "$P_CLI force_version=tls1_2 etm=0 \
5229 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5230 0 \
5231 -s "16384 bytes written in 1 fragments" \
5232 -c "Read from server: 16384 bytes read"
5233
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005234run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5235 "$P_SRV response_size=16384" \
5236 "$P_CLI force_version=tls1_2 \
5237 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5238 0 \
5239 -c "Read from server: 16384 bytes read"
5240
5241requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5242run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5243 "$P_SRV response_size=16384" \
5244 "$P_CLI force_version=tls1_2 \
5245 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5246 trunc_hmac=1" \
5247 0 \
5248 -c "Read from server: 16384 bytes read"
5249
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005250run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5251 "$P_SRV response_size=16384 trunc_hmac=1" \
5252 "$P_CLI force_version=tls1_2 \
5253 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5254 0 \
5255 -s "16384 bytes written in 1 fragments" \
5256 -c "Read from server: 16384 bytes read"
5257
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005258run_test "Large server packet TLS 1.2 StreamCipher" \
5259 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5260 "$P_CLI force_version=tls1_2 \
5261 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5262 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005263 -s "16384 bytes written in 1 fragments" \
5264 -c "Read from server: 16384 bytes read"
5265
5266run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5267 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5268 "$P_CLI force_version=tls1_2 \
5269 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5270 0 \
5271 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005272 -c "Read from server: 16384 bytes read"
5273
5274requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5275run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5276 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5277 "$P_CLI force_version=tls1_2 \
5278 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5279 trunc_hmac=1" \
5280 0 \
5281 -c "Read from server: 16384 bytes read"
5282
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005283requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5284run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5285 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5286 "$P_CLI force_version=tls1_2 \
5287 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5288 0 \
5289 -s "16384 bytes written in 1 fragments" \
5290 -c "Read from server: 16384 bytes read"
5291
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005292run_test "Large server packet TLS 1.2 AEAD" \
5293 "$P_SRV response_size=16384" \
5294 "$P_CLI force_version=tls1_2 \
5295 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5296 0 \
5297 -c "Read from server: 16384 bytes read"
5298
5299run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5300 "$P_SRV response_size=16384" \
5301 "$P_CLI force_version=tls1_2 \
5302 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5303 0 \
5304 -c "Read from server: 16384 bytes read"
5305
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005306# Tests for restartable ECC
5307
5308requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5309run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005310 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005311 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005312 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005313 debug_level=1" \
5314 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005315 -C "x509_verify_cert.*4b00" \
5316 -C "mbedtls_pk_verify.*4b00" \
5317 -C "mbedtls_ecdh_make_public.*4b00" \
5318 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005319
5320requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5321run_test "EC restart: TLS, max_ops=0" \
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 ec_max_ops=0" \
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=65535" \
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=65535" \
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=1000" \
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=1000" \
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
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005357run_test "EC restart: TLS, max_ops=1000, badsign" \
5358 "$P_SRV auth_mode=required \
5359 crt_file=data_files/server5-badsign.crt \
5360 key_file=data_files/server5.key" \
5361 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5362 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5363 debug_level=1 ec_max_ops=1000" \
5364 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005365 -c "x509_verify_cert.*4b00" \
5366 -C "mbedtls_pk_verify.*4b00" \
5367 -C "mbedtls_ecdh_make_public.*4b00" \
5368 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005369 -c "! The certificate is not correctly signed by the trusted CA" \
5370 -c "! mbedtls_ssl_handshake returned" \
5371 -c "X509 - Certificate verification failed"
5372
5373requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5374run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5375 "$P_SRV auth_mode=required \
5376 crt_file=data_files/server5-badsign.crt \
5377 key_file=data_files/server5.key" \
5378 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5379 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5380 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5381 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005382 -c "x509_verify_cert.*4b00" \
5383 -c "mbedtls_pk_verify.*4b00" \
5384 -c "mbedtls_ecdh_make_public.*4b00" \
5385 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005386 -c "! The certificate is not correctly signed by the trusted CA" \
5387 -C "! mbedtls_ssl_handshake returned" \
5388 -C "X509 - Certificate verification failed"
5389
5390requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5391run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5392 "$P_SRV auth_mode=required \
5393 crt_file=data_files/server5-badsign.crt \
5394 key_file=data_files/server5.key" \
5395 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5396 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5397 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5398 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005399 -C "x509_verify_cert.*4b00" \
5400 -c "mbedtls_pk_verify.*4b00" \
5401 -c "mbedtls_ecdh_make_public.*4b00" \
5402 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005403 -C "! The certificate is not correctly signed by the trusted CA" \
5404 -C "! mbedtls_ssl_handshake returned" \
5405 -C "X509 - Certificate verification failed"
5406
5407requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005408run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005409 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005410 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005411 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005412 dtls=1 debug_level=1 ec_max_ops=1000" \
5413 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005414 -c "x509_verify_cert.*4b00" \
5415 -c "mbedtls_pk_verify.*4b00" \
5416 -c "mbedtls_ecdh_make_public.*4b00" \
5417 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005418
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005419requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5420run_test "EC restart: TLS, max_ops=1000 no client auth" \
5421 "$P_SRV" \
5422 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5423 debug_level=1 ec_max_ops=1000" \
5424 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005425 -c "x509_verify_cert.*4b00" \
5426 -c "mbedtls_pk_verify.*4b00" \
5427 -c "mbedtls_ecdh_make_public.*4b00" \
5428 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005429
5430requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5431run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5432 "$P_SRV psk=abc123" \
5433 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5434 psk=abc123 debug_level=1 ec_max_ops=1000" \
5435 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005436 -C "x509_verify_cert.*4b00" \
5437 -C "mbedtls_pk_verify.*4b00" \
5438 -C "mbedtls_ecdh_make_public.*4b00" \
5439 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005440
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005441# Tests of asynchronous private key support in SSL
5442
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005443requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005444run_test "SSL async private: sign, delay=0" \
5445 "$P_SRV \
5446 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005447 "$P_CLI" \
5448 0 \
5449 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005450 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005451
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005452requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005453run_test "SSL async private: sign, delay=1" \
5454 "$P_SRV \
5455 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005456 "$P_CLI" \
5457 0 \
5458 -s "Async sign callback: using key slot " \
5459 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005460 -s "Async resume (slot [0-9]): sign done, status=0"
5461
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005462requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5463run_test "SSL async private: sign, delay=2" \
5464 "$P_SRV \
5465 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5466 "$P_CLI" \
5467 0 \
5468 -s "Async sign callback: using key slot " \
5469 -U "Async sign callback: using key slot " \
5470 -s "Async resume (slot [0-9]): call 1 more times." \
5471 -s "Async resume (slot [0-9]): call 0 more times." \
5472 -s "Async resume (slot [0-9]): sign done, status=0"
5473
Gilles Peskined3268832018-04-26 06:23:59 +02005474# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5475# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5476requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5477requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5478run_test "SSL async private: sign, RSA, TLS 1.1" \
5479 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5480 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5481 "$P_CLI force_version=tls1_1" \
5482 0 \
5483 -s "Async sign callback: using key slot " \
5484 -s "Async resume (slot [0-9]): sign done, status=0"
5485
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005486requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005487run_test "SSL async private: sign, SNI" \
5488 "$P_SRV debug_level=3 \
5489 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5490 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5491 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5492 "$P_CLI server_name=polarssl.example" \
5493 0 \
5494 -s "Async sign callback: using key slot " \
5495 -s "Async resume (slot [0-9]): sign done, status=0" \
5496 -s "parse ServerName extension" \
5497 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5498 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5499
5500requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005501run_test "SSL async private: decrypt, delay=0" \
5502 "$P_SRV \
5503 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5504 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5505 0 \
5506 -s "Async decrypt callback: using key slot " \
5507 -s "Async resume (slot [0-9]): decrypt done, status=0"
5508
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005509requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005510run_test "SSL async private: decrypt, delay=1" \
5511 "$P_SRV \
5512 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5513 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5514 0 \
5515 -s "Async decrypt callback: using key slot " \
5516 -s "Async resume (slot [0-9]): call 0 more times." \
5517 -s "Async resume (slot [0-9]): decrypt done, status=0"
5518
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005519requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005520run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5521 "$P_SRV psk=abc123 \
5522 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5523 "$P_CLI psk=abc123 \
5524 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5525 0 \
5526 -s "Async decrypt callback: using key slot " \
5527 -s "Async resume (slot [0-9]): decrypt done, status=0"
5528
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005529requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005530run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5531 "$P_SRV psk=abc123 \
5532 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5533 "$P_CLI psk=abc123 \
5534 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5535 0 \
5536 -s "Async decrypt callback: using key slot " \
5537 -s "Async resume (slot [0-9]): call 0 more times." \
5538 -s "Async resume (slot [0-9]): decrypt done, status=0"
5539
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005540requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005541run_test "SSL async private: sign callback not present" \
5542 "$P_SRV \
5543 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5544 "$P_CLI; [ \$? -eq 1 ] &&
5545 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5546 0 \
5547 -S "Async sign callback" \
5548 -s "! mbedtls_ssl_handshake returned" \
5549 -s "The own private key or pre-shared key is not set, but needed" \
5550 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5551 -s "Successful connection"
5552
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005553requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005554run_test "SSL async private: decrypt callback not present" \
5555 "$P_SRV debug_level=1 \
5556 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5557 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5558 [ \$? -eq 1 ] && $P_CLI" \
5559 0 \
5560 -S "Async decrypt callback" \
5561 -s "! mbedtls_ssl_handshake returned" \
5562 -s "got no RSA private key" \
5563 -s "Async resume (slot [0-9]): sign done, status=0" \
5564 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005565
5566# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005567requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005568run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005569 "$P_SRV \
5570 async_operations=s async_private_delay1=1 \
5571 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5572 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005573 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5574 0 \
5575 -s "Async sign callback: using key slot 0," \
5576 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005577 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005578
5579# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005580requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005581run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005582 "$P_SRV \
5583 async_operations=s async_private_delay2=1 \
5584 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5585 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005586 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5587 0 \
5588 -s "Async sign callback: using key slot 0," \
5589 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005590 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005591
5592# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005593requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005594run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005595 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005596 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005597 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5598 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005599 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5600 0 \
5601 -s "Async sign callback: using key slot 1," \
5602 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005603 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005604
5605# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005606requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005607run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005608 "$P_SRV \
5609 async_operations=s async_private_delay1=1 \
5610 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5611 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005612 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5613 0 \
5614 -s "Async sign callback: no key matches this certificate."
5615
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005616requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005617run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005618 "$P_SRV \
5619 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5620 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005621 "$P_CLI" \
5622 1 \
5623 -s "Async sign callback: injected error" \
5624 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005625 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005626 -s "! mbedtls_ssl_handshake returned"
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, cancel after 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=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005633 "$P_CLI" \
5634 1 \
5635 -s "Async sign callback: using key slot " \
5636 -S "Async resume" \
5637 -s "Async cancel"
5638
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005639requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005640run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005641 "$P_SRV \
5642 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5643 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005644 "$P_CLI" \
5645 1 \
5646 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005647 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005648 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005649 -s "! mbedtls_ssl_handshake returned"
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: decrypt, error in start" \
5653 "$P_SRV \
5654 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5655 async_private_error=1" \
5656 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5657 1 \
5658 -s "Async decrypt callback: injected error" \
5659 -S "Async resume" \
5660 -S "Async cancel" \
5661 -s "! mbedtls_ssl_handshake returned"
5662
5663requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5664run_test "SSL async private: decrypt, cancel after start" \
5665 "$P_SRV \
5666 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5667 async_private_error=2" \
5668 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5669 1 \
5670 -s "Async decrypt callback: using key slot " \
5671 -S "Async resume" \
5672 -s "Async cancel"
5673
5674requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5675run_test "SSL async private: decrypt, error in resume" \
5676 "$P_SRV \
5677 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5678 async_private_error=3" \
5679 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5680 1 \
5681 -s "Async decrypt callback: using key slot " \
5682 -s "Async resume callback: decrypt done but injected error" \
5683 -S "Async cancel" \
5684 -s "! mbedtls_ssl_handshake returned"
5685
5686requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005687run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005688 "$P_SRV \
5689 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5690 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005691 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5692 0 \
5693 -s "Async cancel" \
5694 -s "! mbedtls_ssl_handshake returned" \
5695 -s "Async resume" \
5696 -s "Successful connection"
5697
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005698requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005699run_test "SSL async private: error in resume 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=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005703 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5704 0 \
5705 -s "! mbedtls_ssl_handshake returned" \
5706 -s "Async resume" \
5707 -s "Successful connection"
5708
5709# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
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: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005712 "$P_SRV \
5713 async_operations=s async_private_delay1=1 async_private_error=-2 \
5714 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5715 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005716 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5717 [ \$? -eq 1 ] &&
5718 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5719 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005720 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005721 -S "Async resume" \
5722 -s "Async cancel" \
5723 -s "! mbedtls_ssl_handshake returned" \
5724 -s "Async sign callback: no key matches this certificate." \
5725 -s "Successful connection"
5726
5727# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005728requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005729run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005730 "$P_SRV \
5731 async_operations=s async_private_delay1=1 async_private_error=-3 \
5732 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5733 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005734 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5735 [ \$? -eq 1 ] &&
5736 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5737 0 \
5738 -s "Async resume" \
5739 -s "! mbedtls_ssl_handshake returned" \
5740 -s "Async sign callback: no key matches this certificate." \
5741 -s "Successful connection"
5742
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005743requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005744requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005745run_test "SSL async private: renegotiation: client-initiated; sign" \
5746 "$P_SRV \
5747 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005748 exchanges=2 renegotiation=1" \
5749 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5750 0 \
5751 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005752 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005753
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005754requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005755requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005756run_test "SSL async private: renegotiation: server-initiated; sign" \
5757 "$P_SRV \
5758 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005759 exchanges=2 renegotiation=1 renegotiate=1" \
5760 "$P_CLI exchanges=2 renegotiation=1" \
5761 0 \
5762 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005763 -s "Async resume (slot [0-9]): sign done, status=0"
5764
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005765requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005766requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5767run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5768 "$P_SRV \
5769 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5770 exchanges=2 renegotiation=1" \
5771 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5772 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5773 0 \
5774 -s "Async decrypt callback: using key slot " \
5775 -s "Async resume (slot [0-9]): decrypt 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: server-initiated; decrypt" \
5780 "$P_SRV \
5781 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5782 exchanges=2 renegotiation=1 renegotiate=1" \
5783 "$P_CLI exchanges=2 renegotiation=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"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005788
Ron Eldor58093c82018-06-28 13:22:05 +03005789# Tests for ECC extensions (rfc 4492)
5790
Ron Eldor643df7c2018-06-28 16:17:00 +03005791requires_config_enabled MBEDTLS_AES_C
5792requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5793requires_config_enabled MBEDTLS_SHA256_C
5794requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005795run_test "Force a non ECC ciphersuite in the client side" \
5796 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005797 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005798 0 \
5799 -C "client hello, adding supported_elliptic_curves extension" \
5800 -C "client hello, adding supported_point_formats extension" \
5801 -S "found supported elliptic curves extension" \
5802 -S "found supported point formats extension"
5803
Ron Eldor643df7c2018-06-28 16:17:00 +03005804requires_config_enabled MBEDTLS_AES_C
5805requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5806requires_config_enabled MBEDTLS_SHA256_C
5807requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005808run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005809 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005810 "$P_CLI debug_level=3" \
5811 0 \
5812 -C "found supported_point_formats extension" \
5813 -S "server hello, supported_point_formats extension"
5814
Ron Eldor643df7c2018-06-28 16:17:00 +03005815requires_config_enabled MBEDTLS_AES_C
5816requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5817requires_config_enabled MBEDTLS_SHA256_C
5818requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005819run_test "Force an ECC ciphersuite in the client side" \
5820 "$P_SRV debug_level=3" \
5821 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5822 0 \
5823 -c "client hello, adding supported_elliptic_curves extension" \
5824 -c "client hello, adding supported_point_formats extension" \
5825 -s "found supported elliptic curves extension" \
5826 -s "found supported point formats extension"
5827
Ron Eldor643df7c2018-06-28 16:17:00 +03005828requires_config_enabled MBEDTLS_AES_C
5829requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5830requires_config_enabled MBEDTLS_SHA256_C
5831requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005832run_test "Force an ECC ciphersuite in the server side" \
5833 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5834 "$P_CLI debug_level=3" \
5835 0 \
5836 -c "found supported_point_formats extension" \
5837 -s "server hello, supported_point_formats extension"
5838
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005839# Tests for DTLS HelloVerifyRequest
5840
5841run_test "DTLS cookie: enabled" \
5842 "$P_SRV dtls=1 debug_level=2" \
5843 "$P_CLI dtls=1 debug_level=2" \
5844 0 \
5845 -s "cookie verification failed" \
5846 -s "cookie verification passed" \
5847 -S "cookie verification skipped" \
5848 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005849 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005850 -S "SSL - The requested feature is not available"
5851
5852run_test "DTLS cookie: disabled" \
5853 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5854 "$P_CLI dtls=1 debug_level=2" \
5855 0 \
5856 -S "cookie verification failed" \
5857 -S "cookie verification passed" \
5858 -s "cookie verification skipped" \
5859 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005860 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005861 -S "SSL - The requested feature is not available"
5862
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005863run_test "DTLS cookie: default (failing)" \
5864 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5865 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5866 1 \
5867 -s "cookie verification failed" \
5868 -S "cookie verification passed" \
5869 -S "cookie verification skipped" \
5870 -C "received hello verify request" \
5871 -S "hello verification requested" \
5872 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005873
5874requires_ipv6
5875run_test "DTLS cookie: enabled, IPv6" \
5876 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5877 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5878 0 \
5879 -s "cookie verification failed" \
5880 -s "cookie verification passed" \
5881 -S "cookie verification skipped" \
5882 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005883 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005884 -S "SSL - The requested feature is not available"
5885
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005886run_test "DTLS cookie: enabled, nbio" \
5887 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5888 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5889 0 \
5890 -s "cookie verification failed" \
5891 -s "cookie verification passed" \
5892 -S "cookie verification skipped" \
5893 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005894 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005895 -S "SSL - The requested feature is not available"
5896
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005897# Tests for client reconnecting from the same port with DTLS
5898
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005899not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005900run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005901 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5902 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005903 0 \
5904 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005905 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005906 -S "Client initiated reconnection from same port"
5907
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005908not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005909run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005910 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5911 "$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 +02005912 0 \
5913 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005914 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005915 -s "Client initiated reconnection from same port"
5916
Paul Bakker362689d2016-05-13 10:33:25 +01005917not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5918run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005919 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5920 "$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 +02005921 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005922 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005923 -s "Client initiated reconnection from same port"
5924
Paul Bakker362689d2016-05-13 10:33:25 +01005925only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5926run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5927 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5928 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5929 0 \
5930 -S "The operation timed out" \
5931 -s "Client initiated reconnection from same port"
5932
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005933run_test "DTLS client reconnect from same port: no cookies" \
5934 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005935 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5936 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005937 -s "The operation timed out" \
5938 -S "Client initiated reconnection from same port"
5939
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005940run_test "DTLS client reconnect from same port: attacker-injected" \
5941 -p "$P_PXY inject_clihlo=1" \
5942 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5943 "$P_CLI dtls=1 exchanges=2" \
5944 0 \
5945 -s "possible client reconnect from the same port" \
5946 -S "Client initiated reconnection from same port"
5947
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005948# Tests for various cases of client authentication with DTLS
5949# (focused on handshake flows and message parsing)
5950
5951run_test "DTLS client auth: required" \
5952 "$P_SRV dtls=1 auth_mode=required" \
5953 "$P_CLI dtls=1" \
5954 0 \
5955 -s "Verifying peer X.509 certificate... ok"
5956
5957run_test "DTLS client auth: optional, client has no cert" \
5958 "$P_SRV dtls=1 auth_mode=optional" \
5959 "$P_CLI dtls=1 crt_file=none key_file=none" \
5960 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005961 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005962
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005963run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005964 "$P_SRV dtls=1 auth_mode=none" \
5965 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5966 0 \
5967 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005968 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005969
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005970run_test "DTLS wrong PSK: badmac alert" \
5971 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5972 "$P_CLI dtls=1 psk=abc124" \
5973 1 \
5974 -s "SSL - Verification of the message MAC failed" \
5975 -c "SSL - A fatal alert message was received from our peer"
5976
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005977# Tests for receiving fragmented handshake messages with DTLS
5978
5979requires_gnutls
5980run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5981 "$G_SRV -u --mtu 2048 -a" \
5982 "$P_CLI dtls=1 debug_level=2" \
5983 0 \
5984 -C "found fragmented DTLS handshake message" \
5985 -C "error"
5986
5987requires_gnutls
5988run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5989 "$G_SRV -u --mtu 512" \
5990 "$P_CLI dtls=1 debug_level=2" \
5991 0 \
5992 -c "found fragmented DTLS handshake message" \
5993 -C "error"
5994
5995requires_gnutls
5996run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5997 "$G_SRV -u --mtu 128" \
5998 "$P_CLI dtls=1 debug_level=2" \
5999 0 \
6000 -c "found fragmented DTLS handshake message" \
6001 -C "error"
6002
6003requires_gnutls
6004run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
6005 "$G_SRV -u --mtu 128" \
6006 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6007 0 \
6008 -c "found fragmented DTLS handshake message" \
6009 -C "error"
6010
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006011requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006012requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006013run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
6014 "$G_SRV -u --mtu 256" \
6015 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
6016 0 \
6017 -c "found fragmented DTLS handshake message" \
6018 -c "client hello, adding renegotiation extension" \
6019 -c "found renegotiation extension" \
6020 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006021 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006022 -C "error" \
6023 -s "Extra-header:"
6024
6025requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006026requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006027run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
6028 "$G_SRV -u --mtu 256" \
6029 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
6030 0 \
6031 -c "found fragmented DTLS handshake message" \
6032 -c "client hello, adding renegotiation extension" \
6033 -c "found renegotiation extension" \
6034 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006035 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006036 -C "error" \
6037 -s "Extra-header:"
6038
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006039run_test "DTLS reassembly: no fragmentation (openssl server)" \
6040 "$O_SRV -dtls1 -mtu 2048" \
6041 "$P_CLI dtls=1 debug_level=2" \
6042 0 \
6043 -C "found fragmented DTLS handshake message" \
6044 -C "error"
6045
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006046run_test "DTLS reassembly: some fragmentation (openssl server)" \
6047 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006048 "$P_CLI dtls=1 debug_level=2" \
6049 0 \
6050 -c "found fragmented DTLS handshake message" \
6051 -C "error"
6052
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006053run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006054 "$O_SRV -dtls1 -mtu 256" \
6055 "$P_CLI dtls=1 debug_level=2" \
6056 0 \
6057 -c "found fragmented DTLS handshake message" \
6058 -C "error"
6059
6060run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6061 "$O_SRV -dtls1 -mtu 256" \
6062 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6063 0 \
6064 -c "found fragmented DTLS handshake message" \
6065 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006066
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006067# Tests for sending fragmented handshake messages with DTLS
6068#
6069# Use client auth when we need the client to send large messages,
6070# and use large cert chains on both sides too (the long chains we have all use
6071# both RSA and ECDSA, but ideally we should have long chains with either).
6072# Sizes reached (UDP payload):
6073# - 2037B for server certificate
6074# - 1542B for client certificate
6075# - 1013B for newsessionticket
6076# - all others below 512B
6077# All those tests assume MAX_CONTENT_LEN is at least 2048
6078
6079requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6080requires_config_enabled MBEDTLS_RSA_C
6081requires_config_enabled MBEDTLS_ECDSA_C
6082requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6083run_test "DTLS fragmenting: none (for reference)" \
6084 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6085 crt_file=data_files/server7_int-ca.crt \
6086 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006087 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006088 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006089 "$P_CLI dtls=1 debug_level=2 \
6090 crt_file=data_files/server8_int-ca2.crt \
6091 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006092 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006093 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006094 0 \
6095 -S "found fragmented DTLS handshake message" \
6096 -C "found fragmented DTLS handshake message" \
6097 -C "error"
6098
6099requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6100requires_config_enabled MBEDTLS_RSA_C
6101requires_config_enabled MBEDTLS_ECDSA_C
6102requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006103run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006104 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6105 crt_file=data_files/server7_int-ca.crt \
6106 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006107 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006108 max_frag_len=1024" \
6109 "$P_CLI dtls=1 debug_level=2 \
6110 crt_file=data_files/server8_int-ca2.crt \
6111 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006112 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006113 max_frag_len=2048" \
6114 0 \
6115 -S "found fragmented DTLS handshake message" \
6116 -c "found fragmented DTLS handshake message" \
6117 -C "error"
6118
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006119# With the MFL extension, the server has no way of forcing
6120# the client to not exceed a certain MTU; hence, the following
6121# test can't be replicated with an MTU proxy such as the one
6122# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006123requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6124requires_config_enabled MBEDTLS_RSA_C
6125requires_config_enabled MBEDTLS_ECDSA_C
6126requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006127run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006128 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6129 crt_file=data_files/server7_int-ca.crt \
6130 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006131 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006132 max_frag_len=512" \
6133 "$P_CLI dtls=1 debug_level=2 \
6134 crt_file=data_files/server8_int-ca2.crt \
6135 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006136 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006137 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006138 0 \
6139 -S "found fragmented DTLS handshake message" \
6140 -c "found fragmented DTLS handshake message" \
6141 -C "error"
6142
6143requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6144requires_config_enabled MBEDTLS_RSA_C
6145requires_config_enabled MBEDTLS_ECDSA_C
6146requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006147run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006148 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6149 crt_file=data_files/server7_int-ca.crt \
6150 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006151 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006152 max_frag_len=2048" \
6153 "$P_CLI dtls=1 debug_level=2 \
6154 crt_file=data_files/server8_int-ca2.crt \
6155 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006156 hs_timeout=2500-60000 \
6157 max_frag_len=1024" \
6158 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006159 -S "found fragmented DTLS handshake message" \
6160 -c "found fragmented DTLS handshake message" \
6161 -C "error"
6162
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006163# While not required by the standard defining the MFL extension
6164# (according to which it only applies to records, not to datagrams),
6165# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6166# as otherwise there wouldn't be any means to communicate MTU restrictions
6167# to the peer.
6168# The next test checks that no datagrams significantly larger than the
6169# negotiated MFL are sent.
6170requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6171requires_config_enabled MBEDTLS_RSA_C
6172requires_config_enabled MBEDTLS_ECDSA_C
6173requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6174run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006175 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006176 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6177 crt_file=data_files/server7_int-ca.crt \
6178 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006179 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006180 max_frag_len=2048" \
6181 "$P_CLI dtls=1 debug_level=2 \
6182 crt_file=data_files/server8_int-ca2.crt \
6183 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006184 hs_timeout=2500-60000 \
6185 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006186 0 \
6187 -S "found fragmented DTLS handshake message" \
6188 -c "found fragmented DTLS handshake message" \
6189 -C "error"
6190
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006191requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6192requires_config_enabled MBEDTLS_RSA_C
6193requires_config_enabled MBEDTLS_ECDSA_C
6194requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006195run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006196 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6197 crt_file=data_files/server7_int-ca.crt \
6198 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006199 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006200 max_frag_len=2048" \
6201 "$P_CLI dtls=1 debug_level=2 \
6202 crt_file=data_files/server8_int-ca2.crt \
6203 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006204 hs_timeout=2500-60000 \
6205 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006206 0 \
6207 -s "found fragmented DTLS handshake message" \
6208 -c "found fragmented DTLS handshake message" \
6209 -C "error"
6210
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006211# While not required by the standard defining the MFL extension
6212# (according to which it only applies to records, not to datagrams),
6213# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6214# as otherwise there wouldn't be any means to communicate MTU restrictions
6215# to the peer.
6216# The next test checks that no datagrams significantly larger than the
6217# negotiated MFL are sent.
6218requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6219requires_config_enabled MBEDTLS_RSA_C
6220requires_config_enabled MBEDTLS_ECDSA_C
6221requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6222run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006223 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006224 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6225 crt_file=data_files/server7_int-ca.crt \
6226 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006227 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006228 max_frag_len=2048" \
6229 "$P_CLI dtls=1 debug_level=2 \
6230 crt_file=data_files/server8_int-ca2.crt \
6231 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006232 hs_timeout=2500-60000 \
6233 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006234 0 \
6235 -s "found fragmented DTLS handshake message" \
6236 -c "found fragmented DTLS handshake message" \
6237 -C "error"
6238
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006239requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6240requires_config_enabled MBEDTLS_RSA_C
6241requires_config_enabled MBEDTLS_ECDSA_C
6242run_test "DTLS fragmenting: none (for reference) (MTU)" \
6243 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6244 crt_file=data_files/server7_int-ca.crt \
6245 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006246 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006247 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006248 "$P_CLI dtls=1 debug_level=2 \
6249 crt_file=data_files/server8_int-ca2.crt \
6250 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006251 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006252 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006253 0 \
6254 -S "found fragmented DTLS handshake message" \
6255 -C "found fragmented DTLS handshake message" \
6256 -C "error"
6257
6258requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6259requires_config_enabled MBEDTLS_RSA_C
6260requires_config_enabled MBEDTLS_ECDSA_C
6261run_test "DTLS fragmenting: client (MTU)" \
6262 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6263 crt_file=data_files/server7_int-ca.crt \
6264 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006265 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006266 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006267 "$P_CLI dtls=1 debug_level=2 \
6268 crt_file=data_files/server8_int-ca2.crt \
6269 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006270 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006271 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006272 0 \
6273 -s "found fragmented DTLS handshake message" \
6274 -C "found fragmented DTLS handshake message" \
6275 -C "error"
6276
6277requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6278requires_config_enabled MBEDTLS_RSA_C
6279requires_config_enabled MBEDTLS_ECDSA_C
6280run_test "DTLS fragmenting: server (MTU)" \
6281 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6282 crt_file=data_files/server7_int-ca.crt \
6283 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006284 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006285 mtu=512" \
6286 "$P_CLI dtls=1 debug_level=2 \
6287 crt_file=data_files/server8_int-ca2.crt \
6288 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006289 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006290 mtu=2048" \
6291 0 \
6292 -S "found fragmented DTLS handshake message" \
6293 -c "found fragmented DTLS handshake message" \
6294 -C "error"
6295
6296requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6297requires_config_enabled MBEDTLS_RSA_C
6298requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006299run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006300 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006301 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6302 crt_file=data_files/server7_int-ca.crt \
6303 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006304 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006305 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006306 "$P_CLI dtls=1 debug_level=2 \
6307 crt_file=data_files/server8_int-ca2.crt \
6308 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006309 hs_timeout=2500-60000 \
6310 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006311 0 \
6312 -s "found fragmented DTLS handshake message" \
6313 -c "found fragmented DTLS handshake message" \
6314 -C "error"
6315
Andrzej Kurek77826052018-10-11 07:34:08 -04006316# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006317requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6318requires_config_enabled MBEDTLS_RSA_C
6319requires_config_enabled MBEDTLS_ECDSA_C
6320requires_config_enabled MBEDTLS_SHA256_C
6321requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6322requires_config_enabled MBEDTLS_AES_C
6323requires_config_enabled MBEDTLS_GCM_C
6324run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006325 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006326 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6327 crt_file=data_files/server7_int-ca.crt \
6328 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006329 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006330 mtu=512" \
6331 "$P_CLI dtls=1 debug_level=2 \
6332 crt_file=data_files/server8_int-ca2.crt \
6333 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006334 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6335 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006336 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006337 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006338 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006339 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006340 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006341
Andrzej Kurek7311c782018-10-11 06:49:41 -04006342# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006343# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006344# The ratio of max/min timeout should ideally equal 4 to accept two
6345# retransmissions, but in some cases (like both the server and client using
6346# fragmentation and auto-reduction) an extra retransmission might occur,
6347# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006348not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006349requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6350requires_config_enabled MBEDTLS_RSA_C
6351requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006352requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6353requires_config_enabled MBEDTLS_AES_C
6354requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006355run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6356 -p "$P_PXY mtu=508" \
6357 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6358 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006359 key_file=data_files/server7.key \
6360 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006361 "$P_CLI dtls=1 debug_level=2 \
6362 crt_file=data_files/server8_int-ca2.crt \
6363 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006364 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6365 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006366 0 \
6367 -s "found fragmented DTLS handshake message" \
6368 -c "found fragmented DTLS handshake message" \
6369 -C "error"
6370
Andrzej Kurek77826052018-10-11 07:34:08 -04006371# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006372only_with_valgrind
6373requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6374requires_config_enabled MBEDTLS_RSA_C
6375requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006376requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6377requires_config_enabled MBEDTLS_AES_C
6378requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006379run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6380 -p "$P_PXY mtu=508" \
6381 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6382 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006383 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006384 hs_timeout=250-10000" \
6385 "$P_CLI dtls=1 debug_level=2 \
6386 crt_file=data_files/server8_int-ca2.crt \
6387 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006388 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006389 hs_timeout=250-10000" \
6390 0 \
6391 -s "found fragmented DTLS handshake message" \
6392 -c "found fragmented DTLS handshake message" \
6393 -C "error"
6394
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006395# 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 +02006396# OTOH the client might resend if the server is to slow to reset after sending
6397# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006398not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006399requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6400requires_config_enabled MBEDTLS_RSA_C
6401requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006402run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006403 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006404 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6405 crt_file=data_files/server7_int-ca.crt \
6406 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006407 hs_timeout=10000-60000 \
6408 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006409 "$P_CLI dtls=1 debug_level=2 \
6410 crt_file=data_files/server8_int-ca2.crt \
6411 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006412 hs_timeout=10000-60000 \
6413 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006414 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006415 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006416 -s "found fragmented DTLS handshake message" \
6417 -c "found fragmented DTLS handshake message" \
6418 -C "error"
6419
Andrzej Kurek77826052018-10-11 07:34:08 -04006420# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006421# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6422# OTOH the client might resend if the server is to slow to reset after sending
6423# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006424not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006425requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6426requires_config_enabled MBEDTLS_RSA_C
6427requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006428requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6429requires_config_enabled MBEDTLS_AES_C
6430requires_config_enabled MBEDTLS_GCM_C
6431run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006432 -p "$P_PXY mtu=512" \
6433 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6434 crt_file=data_files/server7_int-ca.crt \
6435 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006436 hs_timeout=10000-60000 \
6437 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006438 "$P_CLI dtls=1 debug_level=2 \
6439 crt_file=data_files/server8_int-ca2.crt \
6440 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006441 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6442 hs_timeout=10000-60000 \
6443 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006444 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006445 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006446 -s "found fragmented DTLS handshake message" \
6447 -c "found fragmented DTLS handshake message" \
6448 -C "error"
6449
Andrzej Kurek7311c782018-10-11 06:49:41 -04006450not_with_valgrind # spurious autoreduction due to timeout
6451requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6452requires_config_enabled MBEDTLS_RSA_C
6453requires_config_enabled MBEDTLS_ECDSA_C
6454run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006455 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006456 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6457 crt_file=data_files/server7_int-ca.crt \
6458 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006459 hs_timeout=10000-60000 \
6460 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006461 "$P_CLI dtls=1 debug_level=2 \
6462 crt_file=data_files/server8_int-ca2.crt \
6463 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006464 hs_timeout=10000-60000 \
6465 mtu=1024 nbio=2" \
6466 0 \
6467 -S "autoreduction" \
6468 -s "found fragmented DTLS handshake message" \
6469 -c "found fragmented DTLS handshake message" \
6470 -C "error"
6471
Andrzej Kurek77826052018-10-11 07:34:08 -04006472# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006473not_with_valgrind # spurious autoreduction due to timeout
6474requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6475requires_config_enabled MBEDTLS_RSA_C
6476requires_config_enabled MBEDTLS_ECDSA_C
6477requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6478requires_config_enabled MBEDTLS_AES_C
6479requires_config_enabled MBEDTLS_GCM_C
6480run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6481 -p "$P_PXY mtu=512" \
6482 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6483 crt_file=data_files/server7_int-ca.crt \
6484 key_file=data_files/server7.key \
6485 hs_timeout=10000-60000 \
6486 mtu=512 nbio=2" \
6487 "$P_CLI dtls=1 debug_level=2 \
6488 crt_file=data_files/server8_int-ca2.crt \
6489 key_file=data_files/server8.key \
6490 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6491 hs_timeout=10000-60000 \
6492 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006493 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006494 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006495 -s "found fragmented DTLS handshake message" \
6496 -c "found fragmented DTLS handshake message" \
6497 -C "error"
6498
Andrzej Kurek77826052018-10-11 07:34:08 -04006499# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006500# This ensures things still work after session_reset().
6501# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006502# Since we don't support reading fragmented ClientHello yet,
6503# up the MTU to 1450 (larger than ClientHello with session ticket,
6504# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006505# An autoreduction on the client-side might happen if the server is
6506# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006507# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006508# resumed listening, which would result in a spurious autoreduction.
6509not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006510requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6511requires_config_enabled MBEDTLS_RSA_C
6512requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006513requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6514requires_config_enabled MBEDTLS_AES_C
6515requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006516run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6517 -p "$P_PXY mtu=1450" \
6518 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6519 crt_file=data_files/server7_int-ca.crt \
6520 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006521 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006522 mtu=1450" \
6523 "$P_CLI dtls=1 debug_level=2 \
6524 crt_file=data_files/server8_int-ca2.crt \
6525 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006526 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006527 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006528 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006529 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006530 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006531 -s "found fragmented DTLS handshake message" \
6532 -c "found fragmented DTLS handshake message" \
6533 -C "error"
6534
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006535# An autoreduction on the client-side might happen if the server is
6536# slow to reset, therefore omitting '-C "autoreduction"' below.
6537not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006538requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6539requires_config_enabled MBEDTLS_RSA_C
6540requires_config_enabled MBEDTLS_ECDSA_C
6541requires_config_enabled MBEDTLS_SHA256_C
6542requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6543requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6544requires_config_enabled MBEDTLS_CHACHAPOLY_C
6545run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6546 -p "$P_PXY mtu=512" \
6547 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6548 crt_file=data_files/server7_int-ca.crt \
6549 key_file=data_files/server7.key \
6550 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006551 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006552 mtu=512" \
6553 "$P_CLI dtls=1 debug_level=2 \
6554 crt_file=data_files/server8_int-ca2.crt \
6555 key_file=data_files/server8.key \
6556 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006557 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006558 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006559 mtu=512" \
6560 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006561 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006562 -s "found fragmented DTLS handshake message" \
6563 -c "found fragmented DTLS handshake message" \
6564 -C "error"
6565
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006566# An autoreduction on the client-side might happen if the server is
6567# slow to reset, therefore omitting '-C "autoreduction"' below.
6568not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006569requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6570requires_config_enabled MBEDTLS_RSA_C
6571requires_config_enabled MBEDTLS_ECDSA_C
6572requires_config_enabled MBEDTLS_SHA256_C
6573requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6574requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6575requires_config_enabled MBEDTLS_AES_C
6576requires_config_enabled MBEDTLS_GCM_C
6577run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6578 -p "$P_PXY mtu=512" \
6579 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6580 crt_file=data_files/server7_int-ca.crt \
6581 key_file=data_files/server7.key \
6582 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006583 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006584 mtu=512" \
6585 "$P_CLI dtls=1 debug_level=2 \
6586 crt_file=data_files/server8_int-ca2.crt \
6587 key_file=data_files/server8.key \
6588 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006589 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006590 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006591 mtu=512" \
6592 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006593 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006594 -s "found fragmented DTLS handshake message" \
6595 -c "found fragmented DTLS handshake message" \
6596 -C "error"
6597
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006598# An autoreduction on the client-side might happen if the server is
6599# slow to reset, therefore omitting '-C "autoreduction"' below.
6600not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006601requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6602requires_config_enabled MBEDTLS_RSA_C
6603requires_config_enabled MBEDTLS_ECDSA_C
6604requires_config_enabled MBEDTLS_SHA256_C
6605requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6606requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6607requires_config_enabled MBEDTLS_AES_C
6608requires_config_enabled MBEDTLS_CCM_C
6609run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006610 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006611 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6612 crt_file=data_files/server7_int-ca.crt \
6613 key_file=data_files/server7.key \
6614 exchanges=2 renegotiation=1 \
6615 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006616 hs_timeout=10000-60000 \
6617 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006618 "$P_CLI dtls=1 debug_level=2 \
6619 crt_file=data_files/server8_int-ca2.crt \
6620 key_file=data_files/server8.key \
6621 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006622 hs_timeout=10000-60000 \
6623 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006624 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006625 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006626 -s "found fragmented DTLS handshake message" \
6627 -c "found fragmented DTLS handshake message" \
6628 -C "error"
6629
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006630# An autoreduction on the client-side might happen if the server is
6631# slow to reset, therefore omitting '-C "autoreduction"' below.
6632not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006633requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6634requires_config_enabled MBEDTLS_RSA_C
6635requires_config_enabled MBEDTLS_ECDSA_C
6636requires_config_enabled MBEDTLS_SHA256_C
6637requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6638requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6639requires_config_enabled MBEDTLS_AES_C
6640requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6641requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6642run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006643 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006644 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6645 crt_file=data_files/server7_int-ca.crt \
6646 key_file=data_files/server7.key \
6647 exchanges=2 renegotiation=1 \
6648 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006649 hs_timeout=10000-60000 \
6650 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006651 "$P_CLI dtls=1 debug_level=2 \
6652 crt_file=data_files/server8_int-ca2.crt \
6653 key_file=data_files/server8.key \
6654 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006655 hs_timeout=10000-60000 \
6656 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006657 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006658 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006659 -s "found fragmented DTLS handshake message" \
6660 -c "found fragmented DTLS handshake message" \
6661 -C "error"
6662
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006663# An autoreduction on the client-side might happen if the server is
6664# slow to reset, therefore omitting '-C "autoreduction"' below.
6665not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006666requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6667requires_config_enabled MBEDTLS_RSA_C
6668requires_config_enabled MBEDTLS_ECDSA_C
6669requires_config_enabled MBEDTLS_SHA256_C
6670requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6671requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6672requires_config_enabled MBEDTLS_AES_C
6673requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6674run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006675 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006676 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6677 crt_file=data_files/server7_int-ca.crt \
6678 key_file=data_files/server7.key \
6679 exchanges=2 renegotiation=1 \
6680 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006681 hs_timeout=10000-60000 \
6682 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006683 "$P_CLI dtls=1 debug_level=2 \
6684 crt_file=data_files/server8_int-ca2.crt \
6685 key_file=data_files/server8.key \
6686 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006687 hs_timeout=10000-60000 \
6688 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006689 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006690 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006691 -s "found fragmented DTLS handshake message" \
6692 -c "found fragmented DTLS handshake message" \
6693 -C "error"
6694
Andrzej Kurek77826052018-10-11 07:34:08 -04006695# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006696requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6697requires_config_enabled MBEDTLS_RSA_C
6698requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006699requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6700requires_config_enabled MBEDTLS_AES_C
6701requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006702client_needs_more_time 2
6703run_test "DTLS fragmenting: proxy MTU + 3d" \
6704 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006705 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006706 crt_file=data_files/server7_int-ca.crt \
6707 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006708 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006709 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006710 crt_file=data_files/server8_int-ca2.crt \
6711 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006712 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006713 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006714 0 \
6715 -s "found fragmented DTLS handshake message" \
6716 -c "found fragmented DTLS handshake message" \
6717 -C "error"
6718
Andrzej Kurek77826052018-10-11 07:34:08 -04006719# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006720requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6721requires_config_enabled MBEDTLS_RSA_C
6722requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006723requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6724requires_config_enabled MBEDTLS_AES_C
6725requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006726client_needs_more_time 2
6727run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6728 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6729 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6730 crt_file=data_files/server7_int-ca.crt \
6731 key_file=data_files/server7.key \
6732 hs_timeout=250-10000 mtu=512 nbio=2" \
6733 "$P_CLI dtls=1 debug_level=2 \
6734 crt_file=data_files/server8_int-ca2.crt \
6735 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006736 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006737 hs_timeout=250-10000 mtu=512 nbio=2" \
6738 0 \
6739 -s "found fragmented DTLS handshake message" \
6740 -c "found fragmented DTLS handshake message" \
6741 -C "error"
6742
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006743# interop tests for DTLS fragmentating with reliable connection
6744#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006745# here and below we just want to test that the we fragment in a way that
6746# pleases other implementations, so we don't need the peer to fragment
6747requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6748requires_config_enabled MBEDTLS_RSA_C
6749requires_config_enabled MBEDTLS_ECDSA_C
6750requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006751requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006752run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6753 "$G_SRV -u" \
6754 "$P_CLI dtls=1 debug_level=2 \
6755 crt_file=data_files/server8_int-ca2.crt \
6756 key_file=data_files/server8.key \
6757 mtu=512 force_version=dtls1_2" \
6758 0 \
6759 -c "fragmenting handshake message" \
6760 -C "error"
6761
6762requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6763requires_config_enabled MBEDTLS_RSA_C
6764requires_config_enabled MBEDTLS_ECDSA_C
6765requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006766requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006767run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6768 "$G_SRV -u" \
6769 "$P_CLI dtls=1 debug_level=2 \
6770 crt_file=data_files/server8_int-ca2.crt \
6771 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006772 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006773 0 \
6774 -c "fragmenting handshake message" \
6775 -C "error"
6776
Hanno Beckerb9a00862018-08-28 10:20:22 +01006777# We use --insecure for the GnuTLS client because it expects
6778# the hostname / IP it connects to to be the name used in the
6779# certificate obtained from the server. Here, however, it
6780# connects to 127.0.0.1 while our test certificates use 'localhost'
6781# as the server name in the certificate. This will make the
6782# certifiate validation fail, but passing --insecure makes
6783# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006784requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6785requires_config_enabled MBEDTLS_RSA_C
6786requires_config_enabled MBEDTLS_ECDSA_C
6787requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006788requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006789requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006790run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006791 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006792 crt_file=data_files/server7_int-ca.crt \
6793 key_file=data_files/server7.key \
6794 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006795 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006796 0 \
6797 -s "fragmenting handshake message"
6798
Hanno Beckerb9a00862018-08-28 10:20:22 +01006799# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006800requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6801requires_config_enabled MBEDTLS_RSA_C
6802requires_config_enabled MBEDTLS_ECDSA_C
6803requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006804requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006805requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006806run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006807 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006808 crt_file=data_files/server7_int-ca.crt \
6809 key_file=data_files/server7.key \
6810 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006811 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006812 0 \
6813 -s "fragmenting handshake message"
6814
6815requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6816requires_config_enabled MBEDTLS_RSA_C
6817requires_config_enabled MBEDTLS_ECDSA_C
6818requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6819run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6820 "$O_SRV -dtls1_2 -verify 10" \
6821 "$P_CLI dtls=1 debug_level=2 \
6822 crt_file=data_files/server8_int-ca2.crt \
6823 key_file=data_files/server8.key \
6824 mtu=512 force_version=dtls1_2" \
6825 0 \
6826 -c "fragmenting handshake message" \
6827 -C "error"
6828
6829requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6830requires_config_enabled MBEDTLS_RSA_C
6831requires_config_enabled MBEDTLS_ECDSA_C
6832requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6833run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6834 "$O_SRV -dtls1 -verify 10" \
6835 "$P_CLI dtls=1 debug_level=2 \
6836 crt_file=data_files/server8_int-ca2.crt \
6837 key_file=data_files/server8.key \
6838 mtu=512 force_version=dtls1" \
6839 0 \
6840 -c "fragmenting handshake message" \
6841 -C "error"
6842
6843requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6844requires_config_enabled MBEDTLS_RSA_C
6845requires_config_enabled MBEDTLS_ECDSA_C
6846requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6847run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6848 "$P_SRV dtls=1 debug_level=2 \
6849 crt_file=data_files/server7_int-ca.crt \
6850 key_file=data_files/server7.key \
6851 mtu=512 force_version=dtls1_2" \
6852 "$O_CLI -dtls1_2" \
6853 0 \
6854 -s "fragmenting handshake message"
6855
6856requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6857requires_config_enabled MBEDTLS_RSA_C
6858requires_config_enabled MBEDTLS_ECDSA_C
6859requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6860run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6861 "$P_SRV dtls=1 debug_level=2 \
6862 crt_file=data_files/server7_int-ca.crt \
6863 key_file=data_files/server7.key \
6864 mtu=512 force_version=dtls1" \
6865 "$O_CLI -dtls1" \
6866 0 \
6867 -s "fragmenting handshake message"
6868
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006869# interop tests for DTLS fragmentating with unreliable connection
6870#
6871# again we just want to test that the we fragment in a way that
6872# pleases other implementations, so we don't need the peer to fragment
6873requires_gnutls_next
6874requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6875requires_config_enabled MBEDTLS_RSA_C
6876requires_config_enabled MBEDTLS_ECDSA_C
6877requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006878client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006879run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6880 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6881 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006882 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006883 crt_file=data_files/server8_int-ca2.crt \
6884 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006885 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006886 0 \
6887 -c "fragmenting handshake message" \
6888 -C "error"
6889
6890requires_gnutls_next
6891requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6892requires_config_enabled MBEDTLS_RSA_C
6893requires_config_enabled MBEDTLS_ECDSA_C
6894requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006895client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006896run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6897 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6898 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006899 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006900 crt_file=data_files/server8_int-ca2.crt \
6901 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006902 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006903 0 \
6904 -c "fragmenting handshake message" \
6905 -C "error"
6906
k-stachowiakabb843e2019-02-18 16:14:03 +01006907requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006908requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6909requires_config_enabled MBEDTLS_RSA_C
6910requires_config_enabled MBEDTLS_ECDSA_C
6911requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6912client_needs_more_time 4
6913run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6914 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6915 "$P_SRV dtls=1 debug_level=2 \
6916 crt_file=data_files/server7_int-ca.crt \
6917 key_file=data_files/server7.key \
6918 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006919 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006920 0 \
6921 -s "fragmenting handshake message"
6922
k-stachowiakabb843e2019-02-18 16:14:03 +01006923requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006924requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6925requires_config_enabled MBEDTLS_RSA_C
6926requires_config_enabled MBEDTLS_ECDSA_C
6927requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6928client_needs_more_time 4
6929run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6930 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6931 "$P_SRV dtls=1 debug_level=2 \
6932 crt_file=data_files/server7_int-ca.crt \
6933 key_file=data_files/server7.key \
6934 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006935 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006936 0 \
6937 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006938
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006939## Interop test with OpenSSL might trigger a bug in recent versions (including
6940## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006941## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006942## They should be re-enabled once a fixed version of OpenSSL is available
6943## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006944skip_next_test
6945requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6946requires_config_enabled MBEDTLS_RSA_C
6947requires_config_enabled MBEDTLS_ECDSA_C
6948requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6949client_needs_more_time 4
6950run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6951 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6952 "$O_SRV -dtls1_2 -verify 10" \
6953 "$P_CLI dtls=1 debug_level=2 \
6954 crt_file=data_files/server8_int-ca2.crt \
6955 key_file=data_files/server8.key \
6956 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6957 0 \
6958 -c "fragmenting handshake message" \
6959 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006960
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006961skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006962requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6963requires_config_enabled MBEDTLS_RSA_C
6964requires_config_enabled MBEDTLS_ECDSA_C
6965requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006966client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006967run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6968 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006969 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006970 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006971 crt_file=data_files/server8_int-ca2.crt \
6972 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006973 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006974 0 \
6975 -c "fragmenting handshake message" \
6976 -C "error"
6977
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006978skip_next_test
6979requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6980requires_config_enabled MBEDTLS_RSA_C
6981requires_config_enabled MBEDTLS_ECDSA_C
6982requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6983client_needs_more_time 4
6984run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6985 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6986 "$P_SRV dtls=1 debug_level=2 \
6987 crt_file=data_files/server7_int-ca.crt \
6988 key_file=data_files/server7.key \
6989 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6990 "$O_CLI -dtls1_2" \
6991 0 \
6992 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006993
6994# -nbio is added to prevent s_client from blocking in case of duplicated
6995# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006996skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006997requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6998requires_config_enabled MBEDTLS_RSA_C
6999requires_config_enabled MBEDTLS_ECDSA_C
7000requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007001client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007002run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
7003 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007004 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007005 crt_file=data_files/server7_int-ca.crt \
7006 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007007 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007008 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007009 0 \
7010 -s "fragmenting handshake message"
7011
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007012# Tests for specific things with "unreliable" UDP connection
7013
7014not_with_valgrind # spurious resend due to timeout
7015run_test "DTLS proxy: reference" \
7016 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007017 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
7018 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007019 0 \
7020 -C "replayed record" \
7021 -S "replayed record" \
7022 -C "record from another epoch" \
7023 -S "record from another epoch" \
7024 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007025 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007026 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007027 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007028 -c "HTTP/1.0 200 OK"
7029
7030not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007031run_test "DTLS proxy: duplicate every packet" \
7032 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007033 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
7034 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007035 0 \
7036 -c "replayed record" \
7037 -s "replayed record" \
7038 -c "record from another epoch" \
7039 -s "record from another epoch" \
7040 -S "resend" \
7041 -s "Extra-header:" \
7042 -c "HTTP/1.0 200 OK"
7043
7044run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7045 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007046 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7047 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007048 0 \
7049 -c "replayed record" \
7050 -S "replayed record" \
7051 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007052 -s "record from another epoch" \
7053 -c "resend" \
7054 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007055 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007056 -c "HTTP/1.0 200 OK"
7057
7058run_test "DTLS proxy: multiple records in same datagram" \
7059 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007060 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7061 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007062 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007063 -c "next record in same datagram" \
7064 -s "next record in same datagram"
7065
7066run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7067 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007068 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7069 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007070 0 \
7071 -c "next record in same datagram" \
7072 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007073
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007074run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7075 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007076 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7077 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007078 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007079 -c "discarding invalid record (mac)" \
7080 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007081 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007082 -c "HTTP/1.0 200 OK" \
7083 -S "too many records with bad MAC" \
7084 -S "Verification of the message MAC failed"
7085
7086run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
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 badmac_limit=1" \
7089 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007090 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007091 -C "discarding invalid record (mac)" \
7092 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007093 -S "Extra-header:" \
7094 -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 2" \
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=2" \
7101 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007102 0 \
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, exchanges 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 exchanges=2" \
7113 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007114 1 \
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"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007121
7122run_test "DTLS proxy: delay ChangeCipherSpec" \
7123 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007124 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7125 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007126 0 \
7127 -c "record from another epoch" \
7128 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007129 -s "Extra-header:" \
7130 -c "HTTP/1.0 200 OK"
7131
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007132# Tests for reordering support with DTLS
7133
Hanno Becker56cdfd12018-08-17 13:42:15 +01007134run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7135 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007136 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7137 hs_timeout=2500-60000" \
7138 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7139 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007140 0 \
7141 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007142 -c "Next handshake message has been buffered - load"\
7143 -S "Buffering HS message" \
7144 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007145 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007146 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007147 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007148 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007149
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007150run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7151 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007152 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7153 hs_timeout=2500-60000" \
7154 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7155 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007156 0 \
7157 -c "Buffering HS message" \
7158 -c "found fragmented DTLS handshake message"\
7159 -c "Next handshake message 1 not or only partially bufffered" \
7160 -c "Next handshake message has been buffered - load"\
7161 -S "Buffering HS message" \
7162 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007163 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007164 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007165 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007166 -S "Remember CCS message"
7167
Hanno Beckera1adcca2018-08-24 14:41:07 +01007168# The client buffers the ServerKeyExchange before receiving the fragmented
7169# Certificate message; at the time of writing, together these are aroudn 1200b
7170# in size, so that the bound below ensures that the certificate can be reassembled
7171# while keeping the ServerKeyExchange.
7172requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7173run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007174 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007175 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7176 hs_timeout=2500-60000" \
7177 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7178 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007179 0 \
7180 -c "Buffering HS message" \
7181 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007182 -C "attempt to make space by freeing buffered messages" \
7183 -S "Buffering HS message" \
7184 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007185 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007186 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007187 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007188 -S "Remember CCS message"
7189
7190# The size constraints ensure that the delayed certificate message can't
7191# be reassembled while keeping the ServerKeyExchange message, but it can
7192# when dropping it first.
7193requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7194requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7195run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7196 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007197 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7198 hs_timeout=2500-60000" \
7199 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7200 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007201 0 \
7202 -c "Buffering HS message" \
7203 -c "attempt to make space by freeing buffered future messages" \
7204 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007205 -S "Buffering HS message" \
7206 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007207 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007208 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007209 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007210 -S "Remember CCS message"
7211
Hanno Becker56cdfd12018-08-17 13:42:15 +01007212run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7213 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007214 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7215 hs_timeout=2500-60000" \
7216 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7217 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007218 0 \
7219 -C "Buffering HS message" \
7220 -C "Next handshake message has been buffered - load"\
7221 -s "Buffering HS message" \
7222 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007223 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007224 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007225 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007226 -S "Remember CCS message"
7227
7228run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7229 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007230 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7231 hs_timeout=2500-60000" \
7232 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7233 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007234 0 \
7235 -C "Buffering HS message" \
7236 -C "Next handshake message has been buffered - load"\
7237 -S "Buffering HS message" \
7238 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007239 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007240 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007241 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007242 -S "Remember CCS message"
7243
7244run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7245 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007246 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7247 hs_timeout=2500-60000" \
7248 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7249 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007250 0 \
7251 -C "Buffering HS message" \
7252 -C "Next handshake message has been buffered - load"\
7253 -S "Buffering HS message" \
7254 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007255 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007256 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007257 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007258 -s "Remember CCS message"
7259
Hanno Beckera1adcca2018-08-24 14:41:07 +01007260run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007261 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007262 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7263 hs_timeout=2500-60000" \
7264 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7265 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007266 0 \
7267 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007268 -s "Found buffered record from current epoch - load" \
7269 -c "Buffer record from epoch 1" \
7270 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007271
Hanno Beckera1adcca2018-08-24 14:41:07 +01007272# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7273# from the server are delayed, so that the encrypted Finished message
7274# is received and buffered. When the fragmented NewSessionTicket comes
7275# in afterwards, the encrypted Finished message must be freed in order
7276# to make space for the NewSessionTicket to be reassembled.
7277# This works only in very particular circumstances:
7278# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7279# of the NewSessionTicket, but small enough to also allow buffering of
7280# the encrypted Finished message.
7281# - The MTU setting on the server must be so small that the NewSessionTicket
7282# needs to be fragmented.
7283# - All messages sent by the server must be small enough to be either sent
7284# without fragmentation or be reassembled within the bounds of
7285# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7286# handshake, omitting CRTs.
7287requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7288requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7289run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7290 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7291 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7292 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7293 0 \
7294 -s "Buffer record from epoch 1" \
7295 -s "Found buffered record from current epoch - load" \
7296 -c "Buffer record from epoch 1" \
7297 -C "Found buffered record from current epoch - load" \
7298 -c "Enough space available after freeing future epoch record"
7299
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007300# Tests for "randomly unreliable connection": try a variety of flows and peers
7301
7302client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007303run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7304 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007305 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007306 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007307 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007308 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7309 0 \
7310 -s "Extra-header:" \
7311 -c "HTTP/1.0 200 OK"
7312
Janos Follath74537a62016-09-02 13:45:28 +01007313client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007314run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7315 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007316 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7317 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007318 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7319 0 \
7320 -s "Extra-header:" \
7321 -c "HTTP/1.0 200 OK"
7322
Janos Follath74537a62016-09-02 13:45:28 +01007323client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007324run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7325 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007326 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7327 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007328 0 \
7329 -s "Extra-header:" \
7330 -c "HTTP/1.0 200 OK"
7331
Janos Follath74537a62016-09-02 13:45:28 +01007332client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007333run_test "DTLS proxy: 3d, FS, client auth" \
7334 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007335 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7336 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007337 0 \
7338 -s "Extra-header:" \
7339 -c "HTTP/1.0 200 OK"
7340
Janos Follath74537a62016-09-02 13:45:28 +01007341client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007342run_test "DTLS proxy: 3d, FS, ticket" \
7343 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007344 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7345 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007346 0 \
7347 -s "Extra-header:" \
7348 -c "HTTP/1.0 200 OK"
7349
Janos Follath74537a62016-09-02 13:45:28 +01007350client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007351run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7352 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007353 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7354 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007355 0 \
7356 -s "Extra-header:" \
7357 -c "HTTP/1.0 200 OK"
7358
Janos Follath74537a62016-09-02 13:45:28 +01007359client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007360run_test "DTLS proxy: 3d, max handshake, nbio" \
7361 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007362 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007363 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007364 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007365 0 \
7366 -s "Extra-header:" \
7367 -c "HTTP/1.0 200 OK"
7368
Janos Follath74537a62016-09-02 13:45:28 +01007369client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007370run_test "DTLS proxy: 3d, min handshake, resumption" \
7371 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007372 "$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 +02007373 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007374 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007375 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007376 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7377 0 \
7378 -s "a session has been resumed" \
7379 -c "a session has been resumed" \
7380 -s "Extra-header:" \
7381 -c "HTTP/1.0 200 OK"
7382
Janos Follath74537a62016-09-02 13:45:28 +01007383client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007384run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7385 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007386 "$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 +02007387 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007388 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007389 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007390 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7391 0 \
7392 -s "a session has been resumed" \
7393 -c "a session has been resumed" \
7394 -s "Extra-header:" \
7395 -c "HTTP/1.0 200 OK"
7396
Janos Follath74537a62016-09-02 13:45:28 +01007397client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007398requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007399run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007400 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007401 "$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 +02007402 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007403 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007404 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007405 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7406 0 \
7407 -c "=> renegotiate" \
7408 -s "=> renegotiate" \
7409 -s "Extra-header:" \
7410 -c "HTTP/1.0 200 OK"
7411
Janos Follath74537a62016-09-02 13:45:28 +01007412client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007413requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007414run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7415 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007416 "$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 +02007417 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007418 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007419 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007420 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7421 0 \
7422 -c "=> renegotiate" \
7423 -s "=> renegotiate" \
7424 -s "Extra-header:" \
7425 -c "HTTP/1.0 200 OK"
7426
Janos Follath74537a62016-09-02 13:45:28 +01007427client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007428requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007429run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007430 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007431 "$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 +02007432 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007433 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007434 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007435 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007436 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7437 0 \
7438 -c "=> renegotiate" \
7439 -s "=> renegotiate" \
7440 -s "Extra-header:" \
7441 -c "HTTP/1.0 200 OK"
7442
Janos Follath74537a62016-09-02 13:45:28 +01007443client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007444requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007445run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007446 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007447 "$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 +02007448 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007449 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007450 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007451 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007452 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7453 0 \
7454 -c "=> renegotiate" \
7455 -s "=> renegotiate" \
7456 -s "Extra-header:" \
7457 -c "HTTP/1.0 200 OK"
7458
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007459## Interop tests with OpenSSL might trigger a bug in recent versions (including
7460## all versions installed on the CI machines), reported here:
7461## Bug report: https://github.com/openssl/openssl/issues/6902
7462## They should be re-enabled once a fixed version of OpenSSL is available
7463## (this should happen in some 1.1.1_ release according to the ticket).
7464skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007465client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007466not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007467run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007468 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7469 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007470 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007471 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007472 -c "HTTP/1.0 200 OK"
7473
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007474skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007475client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007476not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007477run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7478 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7479 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007480 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007481 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007482 -c "HTTP/1.0 200 OK"
7483
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007484skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007485client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007486not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007487run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7488 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7489 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007490 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007491 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007492 -c "HTTP/1.0 200 OK"
7493
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007494requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007495client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007496not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007497run_test "DTLS proxy: 3d, gnutls server" \
7498 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7499 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007500 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007501 0 \
7502 -s "Extra-header:" \
7503 -c "Extra-header:"
7504
k-stachowiakabb843e2019-02-18 16:14:03 +01007505requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007506client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007507not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007508run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7509 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007510 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007511 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007512 0 \
7513 -s "Extra-header:" \
7514 -c "Extra-header:"
7515
k-stachowiakabb843e2019-02-18 16:14:03 +01007516requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007517client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007518not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007519run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7520 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007521 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007522 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007523 0 \
7524 -s "Extra-header:" \
7525 -c "Extra-header:"
7526
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007527# Final report
7528
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007529echo "------------------------------------------------------------------------"
7530
7531if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007532 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007533else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007534 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007535fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007536PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007537echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007538
7539exit $FAILS