blob: d16808fadb5c50dd9bc9dd724abb5a6508fa11e6 [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
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002883# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2884# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002885
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002886MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002887MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002888
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002889if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002890 cat <<EOF
2891${CONFIG_H} contains a value for the configuration of
2892MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script's
2893test value of ${MAX_IM_CA}.
Simon Butcher06b78632017-07-28 01:00:17 +01002894
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002895The tests assume this value and if it changes, the tests in this
2896script should also be adjusted.
2897EOF
Simon Butcher06b78632017-07-28 01:00:17 +01002898 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002899fi
2900
Angus Grattonc4dd0732018-04-11 16:28:39 +10002901requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002902run_test "Authentication: server max_int chain, client default" \
2903 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2904 key_file=data_files/dir-maxpath/09.key" \
2905 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2906 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002907 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002908
Angus Grattonc4dd0732018-04-11 16:28:39 +10002909requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002910run_test "Authentication: server max_int+1 chain, client default" \
2911 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2912 key_file=data_files/dir-maxpath/10.key" \
2913 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2914 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002915 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002916
Angus Grattonc4dd0732018-04-11 16:28:39 +10002917requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002918run_test "Authentication: server max_int+1 chain, client optional" \
2919 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2920 key_file=data_files/dir-maxpath/10.key" \
2921 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2922 auth_mode=optional" \
2923 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002924 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002925
Angus Grattonc4dd0732018-04-11 16:28:39 +10002926requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002927run_test "Authentication: server max_int+1 chain, client none" \
2928 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2929 key_file=data_files/dir-maxpath/10.key" \
2930 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2931 auth_mode=none" \
2932 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002933 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002934
Angus Grattonc4dd0732018-04-11 16:28:39 +10002935requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002936run_test "Authentication: client max_int+1 chain, server default" \
2937 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2938 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2939 key_file=data_files/dir-maxpath/10.key" \
2940 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002941 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002942
Angus Grattonc4dd0732018-04-11 16:28:39 +10002943requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002944run_test "Authentication: client max_int+1 chain, server optional" \
2945 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2946 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2947 key_file=data_files/dir-maxpath/10.key" \
2948 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002949 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002950
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+1 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/c10.pem \
2955 key_file=data_files/dir-maxpath/10.key" \
2956 1 \
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
Angus Grattonc4dd0732018-04-11 16:28:39 +10002959requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002960run_test "Authentication: client max_int chain, server required" \
2961 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2962 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2963 key_file=data_files/dir-maxpath/09.key" \
2964 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002965 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002966
Janos Follath89baba22017-04-10 14:34:35 +01002967# Tests for CA list in CertificateRequest messages
2968
2969run_test "Authentication: send CA list in CertificateRequest (default)" \
2970 "$P_SRV debug_level=3 auth_mode=required" \
2971 "$P_CLI crt_file=data_files/server6.crt \
2972 key_file=data_files/server6.key" \
2973 0 \
2974 -s "requested DN"
2975
2976run_test "Authentication: do not send CA list in CertificateRequest" \
2977 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2978 "$P_CLI crt_file=data_files/server6.crt \
2979 key_file=data_files/server6.key" \
2980 0 \
2981 -S "requested DN"
2982
2983run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2984 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2985 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2986 key_file=data_files/server5.key" \
2987 1 \
2988 -S "requested DN" \
2989 -s "x509_verify_cert() returned" \
2990 -s "! The certificate is not correctly signed by the trusted CA" \
2991 -s "! mbedtls_ssl_handshake returned" \
2992 -c "! mbedtls_ssl_handshake returned" \
2993 -s "X509 - Certificate verification failed"
2994
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002995# Tests for certificate selection based on SHA verson
2996
2997run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2998 "$P_SRV crt_file=data_files/server5.crt \
2999 key_file=data_files/server5.key \
3000 crt_file2=data_files/server5-sha1.crt \
3001 key_file2=data_files/server5.key" \
3002 "$P_CLI force_version=tls1_2" \
3003 0 \
3004 -c "signed using.*ECDSA with SHA256" \
3005 -C "signed using.*ECDSA with SHA1"
3006
3007run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
3008 "$P_SRV crt_file=data_files/server5.crt \
3009 key_file=data_files/server5.key \
3010 crt_file2=data_files/server5-sha1.crt \
3011 key_file2=data_files/server5.key" \
3012 "$P_CLI force_version=tls1_1" \
3013 0 \
3014 -C "signed using.*ECDSA with SHA256" \
3015 -c "signed using.*ECDSA with SHA1"
3016
3017run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
3018 "$P_SRV crt_file=data_files/server5.crt \
3019 key_file=data_files/server5.key \
3020 crt_file2=data_files/server5-sha1.crt \
3021 key_file2=data_files/server5.key" \
3022 "$P_CLI force_version=tls1" \
3023 0 \
3024 -C "signed using.*ECDSA with SHA256" \
3025 -c "signed using.*ECDSA with SHA1"
3026
3027run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
3028 "$P_SRV crt_file=data_files/server5.crt \
3029 key_file=data_files/server5.key \
3030 crt_file2=data_files/server6.crt \
3031 key_file2=data_files/server6.key" \
3032 "$P_CLI force_version=tls1_1" \
3033 0 \
3034 -c "serial number.*09" \
3035 -c "signed using.*ECDSA with SHA256" \
3036 -C "signed using.*ECDSA with SHA1"
3037
3038run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
3039 "$P_SRV crt_file=data_files/server6.crt \
3040 key_file=data_files/server6.key \
3041 crt_file2=data_files/server5.crt \
3042 key_file2=data_files/server5.key" \
3043 "$P_CLI force_version=tls1_1" \
3044 0 \
3045 -c "serial number.*0A" \
3046 -c "signed using.*ECDSA with SHA256" \
3047 -C "signed using.*ECDSA with SHA1"
3048
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003049# tests for SNI
3050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003051run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003052 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003053 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003054 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003055 0 \
3056 -S "parse ServerName extension" \
3057 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3058 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003060run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003061 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003062 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003063 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 +02003064 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003065 0 \
3066 -s "parse ServerName extension" \
3067 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3068 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003070run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003071 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003072 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003073 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 +02003074 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003075 0 \
3076 -s "parse ServerName extension" \
3077 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3078 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003080run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003081 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003082 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003083 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 +02003084 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003085 1 \
3086 -s "parse ServerName extension" \
3087 -s "ssl_sni_wrapper() returned" \
3088 -s "mbedtls_ssl_handshake returned" \
3089 -c "mbedtls_ssl_handshake returned" \
3090 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003091
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003092run_test "SNI: client auth no override: optional" \
3093 "$P_SRV debug_level=3 auth_mode=optional \
3094 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3095 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3096 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003097 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003098 -S "skip write certificate request" \
3099 -C "skip parse certificate request" \
3100 -c "got a certificate request" \
3101 -C "skip write certificate" \
3102 -C "skip write certificate verify" \
3103 -S "skip parse certificate verify"
3104
3105run_test "SNI: client auth override: none -> optional" \
3106 "$P_SRV debug_level=3 auth_mode=none \
3107 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3108 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3109 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003110 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003111 -S "skip write certificate request" \
3112 -C "skip parse certificate request" \
3113 -c "got a certificate request" \
3114 -C "skip write certificate" \
3115 -C "skip write certificate verify" \
3116 -S "skip parse certificate verify"
3117
3118run_test "SNI: client auth override: optional -> none" \
3119 "$P_SRV debug_level=3 auth_mode=optional \
3120 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3121 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3122 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003123 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003124 -s "skip write certificate request" \
3125 -C "skip parse certificate request" \
3126 -c "got no certificate request" \
3127 -c "skip write certificate" \
3128 -c "skip write certificate verify" \
3129 -s "skip parse certificate verify"
3130
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003131run_test "SNI: CA no override" \
3132 "$P_SRV debug_level=3 auth_mode=optional \
3133 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3134 ca_file=data_files/test-ca.crt \
3135 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3136 "$P_CLI debug_level=3 server_name=localhost \
3137 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3138 1 \
3139 -S "skip write certificate request" \
3140 -C "skip parse certificate request" \
3141 -c "got a certificate request" \
3142 -C "skip write certificate" \
3143 -C "skip write certificate verify" \
3144 -S "skip parse certificate verify" \
3145 -s "x509_verify_cert() returned" \
3146 -s "! The certificate is not correctly signed by the trusted CA" \
3147 -S "The certificate has been revoked (is on a CRL)"
3148
3149run_test "SNI: CA override" \
3150 "$P_SRV debug_level=3 auth_mode=optional \
3151 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3152 ca_file=data_files/test-ca.crt \
3153 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3154 "$P_CLI debug_level=3 server_name=localhost \
3155 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3156 0 \
3157 -S "skip write certificate request" \
3158 -C "skip parse certificate request" \
3159 -c "got a certificate request" \
3160 -C "skip write certificate" \
3161 -C "skip write certificate verify" \
3162 -S "skip parse certificate verify" \
3163 -S "x509_verify_cert() returned" \
3164 -S "! The certificate is not correctly signed by the trusted CA" \
3165 -S "The certificate has been revoked (is on a CRL)"
3166
3167run_test "SNI: CA override with CRL" \
3168 "$P_SRV debug_level=3 auth_mode=optional \
3169 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3170 ca_file=data_files/test-ca.crt \
3171 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3172 "$P_CLI debug_level=3 server_name=localhost \
3173 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3174 1 \
3175 -S "skip write certificate request" \
3176 -C "skip parse certificate request" \
3177 -c "got a certificate request" \
3178 -C "skip write certificate" \
3179 -C "skip write certificate verify" \
3180 -S "skip parse certificate verify" \
3181 -s "x509_verify_cert() returned" \
3182 -S "! The certificate is not correctly signed by the trusted CA" \
3183 -s "The certificate has been revoked (is on a CRL)"
3184
Andres AG1a834452016-12-07 10:01:30 +00003185# Tests for SNI and DTLS
3186
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003187run_test "SNI: DTLS, no SNI callback" \
3188 "$P_SRV debug_level=3 dtls=1 \
3189 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3190 "$P_CLI server_name=localhost dtls=1" \
3191 0 \
3192 -S "parse ServerName extension" \
3193 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3194 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3195
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003196run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003197 "$P_SRV debug_level=3 dtls=1 \
3198 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3199 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3200 "$P_CLI server_name=localhost dtls=1" \
3201 0 \
3202 -s "parse ServerName extension" \
3203 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3204 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3205
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003206run_test "SNI: DTLS, matching cert 2" \
3207 "$P_SRV debug_level=3 dtls=1 \
3208 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3209 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3210 "$P_CLI server_name=polarssl.example dtls=1" \
3211 0 \
3212 -s "parse ServerName extension" \
3213 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3214 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3215
3216run_test "SNI: DTLS, no matching cert" \
3217 "$P_SRV debug_level=3 dtls=1 \
3218 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3219 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3220 "$P_CLI server_name=nonesuch.example dtls=1" \
3221 1 \
3222 -s "parse ServerName extension" \
3223 -s "ssl_sni_wrapper() returned" \
3224 -s "mbedtls_ssl_handshake returned" \
3225 -c "mbedtls_ssl_handshake returned" \
3226 -c "SSL - A fatal alert message was received from our peer"
3227
3228run_test "SNI: DTLS, client auth no override: optional" \
3229 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3230 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3231 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3232 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3233 0 \
3234 -S "skip write certificate request" \
3235 -C "skip parse certificate request" \
3236 -c "got a certificate request" \
3237 -C "skip write certificate" \
3238 -C "skip write certificate verify" \
3239 -S "skip parse certificate verify"
3240
3241run_test "SNI: DTLS, client auth override: none -> optional" \
3242 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3243 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3244 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3245 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3246 0 \
3247 -S "skip write certificate request" \
3248 -C "skip parse certificate request" \
3249 -c "got a certificate request" \
3250 -C "skip write certificate" \
3251 -C "skip write certificate verify" \
3252 -S "skip parse certificate verify"
3253
3254run_test "SNI: DTLS, client auth override: optional -> none" \
3255 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3256 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3257 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3258 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3259 0 \
3260 -s "skip write certificate request" \
3261 -C "skip parse certificate request" \
3262 -c "got no certificate request" \
3263 -c "skip write certificate" \
3264 -c "skip write certificate verify" \
3265 -s "skip parse certificate verify"
3266
3267run_test "SNI: DTLS, CA no override" \
3268 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3269 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3270 ca_file=data_files/test-ca.crt \
3271 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3272 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3273 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3274 1 \
3275 -S "skip write certificate request" \
3276 -C "skip parse certificate request" \
3277 -c "got a certificate request" \
3278 -C "skip write certificate" \
3279 -C "skip write certificate verify" \
3280 -S "skip parse certificate verify" \
3281 -s "x509_verify_cert() returned" \
3282 -s "! The certificate is not correctly signed by the trusted CA" \
3283 -S "The certificate has been revoked (is on a CRL)"
3284
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003285run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003286 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3287 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3288 ca_file=data_files/test-ca.crt \
3289 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3290 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3291 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3292 0 \
3293 -S "skip write certificate request" \
3294 -C "skip parse certificate request" \
3295 -c "got a certificate request" \
3296 -C "skip write certificate" \
3297 -C "skip write certificate verify" \
3298 -S "skip parse certificate verify" \
3299 -S "x509_verify_cert() returned" \
3300 -S "! The certificate is not correctly signed by the trusted CA" \
3301 -S "The certificate has been revoked (is on a CRL)"
3302
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003303run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003304 "$P_SRV debug_level=3 auth_mode=optional \
3305 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3306 ca_file=data_files/test-ca.crt \
3307 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3308 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3309 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3310 1 \
3311 -S "skip write certificate request" \
3312 -C "skip parse certificate request" \
3313 -c "got a certificate request" \
3314 -C "skip write certificate" \
3315 -C "skip write certificate verify" \
3316 -S "skip parse certificate verify" \
3317 -s "x509_verify_cert() returned" \
3318 -S "! The certificate is not correctly signed by the trusted CA" \
3319 -s "The certificate has been revoked (is on a CRL)"
3320
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003321# Tests for non-blocking I/O: exercise a variety of handshake flows
3322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003323run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003324 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
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: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003332 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3333 "$P_CLI nbio=2 tickets=0" \
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" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003340 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
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" \
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" \
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 + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003356 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
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: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003364 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3365 "$P_CLI nbio=2 tickets=1 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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003371run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003372 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3373 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3374 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003375 -S "mbedtls_ssl_handshake returned" \
3376 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003377 -c "Read from server: .* bytes read"
3378
Hanno Becker00076712017-11-15 16:39:08 +00003379# Tests for event-driven I/O: exercise a variety of handshake flows
3380
3381run_test "Event-driven I/O: basic handshake" \
3382 "$P_SRV event=1 tickets=0 auth_mode=none" \
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: client auth" \
3390 "$P_SRV event=1 tickets=0 auth_mode=required" \
3391 "$P_CLI event=1 tickets=0" \
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" \
3398 "$P_SRV event=1 tickets=1 auth_mode=none" \
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" \
3406 "$P_SRV event=1 tickets=1 auth_mode=required" \
3407 "$P_CLI event=1 tickets=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 + client auth + resume" \
3414 "$P_SRV event=1 tickets=1 auth_mode=required" \
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: ticket + resume" \
3422 "$P_SRV event=1 tickets=1 auth_mode=none" \
3423 "$P_CLI event=1 tickets=1 reconnect=1" \
3424 0 \
3425 -S "mbedtls_ssl_handshake returned" \
3426 -C "mbedtls_ssl_handshake returned" \
3427 -c "Read from server: .* bytes read"
3428
3429run_test "Event-driven I/O: session-id resume" \
3430 "$P_SRV event=1 tickets=0 auth_mode=none" \
3431 "$P_CLI event=1 tickets=0 reconnect=1" \
3432 0 \
3433 -S "mbedtls_ssl_handshake returned" \
3434 -C "mbedtls_ssl_handshake returned" \
3435 -c "Read from server: .* bytes read"
3436
Hanno Becker6a33f592018-03-13 11:38:46 +00003437run_test "Event-driven I/O, DTLS: basic handshake" \
3438 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3439 "$P_CLI dtls=1 event=1 tickets=0" \
3440 0 \
3441 -c "Read from server: .* bytes read"
3442
3443run_test "Event-driven I/O, DTLS: client auth" \
3444 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3445 "$P_CLI dtls=1 event=1 tickets=0" \
3446 0 \
3447 -c "Read from server: .* bytes read"
3448
3449run_test "Event-driven I/O, DTLS: ticket" \
3450 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3451 "$P_CLI dtls=1 event=1 tickets=1" \
3452 0 \
3453 -c "Read from server: .* bytes read"
3454
3455run_test "Event-driven I/O, DTLS: ticket + client auth" \
3456 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3457 "$P_CLI dtls=1 event=1 tickets=1" \
3458 0 \
3459 -c "Read from server: .* bytes read"
3460
3461run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3462 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003463 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003464 0 \
3465 -c "Read from server: .* bytes read"
3466
3467run_test "Event-driven I/O, DTLS: ticket + resume" \
3468 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003469 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003470 0 \
3471 -c "Read from server: .* bytes read"
3472
3473run_test "Event-driven I/O, DTLS: session-id resume" \
3474 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003475 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003476 0 \
3477 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003478
3479# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3480# During session resumption, the client will send its ApplicationData record
3481# within the same datagram as the Finished messages. In this situation, the
3482# server MUST NOT idle on the underlying transport after handshake completion,
3483# because the ApplicationData request has already been queued internally.
3484run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003485 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003486 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003487 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003488 0 \
3489 -c "Read from server: .* bytes read"
3490
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003491# Tests for version negotiation
3492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003493run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003494 "$P_SRV" \
3495 "$P_CLI" \
3496 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003497 -S "mbedtls_ssl_handshake returned" \
3498 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003499 -s "Protocol is TLSv1.2" \
3500 -c "Protocol is TLSv1.2"
3501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003502run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003503 "$P_SRV" \
3504 "$P_CLI max_version=tls1_1" \
3505 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003506 -S "mbedtls_ssl_handshake returned" \
3507 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003508 -s "Protocol is TLSv1.1" \
3509 -c "Protocol is TLSv1.1"
3510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003511run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003512 "$P_SRV max_version=tls1_1" \
3513 "$P_CLI" \
3514 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003515 -S "mbedtls_ssl_handshake returned" \
3516 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003517 -s "Protocol is TLSv1.1" \
3518 -c "Protocol is TLSv1.1"
3519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003520run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003521 "$P_SRV max_version=tls1_1" \
3522 "$P_CLI max_version=tls1_1" \
3523 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003524 -S "mbedtls_ssl_handshake returned" \
3525 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003526 -s "Protocol is TLSv1.1" \
3527 -c "Protocol is TLSv1.1"
3528
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003529run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003530 "$P_SRV min_version=tls1_1" \
3531 "$P_CLI max_version=tls1_1" \
3532 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003533 -S "mbedtls_ssl_handshake returned" \
3534 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003535 -s "Protocol is TLSv1.1" \
3536 -c "Protocol is TLSv1.1"
3537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003538run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003539 "$P_SRV max_version=tls1_1" \
3540 "$P_CLI min_version=tls1_1" \
3541 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003542 -S "mbedtls_ssl_handshake returned" \
3543 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003544 -s "Protocol is TLSv1.1" \
3545 -c "Protocol is TLSv1.1"
3546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003547run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003548 "$P_SRV max_version=tls1_1" \
3549 "$P_CLI min_version=tls1_2" \
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 -c "SSL - Handshake protocol not within min/max boundaries"
3554
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003555run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003556 "$P_SRV min_version=tls1_2" \
3557 "$P_CLI max_version=tls1_1" \
3558 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003559 -s "mbedtls_ssl_handshake returned" \
3560 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003561 -s "SSL - Handshake protocol not within min/max boundaries"
3562
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003563# Tests for ALPN extension
3564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003565run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003566 "$P_SRV debug_level=3" \
3567 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003568 0 \
3569 -C "client hello, adding alpn extension" \
3570 -S "found alpn extension" \
3571 -C "got an alert message, type: \\[2:120]" \
3572 -S "server hello, adding alpn extension" \
3573 -C "found alpn extension " \
3574 -C "Application Layer Protocol is" \
3575 -S "Application Layer Protocol is"
3576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003577run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003578 "$P_SRV debug_level=3" \
3579 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003580 0 \
3581 -c "client hello, adding alpn extension" \
3582 -s "found alpn extension" \
3583 -C "got an alert message, type: \\[2:120]" \
3584 -S "server hello, adding alpn extension" \
3585 -C "found alpn extension " \
3586 -c "Application Layer Protocol is (none)" \
3587 -S "Application Layer Protocol is"
3588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003589run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003590 "$P_SRV debug_level=3 alpn=abc,1234" \
3591 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003592 0 \
3593 -C "client hello, adding alpn extension" \
3594 -S "found alpn extension" \
3595 -C "got an alert message, type: \\[2:120]" \
3596 -S "server hello, adding alpn extension" \
3597 -C "found alpn extension " \
3598 -C "Application Layer Protocol is" \
3599 -s "Application Layer Protocol is (none)"
3600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003601run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003602 "$P_SRV debug_level=3 alpn=abc,1234" \
3603 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003604 0 \
3605 -c "client hello, adding alpn extension" \
3606 -s "found alpn extension" \
3607 -C "got an alert message, type: \\[2:120]" \
3608 -s "server hello, adding alpn extension" \
3609 -c "found alpn extension" \
3610 -c "Application Layer Protocol is abc" \
3611 -s "Application Layer Protocol is abc"
3612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003613run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003614 "$P_SRV debug_level=3 alpn=abc,1234" \
3615 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003616 0 \
3617 -c "client hello, adding alpn extension" \
3618 -s "found alpn extension" \
3619 -C "got an alert message, type: \\[2:120]" \
3620 -s "server hello, adding alpn extension" \
3621 -c "found alpn extension" \
3622 -c "Application Layer Protocol is abc" \
3623 -s "Application Layer Protocol is abc"
3624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003625run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003626 "$P_SRV debug_level=3 alpn=abc,1234" \
3627 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003628 0 \
3629 -c "client hello, adding alpn extension" \
3630 -s "found alpn extension" \
3631 -C "got an alert message, type: \\[2:120]" \
3632 -s "server hello, adding alpn extension" \
3633 -c "found alpn extension" \
3634 -c "Application Layer Protocol is 1234" \
3635 -s "Application Layer Protocol is 1234"
3636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003637run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003638 "$P_SRV debug_level=3 alpn=abc,123" \
3639 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003640 1 \
3641 -c "client hello, adding alpn extension" \
3642 -s "found alpn extension" \
3643 -c "got an alert message, type: \\[2:120]" \
3644 -S "server hello, adding alpn extension" \
3645 -C "found alpn extension" \
3646 -C "Application Layer Protocol is 1234" \
3647 -S "Application Layer Protocol is 1234"
3648
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003649
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003650# Tests for keyUsage in leaf certificates, part 1:
3651# server-side certificate/suite selection
3652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003653run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-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-ds.crt" \
3656 "$P_CLI" \
3657 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003658 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003659
3660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003661run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003662 "$P_SRV key_file=data_files/server2.key \
3663 crt_file=data_files/server2.ku-ke.crt" \
3664 "$P_CLI" \
3665 0 \
3666 -c "Ciphersuite is TLS-RSA-WITH-"
3667
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003668run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003669 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003670 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003671 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003672 1 \
3673 -C "Ciphersuite is "
3674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003675run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
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-ds.crt" \
3678 "$P_CLI" \
3679 0 \
3680 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3681
3682
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003683run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003684 "$P_SRV key_file=data_files/server5.key \
3685 crt_file=data_files/server5.ku-ka.crt" \
3686 "$P_CLI" \
3687 0 \
3688 -c "Ciphersuite is TLS-ECDH-"
3689
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003690run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003691 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003692 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003693 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003694 1 \
3695 -C "Ciphersuite is "
3696
3697# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003698# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003699
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003700run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003701 "$O_SRV -key data_files/server2.key \
3702 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003703 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003704 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3705 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003706 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003707 -C "Processing of the Certificate handshake message failed" \
3708 -c "Ciphersuite is TLS-"
3709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003710run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003711 "$O_SRV -key data_files/server2.key \
3712 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003713 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003714 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3715 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003716 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003717 -C "Processing of the Certificate handshake message failed" \
3718 -c "Ciphersuite is TLS-"
3719
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003720run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003721 "$O_SRV -key data_files/server2.key \
3722 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003723 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003724 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3725 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003726 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003727 -C "Processing of the Certificate handshake message failed" \
3728 -c "Ciphersuite is TLS-"
3729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003730run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003731 "$O_SRV -key data_files/server2.key \
3732 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003733 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003734 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3735 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003736 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003737 -c "Processing of the Certificate handshake message failed" \
3738 -C "Ciphersuite is TLS-"
3739
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003740run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3741 "$O_SRV -key data_files/server2.key \
3742 -cert data_files/server2.ku-ke.crt" \
3743 "$P_CLI debug_level=1 auth_mode=optional \
3744 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3745 0 \
3746 -c "bad certificate (usage extensions)" \
3747 -C "Processing of the Certificate handshake message failed" \
3748 -c "Ciphersuite is TLS-" \
3749 -c "! Usage does not match the keyUsage extension"
3750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003751run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003752 "$O_SRV -key data_files/server2.key \
3753 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003754 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003755 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3756 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003757 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003758 -C "Processing of the Certificate handshake message failed" \
3759 -c "Ciphersuite is TLS-"
3760
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003761run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003762 "$O_SRV -key data_files/server2.key \
3763 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003764 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003765 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3766 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003767 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003768 -c "Processing of the Certificate handshake message failed" \
3769 -C "Ciphersuite is TLS-"
3770
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003771run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3772 "$O_SRV -key data_files/server2.key \
3773 -cert data_files/server2.ku-ds.crt" \
3774 "$P_CLI debug_level=1 auth_mode=optional \
3775 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3776 0 \
3777 -c "bad certificate (usage extensions)" \
3778 -C "Processing of the Certificate handshake message failed" \
3779 -c "Ciphersuite is TLS-" \
3780 -c "! Usage does not match the keyUsage extension"
3781
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003782# Tests for keyUsage in leaf certificates, part 3:
3783# server-side checking of client cert
3784
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003785run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
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-ds.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 (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003794 "$P_SRV debug_level=1 auth_mode=optional" \
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 0 \
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: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003802 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003803 "$O_CLI -key data_files/server2.key \
3804 -cert data_files/server2.ku-ke.crt" \
3805 1 \
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, DigitalSignature: OK" \
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-ds.crt" \
3813 0 \
3814 -S "bad certificate (usage extensions)" \
3815 -S "Processing of the Certificate handshake message failed"
3816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003817run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003818 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003819 "$O_CLI -key data_files/server5.key \
3820 -cert data_files/server5.ku-ka.crt" \
3821 0 \
3822 -s "bad certificate (usage extensions)" \
3823 -S "Processing of the Certificate handshake message failed"
3824
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003825# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003827run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003828 "$P_SRV key_file=data_files/server5.key \
3829 crt_file=data_files/server5.eku-srv.crt" \
3830 "$P_CLI" \
3831 0
3832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003833run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003834 "$P_SRV key_file=data_files/server5.key \
3835 crt_file=data_files/server5.eku-srv.crt" \
3836 "$P_CLI" \
3837 0
3838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003839run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003840 "$P_SRV key_file=data_files/server5.key \
3841 crt_file=data_files/server5.eku-cs_any.crt" \
3842 "$P_CLI" \
3843 0
3844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003845run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003846 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003847 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003848 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003849 1
3850
3851# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003853run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003854 "$O_SRV -key data_files/server5.key \
3855 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003856 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003857 0 \
3858 -C "bad certificate (usage extensions)" \
3859 -C "Processing of the Certificate handshake message failed" \
3860 -c "Ciphersuite is TLS-"
3861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003862run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003863 "$O_SRV -key data_files/server5.key \
3864 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003865 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003866 0 \
3867 -C "bad certificate (usage extensions)" \
3868 -C "Processing of the Certificate handshake message failed" \
3869 -c "Ciphersuite is TLS-"
3870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003871run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003872 "$O_SRV -key data_files/server5.key \
3873 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003874 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003875 0 \
3876 -C "bad certificate (usage extensions)" \
3877 -C "Processing of the Certificate handshake message failed" \
3878 -c "Ciphersuite is TLS-"
3879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003880run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003881 "$O_SRV -key data_files/server5.key \
3882 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003883 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003884 1 \
3885 -c "bad certificate (usage extensions)" \
3886 -c "Processing of the Certificate handshake message failed" \
3887 -C "Ciphersuite is TLS-"
3888
3889# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003891run_test "extKeyUsage cli-auth: 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-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: serverAuth,clientAuth -> 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-srv_cli.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,anyEKU -> OK" \
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_any.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 (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003916 "$P_SRV debug_level=1 auth_mode=optional" \
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 0 \
3920 -s "bad certificate (usage extensions)" \
3921 -S "Processing of the Certificate handshake message failed"
3922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003923run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003924 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003925 "$O_CLI -key data_files/server5.key \
3926 -cert data_files/server5.eku-cs.crt" \
3927 1 \
3928 -s "bad certificate (usage extensions)" \
3929 -s "Processing of the Certificate handshake message failed"
3930
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003931# Tests for DHM parameters loading
3932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003933run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003934 "$P_SRV" \
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 ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003939 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003940
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003941run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003942 "$P_SRV dhm_file=data_files/dhparams.pem" \
3943 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3944 debug_level=3" \
3945 0 \
3946 -c "value of 'DHM: P ' (1024 bits)" \
3947 -c "value of 'DHM: G ' (2 bits)"
3948
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003949# Tests for DHM client-side size checking
3950
3951run_test "DHM size: server default, client default, OK" \
3952 "$P_SRV" \
3953 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3954 debug_level=1" \
3955 0 \
3956 -C "DHM prime too short:"
3957
3958run_test "DHM size: server default, client 2048, OK" \
3959 "$P_SRV" \
3960 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3961 debug_level=1 dhmlen=2048" \
3962 0 \
3963 -C "DHM prime too short:"
3964
3965run_test "DHM size: server 1024, client default, OK" \
3966 "$P_SRV dhm_file=data_files/dhparams.pem" \
3967 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3968 debug_level=1" \
3969 0 \
3970 -C "DHM prime too short:"
3971
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01003972run_test "DHM size: server 999, client 999, OK" \
3973 "$P_SRV dhm_file=data_files/dh.999.pem" \
3974 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3975 debug_level=1 dhmlen=999" \
3976 0 \
3977 -C "DHM prime too short:"
3978
3979run_test "DHM size: server 1000, client 1000, OK" \
3980 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3981 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3982 debug_level=1 dhmlen=1000" \
3983 0 \
3984 -C "DHM prime too short:"
3985
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003986run_test "DHM size: server 1000, client default, rejected" \
3987 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3988 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3989 debug_level=1" \
3990 1 \
3991 -c "DHM prime too short:"
3992
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01003993run_test "DHM size: server 1000, client 1001, rejected" \
3994 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3995 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3996 debug_level=1 dhmlen=1001" \
3997 1 \
3998 -c "DHM prime too short:"
3999
4000run_test "DHM size: server 999, client 1000, rejected" \
4001 "$P_SRV dhm_file=data_files/dh.999.pem" \
4002 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4003 debug_level=1 dhmlen=1000" \
4004 1 \
4005 -c "DHM prime too short:"
4006
4007run_test "DHM size: server 998, client 999, rejected" \
4008 "$P_SRV dhm_file=data_files/dh.998.pem" \
4009 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4010 debug_level=1 dhmlen=999" \
4011 1 \
4012 -c "DHM prime too short:"
4013
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004014run_test "DHM size: server default, client 2049, rejected" \
4015 "$P_SRV" \
4016 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4017 debug_level=1 dhmlen=2049" \
4018 1 \
4019 -c "DHM prime too short:"
4020
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004021# Tests for PSK callback
4022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004023run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004024 "$P_SRV psk=abc123 psk_identity=foo" \
4025 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4026 psk_identity=foo psk=abc123" \
4027 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004028 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004029 -S "SSL - Unknown identity received" \
4030 -S "SSL - Verification of the message MAC failed"
4031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004032run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004033 "$P_SRV" \
4034 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4035 psk_identity=foo psk=abc123" \
4036 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004037 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004038 -S "SSL - Unknown identity received" \
4039 -S "SSL - Verification of the message MAC failed"
4040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004041run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004042 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
4043 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4044 psk_identity=foo psk=abc123" \
4045 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004046 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004047 -s "SSL - Unknown identity received" \
4048 -S "SSL - Verification of the message MAC failed"
4049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004050run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004051 "$P_SRV psk_list=abc,dead,def,beef" \
4052 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4053 psk_identity=abc psk=dead" \
4054 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004055 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004056 -S "SSL - Unknown identity received" \
4057 -S "SSL - Verification of the message MAC failed"
4058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004059run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004060 "$P_SRV psk_list=abc,dead,def,beef" \
4061 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4062 psk_identity=def psk=beef" \
4063 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004064 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004065 -S "SSL - Unknown identity received" \
4066 -S "SSL - Verification of the message MAC failed"
4067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004068run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004069 "$P_SRV psk_list=abc,dead,def,beef" \
4070 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4071 psk_identity=ghi psk=beef" \
4072 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004073 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004074 -s "SSL - Unknown identity received" \
4075 -S "SSL - Verification of the message MAC failed"
4076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004077run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004078 "$P_SRV psk_list=abc,dead,def,beef" \
4079 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4080 psk_identity=abc psk=beef" \
4081 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004082 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004083 -S "SSL - Unknown identity received" \
4084 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004085
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004086# Tests for EC J-PAKE
4087
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004088requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004089run_test "ECJPAKE: client not configured" \
4090 "$P_SRV debug_level=3" \
4091 "$P_CLI debug_level=3" \
4092 0 \
4093 -C "add ciphersuite: c0ff" \
4094 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004095 -S "found ecjpake kkpp extension" \
4096 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004097 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004098 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004099 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004100 -S "None of the common ciphersuites is usable"
4101
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004102requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004103run_test "ECJPAKE: server not configured" \
4104 "$P_SRV debug_level=3" \
4105 "$P_CLI debug_level=3 ecjpake_pw=bla \
4106 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4107 1 \
4108 -c "add ciphersuite: c0ff" \
4109 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004110 -s "found ecjpake kkpp extension" \
4111 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004112 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004113 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004114 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004115 -s "None of the common ciphersuites is usable"
4116
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004117requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004118run_test "ECJPAKE: working, TLS" \
4119 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4120 "$P_CLI debug_level=3 ecjpake_pw=bla \
4121 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004122 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004123 -c "add ciphersuite: c0ff" \
4124 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004125 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004126 -s "found ecjpake kkpp extension" \
4127 -S "skip ecjpake kkpp extension" \
4128 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004129 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004130 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004131 -S "None of the common ciphersuites is usable" \
4132 -S "SSL - Verification of the message MAC failed"
4133
Janos Follath74537a62016-09-02 13:45:28 +01004134server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004135requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004136run_test "ECJPAKE: password mismatch, TLS" \
4137 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4138 "$P_CLI debug_level=3 ecjpake_pw=bad \
4139 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4140 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004141 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004142 -s "SSL - Verification of the message MAC failed"
4143
Dave Rodgmancee9e922021-06-29 19:05:34 +01004144requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004145run_test "ECJPAKE: working, DTLS" \
4146 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4147 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4148 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4149 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004150 -c "re-using cached ecjpake parameters" \
4151 -S "SSL - Verification of the message MAC failed"
4152
Dave Rodgmancee9e922021-06-29 19:05:34 +01004153requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004154run_test "ECJPAKE: working, DTLS, no cookie" \
4155 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4156 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4157 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4158 0 \
4159 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004160 -S "SSL - Verification of the message MAC failed"
4161
Janos Follath74537a62016-09-02 13:45:28 +01004162server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004163requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004164run_test "ECJPAKE: password mismatch, DTLS" \
4165 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4166 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4167 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4168 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004169 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004170 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004171
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004172# for tests with configs/config-thread.h
Dave Rodgmancee9e922021-06-29 19:05:34 +01004173requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004174run_test "ECJPAKE: working, DTLS, nolog" \
4175 "$P_SRV dtls=1 ecjpake_pw=bla" \
4176 "$P_CLI dtls=1 ecjpake_pw=bla \
4177 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4178 0
4179
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004180# Tests for ciphersuites per version
4181
Janos Follathe2681a42016-03-07 15:57:05 +00004182requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004183requires_config_enabled MBEDTLS_CAMELLIA_C
4184requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004185run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004186 "$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 +02004187 "$P_CLI force_version=ssl3" \
4188 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004189 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004190
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004191requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4192requires_config_enabled MBEDTLS_CAMELLIA_C
4193requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004194run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004195 "$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 +01004196 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004197 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004198 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004199
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004200requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4201requires_config_enabled MBEDTLS_CAMELLIA_C
4202requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004203run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004204 "$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 +02004205 "$P_CLI force_version=tls1_1" \
4206 0 \
4207 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4208
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004209requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4210requires_config_enabled MBEDTLS_CAMELLIA_C
4211requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004212run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004213 "$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 +02004214 "$P_CLI force_version=tls1_2" \
4215 0 \
4216 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4217
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004218# Test for ClientHello without extensions
4219
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004220requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004221run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004222 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004223 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004224 0 \
4225 -s "dumping 'client hello extensions' (0 bytes)"
4226
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004227# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004228
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004229run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004230 "$P_SRV" \
4231 "$P_CLI request_size=100" \
4232 0 \
4233 -s "Read from client: 100 bytes read$"
4234
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004235run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004236 "$P_SRV" \
4237 "$P_CLI request_size=500" \
4238 0 \
4239 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004240
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004241# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004242
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 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004245 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004246 "$P_CLI request_size=1 force_version=ssl3 \
4247 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4248 0 \
4249 -s "Read from client: 1 bytes read"
4250
Janos Follathe2681a42016-03-07 15:57:05 +00004251requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004252run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004253 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004254 "$P_CLI request_size=1 force_version=ssl3 \
4255 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4256 0 \
4257 -s "Read from client: 1 bytes read"
4258
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004259run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004260 "$P_SRV" \
4261 "$P_CLI request_size=1 force_version=tls1 \
4262 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4263 0 \
4264 -s "Read from client: 1 bytes read"
4265
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004266run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004267 "$P_SRV" \
4268 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4269 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4270 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, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004275 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004276 "$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" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004278 0 \
4279 -s "Read from client: 1 bytes read"
4280
Hanno Becker32c55012017-11-10 08:42:54 +00004281requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004282run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004283 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004284 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004285 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004286 0 \
4287 -s "Read from client: 1 bytes read"
4288
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004289run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004290 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004291 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004292 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4293 0 \
4294 -s "Read from client: 1 bytes read"
4295
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004296run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004297 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4298 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004299 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004300 0 \
4301 -s "Read from client: 1 bytes read"
4302
4303requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004304run_test "Small client packet TLS 1.0 StreamCipher, 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" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004306 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004307 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004308 0 \
4309 -s "Read from client: 1 bytes read"
4310
Hanno Becker8501f982017-11-10 08:59:04 +00004311requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004312run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004313 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4314 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4315 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004316 0 \
4317 -s "Read from client: 1 bytes read"
4318
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004319run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004320 "$P_SRV" \
4321 "$P_CLI request_size=1 force_version=tls1_1 \
4322 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4323 0 \
4324 -s "Read from client: 1 bytes read"
4325
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004326run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004327 "$P_SRV" \
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 etm=0" \
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, 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" \
Hanno Becker8501f982017-11-10 08:59:04 +00004338 0 \
4339 -s "Read from client: 1 bytes read"
4340
4341requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004342run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004343 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004344 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004345 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004346 0 \
4347 -s "Read from client: 1 bytes read"
4348
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004349run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004350 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004351 "$P_CLI request_size=1 force_version=tls1_1 \
4352 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4353 0 \
4354 -s "Read from client: 1 bytes read"
4355
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004356run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004357 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
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 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004360 0 \
4361 -s "Read from client: 1 bytes read"
4362
Hanno Becker8501f982017-11-10 08:59:04 +00004363requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004364run_test "Small client packet TLS 1.1 StreamCipher, 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" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004368 0 \
4369 -s "Read from client: 1 bytes read"
4370
Hanno Becker32c55012017-11-10 08:42:54 +00004371requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004372run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004373 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004374 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004375 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004376 0 \
4377 -s "Read from client: 1 bytes read"
4378
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004379run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004380 "$P_SRV" \
4381 "$P_CLI request_size=1 force_version=tls1_2 \
4382 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4383 0 \
4384 -s "Read from client: 1 bytes read"
4385
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004386run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004387 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004388 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004389 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004390 0 \
4391 -s "Read from client: 1 bytes read"
4392
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004393run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004394 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004395 "$P_CLI request_size=1 force_version=tls1_2 \
4396 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004397 0 \
4398 -s "Read from client: 1 bytes read"
4399
Hanno Becker32c55012017-11-10 08:42:54 +00004400requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004401run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004402 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004403 "$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" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004405 0 \
4406 -s "Read from client: 1 bytes read"
4407
Hanno Becker8501f982017-11-10 08:59:04 +00004408requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004409run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004410 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004411 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004412 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004413 0 \
4414 -s "Read from client: 1 bytes read"
4415
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004416run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004417 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004418 "$P_CLI request_size=1 force_version=tls1_2 \
4419 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4420 0 \
4421 -s "Read from client: 1 bytes read"
4422
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004423run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004424 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
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 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004427 0 \
4428 -s "Read from client: 1 bytes read"
4429
Hanno Becker32c55012017-11-10 08:42:54 +00004430requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004431run_test "Small client packet TLS 1.2 StreamCipher, 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" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004433 "$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" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004435 0 \
4436 -s "Read from client: 1 bytes read"
4437
Hanno Becker8501f982017-11-10 08:59:04 +00004438requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004439run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004440 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004441 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004442 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004443 0 \
4444 -s "Read from client: 1 bytes read"
4445
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004446run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004447 "$P_SRV" \
4448 "$P_CLI request_size=1 force_version=tls1_2 \
4449 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4450 0 \
4451 -s "Read from client: 1 bytes read"
4452
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004453run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004454 "$P_SRV" \
4455 "$P_CLI request_size=1 force_version=tls1_2 \
4456 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4457 0 \
4458 -s "Read from client: 1 bytes read"
4459
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004460# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004461
4462requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004463run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004464 "$P_SRV dtls=1 force_version=dtls1" \
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
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004471run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004472 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4473 "$P_CLI dtls=1 request_size=1 \
4474 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4475 0 \
4476 -s "Read from client: 1 bytes read"
4477
4478requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4479requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004480run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004481 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4482 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004483 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4484 0 \
4485 -s "Read from client: 1 bytes read"
4486
4487requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4488requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004489run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004490 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004491 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004492 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004493 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" \
Hanno Beckere2148042017-11-10 08:59:18 +00004498 "$P_SRV dtls=1 force_version=dtls1_2" \
4499 "$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
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004505run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004506 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004507 "$P_CLI dtls=1 request_size=1 \
4508 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4509 0 \
4510 -s "Read from client: 1 bytes read"
4511
4512requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4513requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004514run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004515 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004516 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004517 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004518 0 \
4519 -s "Read from client: 1 bytes read"
4520
4521requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4522requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004523run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004524 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004525 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004526 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004527 0 \
4528 -s "Read from client: 1 bytes read"
4529
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004530# Tests for small server packets
4531
4532requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4533run_test "Small server packet SSLv3 BlockCipher" \
4534 "$P_SRV response_size=1 min_version=ssl3" \
4535 "$P_CLI force_version=ssl3 \
4536 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4537 0 \
4538 -c "Read from server: 1 bytes read"
4539
4540requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4541run_test "Small server packet SSLv3 StreamCipher" \
4542 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4543 "$P_CLI force_version=ssl3 \
4544 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4545 0 \
4546 -c "Read from server: 1 bytes read"
4547
4548run_test "Small server packet TLS 1.0 BlockCipher" \
4549 "$P_SRV response_size=1" \
4550 "$P_CLI force_version=tls1 \
4551 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4552 0 \
4553 -c "Read from server: 1 bytes read"
4554
4555run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4556 "$P_SRV response_size=1" \
4557 "$P_CLI force_version=tls1 etm=0 \
4558 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
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, 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" \
4567 0 \
4568 -c "Read from server: 1 bytes read"
4569
4570requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4571run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4572 "$P_SRV response_size=1 trunc_hmac=1" \
4573 "$P_CLI force_version=tls1 \
4574 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4575 0 \
4576 -c "Read from server: 1 bytes read"
4577
4578run_test "Small server packet TLS 1.0 StreamCipher" \
4579 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4580 "$P_CLI force_version=tls1 \
4581 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4582 0 \
4583 -c "Read from server: 1 bytes read"
4584
4585run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4586 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4587 "$P_CLI force_version=tls1 \
4588 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
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, 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 \
4596 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4597 0 \
4598 -c "Read from server: 1 bytes read"
4599
4600requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4601run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4602 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4603 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4604 trunc_hmac=1 etm=0" \
4605 0 \
4606 -c "Read from server: 1 bytes read"
4607
4608run_test "Small server packet TLS 1.1 BlockCipher" \
4609 "$P_SRV response_size=1" \
4610 "$P_CLI force_version=tls1_1 \
4611 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4612 0 \
4613 -c "Read from server: 1 bytes read"
4614
4615run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4616 "$P_SRV response_size=1" \
4617 "$P_CLI force_version=tls1_1 \
4618 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
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, 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" \
4627 0 \
4628 -c "Read from server: 1 bytes read"
4629
4630requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4631run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4632 "$P_SRV response_size=1 trunc_hmac=1" \
4633 "$P_CLI force_version=tls1_1 \
4634 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4635 0 \
4636 -c "Read from server: 1 bytes read"
4637
4638run_test "Small server packet TLS 1.1 StreamCipher" \
4639 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4640 "$P_CLI force_version=tls1_1 \
4641 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4642 0 \
4643 -c "Read from server: 1 bytes read"
4644
4645run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4646 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4647 "$P_CLI force_version=tls1_1 \
4648 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
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, 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" \
4657 0 \
4658 -c "Read from server: 1 bytes read"
4659
4660requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4661run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4662 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4663 "$P_CLI force_version=tls1_1 \
4664 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4665 0 \
4666 -c "Read from server: 1 bytes read"
4667
4668run_test "Small server packet TLS 1.2 BlockCipher" \
4669 "$P_SRV response_size=1" \
4670 "$P_CLI force_version=tls1_2 \
4671 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4672 0 \
4673 -c "Read from server: 1 bytes read"
4674
4675run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4676 "$P_SRV response_size=1" \
4677 "$P_CLI force_version=tls1_2 \
4678 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4679 0 \
4680 -c "Read from server: 1 bytes read"
4681
4682run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4683 "$P_SRV response_size=1" \
4684 "$P_CLI force_version=tls1_2 \
4685 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
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, 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" \
4694 0 \
4695 -c "Read from server: 1 bytes read"
4696
4697requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4698run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4699 "$P_SRV response_size=1 trunc_hmac=1" \
4700 "$P_CLI force_version=tls1_2 \
4701 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4702 0 \
4703 -c "Read from server: 1 bytes read"
4704
4705run_test "Small server packet TLS 1.2 StreamCipher" \
4706 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4707 "$P_CLI force_version=tls1_2 \
4708 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4709 0 \
4710 -c "Read from server: 1 bytes read"
4711
4712run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4713 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4714 "$P_CLI force_version=tls1_2 \
4715 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
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, 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" \
4724 0 \
4725 -c "Read from server: 1 bytes read"
4726
4727requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4728run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4729 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4730 "$P_CLI force_version=tls1_2 \
4731 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4732 0 \
4733 -c "Read from server: 1 bytes read"
4734
4735run_test "Small server packet TLS 1.2 AEAD" \
4736 "$P_SRV response_size=1" \
4737 "$P_CLI force_version=tls1_2 \
4738 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4739 0 \
4740 -c "Read from server: 1 bytes read"
4741
4742run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4743 "$P_SRV response_size=1" \
4744 "$P_CLI force_version=tls1_2 \
4745 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4746 0 \
4747 -c "Read from server: 1 bytes read"
4748
4749# Tests for small server packets in DTLS
4750
4751requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4752run_test "Small server packet DTLS 1.0" \
4753 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
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
4760run_test "Small server packet DTLS 1.0, without EtM" \
4761 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4762 "$P_CLI dtls=1 \
4763 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4764 0 \
4765 -c "Read from server: 1 bytes read"
4766
4767requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4768requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4769run_test "Small server packet DTLS 1.0, truncated hmac" \
4770 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4771 "$P_CLI dtls=1 trunc_hmac=1 \
4772 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4773 0 \
4774 -c "Read from server: 1 bytes read"
4775
4776requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4777requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4778run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4779 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4780 "$P_CLI dtls=1 \
4781 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
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" \
4787 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
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
4794run_test "Small server packet DTLS 1.2, without EtM" \
4795 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4796 "$P_CLI dtls=1 \
4797 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4798 0 \
4799 -c "Read from server: 1 bytes read"
4800
4801requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4802requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4803run_test "Small server packet DTLS 1.2, truncated hmac" \
4804 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4805 "$P_CLI dtls=1 \
4806 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4807 0 \
4808 -c "Read from server: 1 bytes read"
4809
4810requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4811requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4812run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4813 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4814 "$P_CLI dtls=1 \
4815 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4816 0 \
4817 -c "Read from server: 1 bytes read"
4818
Janos Follath00efff72016-05-06 13:48:23 +01004819# A test for extensions in SSLv3
4820
4821requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4822run_test "SSLv3 with extensions, server side" \
4823 "$P_SRV min_version=ssl3 debug_level=3" \
4824 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4825 0 \
4826 -S "dumping 'client hello extensions'" \
4827 -S "server hello, total extension length:"
4828
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004829# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004830
Angus Grattonc4dd0732018-04-11 16:28:39 +10004831# How many fragments do we expect to write $1 bytes?
4832fragments_for_write() {
4833 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4834}
4835
Janos Follathe2681a42016-03-07 15:57:05 +00004836requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004837run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004838 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004839 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004840 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4841 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004842 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4843 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004844
Janos Follathe2681a42016-03-07 15:57:05 +00004845requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004846run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004847 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004848 "$P_CLI request_size=16384 force_version=ssl3 \
4849 force_ciphersuite=TLS-RSA-WITH-RC4-128-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" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004855 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004856 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004857 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4858 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004859 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4860 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004861
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004862run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004863 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004864 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4865 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4866 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004867 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004868
Hanno Becker32c55012017-11-10 08:42:54 +00004869requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004870run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004871 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004872 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004873 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004874 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004875 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4876 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004877
Hanno Becker32c55012017-11-10 08:42:54 +00004878requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004879run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004880 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004881 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004882 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004883 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004884 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004885
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004886run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004887 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004888 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004889 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4890 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004891 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004892
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004893run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004894 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4895 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004896 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004897 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004898 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004899
4900requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004901run_test "Large client packet TLS 1.0 StreamCipher, 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" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004903 "$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" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004905 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004906 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004907
Hanno Becker278fc7a2017-11-10 09:16:28 +00004908requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004909run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004910 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004911 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004912 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004913 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004914 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4915 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004916
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004917run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004918 "$P_SRV" \
4919 "$P_CLI request_size=16384 force_version=tls1_1 \
4920 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4921 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004922 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4923 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004924
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004925run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004926 "$P_SRV" \
4927 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4928 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
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, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004934 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004935 "$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" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004937 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004938 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004939
Hanno Becker32c55012017-11-10 08:42:54 +00004940requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004941run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004942 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004943 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004944 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004945 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004946 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004947
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004948run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004949 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4950 "$P_CLI request_size=16384 force_version=tls1_1 \
4951 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4952 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
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004956run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004957 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004958 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004959 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004960 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004961 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4962 -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, 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" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004967 "$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" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004969 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004970 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004971
Hanno Becker278fc7a2017-11-10 09:16:28 +00004972requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004973run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004974 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004975 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004976 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004977 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" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004982 "$P_SRV" \
4983 "$P_CLI request_size=16384 force_version=tls1_2 \
4984 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4985 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004986 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4987 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004988
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004989run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004990 "$P_SRV" \
4991 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4992 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4993 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004994 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004995
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004996run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004997 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004998 "$P_CLI request_size=16384 force_version=tls1_2 \
4999 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005000 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005001 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5002 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005003
Hanno Becker32c55012017-11-10 08:42:54 +00005004requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005005run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005006 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005007 "$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" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005009 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005010 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005011
Hanno Becker278fc7a2017-11-10 09:16:28 +00005012requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005013run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005014 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005015 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005016 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005017 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" \
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 \
5024 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5025 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005026 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5027 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005028
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005029run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005030 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005031 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005032 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5033 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005034 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005035
Hanno Becker32c55012017-11-10 08:42:54 +00005036requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005037run_test "Large client packet TLS 1.2 StreamCipher, 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" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005039 "$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" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005041 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005042 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005043
Hanno Becker278fc7a2017-11-10 09:16:28 +00005044requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005045run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005046 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005047 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005048 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005049 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" \
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" \
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 +02005061run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005062 "$P_SRV" \
5063 "$P_CLI request_size=16384 force_version=tls1_2 \
5064 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5065 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005066 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5067 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005068
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005069# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005070requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5071run_test "Large server packet SSLv3 StreamCipher" \
5072 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5073 "$P_CLI force_version=ssl3 \
5074 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5075 0 \
5076 -c "Read from server: 16384 bytes read"
5077
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04005078# Checking next 4 tests logs for 1n-1 split against BEAST too
5079requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5080run_test "Large server packet SSLv3 BlockCipher" \
5081 "$P_SRV response_size=16384 min_version=ssl3" \
5082 "$P_CLI force_version=ssl3 recsplit=0 \
5083 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5084 0 \
5085 -c "Read from server: 1 bytes read"\
5086 -c "16383 bytes read"\
5087 -C "Read from server: 16384 bytes read"
5088
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005089run_test "Large server packet TLS 1.0 BlockCipher" \
5090 "$P_SRV response_size=16384" \
5091 "$P_CLI force_version=tls1 recsplit=0 \
5092 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5093 0 \
5094 -c "Read from server: 1 bytes read"\
5095 -c "16383 bytes read"\
5096 -C "Read from server: 16384 bytes read"
5097
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005098run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5099 "$P_SRV response_size=16384" \
5100 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5101 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5102 0 \
5103 -c "Read from server: 1 bytes read"\
5104 -c "16383 bytes read"\
5105 -C "Read from server: 16384 bytes read"
5106
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005107requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5108run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5109 "$P_SRV response_size=16384" \
5110 "$P_CLI force_version=tls1 recsplit=0 \
5111 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5112 trunc_hmac=1" \
5113 0 \
5114 -c "Read from server: 1 bytes read"\
5115 -c "16383 bytes read"\
5116 -C "Read from server: 16384 bytes read"
5117
5118requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5119run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5120 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5121 "$P_CLI force_version=tls1 \
5122 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5123 trunc_hmac=1" \
5124 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005125 -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" \
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" \
5132 0 \
5133 -s "16384 bytes written in 1 fragments" \
5134 -c "Read from server: 16384 bytes read"
5135
5136run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5137 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5138 "$P_CLI force_version=tls1 \
5139 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5140 0 \
5141 -s "16384 bytes written in 1 fragments" \
5142 -c "Read from server: 16384 bytes read"
5143
5144requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5145run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5146 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5147 "$P_CLI force_version=tls1 \
5148 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5149 0 \
5150 -s "16384 bytes written in 1 fragments" \
5151 -c "Read from server: 16384 bytes read"
5152
5153requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5154run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5155 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5156 "$P_CLI force_version=tls1 \
5157 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5158 0 \
5159 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005160 -c "Read from server: 16384 bytes read"
5161
5162run_test "Large server packet TLS 1.1 BlockCipher" \
5163 "$P_SRV response_size=16384" \
5164 "$P_CLI force_version=tls1_1 \
5165 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5166 0 \
5167 -c "Read from server: 16384 bytes read"
5168
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005169run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5170 "$P_SRV response_size=16384" \
5171 "$P_CLI force_version=tls1_1 etm=0 \
5172 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005173 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005174 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005175 -c "Read from server: 16384 bytes read"
5176
5177requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5178run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5179 "$P_SRV response_size=16384" \
5180 "$P_CLI force_version=tls1_1 \
5181 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5182 trunc_hmac=1" \
5183 0 \
5184 -c "Read from server: 16384 bytes read"
5185
5186requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005187run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5188 "$P_SRV response_size=16384 trunc_hmac=1" \
5189 "$P_CLI force_version=tls1_1 \
5190 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5191 0 \
5192 -s "16384 bytes written in 1 fragments" \
5193 -c "Read from server: 16384 bytes read"
5194
5195run_test "Large server packet TLS 1.1 StreamCipher" \
5196 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5197 "$P_CLI force_version=tls1_1 \
5198 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5199 0 \
5200 -c "Read from server: 16384 bytes read"
5201
5202run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5203 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5204 "$P_CLI force_version=tls1_1 \
5205 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5206 0 \
5207 -s "16384 bytes written in 1 fragments" \
5208 -c "Read from server: 16384 bytes read"
5209
5210requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005211run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5212 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5213 "$P_CLI force_version=tls1_1 \
5214 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5215 trunc_hmac=1" \
5216 0 \
5217 -c "Read from server: 16384 bytes read"
5218
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005219run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5220 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5221 "$P_CLI force_version=tls1_1 \
5222 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5223 0 \
5224 -s "16384 bytes written in 1 fragments" \
5225 -c "Read from server: 16384 bytes read"
5226
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005227run_test "Large server packet TLS 1.2 BlockCipher" \
5228 "$P_SRV response_size=16384" \
5229 "$P_CLI force_version=tls1_2 \
5230 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5231 0 \
5232 -c "Read from server: 16384 bytes read"
5233
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005234run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5235 "$P_SRV response_size=16384" \
5236 "$P_CLI force_version=tls1_2 etm=0 \
5237 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5238 0 \
5239 -s "16384 bytes written in 1 fragments" \
5240 -c "Read from server: 16384 bytes read"
5241
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005242run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5243 "$P_SRV response_size=16384" \
5244 "$P_CLI force_version=tls1_2 \
5245 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5246 0 \
5247 -c "Read from server: 16384 bytes read"
5248
5249requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5250run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5251 "$P_SRV response_size=16384" \
5252 "$P_CLI force_version=tls1_2 \
5253 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5254 trunc_hmac=1" \
5255 0 \
5256 -c "Read from server: 16384 bytes read"
5257
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005258run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5259 "$P_SRV response_size=16384 trunc_hmac=1" \
5260 "$P_CLI force_version=tls1_2 \
5261 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5262 0 \
5263 -s "16384 bytes written in 1 fragments" \
5264 -c "Read from server: 16384 bytes read"
5265
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005266run_test "Large server packet TLS 1.2 StreamCipher" \
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" \
5270 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005271 -s "16384 bytes written in 1 fragments" \
5272 -c "Read from server: 16384 bytes read"
5273
5274run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5275 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5276 "$P_CLI force_version=tls1_2 \
5277 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5278 0 \
5279 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005280 -c "Read from server: 16384 bytes read"
5281
5282requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5283run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5284 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5285 "$P_CLI force_version=tls1_2 \
5286 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5287 trunc_hmac=1" \
5288 0 \
5289 -c "Read from server: 16384 bytes read"
5290
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005291requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5292run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5293 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5294 "$P_CLI force_version=tls1_2 \
5295 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5296 0 \
5297 -s "16384 bytes written in 1 fragments" \
5298 -c "Read from server: 16384 bytes read"
5299
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005300run_test "Large server packet TLS 1.2 AEAD" \
5301 "$P_SRV response_size=16384" \
5302 "$P_CLI force_version=tls1_2 \
5303 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5304 0 \
5305 -c "Read from server: 16384 bytes read"
5306
5307run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5308 "$P_SRV response_size=16384" \
5309 "$P_CLI force_version=tls1_2 \
5310 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5311 0 \
5312 -c "Read from server: 16384 bytes read"
5313
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005314# Tests for restartable ECC
5315
5316requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5317run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005318 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005319 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005320 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005321 debug_level=1" \
5322 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005323 -C "x509_verify_cert.*4b00" \
5324 -C "mbedtls_pk_verify.*4b00" \
5325 -C "mbedtls_ecdh_make_public.*4b00" \
5326 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005327
5328requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5329run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005330 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005331 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005332 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005333 debug_level=1 ec_max_ops=0" \
5334 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005335 -C "x509_verify_cert.*4b00" \
5336 -C "mbedtls_pk_verify.*4b00" \
5337 -C "mbedtls_ecdh_make_public.*4b00" \
5338 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005339
5340requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5341run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005342 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005343 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005344 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005345 debug_level=1 ec_max_ops=65535" \
5346 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005347 -C "x509_verify_cert.*4b00" \
5348 -C "mbedtls_pk_verify.*4b00" \
5349 -C "mbedtls_ecdh_make_public.*4b00" \
5350 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005351
5352requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5353run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005354 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005355 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005356 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005357 debug_level=1 ec_max_ops=1000" \
5358 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005359 -c "x509_verify_cert.*4b00" \
5360 -c "mbedtls_pk_verify.*4b00" \
5361 -c "mbedtls_ecdh_make_public.*4b00" \
5362 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005363
5364requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005365run_test "EC restart: TLS, max_ops=1000, badsign" \
5366 "$P_SRV auth_mode=required \
5367 crt_file=data_files/server5-badsign.crt \
5368 key_file=data_files/server5.key" \
5369 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5370 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5371 debug_level=1 ec_max_ops=1000" \
5372 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005373 -c "x509_verify_cert.*4b00" \
5374 -C "mbedtls_pk_verify.*4b00" \
5375 -C "mbedtls_ecdh_make_public.*4b00" \
5376 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005377 -c "! The certificate is not correctly signed by the trusted CA" \
5378 -c "! mbedtls_ssl_handshake returned" \
5379 -c "X509 - Certificate verification failed"
5380
5381requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5382run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5383 "$P_SRV auth_mode=required \
5384 crt_file=data_files/server5-badsign.crt \
5385 key_file=data_files/server5.key" \
5386 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5387 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5388 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5389 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005390 -c "x509_verify_cert.*4b00" \
5391 -c "mbedtls_pk_verify.*4b00" \
5392 -c "mbedtls_ecdh_make_public.*4b00" \
5393 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005394 -c "! The certificate is not correctly signed by the trusted CA" \
5395 -C "! mbedtls_ssl_handshake returned" \
5396 -C "X509 - Certificate verification failed"
5397
5398requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5399run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5400 "$P_SRV auth_mode=required \
5401 crt_file=data_files/server5-badsign.crt \
5402 key_file=data_files/server5.key" \
5403 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5404 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5405 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5406 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005407 -C "x509_verify_cert.*4b00" \
5408 -c "mbedtls_pk_verify.*4b00" \
5409 -c "mbedtls_ecdh_make_public.*4b00" \
5410 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005411 -C "! The certificate is not correctly signed by the trusted CA" \
5412 -C "! mbedtls_ssl_handshake returned" \
5413 -C "X509 - Certificate verification failed"
5414
5415requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005416run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005417 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005418 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005419 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005420 dtls=1 debug_level=1 ec_max_ops=1000" \
5421 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005422 -c "x509_verify_cert.*4b00" \
5423 -c "mbedtls_pk_verify.*4b00" \
5424 -c "mbedtls_ecdh_make_public.*4b00" \
5425 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005426
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005427requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5428run_test "EC restart: TLS, max_ops=1000 no client auth" \
5429 "$P_SRV" \
5430 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5431 debug_level=1 ec_max_ops=1000" \
5432 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005433 -c "x509_verify_cert.*4b00" \
5434 -c "mbedtls_pk_verify.*4b00" \
5435 -c "mbedtls_ecdh_make_public.*4b00" \
5436 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005437
5438requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5439run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5440 "$P_SRV psk=abc123" \
5441 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5442 psk=abc123 debug_level=1 ec_max_ops=1000" \
5443 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005444 -C "x509_verify_cert.*4b00" \
5445 -C "mbedtls_pk_verify.*4b00" \
5446 -C "mbedtls_ecdh_make_public.*4b00" \
5447 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005448
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005449# Tests of asynchronous private key support in SSL
5450
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005451requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005452run_test "SSL async private: sign, delay=0" \
5453 "$P_SRV \
5454 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005455 "$P_CLI" \
5456 0 \
5457 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005458 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005459
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005460requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005461run_test "SSL async private: sign, delay=1" \
5462 "$P_SRV \
5463 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005464 "$P_CLI" \
5465 0 \
5466 -s "Async sign callback: using key slot " \
5467 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005468 -s "Async resume (slot [0-9]): sign done, status=0"
5469
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005470requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5471run_test "SSL async private: sign, delay=2" \
5472 "$P_SRV \
5473 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5474 "$P_CLI" \
5475 0 \
5476 -s "Async sign callback: using key slot " \
5477 -U "Async sign callback: using key slot " \
5478 -s "Async resume (slot [0-9]): call 1 more times." \
5479 -s "Async resume (slot [0-9]): call 0 more times." \
5480 -s "Async resume (slot [0-9]): sign done, status=0"
5481
Gilles Peskined3268832018-04-26 06:23:59 +02005482# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5483# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5484requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5485requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5486run_test "SSL async private: sign, RSA, TLS 1.1" \
5487 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5488 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5489 "$P_CLI force_version=tls1_1" \
5490 0 \
5491 -s "Async sign callback: using key slot " \
5492 -s "Async resume (slot [0-9]): sign done, status=0"
5493
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005494requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005495run_test "SSL async private: sign, SNI" \
5496 "$P_SRV debug_level=3 \
5497 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5498 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5499 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5500 "$P_CLI server_name=polarssl.example" \
5501 0 \
5502 -s "Async sign callback: using key slot " \
5503 -s "Async resume (slot [0-9]): sign done, status=0" \
5504 -s "parse ServerName extension" \
5505 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5506 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5507
5508requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005509run_test "SSL async private: decrypt, delay=0" \
5510 "$P_SRV \
5511 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5512 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5513 0 \
5514 -s "Async decrypt callback: using key slot " \
5515 -s "Async resume (slot [0-9]): decrypt done, status=0"
5516
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005517requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005518run_test "SSL async private: decrypt, delay=1" \
5519 "$P_SRV \
5520 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5521 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5522 0 \
5523 -s "Async decrypt callback: using key slot " \
5524 -s "Async resume (slot [0-9]): call 0 more times." \
5525 -s "Async resume (slot [0-9]): decrypt done, status=0"
5526
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005527requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005528run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5529 "$P_SRV psk=abc123 \
5530 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5531 "$P_CLI psk=abc123 \
5532 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5533 0 \
5534 -s "Async decrypt callback: using key slot " \
5535 -s "Async resume (slot [0-9]): decrypt done, status=0"
5536
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005537requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005538run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5539 "$P_SRV psk=abc123 \
5540 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5541 "$P_CLI psk=abc123 \
5542 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5543 0 \
5544 -s "Async decrypt callback: using key slot " \
5545 -s "Async resume (slot [0-9]): call 0 more times." \
5546 -s "Async resume (slot [0-9]): decrypt done, status=0"
5547
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005548requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005549run_test "SSL async private: sign callback not present" \
5550 "$P_SRV \
5551 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5552 "$P_CLI; [ \$? -eq 1 ] &&
5553 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5554 0 \
5555 -S "Async sign callback" \
5556 -s "! mbedtls_ssl_handshake returned" \
5557 -s "The own private key or pre-shared key is not set, but needed" \
5558 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5559 -s "Successful connection"
5560
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005561requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005562run_test "SSL async private: decrypt callback not present" \
5563 "$P_SRV debug_level=1 \
5564 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5565 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5566 [ \$? -eq 1 ] && $P_CLI" \
5567 0 \
5568 -S "Async decrypt callback" \
5569 -s "! mbedtls_ssl_handshake returned" \
5570 -s "got no RSA private key" \
5571 -s "Async resume (slot [0-9]): sign done, status=0" \
5572 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005573
5574# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005575requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005576run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005577 "$P_SRV \
5578 async_operations=s async_private_delay1=1 \
5579 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5580 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005581 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5582 0 \
5583 -s "Async sign callback: using key slot 0," \
5584 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005585 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005586
5587# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005588requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005589run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005590 "$P_SRV \
5591 async_operations=s async_private_delay2=1 \
5592 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5593 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005594 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5595 0 \
5596 -s "Async sign callback: using key slot 0," \
5597 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005598 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005599
5600# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005601requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005602run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005603 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005604 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005605 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5606 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005607 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5608 0 \
5609 -s "Async sign callback: using key slot 1," \
5610 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005611 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005612
5613# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005614requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005615run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005616 "$P_SRV \
5617 async_operations=s async_private_delay1=1 \
5618 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5619 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005620 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5621 0 \
5622 -s "Async sign callback: no key matches this certificate."
5623
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005624requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005625run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005626 "$P_SRV \
5627 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5628 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005629 "$P_CLI" \
5630 1 \
5631 -s "Async sign callback: injected error" \
5632 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005633 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005634 -s "! mbedtls_ssl_handshake returned"
5635
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005636requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005637run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005638 "$P_SRV \
5639 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5640 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005641 "$P_CLI" \
5642 1 \
5643 -s "Async sign callback: using key slot " \
5644 -S "Async resume" \
5645 -s "Async cancel"
5646
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005647requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005648run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005649 "$P_SRV \
5650 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5651 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005652 "$P_CLI" \
5653 1 \
5654 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005655 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005656 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005657 -s "! mbedtls_ssl_handshake returned"
5658
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005659requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005660run_test "SSL async private: decrypt, error in start" \
5661 "$P_SRV \
5662 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5663 async_private_error=1" \
5664 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5665 1 \
5666 -s "Async decrypt callback: injected error" \
5667 -S "Async resume" \
5668 -S "Async cancel" \
5669 -s "! mbedtls_ssl_handshake returned"
5670
5671requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5672run_test "SSL async private: decrypt, cancel after start" \
5673 "$P_SRV \
5674 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5675 async_private_error=2" \
5676 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5677 1 \
5678 -s "Async decrypt callback: using key slot " \
5679 -S "Async resume" \
5680 -s "Async cancel"
5681
5682requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5683run_test "SSL async private: decrypt, error in resume" \
5684 "$P_SRV \
5685 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5686 async_private_error=3" \
5687 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5688 1 \
5689 -s "Async decrypt callback: using key slot " \
5690 -s "Async resume callback: decrypt done but injected error" \
5691 -S "Async cancel" \
5692 -s "! mbedtls_ssl_handshake returned"
5693
5694requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005695run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005696 "$P_SRV \
5697 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5698 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005699 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5700 0 \
5701 -s "Async cancel" \
5702 -s "! mbedtls_ssl_handshake returned" \
5703 -s "Async resume" \
5704 -s "Successful connection"
5705
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005706requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005707run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005708 "$P_SRV \
5709 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5710 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005711 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5712 0 \
5713 -s "! mbedtls_ssl_handshake returned" \
5714 -s "Async resume" \
5715 -s "Successful connection"
5716
5717# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005718requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005719run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005720 "$P_SRV \
5721 async_operations=s async_private_delay1=1 async_private_error=-2 \
5722 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5723 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005724 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5725 [ \$? -eq 1 ] &&
5726 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5727 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005728 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005729 -S "Async resume" \
5730 -s "Async cancel" \
5731 -s "! mbedtls_ssl_handshake returned" \
5732 -s "Async sign callback: no key matches this certificate." \
5733 -s "Successful connection"
5734
5735# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005736requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005737run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005738 "$P_SRV \
5739 async_operations=s async_private_delay1=1 async_private_error=-3 \
5740 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5741 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005742 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5743 [ \$? -eq 1 ] &&
5744 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5745 0 \
5746 -s "Async resume" \
5747 -s "! mbedtls_ssl_handshake returned" \
5748 -s "Async sign callback: no key matches this certificate." \
5749 -s "Successful connection"
5750
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005751requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005752requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005753run_test "SSL async private: renegotiation: client-initiated; sign" \
5754 "$P_SRV \
5755 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005756 exchanges=2 renegotiation=1" \
5757 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5758 0 \
5759 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005760 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005761
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005762requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005763requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005764run_test "SSL async private: renegotiation: server-initiated; sign" \
5765 "$P_SRV \
5766 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005767 exchanges=2 renegotiation=1 renegotiate=1" \
5768 "$P_CLI exchanges=2 renegotiation=1" \
5769 0 \
5770 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005771 -s "Async resume (slot [0-9]): sign done, status=0"
5772
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005773requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005774requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5775run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5776 "$P_SRV \
5777 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5778 exchanges=2 renegotiation=1" \
5779 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5780 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5781 0 \
5782 -s "Async decrypt callback: using key slot " \
5783 -s "Async resume (slot [0-9]): decrypt done, status=0"
5784
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005785requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005786requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5787run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5788 "$P_SRV \
5789 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5790 exchanges=2 renegotiation=1 renegotiate=1" \
5791 "$P_CLI exchanges=2 renegotiation=1 \
5792 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5793 0 \
5794 -s "Async decrypt callback: using key slot " \
5795 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005796
Ron Eldor58093c82018-06-28 13:22:05 +03005797# Tests for ECC extensions (rfc 4492)
5798
Ron Eldor643df7c2018-06-28 16:17:00 +03005799requires_config_enabled MBEDTLS_AES_C
5800requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5801requires_config_enabled MBEDTLS_SHA256_C
5802requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005803run_test "Force a non ECC ciphersuite in the client side" \
5804 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005805 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005806 0 \
5807 -C "client hello, adding supported_elliptic_curves extension" \
5808 -C "client hello, adding supported_point_formats extension" \
5809 -S "found supported elliptic curves extension" \
5810 -S "found supported point formats extension"
5811
Ron Eldor643df7c2018-06-28 16:17:00 +03005812requires_config_enabled MBEDTLS_AES_C
5813requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5814requires_config_enabled MBEDTLS_SHA256_C
5815requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005816run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005817 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005818 "$P_CLI debug_level=3" \
5819 0 \
5820 -C "found supported_point_formats extension" \
5821 -S "server hello, supported_point_formats extension"
5822
Ron Eldor643df7c2018-06-28 16:17:00 +03005823requires_config_enabled MBEDTLS_AES_C
5824requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5825requires_config_enabled MBEDTLS_SHA256_C
5826requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005827run_test "Force an ECC ciphersuite in the client side" \
5828 "$P_SRV debug_level=3" \
5829 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5830 0 \
5831 -c "client hello, adding supported_elliptic_curves extension" \
5832 -c "client hello, adding supported_point_formats extension" \
5833 -s "found supported elliptic curves extension" \
5834 -s "found supported point formats extension"
5835
Ron Eldor643df7c2018-06-28 16:17:00 +03005836requires_config_enabled MBEDTLS_AES_C
5837requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5838requires_config_enabled MBEDTLS_SHA256_C
5839requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005840run_test "Force an ECC ciphersuite in the server side" \
5841 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5842 "$P_CLI debug_level=3" \
5843 0 \
5844 -c "found supported_point_formats extension" \
5845 -s "server hello, supported_point_formats extension"
5846
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005847# Tests for DTLS HelloVerifyRequest
5848
5849run_test "DTLS cookie: enabled" \
5850 "$P_SRV dtls=1 debug_level=2" \
5851 "$P_CLI dtls=1 debug_level=2" \
5852 0 \
5853 -s "cookie verification failed" \
5854 -s "cookie verification passed" \
5855 -S "cookie verification skipped" \
5856 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005857 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005858 -S "SSL - The requested feature is not available"
5859
5860run_test "DTLS cookie: disabled" \
5861 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5862 "$P_CLI dtls=1 debug_level=2" \
5863 0 \
5864 -S "cookie verification failed" \
5865 -S "cookie verification passed" \
5866 -s "cookie verification skipped" \
5867 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005868 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005869 -S "SSL - The requested feature is not available"
5870
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005871run_test "DTLS cookie: default (failing)" \
5872 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5873 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5874 1 \
5875 -s "cookie verification failed" \
5876 -S "cookie verification passed" \
5877 -S "cookie verification skipped" \
5878 -C "received hello verify request" \
5879 -S "hello verification requested" \
5880 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005881
5882requires_ipv6
5883run_test "DTLS cookie: enabled, IPv6" \
5884 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5885 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5886 0 \
5887 -s "cookie verification failed" \
5888 -s "cookie verification passed" \
5889 -S "cookie verification skipped" \
5890 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005891 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005892 -S "SSL - The requested feature is not available"
5893
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005894run_test "DTLS cookie: enabled, nbio" \
5895 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5896 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5897 0 \
5898 -s "cookie verification failed" \
5899 -s "cookie verification passed" \
5900 -S "cookie verification skipped" \
5901 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005902 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005903 -S "SSL - The requested feature is not available"
5904
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005905# Tests for client reconnecting from the same port with DTLS
5906
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005907not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005908run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005909 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5910 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005911 0 \
5912 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005913 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005914 -S "Client initiated reconnection from same port"
5915
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005916not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005917run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005918 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5919 "$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 +02005920 0 \
5921 -C "resend" \
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 +01005925not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5926run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005927 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5928 "$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 +02005929 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005930 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005931 -s "Client initiated reconnection from same port"
5932
Paul Bakker362689d2016-05-13 10:33:25 +01005933only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5934run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5935 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5936 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5937 0 \
5938 -S "The operation timed out" \
5939 -s "Client initiated reconnection from same port"
5940
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005941run_test "DTLS client reconnect from same port: no cookies" \
5942 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005943 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5944 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005945 -s "The operation timed out" \
5946 -S "Client initiated reconnection from same port"
5947
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005948run_test "DTLS client reconnect from same port: attacker-injected" \
5949 -p "$P_PXY inject_clihlo=1" \
5950 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5951 "$P_CLI dtls=1 exchanges=2" \
5952 0 \
5953 -s "possible client reconnect from the same port" \
5954 -S "Client initiated reconnection from same port"
5955
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005956# Tests for various cases of client authentication with DTLS
5957# (focused on handshake flows and message parsing)
5958
5959run_test "DTLS client auth: required" \
5960 "$P_SRV dtls=1 auth_mode=required" \
5961 "$P_CLI dtls=1" \
5962 0 \
5963 -s "Verifying peer X.509 certificate... ok"
5964
5965run_test "DTLS client auth: optional, client has no cert" \
5966 "$P_SRV dtls=1 auth_mode=optional" \
5967 "$P_CLI dtls=1 crt_file=none key_file=none" \
5968 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005969 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005970
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005971run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005972 "$P_SRV dtls=1 auth_mode=none" \
5973 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5974 0 \
5975 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005976 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005977
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005978run_test "DTLS wrong PSK: badmac alert" \
5979 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5980 "$P_CLI dtls=1 psk=abc124" \
5981 1 \
5982 -s "SSL - Verification of the message MAC failed" \
5983 -c "SSL - A fatal alert message was received from our peer"
5984
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005985# Tests for receiving fragmented handshake messages with DTLS
5986
5987requires_gnutls
5988run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5989 "$G_SRV -u --mtu 2048 -a" \
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: some fragmentation (gnutls server)" \
5997 "$G_SRV -u --mtu 512" \
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 (gnutls server)" \
6005 "$G_SRV -u --mtu 128" \
6006 "$P_CLI dtls=1 debug_level=2" \
6007 0 \
6008 -c "found fragmented DTLS handshake message" \
6009 -C "error"
6010
6011requires_gnutls
6012run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
6013 "$G_SRV -u --mtu 128" \
6014 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6015 0 \
6016 -c "found fragmented DTLS handshake message" \
6017 -C "error"
6018
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006019requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006020requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006021run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
6022 "$G_SRV -u --mtu 256" \
6023 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
6024 0 \
6025 -c "found fragmented DTLS handshake message" \
6026 -c "client hello, adding renegotiation extension" \
6027 -c "found renegotiation extension" \
6028 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006029 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006030 -C "error" \
6031 -s "Extra-header:"
6032
6033requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006034requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006035run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
6036 "$G_SRV -u --mtu 256" \
6037 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
6038 0 \
6039 -c "found fragmented DTLS handshake message" \
6040 -c "client hello, adding renegotiation extension" \
6041 -c "found renegotiation extension" \
6042 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006043 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006044 -C "error" \
6045 -s "Extra-header:"
6046
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006047run_test "DTLS reassembly: no fragmentation (openssl server)" \
6048 "$O_SRV -dtls1 -mtu 2048" \
6049 "$P_CLI dtls=1 debug_level=2" \
6050 0 \
6051 -C "found fragmented DTLS handshake message" \
6052 -C "error"
6053
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006054run_test "DTLS reassembly: some fragmentation (openssl server)" \
6055 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006056 "$P_CLI dtls=1 debug_level=2" \
6057 0 \
6058 -c "found fragmented DTLS handshake message" \
6059 -C "error"
6060
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006061run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006062 "$O_SRV -dtls1 -mtu 256" \
6063 "$P_CLI dtls=1 debug_level=2" \
6064 0 \
6065 -c "found fragmented DTLS handshake message" \
6066 -C "error"
6067
6068run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6069 "$O_SRV -dtls1 -mtu 256" \
6070 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6071 0 \
6072 -c "found fragmented DTLS handshake message" \
6073 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006074
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006075# Tests for sending fragmented handshake messages with DTLS
6076#
6077# Use client auth when we need the client to send large messages,
6078# and use large cert chains on both sides too (the long chains we have all use
6079# both RSA and ECDSA, but ideally we should have long chains with either).
6080# Sizes reached (UDP payload):
6081# - 2037B for server certificate
6082# - 1542B for client certificate
6083# - 1013B for newsessionticket
6084# - all others below 512B
6085# All those tests assume MAX_CONTENT_LEN is at least 2048
6086
6087requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6088requires_config_enabled MBEDTLS_RSA_C
6089requires_config_enabled MBEDTLS_ECDSA_C
6090requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6091run_test "DTLS fragmenting: none (for reference)" \
6092 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6093 crt_file=data_files/server7_int-ca.crt \
6094 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006095 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006096 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006097 "$P_CLI dtls=1 debug_level=2 \
6098 crt_file=data_files/server8_int-ca2.crt \
6099 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006100 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006101 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006102 0 \
6103 -S "found fragmented DTLS handshake message" \
6104 -C "found fragmented DTLS handshake message" \
6105 -C "error"
6106
6107requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6108requires_config_enabled MBEDTLS_RSA_C
6109requires_config_enabled MBEDTLS_ECDSA_C
6110requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006111run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006112 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6113 crt_file=data_files/server7_int-ca.crt \
6114 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006115 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006116 max_frag_len=1024" \
6117 "$P_CLI dtls=1 debug_level=2 \
6118 crt_file=data_files/server8_int-ca2.crt \
6119 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006120 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006121 max_frag_len=2048" \
6122 0 \
6123 -S "found fragmented DTLS handshake message" \
6124 -c "found fragmented DTLS handshake message" \
6125 -C "error"
6126
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006127# With the MFL extension, the server has no way of forcing
6128# the client to not exceed a certain MTU; hence, the following
6129# test can't be replicated with an MTU proxy such as the one
6130# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006131requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6132requires_config_enabled MBEDTLS_RSA_C
6133requires_config_enabled MBEDTLS_ECDSA_C
6134requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006135run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006136 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6137 crt_file=data_files/server7_int-ca.crt \
6138 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006139 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006140 max_frag_len=512" \
6141 "$P_CLI dtls=1 debug_level=2 \
6142 crt_file=data_files/server8_int-ca2.crt \
6143 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006144 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006145 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006146 0 \
6147 -S "found fragmented DTLS handshake message" \
6148 -c "found fragmented DTLS handshake message" \
6149 -C "error"
6150
6151requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6152requires_config_enabled MBEDTLS_RSA_C
6153requires_config_enabled MBEDTLS_ECDSA_C
6154requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006155run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006156 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6157 crt_file=data_files/server7_int-ca.crt \
6158 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006159 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006160 max_frag_len=2048" \
6161 "$P_CLI dtls=1 debug_level=2 \
6162 crt_file=data_files/server8_int-ca2.crt \
6163 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006164 hs_timeout=2500-60000 \
6165 max_frag_len=1024" \
6166 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006167 -S "found fragmented DTLS handshake message" \
6168 -c "found fragmented DTLS handshake message" \
6169 -C "error"
6170
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006171# While not required by the standard defining the MFL extension
6172# (according to which it only applies to records, not to datagrams),
6173# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6174# as otherwise there wouldn't be any means to communicate MTU restrictions
6175# to the peer.
6176# The next test checks that no datagrams significantly larger than the
6177# negotiated MFL are sent.
6178requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6179requires_config_enabled MBEDTLS_RSA_C
6180requires_config_enabled MBEDTLS_ECDSA_C
6181requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6182run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006183 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006184 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6185 crt_file=data_files/server7_int-ca.crt \
6186 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006187 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006188 max_frag_len=2048" \
6189 "$P_CLI dtls=1 debug_level=2 \
6190 crt_file=data_files/server8_int-ca2.crt \
6191 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006192 hs_timeout=2500-60000 \
6193 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006194 0 \
6195 -S "found fragmented DTLS handshake message" \
6196 -c "found fragmented DTLS handshake message" \
6197 -C "error"
6198
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006199requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6200requires_config_enabled MBEDTLS_RSA_C
6201requires_config_enabled MBEDTLS_ECDSA_C
6202requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006203run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006204 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6205 crt_file=data_files/server7_int-ca.crt \
6206 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006207 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006208 max_frag_len=2048" \
6209 "$P_CLI dtls=1 debug_level=2 \
6210 crt_file=data_files/server8_int-ca2.crt \
6211 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006212 hs_timeout=2500-60000 \
6213 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006214 0 \
6215 -s "found fragmented DTLS handshake message" \
6216 -c "found fragmented DTLS handshake message" \
6217 -C "error"
6218
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006219# While not required by the standard defining the MFL extension
6220# (according to which it only applies to records, not to datagrams),
6221# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6222# as otherwise there wouldn't be any means to communicate MTU restrictions
6223# to the peer.
6224# The next test checks that no datagrams significantly larger than the
6225# negotiated MFL are sent.
6226requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6227requires_config_enabled MBEDTLS_RSA_C
6228requires_config_enabled MBEDTLS_ECDSA_C
6229requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6230run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006231 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006232 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6233 crt_file=data_files/server7_int-ca.crt \
6234 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006235 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006236 max_frag_len=2048" \
6237 "$P_CLI dtls=1 debug_level=2 \
6238 crt_file=data_files/server8_int-ca2.crt \
6239 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006240 hs_timeout=2500-60000 \
6241 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006242 0 \
6243 -s "found fragmented DTLS handshake message" \
6244 -c "found fragmented DTLS handshake message" \
6245 -C "error"
6246
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006247requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6248requires_config_enabled MBEDTLS_RSA_C
6249requires_config_enabled MBEDTLS_ECDSA_C
6250run_test "DTLS fragmenting: none (for reference) (MTU)" \
6251 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6252 crt_file=data_files/server7_int-ca.crt \
6253 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006254 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006255 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006256 "$P_CLI dtls=1 debug_level=2 \
6257 crt_file=data_files/server8_int-ca2.crt \
6258 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006259 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006260 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006261 0 \
6262 -S "found fragmented DTLS handshake message" \
6263 -C "found fragmented DTLS handshake message" \
6264 -C "error"
6265
6266requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6267requires_config_enabled MBEDTLS_RSA_C
6268requires_config_enabled MBEDTLS_ECDSA_C
6269run_test "DTLS fragmenting: client (MTU)" \
6270 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6271 crt_file=data_files/server7_int-ca.crt \
6272 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006273 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006274 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006275 "$P_CLI dtls=1 debug_level=2 \
6276 crt_file=data_files/server8_int-ca2.crt \
6277 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006278 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006279 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006280 0 \
6281 -s "found fragmented DTLS handshake message" \
6282 -C "found fragmented DTLS handshake message" \
6283 -C "error"
6284
6285requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6286requires_config_enabled MBEDTLS_RSA_C
6287requires_config_enabled MBEDTLS_ECDSA_C
6288run_test "DTLS fragmenting: server (MTU)" \
6289 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6290 crt_file=data_files/server7_int-ca.crt \
6291 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006292 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006293 mtu=512" \
6294 "$P_CLI dtls=1 debug_level=2 \
6295 crt_file=data_files/server8_int-ca2.crt \
6296 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006297 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006298 mtu=2048" \
6299 0 \
6300 -S "found fragmented DTLS handshake message" \
6301 -c "found fragmented DTLS handshake message" \
6302 -C "error"
6303
6304requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6305requires_config_enabled MBEDTLS_RSA_C
6306requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006307run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006308 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006309 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6310 crt_file=data_files/server7_int-ca.crt \
6311 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006312 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006313 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006314 "$P_CLI dtls=1 debug_level=2 \
6315 crt_file=data_files/server8_int-ca2.crt \
6316 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006317 hs_timeout=2500-60000 \
6318 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006319 0 \
6320 -s "found fragmented DTLS handshake message" \
6321 -c "found fragmented DTLS handshake message" \
6322 -C "error"
6323
Andrzej Kurek77826052018-10-11 07:34:08 -04006324# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006325requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6326requires_config_enabled MBEDTLS_RSA_C
6327requires_config_enabled MBEDTLS_ECDSA_C
6328requires_config_enabled MBEDTLS_SHA256_C
6329requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6330requires_config_enabled MBEDTLS_AES_C
6331requires_config_enabled MBEDTLS_GCM_C
6332run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006333 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006334 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6335 crt_file=data_files/server7_int-ca.crt \
6336 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006337 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006338 mtu=512" \
6339 "$P_CLI dtls=1 debug_level=2 \
6340 crt_file=data_files/server8_int-ca2.crt \
6341 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006342 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6343 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006344 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006345 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006346 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006347 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006348 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006349
Andrzej Kurek7311c782018-10-11 06:49:41 -04006350# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006351# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006352# The ratio of max/min timeout should ideally equal 4 to accept two
6353# retransmissions, but in some cases (like both the server and client using
6354# fragmentation and auto-reduction) an extra retransmission might occur,
6355# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006356not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006357requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6358requires_config_enabled MBEDTLS_RSA_C
6359requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006360requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6361requires_config_enabled MBEDTLS_AES_C
6362requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006363run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6364 -p "$P_PXY mtu=508" \
6365 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6366 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006367 key_file=data_files/server7.key \
6368 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006369 "$P_CLI dtls=1 debug_level=2 \
6370 crt_file=data_files/server8_int-ca2.crt \
6371 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006372 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6373 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006374 0 \
6375 -s "found fragmented DTLS handshake message" \
6376 -c "found fragmented DTLS handshake message" \
6377 -C "error"
6378
Andrzej Kurek77826052018-10-11 07:34:08 -04006379# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006380only_with_valgrind
6381requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6382requires_config_enabled MBEDTLS_RSA_C
6383requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006384requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6385requires_config_enabled MBEDTLS_AES_C
6386requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006387run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6388 -p "$P_PXY mtu=508" \
6389 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6390 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006391 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006392 hs_timeout=250-10000" \
6393 "$P_CLI dtls=1 debug_level=2 \
6394 crt_file=data_files/server8_int-ca2.crt \
6395 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006396 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006397 hs_timeout=250-10000" \
6398 0 \
6399 -s "found fragmented DTLS handshake message" \
6400 -c "found fragmented DTLS handshake message" \
6401 -C "error"
6402
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006403# 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 +02006404# OTOH the client might resend if the server is to slow to reset after sending
6405# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006406not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006407requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6408requires_config_enabled MBEDTLS_RSA_C
6409requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006410run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006411 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006412 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6413 crt_file=data_files/server7_int-ca.crt \
6414 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006415 hs_timeout=10000-60000 \
6416 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006417 "$P_CLI dtls=1 debug_level=2 \
6418 crt_file=data_files/server8_int-ca2.crt \
6419 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006420 hs_timeout=10000-60000 \
6421 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006422 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006423 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006424 -s "found fragmented DTLS handshake message" \
6425 -c "found fragmented DTLS handshake message" \
6426 -C "error"
6427
Andrzej Kurek77826052018-10-11 07:34:08 -04006428# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006429# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6430# OTOH the client might resend if the server is to slow to reset after sending
6431# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006432not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006433requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6434requires_config_enabled MBEDTLS_RSA_C
6435requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006436requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6437requires_config_enabled MBEDTLS_AES_C
6438requires_config_enabled MBEDTLS_GCM_C
6439run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006440 -p "$P_PXY mtu=512" \
6441 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6442 crt_file=data_files/server7_int-ca.crt \
6443 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006444 hs_timeout=10000-60000 \
6445 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006446 "$P_CLI dtls=1 debug_level=2 \
6447 crt_file=data_files/server8_int-ca2.crt \
6448 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006449 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6450 hs_timeout=10000-60000 \
6451 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006452 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006453 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006454 -s "found fragmented DTLS handshake message" \
6455 -c "found fragmented DTLS handshake message" \
6456 -C "error"
6457
Andrzej Kurek7311c782018-10-11 06:49:41 -04006458not_with_valgrind # spurious autoreduction due to timeout
6459requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6460requires_config_enabled MBEDTLS_RSA_C
6461requires_config_enabled MBEDTLS_ECDSA_C
6462run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006463 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006464 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6465 crt_file=data_files/server7_int-ca.crt \
6466 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006467 hs_timeout=10000-60000 \
6468 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006469 "$P_CLI dtls=1 debug_level=2 \
6470 crt_file=data_files/server8_int-ca2.crt \
6471 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006472 hs_timeout=10000-60000 \
6473 mtu=1024 nbio=2" \
6474 0 \
6475 -S "autoreduction" \
6476 -s "found fragmented DTLS handshake message" \
6477 -c "found fragmented DTLS handshake message" \
6478 -C "error"
6479
Andrzej Kurek77826052018-10-11 07:34:08 -04006480# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006481not_with_valgrind # spurious autoreduction due to timeout
6482requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6483requires_config_enabled MBEDTLS_RSA_C
6484requires_config_enabled MBEDTLS_ECDSA_C
6485requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6486requires_config_enabled MBEDTLS_AES_C
6487requires_config_enabled MBEDTLS_GCM_C
6488run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6489 -p "$P_PXY mtu=512" \
6490 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6491 crt_file=data_files/server7_int-ca.crt \
6492 key_file=data_files/server7.key \
6493 hs_timeout=10000-60000 \
6494 mtu=512 nbio=2" \
6495 "$P_CLI dtls=1 debug_level=2 \
6496 crt_file=data_files/server8_int-ca2.crt \
6497 key_file=data_files/server8.key \
6498 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6499 hs_timeout=10000-60000 \
6500 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006501 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006502 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006503 -s "found fragmented DTLS handshake message" \
6504 -c "found fragmented DTLS handshake message" \
6505 -C "error"
6506
Andrzej Kurek77826052018-10-11 07:34:08 -04006507# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006508# This ensures things still work after session_reset().
6509# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006510# Since we don't support reading fragmented ClientHello yet,
6511# up the MTU to 1450 (larger than ClientHello with session ticket,
6512# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006513# An autoreduction on the client-side might happen if the server is
6514# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006515# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006516# resumed listening, which would result in a spurious autoreduction.
6517not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006518requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6519requires_config_enabled MBEDTLS_RSA_C
6520requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006521requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6522requires_config_enabled MBEDTLS_AES_C
6523requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006524run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6525 -p "$P_PXY mtu=1450" \
6526 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6527 crt_file=data_files/server7_int-ca.crt \
6528 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006529 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006530 mtu=1450" \
6531 "$P_CLI dtls=1 debug_level=2 \
6532 crt_file=data_files/server8_int-ca2.crt \
6533 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006534 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006535 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006536 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006537 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006538 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006539 -s "found fragmented DTLS handshake message" \
6540 -c "found fragmented DTLS handshake message" \
6541 -C "error"
6542
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006543# An autoreduction on the client-side might happen if the server is
6544# slow to reset, therefore omitting '-C "autoreduction"' below.
6545not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006546requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6547requires_config_enabled MBEDTLS_RSA_C
6548requires_config_enabled MBEDTLS_ECDSA_C
6549requires_config_enabled MBEDTLS_SHA256_C
6550requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6551requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6552requires_config_enabled MBEDTLS_CHACHAPOLY_C
6553run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6554 -p "$P_PXY mtu=512" \
6555 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6556 crt_file=data_files/server7_int-ca.crt \
6557 key_file=data_files/server7.key \
6558 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006559 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006560 mtu=512" \
6561 "$P_CLI dtls=1 debug_level=2 \
6562 crt_file=data_files/server8_int-ca2.crt \
6563 key_file=data_files/server8.key \
6564 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006565 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006566 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006567 mtu=512" \
6568 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006569 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006570 -s "found fragmented DTLS handshake message" \
6571 -c "found fragmented DTLS handshake message" \
6572 -C "error"
6573
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006574# An autoreduction on the client-side might happen if the server is
6575# slow to reset, therefore omitting '-C "autoreduction"' below.
6576not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006577requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6578requires_config_enabled MBEDTLS_RSA_C
6579requires_config_enabled MBEDTLS_ECDSA_C
6580requires_config_enabled MBEDTLS_SHA256_C
6581requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6582requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6583requires_config_enabled MBEDTLS_AES_C
6584requires_config_enabled MBEDTLS_GCM_C
6585run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6586 -p "$P_PXY mtu=512" \
6587 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6588 crt_file=data_files/server7_int-ca.crt \
6589 key_file=data_files/server7.key \
6590 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006591 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006592 mtu=512" \
6593 "$P_CLI dtls=1 debug_level=2 \
6594 crt_file=data_files/server8_int-ca2.crt \
6595 key_file=data_files/server8.key \
6596 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006597 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006598 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006599 mtu=512" \
6600 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006601 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006602 -s "found fragmented DTLS handshake message" \
6603 -c "found fragmented DTLS handshake message" \
6604 -C "error"
6605
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006606# An autoreduction on the client-side might happen if the server is
6607# slow to reset, therefore omitting '-C "autoreduction"' below.
6608not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006609requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6610requires_config_enabled MBEDTLS_RSA_C
6611requires_config_enabled MBEDTLS_ECDSA_C
6612requires_config_enabled MBEDTLS_SHA256_C
6613requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6614requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6615requires_config_enabled MBEDTLS_AES_C
6616requires_config_enabled MBEDTLS_CCM_C
6617run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006618 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006619 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6620 crt_file=data_files/server7_int-ca.crt \
6621 key_file=data_files/server7.key \
6622 exchanges=2 renegotiation=1 \
6623 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006624 hs_timeout=10000-60000 \
6625 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006626 "$P_CLI dtls=1 debug_level=2 \
6627 crt_file=data_files/server8_int-ca2.crt \
6628 key_file=data_files/server8.key \
6629 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006630 hs_timeout=10000-60000 \
6631 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006632 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006633 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006634 -s "found fragmented DTLS handshake message" \
6635 -c "found fragmented DTLS handshake message" \
6636 -C "error"
6637
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006638# An autoreduction on the client-side might happen if the server is
6639# slow to reset, therefore omitting '-C "autoreduction"' below.
6640not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006641requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6642requires_config_enabled MBEDTLS_RSA_C
6643requires_config_enabled MBEDTLS_ECDSA_C
6644requires_config_enabled MBEDTLS_SHA256_C
6645requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6646requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6647requires_config_enabled MBEDTLS_AES_C
6648requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6649requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6650run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006651 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006652 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6653 crt_file=data_files/server7_int-ca.crt \
6654 key_file=data_files/server7.key \
6655 exchanges=2 renegotiation=1 \
6656 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006657 hs_timeout=10000-60000 \
6658 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006659 "$P_CLI dtls=1 debug_level=2 \
6660 crt_file=data_files/server8_int-ca2.crt \
6661 key_file=data_files/server8.key \
6662 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006663 hs_timeout=10000-60000 \
6664 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006665 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006666 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006667 -s "found fragmented DTLS handshake message" \
6668 -c "found fragmented DTLS handshake message" \
6669 -C "error"
6670
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006671# An autoreduction on the client-side might happen if the server is
6672# slow to reset, therefore omitting '-C "autoreduction"' below.
6673not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006674requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6675requires_config_enabled MBEDTLS_RSA_C
6676requires_config_enabled MBEDTLS_ECDSA_C
6677requires_config_enabled MBEDTLS_SHA256_C
6678requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6679requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6680requires_config_enabled MBEDTLS_AES_C
6681requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6682run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006683 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006684 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6685 crt_file=data_files/server7_int-ca.crt \
6686 key_file=data_files/server7.key \
6687 exchanges=2 renegotiation=1 \
6688 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006689 hs_timeout=10000-60000 \
6690 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006691 "$P_CLI dtls=1 debug_level=2 \
6692 crt_file=data_files/server8_int-ca2.crt \
6693 key_file=data_files/server8.key \
6694 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006695 hs_timeout=10000-60000 \
6696 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006697 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006698 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006699 -s "found fragmented DTLS handshake message" \
6700 -c "found fragmented DTLS handshake message" \
6701 -C "error"
6702
Andrzej Kurek77826052018-10-11 07:34:08 -04006703# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006704requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6705requires_config_enabled MBEDTLS_RSA_C
6706requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006707requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6708requires_config_enabled MBEDTLS_AES_C
6709requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006710client_needs_more_time 2
6711run_test "DTLS fragmenting: proxy MTU + 3d" \
6712 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006713 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006714 crt_file=data_files/server7_int-ca.crt \
6715 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006716 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006717 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006718 crt_file=data_files/server8_int-ca2.crt \
6719 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006720 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006721 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006722 0 \
6723 -s "found fragmented DTLS handshake message" \
6724 -c "found fragmented DTLS handshake message" \
6725 -C "error"
6726
Andrzej Kurek77826052018-10-11 07:34:08 -04006727# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006728requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6729requires_config_enabled MBEDTLS_RSA_C
6730requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006731requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6732requires_config_enabled MBEDTLS_AES_C
6733requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006734client_needs_more_time 2
6735run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6736 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6737 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6738 crt_file=data_files/server7_int-ca.crt \
6739 key_file=data_files/server7.key \
6740 hs_timeout=250-10000 mtu=512 nbio=2" \
6741 "$P_CLI dtls=1 debug_level=2 \
6742 crt_file=data_files/server8_int-ca2.crt \
6743 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006744 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006745 hs_timeout=250-10000 mtu=512 nbio=2" \
6746 0 \
6747 -s "found fragmented DTLS handshake message" \
6748 -c "found fragmented DTLS handshake message" \
6749 -C "error"
6750
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006751# interop tests for DTLS fragmentating with reliable connection
6752#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006753# here and below we just want to test that the we fragment in a way that
6754# pleases other implementations, so we don't need the peer to fragment
6755requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6756requires_config_enabled MBEDTLS_RSA_C
6757requires_config_enabled MBEDTLS_ECDSA_C
6758requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006759requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006760run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6761 "$G_SRV -u" \
6762 "$P_CLI dtls=1 debug_level=2 \
6763 crt_file=data_files/server8_int-ca2.crt \
6764 key_file=data_files/server8.key \
6765 mtu=512 force_version=dtls1_2" \
6766 0 \
6767 -c "fragmenting handshake message" \
6768 -C "error"
6769
6770requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6771requires_config_enabled MBEDTLS_RSA_C
6772requires_config_enabled MBEDTLS_ECDSA_C
6773requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006774requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006775run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6776 "$G_SRV -u" \
6777 "$P_CLI dtls=1 debug_level=2 \
6778 crt_file=data_files/server8_int-ca2.crt \
6779 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006780 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006781 0 \
6782 -c "fragmenting handshake message" \
6783 -C "error"
6784
Hanno Beckerb9a00862018-08-28 10:20:22 +01006785# We use --insecure for the GnuTLS client because it expects
6786# the hostname / IP it connects to to be the name used in the
6787# certificate obtained from the server. Here, however, it
6788# connects to 127.0.0.1 while our test certificates use 'localhost'
6789# as the server name in the certificate. This will make the
6790# certifiate validation fail, but passing --insecure makes
6791# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006792requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6793requires_config_enabled MBEDTLS_RSA_C
6794requires_config_enabled MBEDTLS_ECDSA_C
6795requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006796requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006797requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006798run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006799 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006800 crt_file=data_files/server7_int-ca.crt \
6801 key_file=data_files/server7.key \
6802 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006803 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006804 0 \
6805 -s "fragmenting handshake message"
6806
Hanno Beckerb9a00862018-08-28 10:20:22 +01006807# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006808requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6809requires_config_enabled MBEDTLS_RSA_C
6810requires_config_enabled MBEDTLS_ECDSA_C
6811requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006812requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006813requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006814run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006815 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006816 crt_file=data_files/server7_int-ca.crt \
6817 key_file=data_files/server7.key \
6818 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006819 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006820 0 \
6821 -s "fragmenting handshake message"
6822
6823requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6824requires_config_enabled MBEDTLS_RSA_C
6825requires_config_enabled MBEDTLS_ECDSA_C
6826requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6827run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6828 "$O_SRV -dtls1_2 -verify 10" \
6829 "$P_CLI dtls=1 debug_level=2 \
6830 crt_file=data_files/server8_int-ca2.crt \
6831 key_file=data_files/server8.key \
6832 mtu=512 force_version=dtls1_2" \
6833 0 \
6834 -c "fragmenting handshake message" \
6835 -C "error"
6836
6837requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6838requires_config_enabled MBEDTLS_RSA_C
6839requires_config_enabled MBEDTLS_ECDSA_C
6840requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6841run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6842 "$O_SRV -dtls1 -verify 10" \
6843 "$P_CLI dtls=1 debug_level=2 \
6844 crt_file=data_files/server8_int-ca2.crt \
6845 key_file=data_files/server8.key \
6846 mtu=512 force_version=dtls1" \
6847 0 \
6848 -c "fragmenting handshake message" \
6849 -C "error"
6850
6851requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6852requires_config_enabled MBEDTLS_RSA_C
6853requires_config_enabled MBEDTLS_ECDSA_C
6854requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6855run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6856 "$P_SRV dtls=1 debug_level=2 \
6857 crt_file=data_files/server7_int-ca.crt \
6858 key_file=data_files/server7.key \
6859 mtu=512 force_version=dtls1_2" \
6860 "$O_CLI -dtls1_2" \
6861 0 \
6862 -s "fragmenting handshake message"
6863
6864requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6865requires_config_enabled MBEDTLS_RSA_C
6866requires_config_enabled MBEDTLS_ECDSA_C
6867requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6868run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6869 "$P_SRV dtls=1 debug_level=2 \
6870 crt_file=data_files/server7_int-ca.crt \
6871 key_file=data_files/server7.key \
6872 mtu=512 force_version=dtls1" \
6873 "$O_CLI -dtls1" \
6874 0 \
6875 -s "fragmenting handshake message"
6876
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006877# interop tests for DTLS fragmentating with unreliable connection
6878#
6879# again we just want to test that the we fragment in a way that
6880# pleases other implementations, so we don't need the peer to fragment
6881requires_gnutls_next
6882requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6883requires_config_enabled MBEDTLS_RSA_C
6884requires_config_enabled MBEDTLS_ECDSA_C
6885requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006886client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006887run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6888 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6889 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006890 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006891 crt_file=data_files/server8_int-ca2.crt \
6892 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006893 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006894 0 \
6895 -c "fragmenting handshake message" \
6896 -C "error"
6897
6898requires_gnutls_next
6899requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6900requires_config_enabled MBEDTLS_RSA_C
6901requires_config_enabled MBEDTLS_ECDSA_C
6902requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006903client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006904run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6905 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6906 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006907 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006908 crt_file=data_files/server8_int-ca2.crt \
6909 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006910 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006911 0 \
6912 -c "fragmenting handshake message" \
6913 -C "error"
6914
k-stachowiakabb843e2019-02-18 16:14:03 +01006915requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006916requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6917requires_config_enabled MBEDTLS_RSA_C
6918requires_config_enabled MBEDTLS_ECDSA_C
6919requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6920client_needs_more_time 4
6921run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6922 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6923 "$P_SRV dtls=1 debug_level=2 \
6924 crt_file=data_files/server7_int-ca.crt \
6925 key_file=data_files/server7.key \
6926 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006927 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006928 0 \
6929 -s "fragmenting handshake message"
6930
k-stachowiakabb843e2019-02-18 16:14:03 +01006931requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006932requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6933requires_config_enabled MBEDTLS_RSA_C
6934requires_config_enabled MBEDTLS_ECDSA_C
6935requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6936client_needs_more_time 4
6937run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6938 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6939 "$P_SRV dtls=1 debug_level=2 \
6940 crt_file=data_files/server7_int-ca.crt \
6941 key_file=data_files/server7.key \
6942 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006943 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006944 0 \
6945 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006946
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006947## Interop test with OpenSSL might trigger a bug in recent versions (including
6948## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006949## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006950## They should be re-enabled once a fixed version of OpenSSL is available
6951## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006952skip_next_test
6953requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6954requires_config_enabled MBEDTLS_RSA_C
6955requires_config_enabled MBEDTLS_ECDSA_C
6956requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6957client_needs_more_time 4
6958run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6959 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6960 "$O_SRV -dtls1_2 -verify 10" \
6961 "$P_CLI dtls=1 debug_level=2 \
6962 crt_file=data_files/server8_int-ca2.crt \
6963 key_file=data_files/server8.key \
6964 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6965 0 \
6966 -c "fragmenting handshake message" \
6967 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006968
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006969skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006970requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6971requires_config_enabled MBEDTLS_RSA_C
6972requires_config_enabled MBEDTLS_ECDSA_C
6973requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006974client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006975run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6976 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006977 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006978 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006979 crt_file=data_files/server8_int-ca2.crt \
6980 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006981 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006982 0 \
6983 -c "fragmenting handshake message" \
6984 -C "error"
6985
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006986skip_next_test
6987requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6988requires_config_enabled MBEDTLS_RSA_C
6989requires_config_enabled MBEDTLS_ECDSA_C
6990requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6991client_needs_more_time 4
6992run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6993 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6994 "$P_SRV dtls=1 debug_level=2 \
6995 crt_file=data_files/server7_int-ca.crt \
6996 key_file=data_files/server7.key \
6997 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6998 "$O_CLI -dtls1_2" \
6999 0 \
7000 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007001
7002# -nbio is added to prevent s_client from blocking in case of duplicated
7003# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007004skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007005requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7006requires_config_enabled MBEDTLS_RSA_C
7007requires_config_enabled MBEDTLS_ECDSA_C
7008requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007009client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007010run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
7011 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007012 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007013 crt_file=data_files/server7_int-ca.crt \
7014 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007015 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007016 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007017 0 \
7018 -s "fragmenting handshake message"
7019
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007020# Tests for specific things with "unreliable" UDP connection
7021
7022not_with_valgrind # spurious resend due to timeout
7023run_test "DTLS proxy: reference" \
7024 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007025 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
7026 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007027 0 \
7028 -C "replayed record" \
7029 -S "replayed record" \
7030 -C "record from another epoch" \
7031 -S "record from another epoch" \
7032 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007033 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007034 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007035 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007036 -c "HTTP/1.0 200 OK"
7037
7038not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007039run_test "DTLS proxy: duplicate every packet" \
7040 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007041 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
7042 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007043 0 \
7044 -c "replayed record" \
7045 -s "replayed record" \
7046 -c "record from another epoch" \
7047 -s "record from another epoch" \
7048 -S "resend" \
7049 -s "Extra-header:" \
7050 -c "HTTP/1.0 200 OK"
7051
7052run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7053 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007054 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7055 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007056 0 \
7057 -c "replayed record" \
7058 -S "replayed record" \
7059 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007060 -s "record from another epoch" \
7061 -c "resend" \
7062 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007063 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007064 -c "HTTP/1.0 200 OK"
7065
7066run_test "DTLS proxy: multiple records in same datagram" \
7067 -p "$P_PXY pack=50" \
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é-Gonnard63eca932014-09-08 16:39:08 +02007070 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007071 -c "next record in same datagram" \
7072 -s "next record in same datagram"
7073
7074run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7075 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007076 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7077 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007078 0 \
7079 -c "next record in same datagram" \
7080 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007081
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007082run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7083 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007084 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7085 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007086 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007087 -c "discarding invalid record (mac)" \
7088 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007089 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007090 -c "HTTP/1.0 200 OK" \
7091 -S "too many records with bad MAC" \
7092 -S "Verification of the message MAC failed"
7093
7094run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
7095 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007096 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7097 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007098 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007099 -C "discarding invalid record (mac)" \
7100 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007101 -S "Extra-header:" \
7102 -C "HTTP/1.0 200 OK" \
7103 -s "too many records with bad MAC" \
7104 -s "Verification of the message MAC failed"
7105
7106run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7107 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007108 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7109 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007110 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007111 -c "discarding invalid record (mac)" \
7112 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007113 -s "Extra-header:" \
7114 -c "HTTP/1.0 200 OK" \
7115 -S "too many records with bad MAC" \
7116 -S "Verification of the message MAC failed"
7117
7118run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7119 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007120 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7121 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007122 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007123 -c "discarding invalid record (mac)" \
7124 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007125 -s "Extra-header:" \
7126 -c "HTTP/1.0 200 OK" \
7127 -s "too many records with bad MAC" \
7128 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007129
7130run_test "DTLS proxy: delay ChangeCipherSpec" \
7131 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007132 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7133 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007134 0 \
7135 -c "record from another epoch" \
7136 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007137 -s "Extra-header:" \
7138 -c "HTTP/1.0 200 OK"
7139
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007140# Tests for reordering support with DTLS
7141
Hanno Becker56cdfd12018-08-17 13:42:15 +01007142run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7143 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007144 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7145 hs_timeout=2500-60000" \
7146 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7147 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007148 0 \
7149 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007150 -c "Next handshake message has been buffered - load"\
7151 -S "Buffering HS message" \
7152 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007153 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007154 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007155 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007156 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007157
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007158run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7159 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007160 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7161 hs_timeout=2500-60000" \
7162 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7163 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007164 0 \
7165 -c "Buffering HS message" \
7166 -c "found fragmented DTLS handshake message"\
7167 -c "Next handshake message 1 not or only partially bufffered" \
7168 -c "Next handshake message has been buffered - load"\
7169 -S "Buffering HS message" \
7170 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007171 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007172 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007173 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007174 -S "Remember CCS message"
7175
Hanno Beckera1adcca2018-08-24 14:41:07 +01007176# The client buffers the ServerKeyExchange before receiving the fragmented
7177# Certificate message; at the time of writing, together these are aroudn 1200b
7178# in size, so that the bound below ensures that the certificate can be reassembled
7179# while keeping the ServerKeyExchange.
7180requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7181run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007182 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007183 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7184 hs_timeout=2500-60000" \
7185 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7186 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007187 0 \
7188 -c "Buffering HS message" \
7189 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007190 -C "attempt to make space by freeing buffered messages" \
7191 -S "Buffering HS message" \
7192 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007193 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007194 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007195 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007196 -S "Remember CCS message"
7197
7198# The size constraints ensure that the delayed certificate message can't
7199# be reassembled while keeping the ServerKeyExchange message, but it can
7200# when dropping it first.
7201requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7202requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7203run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7204 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007205 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7206 hs_timeout=2500-60000" \
7207 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7208 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007209 0 \
7210 -c "Buffering HS message" \
7211 -c "attempt to make space by freeing buffered future messages" \
7212 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007213 -S "Buffering HS message" \
7214 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007215 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007216 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007217 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007218 -S "Remember CCS message"
7219
Hanno Becker56cdfd12018-08-17 13:42:15 +01007220run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7221 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007222 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7223 hs_timeout=2500-60000" \
7224 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7225 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007226 0 \
7227 -C "Buffering HS message" \
7228 -C "Next handshake message has been buffered - load"\
7229 -s "Buffering HS message" \
7230 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007231 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007232 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007233 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007234 -S "Remember CCS message"
7235
7236run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7237 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007238 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7239 hs_timeout=2500-60000" \
7240 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7241 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007242 0 \
7243 -C "Buffering HS message" \
7244 -C "Next handshake message has been buffered - load"\
7245 -S "Buffering HS message" \
7246 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007247 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007248 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007249 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007250 -S "Remember CCS message"
7251
7252run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7253 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007254 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7255 hs_timeout=2500-60000" \
7256 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7257 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007258 0 \
7259 -C "Buffering HS message" \
7260 -C "Next handshake message has been buffered - load"\
7261 -S "Buffering HS message" \
7262 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007263 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007264 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007265 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007266 -s "Remember CCS message"
7267
Hanno Beckera1adcca2018-08-24 14:41:07 +01007268run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007269 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007270 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7271 hs_timeout=2500-60000" \
7272 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7273 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007274 0 \
7275 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007276 -s "Found buffered record from current epoch - load" \
7277 -c "Buffer record from epoch 1" \
7278 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007279
Hanno Beckera1adcca2018-08-24 14:41:07 +01007280# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7281# from the server are delayed, so that the encrypted Finished message
7282# is received and buffered. When the fragmented NewSessionTicket comes
7283# in afterwards, the encrypted Finished message must be freed in order
7284# to make space for the NewSessionTicket to be reassembled.
7285# This works only in very particular circumstances:
7286# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7287# of the NewSessionTicket, but small enough to also allow buffering of
7288# the encrypted Finished message.
7289# - The MTU setting on the server must be so small that the NewSessionTicket
7290# needs to be fragmented.
7291# - All messages sent by the server must be small enough to be either sent
7292# without fragmentation or be reassembled within the bounds of
7293# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7294# handshake, omitting CRTs.
7295requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7296requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7297run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7298 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7299 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7300 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7301 0 \
7302 -s "Buffer record from epoch 1" \
7303 -s "Found buffered record from current epoch - load" \
7304 -c "Buffer record from epoch 1" \
7305 -C "Found buffered record from current epoch - load" \
7306 -c "Enough space available after freeing future epoch record"
7307
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007308# Tests for "randomly unreliable connection": try a variety of flows and peers
7309
7310client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007311run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7312 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007313 "$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 +02007314 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007315 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007316 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7317 0 \
7318 -s "Extra-header:" \
7319 -c "HTTP/1.0 200 OK"
7320
Janos Follath74537a62016-09-02 13:45:28 +01007321client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007322run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7323 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007324 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7325 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007326 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7327 0 \
7328 -s "Extra-header:" \
7329 -c "HTTP/1.0 200 OK"
7330
Janos Follath74537a62016-09-02 13:45:28 +01007331client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007332run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7333 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007334 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7335 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007336 0 \
7337 -s "Extra-header:" \
7338 -c "HTTP/1.0 200 OK"
7339
Janos Follath74537a62016-09-02 13:45:28 +01007340client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007341run_test "DTLS proxy: 3d, FS, client auth" \
7342 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007343 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7344 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007345 0 \
7346 -s "Extra-header:" \
7347 -c "HTTP/1.0 200 OK"
7348
Janos Follath74537a62016-09-02 13:45:28 +01007349client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007350run_test "DTLS proxy: 3d, FS, ticket" \
7351 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007352 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7353 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007354 0 \
7355 -s "Extra-header:" \
7356 -c "HTTP/1.0 200 OK"
7357
Janos Follath74537a62016-09-02 13:45:28 +01007358client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007359run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7360 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007361 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7362 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007363 0 \
7364 -s "Extra-header:" \
7365 -c "HTTP/1.0 200 OK"
7366
Janos Follath74537a62016-09-02 13:45:28 +01007367client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007368run_test "DTLS proxy: 3d, max handshake, nbio" \
7369 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007370 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007371 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007372 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007373 0 \
7374 -s "Extra-header:" \
7375 -c "HTTP/1.0 200 OK"
7376
Janos Follath74537a62016-09-02 13:45:28 +01007377client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007378run_test "DTLS proxy: 3d, min handshake, resumption" \
7379 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007380 "$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 +02007381 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007382 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007383 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007384 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7385 0 \
7386 -s "a session has been resumed" \
7387 -c "a session has been resumed" \
7388 -s "Extra-header:" \
7389 -c "HTTP/1.0 200 OK"
7390
Janos Follath74537a62016-09-02 13:45:28 +01007391client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007392run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7393 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007394 "$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 +02007395 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007396 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007397 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007398 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7399 0 \
7400 -s "a session has been resumed" \
7401 -c "a session has been resumed" \
7402 -s "Extra-header:" \
7403 -c "HTTP/1.0 200 OK"
7404
Janos Follath74537a62016-09-02 13:45:28 +01007405client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007406requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007407run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007408 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007409 "$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 +02007410 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007411 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007412 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007413 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7414 0 \
7415 -c "=> renegotiate" \
7416 -s "=> renegotiate" \
7417 -s "Extra-header:" \
7418 -c "HTTP/1.0 200 OK"
7419
Janos Follath74537a62016-09-02 13:45:28 +01007420client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007421requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007422run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7423 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007424 "$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 +02007425 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007426 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007427 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007428 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7429 0 \
7430 -c "=> renegotiate" \
7431 -s "=> renegotiate" \
7432 -s "Extra-header:" \
7433 -c "HTTP/1.0 200 OK"
7434
Janos Follath74537a62016-09-02 13:45:28 +01007435client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007436requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007437run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007438 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007439 "$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 +02007440 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007441 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007442 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007443 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007444 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7445 0 \
7446 -c "=> renegotiate" \
7447 -s "=> renegotiate" \
7448 -s "Extra-header:" \
7449 -c "HTTP/1.0 200 OK"
7450
Janos Follath74537a62016-09-02 13:45:28 +01007451client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007452requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007453run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007454 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007455 "$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 +02007456 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007457 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007458 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007459 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007460 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7461 0 \
7462 -c "=> renegotiate" \
7463 -s "=> renegotiate" \
7464 -s "Extra-header:" \
7465 -c "HTTP/1.0 200 OK"
7466
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007467## Interop tests with OpenSSL might trigger a bug in recent versions (including
7468## all versions installed on the CI machines), reported here:
7469## Bug report: https://github.com/openssl/openssl/issues/6902
7470## They should be re-enabled once a fixed version of OpenSSL is available
7471## (this should happen in some 1.1.1_ release according to the ticket).
7472skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007473client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007474not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007475run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007476 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7477 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007478 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007479 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007480 -c "HTTP/1.0 200 OK"
7481
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007482skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007483client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007484not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007485run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7486 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7487 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007488 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007489 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007490 -c "HTTP/1.0 200 OK"
7491
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007492skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007493client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007494not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007495run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7496 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7497 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007498 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007499 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007500 -c "HTTP/1.0 200 OK"
7501
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007502requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007503client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007504not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007505run_test "DTLS proxy: 3d, gnutls server" \
7506 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7507 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007508 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007509 0 \
7510 -s "Extra-header:" \
7511 -c "Extra-header:"
7512
k-stachowiakabb843e2019-02-18 16:14:03 +01007513requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007514client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007515not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007516run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7517 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007518 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007519 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007520 0 \
7521 -s "Extra-header:" \
7522 -c "Extra-header:"
7523
k-stachowiakabb843e2019-02-18 16:14:03 +01007524requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007525client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007526not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007527run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7528 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007529 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007530 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007531 0 \
7532 -s "Extra-header:" \
7533 -c "Extra-header:"
7534
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007535# Final report
7536
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007537echo "------------------------------------------------------------------------"
7538
7539if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007540 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007541else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007542 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007543fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007544PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007545echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007546
7547exit $FAILS