blob: f5ac5ac20c47e6c4d7c529b6c2eec167f47ce5b7 [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#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Jaeden Amero6e70eb22019-07-03 13:51:04 +010024# Limit the size of each log to 10 GiB, in case of failures with this script
25# where it may output seemingly unlimited length error logs.
26ulimit -f 20971520
27
Gilles Peskine560280b2019-09-16 15:17:38 +020028ORIGINAL_PWD=$PWD
29if ! cd "$(dirname "$0")"; then
30 exit 125
Angus Grattonc4dd0732018-04-11 16:28:39 +100031fi
32
Antonin Décimo36e89b52019-01-23 15:24:37 +010033# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010034: ${P_SRV:=../programs/ssl/ssl_server2}
35: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020036: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010037: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020038: ${GNUTLS_CLI:=gnutls-cli}
39: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020040: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010041
Gilles Peskine560280b2019-09-16 15:17:38 +020042guess_config_name() {
43 if git diff --quiet ../include/mbedtls/config.h 2>/dev/null; then
44 echo "default"
45 else
46 echo "unknown"
47 fi
48}
49: ${MBEDTLS_TEST_OUTCOME_FILE=}
50: ${MBEDTLS_TEST_CONFIGURATION:="$(guess_config_name)"}
51: ${MBEDTLS_TEST_PLATFORM:="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"}
52
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020053O_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 +010054O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020055G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010056G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020057TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010058
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020059# alternative versions of OpenSSL and GnuTLS (no default path)
60
61if [ -n "${OPENSSL_LEGACY:-}" ]; then
62 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
63 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
64else
65 O_LEGACY_SRV=false
66 O_LEGACY_CLI=false
67fi
68
Hanno Becker58e9dc32018-08-17 15:53:21 +010069if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020070 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
71else
72 G_NEXT_SRV=false
73fi
74
Hanno Becker58e9dc32018-08-17 15:53:21 +010075if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020076 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
77else
78 G_NEXT_CLI=false
79fi
80
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010081TESTS=0
82FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020083SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010084
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000085CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020086
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010087MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010088FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020089EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010090
Paul Bakkere20310a2016-05-10 11:18:17 +010091SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010092RUN_TEST_NUMBER=''
93
Paul Bakkeracaac852016-05-10 11:47:13 +010094PRESERVE_LOGS=0
95
Gilles Peskinef93c7d32017-04-14 17:55:28 +020096# Pick a "unique" server port in the range 10000-19999, and a proxy
97# port which is this plus 10000. Each port number may be independently
98# overridden by a command line option.
99SRV_PORT=$(($$ % 10000 + 10000))
100PXY_PORT=$((SRV_PORT + 10000))
101
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100102print_usage() {
103 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100104 printf " -h|--help\tPrint this help.\n"
105 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200106 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
107 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100108 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100109 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100110 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskine560280b2019-09-16 15:17:38 +0200111 printf " --outcome-file\tFile where test outcomes are written\n"
112 printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n"
113 printf " --port \tTCP/UDP port (default: randomish 1xxxx)\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200114 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Gilles Peskine560280b2019-09-16 15:17:38 +0200115 printf " --seed \tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100116}
117
118get_options() {
119 while [ $# -gt 0 ]; do
120 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100121 -f|--filter)
122 shift; FILTER=$1
123 ;;
124 -e|--exclude)
125 shift; EXCLUDE=$1
126 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100127 -m|--memcheck)
128 MEMCHECK=1
129 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100130 -n|--number)
131 shift; RUN_TEST_NUMBER=$1
132 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100133 -s|--show-numbers)
134 SHOW_TEST_NUMBER=1
135 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100136 -p|--preserve-logs)
137 PRESERVE_LOGS=1
138 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200139 --port)
140 shift; SRV_PORT=$1
141 ;;
142 --proxy-port)
143 shift; PXY_PORT=$1
144 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100145 --seed)
146 shift; SEED="$1"
147 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100148 -h|--help)
149 print_usage
150 exit 0
151 ;;
152 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200153 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100154 print_usage
155 exit 1
156 ;;
157 esac
158 shift
159 done
160}
161
Gilles Peskine560280b2019-09-16 15:17:38 +0200162# Make the outcome file path relative to the original directory, not
163# to .../tests
164case "$MBEDTLS_TEST_OUTCOME_FILE" in
165 [!/]*)
166 MBEDTLS_TEST_OUTCOME_FILE="$ORIGINAL_PWD/$MBEDTLS_TEST_OUTCOME_FILE"
167 ;;
168esac
169
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100170# Skip next test; use this macro to skip tests which are legitimate
171# in theory and expected to be re-introduced at some point, but
172# aren't expected to succeed at the moment due to problems outside
173# our control (such as bugs in other TLS implementations).
174skip_next_test() {
175 SKIP_NEXT="YES"
176}
177
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100178# skip next test if the flag is not enabled in config.h
179requires_config_enabled() {
180 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
181 SKIP_NEXT="YES"
182 fi
183}
184
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200185# skip next test if the flag is enabled in config.h
186requires_config_disabled() {
187 if grep "^#define $1" $CONFIG_H > /dev/null; then
188 SKIP_NEXT="YES"
189 fi
190}
191
Hanno Becker7c48dd12018-08-28 16:09:22 +0100192get_config_value_or_default() {
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100193 # This function uses the query_config command line option to query the
194 # required Mbed TLS compile time configuration from the ssl_server2
195 # program. The command will always return a success value if the
196 # configuration is defined and the value will be printed to stdout.
197 #
198 # Note that if the configuration is not defined or is defined to nothing,
199 # the output of this function will be an empty string.
200 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100201}
202
203requires_config_value_at_least() {
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100204 VAL="$( get_config_value_or_default "$1" )"
205 if [ -z "$VAL" ]; then
206 # Should never happen
207 echo "Mbed TLS configuration $1 is not defined"
208 exit 1
209 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100210 SKIP_NEXT="YES"
211 fi
212}
213
214requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100215 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100216 if [ -z "$VAL" ]; then
217 # Should never happen
218 echo "Mbed TLS configuration $1 is not defined"
219 exit 1
220 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100221 SKIP_NEXT="YES"
222 fi
223}
224
Hanno Becker9d76d562018-11-16 17:27:29 +0000225requires_ciphersuite_enabled() {
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100226 if [ -z "$($P_CLI --help 2>/dev/null | grep $1)" ]; then
Hanno Becker9d76d562018-11-16 17:27:29 +0000227 SKIP_NEXT="YES"
228 fi
229}
230
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200231# skip next test if OpenSSL doesn't support FALLBACK_SCSV
232requires_openssl_with_fallback_scsv() {
233 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
234 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
235 then
236 OPENSSL_HAS_FBSCSV="YES"
237 else
238 OPENSSL_HAS_FBSCSV="NO"
239 fi
240 fi
241 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
242 SKIP_NEXT="YES"
243 fi
244}
245
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200246# skip next test if GnuTLS isn't available
247requires_gnutls() {
248 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200249 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200250 GNUTLS_AVAILABLE="YES"
251 else
252 GNUTLS_AVAILABLE="NO"
253 fi
254 fi
255 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
256 SKIP_NEXT="YES"
257 fi
258}
259
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200260# skip next test if GnuTLS-next isn't available
261requires_gnutls_next() {
262 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
263 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
264 GNUTLS_NEXT_AVAILABLE="YES"
265 else
266 GNUTLS_NEXT_AVAILABLE="NO"
267 fi
268 fi
269 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
270 SKIP_NEXT="YES"
271 fi
272}
273
274# skip next test if OpenSSL-legacy isn't available
275requires_openssl_legacy() {
276 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
277 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
278 OPENSSL_LEGACY_AVAILABLE="YES"
279 else
280 OPENSSL_LEGACY_AVAILABLE="NO"
281 fi
282 fi
283 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
284 SKIP_NEXT="YES"
285 fi
286}
287
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200288# skip next test if IPv6 isn't available on this host
289requires_ipv6() {
290 if [ -z "${HAS_IPV6:-}" ]; then
291 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
292 SRV_PID=$!
293 sleep 1
294 kill $SRV_PID >/dev/null 2>&1
295 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
296 HAS_IPV6="NO"
297 else
298 HAS_IPV6="YES"
299 fi
300 rm -r $SRV_OUT
301 fi
302
303 if [ "$HAS_IPV6" = "NO" ]; then
304 SKIP_NEXT="YES"
305 fi
306}
307
Andrzej Kurekb4593462018-10-11 08:43:30 -0400308# skip next test if it's i686 or uname is not available
309requires_not_i686() {
310 if [ -z "${IS_I686:-}" ]; then
311 IS_I686="YES"
312 if which "uname" >/dev/null 2>&1; then
313 if [ -z "$(uname -a | grep i686)" ]; then
314 IS_I686="NO"
315 fi
316 fi
317 fi
318 if [ "$IS_I686" = "YES" ]; then
319 SKIP_NEXT="YES"
320 fi
321}
322
Angus Grattonc4dd0732018-04-11 16:28:39 +1000323# Calculate the input & output maximum content lengths set in the config
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200324MAX_CONTENT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
325MAX_IN_LEN=$( ../scripts/config.py get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
326MAX_OUT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
Angus Grattonc4dd0732018-04-11 16:28:39 +1000327
328if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
329 MAX_CONTENT_LEN="$MAX_IN_LEN"
330fi
331if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
332 MAX_CONTENT_LEN="$MAX_OUT_LEN"
333fi
334
335# skip the next test if the SSL output buffer is less than 16KB
336requires_full_size_output_buffer() {
337 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
338 SKIP_NEXT="YES"
339 fi
340}
341
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200342# skip the next test if valgrind is in use
343not_with_valgrind() {
344 if [ "$MEMCHECK" -gt 0 ]; then
345 SKIP_NEXT="YES"
346 fi
347}
348
Paul Bakker362689d2016-05-13 10:33:25 +0100349# skip the next test if valgrind is NOT in use
350only_with_valgrind() {
351 if [ "$MEMCHECK" -eq 0 ]; then
352 SKIP_NEXT="YES"
353 fi
354}
355
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200356# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100357client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200358 CLI_DELAY_FACTOR=$1
359}
360
Janos Follath74537a62016-09-02 13:45:28 +0100361# wait for the given seconds after the client finished in the next test
362server_needs_more_time() {
363 SRV_DELAY_SECONDS=$1
364}
365
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100366# print_name <name>
367print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100368 TESTS=$(( $TESTS + 1 ))
369 LINE=""
370
371 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
372 LINE="$TESTS "
373 fi
374
375 LINE="$LINE$1"
376 printf "$LINE "
377 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100378 for i in `seq 1 $LEN`; do printf '.'; done
379 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100380
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100381}
382
Gilles Peskine560280b2019-09-16 15:17:38 +0200383# record_outcome <outcome> [<failure-reason>]
384# The test name must be in $NAME.
385record_outcome() {
386 echo "$1"
387 if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ]; then
388 printf '%s;%s;%s;%s;%s;%s\n' \
389 "$MBEDTLS_TEST_PLATFORM" "$MBEDTLS_TEST_CONFIGURATION" \
390 "ssl-opt" "$NAME" \
391 "$1" "${2-}" \
392 >>"$MBEDTLS_TEST_OUTCOME_FILE"
393 fi
394}
395
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100396# fail <message>
397fail() {
Gilles Peskine560280b2019-09-16 15:17:38 +0200398 record_outcome "FAIL" "$1"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100399 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100400
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200401 mv $SRV_OUT o-srv-${TESTS}.log
402 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200403 if [ -n "$PXY_CMD" ]; then
404 mv $PXY_OUT o-pxy-${TESTS}.log
405 fi
406 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100407
Azim Khan19d13732018-03-29 11:04:20 +0100408 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot -o "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200409 echo " ! server output:"
410 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200411 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200412 echo " ! client output:"
413 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200414 if [ -n "$PXY_CMD" ]; then
415 echo " ! ========================================================"
416 echo " ! proxy output:"
417 cat o-pxy-${TESTS}.log
418 fi
419 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200420 fi
421
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200422 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100423}
424
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100425# is_polar <cmd_line>
426is_polar() {
427 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
428}
429
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200430# openssl s_server doesn't have -www with DTLS
431check_osrv_dtls() {
432 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
433 NEEDS_INPUT=1
434 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
435 else
436 NEEDS_INPUT=0
437 fi
438}
439
440# provide input to commands that need it
441provide_input() {
442 if [ $NEEDS_INPUT -eq 0 ]; then
443 return
444 fi
445
446 while true; do
447 echo "HTTP/1.0 200 OK"
448 sleep 1
449 done
450}
451
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100452# has_mem_err <log_file_name>
453has_mem_err() {
454 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
455 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
456 then
457 return 1 # false: does not have errors
458 else
459 return 0 # true: has errors
460 fi
461}
462
Unknownd364f4c2019-09-02 10:42:57 -0400463# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100464if type lsof >/dev/null 2>/dev/null; then
Unknownd364f4c2019-09-02 10:42:57 -0400465 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100466 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200467 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100468 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200469 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100470 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200471 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100472 # Make a tight loop, server normally takes less than 1s to start.
473 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
474 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknownd364f4c2019-09-02 10:42:57 -0400475 echo "$3 START TIMEOUT"
476 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100477 break
478 fi
479 # Linux and *BSD support decimal arguments to sleep. On other
480 # OSes this may be a tight loop.
481 sleep 0.1 2>/dev/null || true
482 done
483 }
484else
Unknownd364f4c2019-09-02 10:42:57 -0400485 echo "Warning: lsof not available, wait_app_start = sleep"
486 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200487 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100488 }
489fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200490
Unknownd364f4c2019-09-02 10:42:57 -0400491# Wait for server process $2 to be listening on port $1.
492wait_server_start() {
493 wait_app_start $1 $2 "SERVER" $SRV_OUT
494}
495
496# Wait for proxy process $2 to be listening on port $1.
497wait_proxy_start() {
498 wait_app_start $1 $2 "PROXY" $PXY_OUT
499}
500
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100501# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100502# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100503# acceptable bounds
504check_server_hello_time() {
505 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100506 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100507 # Get the Unix timestamp for now
508 CUR_TIME=$(date +'%s')
509 THRESHOLD_IN_SECS=300
510
511 # Check if the ServerHello time was printed
512 if [ -z "$SERVER_HELLO_TIME" ]; then
513 return 1
514 fi
515
516 # Check the time in ServerHello is within acceptable bounds
517 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
518 # The time in ServerHello is at least 5 minutes before now
519 return 1
520 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100521 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100522 return 1
523 else
524 return 0
525 fi
526}
527
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100528# Get handshake memory usage from server or client output and put it into the variable specified by the first argument
529handshake_memory_get() {
530 OUTPUT_VARIABLE="$1"
531 OUTPUT_FILE="$2"
532
533 # Get memory usage from a pattern like "Heap memory usage after handshake: 23112 bytes. Peak memory usage was 33112"
534 MEM_USAGE=$(sed -n 's/.*Heap memory usage after handshake: //p' < "$OUTPUT_FILE" | grep -o "[0-9]*" | head -1)
535
536 # Check if memory usage was read
537 if [ -z "$MEM_USAGE" ]; then
538 echo "Error: Can not read the value of handshake memory usage"
539 return 1
540 else
541 eval "$OUTPUT_VARIABLE=$MEM_USAGE"
542 return 0
543 fi
544}
545
546# Get handshake memory usage from server or client output and check if this value
547# is not higher than the maximum given by the first argument
548handshake_memory_check() {
549 MAX_MEMORY="$1"
550 OUTPUT_FILE="$2"
551
552 # Get memory usage
553 if ! handshake_memory_get "MEMORY_USAGE" "$OUTPUT_FILE"; then
554 return 1
555 fi
556
557 # Check if memory usage is below max value
558 if [ "$MEMORY_USAGE" -gt "$MAX_MEMORY" ]; then
559 echo "\nFailed: Handshake memory usage was $MEMORY_USAGE bytes," \
560 "but should be below $MAX_MEMORY bytes"
561 return 1
562 else
563 return 0
564 fi
565}
566
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200567# wait for client to terminate and set CLI_EXIT
568# must be called right after starting the client
569wait_client_done() {
570 CLI_PID=$!
571
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200572 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
573 CLI_DELAY_FACTOR=1
574
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200575 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200576 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200577
578 wait $CLI_PID
579 CLI_EXIT=$?
580
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200581 kill $DOG_PID >/dev/null 2>&1
582 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200583
584 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100585
586 sleep $SRV_DELAY_SECONDS
587 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200588}
589
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200590# check if the given command uses dtls and sets global variable DTLS
591detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200592 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200593 DTLS=1
594 else
595 DTLS=0
596 fi
597}
598
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200599# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100600# Options: -s pattern pattern that must be present in server output
601# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100602# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100603# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100604# -S pattern pattern that must be absent in server output
605# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100606# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100607# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100608run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100609 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200610 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100611
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100612 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
613 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200614 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200615 # There was no request to run the test, so don't record its outcome.
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100616 return
617 fi
618
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100619 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100620
Paul Bakkerb7584a52016-05-10 10:50:43 +0100621 # Do we only run numbered tests?
622 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
623 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
624 else
625 SKIP_NEXT="YES"
626 fi
627
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200628 # does this test use a proxy?
629 if [ "X$1" = "X-p" ]; then
630 PXY_CMD="$2"
631 shift 2
632 else
633 PXY_CMD=""
634 fi
635
636 # get commands and client output
637 SRV_CMD="$1"
638 CLI_CMD="$2"
639 CLI_EXPECT="$3"
640 shift 3
641
Hanno Becker91e72c32019-05-10 14:38:42 +0100642 # Check if test uses files
643 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
644 if [ ! -z "$TEST_USES_FILES" ]; then
645 requires_config_enabled MBEDTLS_FS_IO
646 fi
647
Hanno Becker9d76d562018-11-16 17:27:29 +0000648 # Check if server forces ciphersuite
649 FORCE_CIPHERSUITE=$(echo "$SRV_CMD" | sed -n 's/^.*force_ciphersuite=\([a-zA-Z0-9\-]*\).*$/\1/p')
650 if [ ! -z "$FORCE_CIPHERSUITE" ]; then
651 requires_ciphersuite_enabled $FORCE_CIPHERSUITE
652 fi
653
654 # Check if client forces ciphersuite
655 FORCE_CIPHERSUITE=$(echo "$CLI_CMD" | sed -n 's/^.*force_ciphersuite=\([a-zA-Z0-9\-]*\).*$/\1/p')
656 if [ ! -z "$FORCE_CIPHERSUITE" ]; then
657 requires_ciphersuite_enabled $FORCE_CIPHERSUITE
658 fi
659
660 # should we skip?
661 if [ "X$SKIP_NEXT" = "XYES" ]; then
662 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200663 record_outcome "SKIP"
Hanno Becker9d76d562018-11-16 17:27:29 +0000664 SKIPS=$(( $SKIPS + 1 ))
665 return
666 fi
667
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200668 # fix client port
669 if [ -n "$PXY_CMD" ]; then
670 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
671 else
672 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
673 fi
674
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200675 # update DTLS variable
676 detect_dtls "$SRV_CMD"
677
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200678 # if the test uses DTLS but no custom proxy, add a simple proxy
679 # as it provides timing info that's useful to debug failures
680 if [ "X$PXY_CMD" = "X" -a "$DTLS" -eq 1 ]; then
681 PXY_CMD="$P_PXY"
682 fi
683
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100684 # prepend valgrind to our commands if active
685 if [ "$MEMCHECK" -gt 0 ]; then
686 if is_polar "$SRV_CMD"; then
687 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
688 fi
689 if is_polar "$CLI_CMD"; then
690 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
691 fi
692 fi
693
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200694 TIMES_LEFT=2
695 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200696 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200697
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200698 # run the commands
699 if [ -n "$PXY_CMD" ]; then
700 echo "$PXY_CMD" > $PXY_OUT
701 $PXY_CMD >> $PXY_OUT 2>&1 &
702 PXY_PID=$!
Unknownd364f4c2019-09-02 10:42:57 -0400703 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200704 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200705
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200706 check_osrv_dtls
707 echo "$SRV_CMD" > $SRV_OUT
708 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
709 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100710 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200711
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200712 echo "$CLI_CMD" > $CLI_OUT
713 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
714 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100715
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100716 sleep 0.05
717
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200718 # terminate the server (and the proxy)
719 kill $SRV_PID
720 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100721
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200722 if [ -n "$PXY_CMD" ]; then
723 kill $PXY_PID >/dev/null 2>&1
724 wait $PXY_PID
725 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100726
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200727 # retry only on timeouts
728 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
729 printf "RETRY "
730 else
731 TIMES_LEFT=0
732 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200733 done
734
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100735 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200736 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100737 # expected client exit to incorrectly succeed in case of catastrophic
738 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100739 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200740 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100741 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100742 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100743 return
744 fi
745 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100746 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200747 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100748 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100749 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100750 return
751 fi
752 fi
753
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100754 # check server exit code
755 if [ $? != 0 ]; then
756 fail "server fail"
757 return
758 fi
759
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100760 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100761 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
762 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100763 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200764 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100765 return
766 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100767
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100768 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200769 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100770 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100771 while [ $# -gt 0 ]
772 do
773 case $1 in
774 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100775 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 +0100776 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100777 return
778 fi
779 ;;
780
781 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100782 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 +0100783 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100784 return
785 fi
786 ;;
787
788 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100789 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 +0100790 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100791 return
792 fi
793 ;;
794
795 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100796 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 +0100797 fail "pattern '$2' MUST NOT be present in the Client output"
798 return
799 fi
800 ;;
801
802 # The filtering in the following two options (-u and -U) do the following
803 # - ignore valgrind output
Antonin Décimo36e89b52019-01-23 15:24:37 +0100804 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100805 # - keep one of each non-unique line
806 # - count how many lines remain
807 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
808 # if there were no duplicates.
809 "-U")
810 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
811 fail "lines following pattern '$2' must be unique in Server output"
812 return
813 fi
814 ;;
815
816 "-u")
817 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
818 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100819 return
820 fi
821 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100822 "-F")
823 if ! $2 "$SRV_OUT"; then
824 fail "function call to '$2' failed on Server output"
825 return
826 fi
827 ;;
828 "-f")
829 if ! $2 "$CLI_OUT"; then
830 fail "function call to '$2' failed on Client output"
831 return
832 fi
833 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100834
835 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200836 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100837 exit 1
838 esac
839 shift 2
840 done
841
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100842 # check valgrind's results
843 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200844 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100845 fail "Server has memory errors"
846 return
847 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200848 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100849 fail "Client has memory errors"
850 return
851 fi
852 fi
853
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100854 # if we're here, everything is ok
Gilles Peskine560280b2019-09-16 15:17:38 +0200855 record_outcome "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100856 if [ "$PRESERVE_LOGS" -gt 0 ]; then
857 mv $SRV_OUT o-srv-${TESTS}.log
858 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100859 if [ -n "$PXY_CMD" ]; then
860 mv $PXY_OUT o-pxy-${TESTS}.log
861 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100862 fi
863
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200864 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100865}
866
Hanno Becker9b5853c2018-11-16 17:28:40 +0000867run_test_psa() {
868 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
Hanno Beckere9420c22018-11-20 11:37:34 +0000869 run_test "PSA-supported ciphersuite: $1" \
Hanno Becker4c8c7aa2019-04-10 09:25:41 +0100870 "$P_SRV debug_level=3 force_version=tls1_2" \
871 "$P_CLI debug_level=3 force_version=tls1_2 force_ciphersuite=$1" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000872 0 \
873 -c "Successfully setup PSA-based decryption cipher context" \
874 -c "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500875 -c "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500876 -c "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000877 -s "Successfully setup PSA-based decryption cipher context" \
878 -s "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500879 -s "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500880 -s "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000881 -C "Failed to setup PSA-based cipher context"\
882 -S "Failed to setup PSA-based cipher context"\
883 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000884 -c "Perform PSA-based ECDH computation."\
Andrzej Kureke85414e2019-01-15 05:23:59 -0500885 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000886 -S "error" \
887 -C "error"
888}
889
Hanno Becker354e2482019-01-08 11:40:25 +0000890run_test_psa_force_curve() {
891 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
892 run_test "PSA - ECDH with $1" \
893 "$P_SRV debug_level=4 force_version=tls1_2" \
894 "$P_CLI debug_level=4 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=$1" \
895 0 \
Hanno Becker28f78442019-02-18 16:47:50 +0000896 -c "Successfully setup PSA-based decryption cipher context" \
897 -c "Successfully setup PSA-based encryption cipher context" \
898 -c "PSA calc verify" \
899 -c "calc PSA finished" \
900 -s "Successfully setup PSA-based decryption cipher context" \
901 -s "Successfully setup PSA-based encryption cipher context" \
902 -s "PSA calc verify" \
903 -s "calc PSA finished" \
904 -C "Failed to setup PSA-based cipher context"\
905 -S "Failed to setup PSA-based cipher context"\
Hanno Becker354e2482019-01-08 11:40:25 +0000906 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000907 -c "Perform PSA-based ECDH computation."\
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100908 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200909 -S "error" \
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200910 -C "error"
911}
912
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100913# Test that the server's memory usage after a handshake is reduced when a client specifies
914# a maximum fragment length.
915# first argument ($1) is MFL for SSL client
916# second argument ($2) is memory usage for SSL client with default MFL (16k)
917run_test_memory_after_hanshake_with_mfl()
918{
919 # The test passes if the difference is around 2*(16k-MFL)
920 local MEMORY_USAGE_LIMIT="$(( $2 - ( 2 * ( 16384 - $1 )) ))"
921
922 # Leave some margin for robustness
923 MEMORY_USAGE_LIMIT="$(( ( MEMORY_USAGE_LIMIT * 110 ) / 100 ))"
924
925 run_test "Handshake memory usage (MFL $1)" \
926 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
927 "$P_CLI debug_level=3 force_version=tls1_2 \
928 crt_file=data_files/server5.crt key_file=data_files/server5.key \
929 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM max_frag_len=$1" \
930 0 \
931 -F "handshake_memory_check $MEMORY_USAGE_LIMIT"
932}
933
934
935# Test that the server's memory usage after a handshake is reduced when a client specifies
936# different values of Maximum Fragment Length: default (16k), 4k, 2k, 1k and 512 bytes
937run_tests_memory_after_hanshake()
938{
939 # all tests in this sequence requires the same configuration (see requires_config_enabled())
940 SKIP_THIS_TESTS="$SKIP_NEXT"
941
942 # first test with default MFU is to get reference memory usage
943 MEMORY_USAGE_MFL_16K=0
944 run_test "Handshake memory usage initial (MFL 16384 - default)" \
945 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
946 "$P_CLI debug_level=3 force_version=tls1_2 \
947 crt_file=data_files/server5.crt key_file=data_files/server5.key \
948 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM" \
949 0 \
950 -F "handshake_memory_get MEMORY_USAGE_MFL_16K"
951
952 SKIP_NEXT="$SKIP_THIS_TESTS"
953 run_test_memory_after_hanshake_with_mfl 4096 "$MEMORY_USAGE_MFL_16K"
954
955 SKIP_NEXT="$SKIP_THIS_TESTS"
956 run_test_memory_after_hanshake_with_mfl 2048 "$MEMORY_USAGE_MFL_16K"
957
958 SKIP_NEXT="$SKIP_THIS_TESTS"
959 run_test_memory_after_hanshake_with_mfl 1024 "$MEMORY_USAGE_MFL_16K"
960
961 SKIP_NEXT="$SKIP_THIS_TESTS"
962 run_test_memory_after_hanshake_with_mfl 512 "$MEMORY_USAGE_MFL_16K"
963}
964
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100965cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200966 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Piotr Nowicki3de298f2020-04-16 14:35:19 +0200967 rm -f context_srv.txt
968 rm -f context_cli.txt
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200969 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
970 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
971 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
972 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100973 exit 1
974}
975
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100976#
977# MAIN
978#
979
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100980get_options "$@"
981
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100982# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100983P_SRV_BIN="${P_SRV%%[ ]*}"
984P_CLI_BIN="${P_CLI%%[ ]*}"
985P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100986if [ ! -x "$P_SRV_BIN" ]; then
987 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100988 exit 1
989fi
Hanno Becker17c04932017-10-10 14:44:53 +0100990if [ ! -x "$P_CLI_BIN" ]; then
991 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100992 exit 1
993fi
Hanno Becker17c04932017-10-10 14:44:53 +0100994if [ ! -x "$P_PXY_BIN" ]; then
995 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200996 exit 1
997fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100998if [ "$MEMCHECK" -gt 0 ]; then
999 if which valgrind >/dev/null 2>&1; then :; else
1000 echo "Memcheck not possible. Valgrind not found"
1001 exit 1
1002 fi
1003fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001004if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1005 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001006 exit 1
1007fi
1008
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001009# used by watchdog
1010MAIN_PID="$$"
1011
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001012# We use somewhat arbitrary delays for tests:
1013# - how long do we wait for the server to start (when lsof not available)?
1014# - how long do we allow for the client to finish?
1015# (not to check performance, just to avoid waiting indefinitely)
1016# Things are slower with valgrind, so give extra time here.
1017#
1018# Note: without lsof, there is a trade-off between the running time of this
1019# script and the risk of spurious errors because we didn't wait long enough.
1020# The watchdog delay on the other hand doesn't affect normal running time of
1021# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001022if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001023 START_DELAY=6
1024 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001025else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001026 START_DELAY=2
1027 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001028fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001029
1030# some particular tests need more time:
1031# - for the client, we multiply the usual watchdog limit by a factor
1032# - for the server, we sleep for a number of seconds after the client exits
1033# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001034CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001035SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001036
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001037# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001038# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001039P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1040P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001041P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +02001042O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001043O_CLI="$O_CLI -connect localhost:+SRV_PORT"
1044G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001045G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001046
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001047if [ -n "${OPENSSL_LEGACY:-}" ]; then
1048 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1049 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1050fi
1051
Hanno Becker58e9dc32018-08-17 15:53:21 +01001052if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001053 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1054fi
1055
Hanno Becker58e9dc32018-08-17 15:53:21 +01001056if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001057 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001058fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001059
Gilles Peskine62469d92017-05-10 10:13:59 +02001060# Allow SHA-1, because many of our test certificates use it
1061P_SRV="$P_SRV allow_sha1=1"
1062P_CLI="$P_CLI allow_sha1=1"
1063
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001064# Also pick a unique name for intermediate files
1065SRV_OUT="srv_out.$$"
1066CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001067PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001068SESSION="session.$$"
1069
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001070SKIP_NEXT="NO"
1071
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001072trap cleanup INT TERM HUP
1073
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001074# Basic test
1075
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001076# Checks that:
1077# - things work with all ciphersuites active (used with config-full in all.sh)
1078# - the expected (highest security) parameters are selected
1079# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001080run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001081 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001082 "$P_CLI" \
1083 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001084 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001085 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001086 -s "client hello v3, signature_algorithm ext: 6" \
1087 -s "ECDHE curve: secp521r1" \
1088 -S "error" \
1089 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001090
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001091run_test "Default, DTLS" \
1092 "$P_SRV dtls=1" \
1093 "$P_CLI dtls=1" \
1094 0 \
1095 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001096 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001097
Manuel Pégourié-Gonnard342d2ca2020-01-02 11:58:00 +01001098requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1099run_test "Default (compression enabled)" \
1100 "$P_SRV debug_level=3" \
1101 "$P_CLI debug_level=3" \
1102 0 \
1103 -s "Allocating compression buffer" \
1104 -c "Allocating compression buffer" \
1105 -s "Record expansion is unknown (compression)" \
1106 -c "Record expansion is unknown (compression)" \
1107 -S "error" \
1108 -C "error"
1109
Hanno Becker746aaf32019-03-28 15:25:23 +00001110requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1111run_test "CA callback on client" \
1112 "$P_SRV debug_level=3" \
1113 "$P_CLI ca_callback=1 debug_level=3 " \
1114 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001115 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001116 -S "error" \
1117 -C "error"
1118
1119requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1120requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1121requires_config_enabled MBEDTLS_ECDSA_C
1122requires_config_enabled MBEDTLS_SHA256_C
1123run_test "CA callback on server" \
1124 "$P_SRV auth_mode=required" \
1125 "$P_CLI ca_callback=1 debug_level=3 crt_file=data_files/server5.crt \
1126 key_file=data_files/server5.key" \
1127 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001128 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001129 -s "Verifying peer X.509 certificate... ok" \
1130 -S "error" \
1131 -C "error"
1132
Manuel Pégourié-Gonnardcfdf8f42018-11-08 09:52:25 +01001133# Test using an opaque private key for client authentication
1134requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
1135requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1136requires_config_enabled MBEDTLS_ECDSA_C
1137requires_config_enabled MBEDTLS_SHA256_C
1138run_test "Opaque key for client authentication" \
1139 "$P_SRV auth_mode=required" \
1140 "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \
1141 key_file=data_files/server5.key" \
1142 0 \
1143 -c "key type: Opaque" \
1144 -s "Verifying peer X.509 certificate... ok" \
1145 -S "error" \
1146 -C "error"
1147
Hanno Becker9b5853c2018-11-16 17:28:40 +00001148# Test ciphersuites which we expect to be fully supported by PSA Crypto
1149# and check that we don't fall back to Mbed TLS' internal crypto primitives.
1150run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM
1151run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
1152run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM
1153run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8
1154run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
1155run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384
1156run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA
1157run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
1158run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384
1159
Hanno Becker354e2482019-01-08 11:40:25 +00001160requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1161run_test_psa_force_curve "secp521r1"
1162requires_config_enabled MBEDTLS_ECP_DP_BP512R1_ENABLED
1163run_test_psa_force_curve "brainpoolP512r1"
1164requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
1165run_test_psa_force_curve "secp384r1"
1166requires_config_enabled MBEDTLS_ECP_DP_BP384R1_ENABLED
1167run_test_psa_force_curve "brainpoolP384r1"
1168requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED
1169run_test_psa_force_curve "secp256r1"
1170requires_config_enabled MBEDTLS_ECP_DP_SECP256K1_ENABLED
1171run_test_psa_force_curve "secp256k1"
1172requires_config_enabled MBEDTLS_ECP_DP_BP256R1_ENABLED
1173run_test_psa_force_curve "brainpoolP256r1"
1174requires_config_enabled MBEDTLS_ECP_DP_SECP224R1_ENABLED
1175run_test_psa_force_curve "secp224r1"
1176requires_config_enabled MBEDTLS_ECP_DP_SECP224K1_ENABLED
1177run_test_psa_force_curve "secp224k1"
1178requires_config_enabled MBEDTLS_ECP_DP_SECP192R1_ENABLED
1179run_test_psa_force_curve "secp192r1"
1180requires_config_enabled MBEDTLS_ECP_DP_SECP192K1_ENABLED
1181run_test_psa_force_curve "secp192k1"
1182
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001183# Test current time in ServerHello
1184requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001185run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001186 "$P_SRV debug_level=3" \
1187 "$P_CLI debug_level=3" \
1188 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001189 -f "check_server_hello_time" \
1190 -F "check_server_hello_time"
1191
Simon Butcher8e004102016-10-14 00:48:33 +01001192# Test for uniqueness of IVs in AEAD ciphersuites
1193run_test "Unique IV in GCM" \
1194 "$P_SRV exchanges=20 debug_level=4" \
1195 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1196 0 \
1197 -u "IV used" \
1198 -U "IV used"
1199
Janos Follathee11be62019-04-04 12:03:30 +01001200# Tests for certificate verification callback
1201run_test "Configuration-specific CRT verification callback" \
1202 "$P_SRV debug_level=3" \
1203 "$P_CLI context_crt_cb=0 debug_level=3" \
1204 0 \
Janos Follathee11be62019-04-04 12:03:30 +01001205 -S "error" \
1206 -c "Verify requested for " \
1207 -c "Use configuration-specific verification callback" \
1208 -C "Use context-specific verification callback" \
1209 -C "error"
1210
Hanno Beckerefb440a2019-04-03 13:04:33 +01001211run_test "Context-specific CRT verification callback" \
1212 "$P_SRV debug_level=3" \
1213 "$P_CLI context_crt_cb=1 debug_level=3" \
1214 0 \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001215 -S "error" \
Janos Follathee11be62019-04-04 12:03:30 +01001216 -c "Verify requested for " \
1217 -c "Use context-specific verification callback" \
1218 -C "Use configuration-specific verification callback" \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001219 -C "error"
1220
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001221# Tests for rc4 option
1222
Simon Butchera410af52016-05-19 22:12:18 +01001223requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001224run_test "RC4: server disabled, client enabled" \
1225 "$P_SRV" \
1226 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1227 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001228 -s "SSL - The server has no ciphersuites in common"
1229
Simon Butchera410af52016-05-19 22:12:18 +01001230requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001231run_test "RC4: server half, client enabled" \
1232 "$P_SRV arc4=1" \
1233 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1234 1 \
1235 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001236
1237run_test "RC4: server enabled, client disabled" \
1238 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1239 "$P_CLI" \
1240 1 \
1241 -s "SSL - The server has no ciphersuites in common"
1242
1243run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001244 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001245 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1246 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001247 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001248 -S "SSL - The server has no ciphersuites in common"
1249
Hanno Beckerd26bb202018-08-17 09:54:10 +01001250# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1251
1252requires_gnutls
1253requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1254run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1255 "$G_SRV"\
1256 "$P_CLI force_version=tls1_1" \
1257 0
1258
1259requires_gnutls
1260requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1261run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1262 "$G_SRV"\
1263 "$P_CLI force_version=tls1" \
1264 0
1265
Gilles Peskinebc70a182017-05-09 15:59:24 +02001266# Tests for SHA-1 support
1267
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001268requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001269run_test "SHA-1 forbidden by default in server certificate" \
1270 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1271 "$P_CLI debug_level=2 allow_sha1=0" \
1272 1 \
1273 -c "The certificate is signed with an unacceptable hash"
1274
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001275requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02001276run_test "SHA-1 allowed by default in server certificate" \
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001277 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1278 "$P_CLI debug_level=2 allow_sha1=0" \
1279 0
1280
Gilles Peskinebc70a182017-05-09 15:59:24 +02001281run_test "SHA-1 explicitly allowed in server certificate" \
1282 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1283 "$P_CLI allow_sha1=1" \
1284 0
1285
1286run_test "SHA-256 allowed by default in server certificate" \
1287 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1288 "$P_CLI allow_sha1=0" \
1289 0
1290
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001291requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001292run_test "SHA-1 forbidden by default in client certificate" \
1293 "$P_SRV auth_mode=required allow_sha1=0" \
1294 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1295 1 \
1296 -s "The certificate is signed with an unacceptable hash"
1297
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001298requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02001299run_test "SHA-1 allowed by default in client certificate" \
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001300 "$P_SRV auth_mode=required allow_sha1=0" \
1301 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1302 0
1303
Gilles Peskinebc70a182017-05-09 15:59:24 +02001304run_test "SHA-1 explicitly allowed in client certificate" \
1305 "$P_SRV auth_mode=required allow_sha1=1" \
1306 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1307 0
1308
1309run_test "SHA-256 allowed by default in client certificate" \
1310 "$P_SRV auth_mode=required allow_sha1=0" \
1311 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1312 0
1313
Hanno Becker7ae8a762018-08-14 15:43:35 +01001314# Tests for datagram packing
1315run_test "DTLS: multiple records in same datagram, client and server" \
1316 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1317 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1318 0 \
1319 -c "next record in same datagram" \
1320 -s "next record in same datagram"
1321
1322run_test "DTLS: multiple records in same datagram, client only" \
1323 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1324 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1325 0 \
1326 -s "next record in same datagram" \
1327 -C "next record in same datagram"
1328
1329run_test "DTLS: multiple records in same datagram, server only" \
1330 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1331 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1332 0 \
1333 -S "next record in same datagram" \
1334 -c "next record in same datagram"
1335
1336run_test "DTLS: multiple records in same datagram, neither client nor server" \
1337 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1338 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1339 0 \
1340 -S "next record in same datagram" \
1341 -C "next record in same datagram"
1342
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001343# Tests for Truncated HMAC extension
1344
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001345run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001346 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001347 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001348 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001349 -s "dumping 'expected mac' (20 bytes)" \
1350 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001351
Hanno Becker32c55012017-11-10 08:42:54 +00001352requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001353run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001354 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001355 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001356 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001357 -s "dumping 'expected mac' (20 bytes)" \
1358 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001359
Hanno Becker32c55012017-11-10 08:42:54 +00001360requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001361run_test "Truncated HMAC: client enabled, server default" \
1362 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001363 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001364 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001365 -s "dumping 'expected mac' (20 bytes)" \
1366 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001367
Hanno Becker32c55012017-11-10 08:42:54 +00001368requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001369run_test "Truncated HMAC: client enabled, server disabled" \
1370 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001371 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001372 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001373 -s "dumping 'expected mac' (20 bytes)" \
1374 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001375
Hanno Becker32c55012017-11-10 08:42:54 +00001376requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001377run_test "Truncated HMAC: client disabled, server enabled" \
1378 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001379 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001380 0 \
1381 -s "dumping 'expected mac' (20 bytes)" \
1382 -S "dumping 'expected mac' (10 bytes)"
1383
1384requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001385run_test "Truncated HMAC: client enabled, server enabled" \
1386 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001387 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001388 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001389 -S "dumping 'expected mac' (20 bytes)" \
1390 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001391
Hanno Becker4c4f4102017-11-10 09:16:05 +00001392run_test "Truncated HMAC, DTLS: client default, server default" \
1393 "$P_SRV dtls=1 debug_level=4" \
1394 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1395 0 \
1396 -s "dumping 'expected mac' (20 bytes)" \
1397 -S "dumping 'expected mac' (10 bytes)"
1398
1399requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1400run_test "Truncated HMAC, DTLS: client disabled, server default" \
1401 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001402 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001403 0 \
1404 -s "dumping 'expected mac' (20 bytes)" \
1405 -S "dumping 'expected mac' (10 bytes)"
1406
1407requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1408run_test "Truncated HMAC, DTLS: client enabled, server default" \
1409 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001410 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001411 0 \
1412 -s "dumping 'expected mac' (20 bytes)" \
1413 -S "dumping 'expected mac' (10 bytes)"
1414
1415requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1416run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1417 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001418 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001419 0 \
1420 -s "dumping 'expected mac' (20 bytes)" \
1421 -S "dumping 'expected mac' (10 bytes)"
1422
1423requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1424run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1425 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001426 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001427 0 \
1428 -s "dumping 'expected mac' (20 bytes)" \
1429 -S "dumping 'expected mac' (10 bytes)"
1430
1431requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1432run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1433 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001434 "$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 +01001435 0 \
1436 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001437 -s "dumping 'expected mac' (10 bytes)"
1438
Jarno Lamsa2937d812019-06-04 11:33:23 +03001439# Tests for Context serialization
1440
1441requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001442run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001443 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001444 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1445 0 \
1446 -c "Deserializing connection..." \
1447 -S "Deserializing connection..."
1448
1449requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1450run_test "Context serialization, client serializes, ChaChaPoly" \
1451 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1452 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1453 0 \
1454 -c "Deserializing connection..." \
1455 -S "Deserializing connection..."
1456
1457requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1458run_test "Context serialization, client serializes, GCM" \
1459 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1460 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001461 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001462 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001463 -S "Deserializing connection..."
1464
1465requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001466requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1467run_test "Context serialization, client serializes, with CID" \
1468 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1469 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1470 0 \
1471 -c "Deserializing connection..." \
1472 -S "Deserializing connection..."
1473
1474requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001475run_test "Context serialization, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001476 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001477 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1478 0 \
1479 -C "Deserializing connection..." \
1480 -s "Deserializing connection..."
1481
1482requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1483run_test "Context serialization, server serializes, ChaChaPoly" \
1484 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1485 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1486 0 \
1487 -C "Deserializing connection..." \
1488 -s "Deserializing connection..."
1489
1490requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1491run_test "Context serialization, server serializes, GCM" \
1492 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1493 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001494 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001495 -C "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001496 -s "Deserializing connection..."
1497
1498requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001499requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1500run_test "Context serialization, server serializes, with CID" \
1501 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1502 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1503 0 \
1504 -C "Deserializing connection..." \
1505 -s "Deserializing connection..."
1506
1507requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001508run_test "Context serialization, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001509 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001510 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1511 0 \
1512 -c "Deserializing connection..." \
1513 -s "Deserializing connection..."
1514
1515requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1516run_test "Context serialization, both serialize, ChaChaPoly" \
1517 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1518 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1519 0 \
1520 -c "Deserializing connection..." \
1521 -s "Deserializing connection..."
1522
1523requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1524run_test "Context serialization, both serialize, GCM" \
1525 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1526 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001527 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001528 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001529 -s "Deserializing connection..."
1530
Jarno Lamsac2376f02019-06-06 10:44:14 +03001531requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001532requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1533run_test "Context serialization, both serialize, with CID" \
1534 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1535 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1536 0 \
1537 -c "Deserializing connection..." \
1538 -s "Deserializing connection..."
1539
1540requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001541run_test "Context serialization, re-init, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001542 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001543 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1544 0 \
1545 -c "Deserializing connection..." \
1546 -S "Deserializing connection..."
1547
1548requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1549run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1550 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1551 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1552 0 \
1553 -c "Deserializing connection..." \
1554 -S "Deserializing connection..."
1555
1556requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1557run_test "Context serialization, re-init, client serializes, GCM" \
1558 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1559 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001560 0 \
1561 -c "Deserializing connection..." \
1562 -S "Deserializing connection..."
1563
Jarno Lamsac2376f02019-06-06 10:44:14 +03001564requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001565requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1566run_test "Context serialization, re-init, client serializes, with CID" \
1567 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1568 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1569 0 \
1570 -c "Deserializing connection..." \
1571 -S "Deserializing connection..."
1572
1573requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001574run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001575 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001576 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1577 0 \
1578 -C "Deserializing connection..." \
1579 -s "Deserializing connection..."
1580
1581requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1582run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1583 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1584 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1585 0 \
1586 -C "Deserializing connection..." \
1587 -s "Deserializing connection..."
1588
1589requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1590run_test "Context serialization, re-init, server serializes, GCM" \
1591 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1592 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001593 0 \
1594 -C "Deserializing connection..." \
1595 -s "Deserializing connection..."
1596
Jarno Lamsac2376f02019-06-06 10:44:14 +03001597requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001598requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1599run_test "Context serialization, re-init, server serializes, with CID" \
1600 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1601 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1602 0 \
1603 -C "Deserializing connection..." \
1604 -s "Deserializing connection..."
1605
1606requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001607run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001608 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001609 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1610 0 \
1611 -c "Deserializing connection..." \
1612 -s "Deserializing connection..."
1613
1614requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1615run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1616 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1617 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1618 0 \
1619 -c "Deserializing connection..." \
1620 -s "Deserializing connection..."
1621
1622requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1623run_test "Context serialization, re-init, both serialize, GCM" \
1624 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1625 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001626 0 \
1627 -c "Deserializing connection..." \
1628 -s "Deserializing connection..."
1629
Hanno Becker1b18fd32019-08-30 11:18:59 +01001630requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1631requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1632run_test "Context serialization, re-init, both serialize, with CID" \
1633 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1634 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1635 0 \
1636 -c "Deserializing connection..." \
1637 -s "Deserializing connection..."
1638
Piotr Nowicki3de298f2020-04-16 14:35:19 +02001639requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1640run_test "Saving the serialized context to a file" \
1641 "$P_SRV dtls=1 serialize=1 context_file=context_srv.txt" \
1642 "$P_CLI dtls=1 serialize=1 context_file=context_cli.txt" \
1643 0 \
1644 -s "Save serialized context to a file... ok" \
1645 -c "Save serialized context to a file... ok"
1646rm -f context_srv.txt
1647rm -f context_cli.txt
1648
Hanno Becker7cf463e2019-04-09 18:08:47 +01001649# Tests for DTLS Connection ID extension
1650
Hanno Becker7cf463e2019-04-09 18:08:47 +01001651# So far, the CID API isn't implemented, so we can't
1652# grep for output witnessing its use. This needs to be
1653# changed once the CID extension is implemented.
1654
Hanno Beckera0e20d02019-05-15 14:03:01 +01001655requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001656run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001657 "$P_SRV debug_level=3 dtls=1 cid=0" \
1658 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1659 0 \
1660 -s "Disable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001661 -s "found CID extension" \
1662 -s "Client sent CID extension, but CID disabled" \
Hanno Becker6b78c832019-04-25 17:01:43 +01001663 -c "Enable use of CID extension." \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001664 -c "client hello, adding CID extension" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001665 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001666 -C "found CID extension" \
1667 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001668 -C "Copy CIDs into SSL transform" \
1669 -c "Use of Connection ID was rejected by the server"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001670
Hanno Beckera0e20d02019-05-15 14:03:01 +01001671requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001672run_test "Connection ID: Cli disabled, Srv enabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001673 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1674 "$P_CLI debug_level=3 dtls=1 cid=0" \
1675 0 \
1676 -c "Disable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001677 -C "client hello, adding CID extension" \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001678 -S "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001679 -s "Enable use of CID extension." \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001680 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001681 -C "found CID extension" \
1682 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001683 -C "Copy CIDs into SSL transform" \
Hanno Beckerb3e9dd52019-05-08 13:19:53 +01001684 -s "Use of Connection ID was not offered by client"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001685
Hanno Beckera0e20d02019-05-15 14:03:01 +01001686requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001687run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001688 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1689 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1690 0 \
1691 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001692 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001693 -c "client hello, adding CID extension" \
1694 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001695 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001696 -s "server hello, adding CID extension" \
1697 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001698 -c "Use of CID extension negotiated" \
1699 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001700 -c "Copy CIDs into SSL transform" \
1701 -c "Peer CID (length 2 Bytes): de ad" \
1702 -s "Peer CID (length 2 Bytes): be ef" \
1703 -s "Use of Connection ID has been negotiated" \
1704 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001705
Hanno Beckera0e20d02019-05-15 14:03:01 +01001706requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001707run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001708 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001709 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1710 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1711 0 \
1712 -c "Enable use of CID extension." \
1713 -s "Enable use of CID extension." \
1714 -c "client hello, adding CID extension" \
1715 -s "found CID extension" \
1716 -s "Use of CID extension negotiated" \
1717 -s "server hello, adding CID extension" \
1718 -c "found CID extension" \
1719 -c "Use of CID extension negotiated" \
1720 -s "Copy CIDs into SSL transform" \
1721 -c "Copy CIDs into SSL transform" \
1722 -c "Peer CID (length 2 Bytes): de ad" \
1723 -s "Peer CID (length 2 Bytes): be ef" \
1724 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001725 -c "Use of Connection ID has been negotiated" \
1726 -c "ignoring unexpected CID" \
1727 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001728
Hanno Beckera0e20d02019-05-15 14:03:01 +01001729requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001730run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1731 -p "$P_PXY mtu=800" \
1732 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1733 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1734 0 \
1735 -c "Enable use of CID extension." \
1736 -s "Enable use of CID extension." \
1737 -c "client hello, adding CID extension" \
1738 -s "found CID extension" \
1739 -s "Use of CID extension negotiated" \
1740 -s "server hello, adding CID extension" \
1741 -c "found CID extension" \
1742 -c "Use of CID extension negotiated" \
1743 -s "Copy CIDs into SSL transform" \
1744 -c "Copy CIDs into SSL transform" \
1745 -c "Peer CID (length 2 Bytes): de ad" \
1746 -s "Peer CID (length 2 Bytes): be ef" \
1747 -s "Use of Connection ID has been negotiated" \
1748 -c "Use of Connection ID has been negotiated"
1749
Hanno Beckera0e20d02019-05-15 14:03:01 +01001750requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001751run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001752 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001753 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1754 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1755 0 \
1756 -c "Enable use of CID extension." \
1757 -s "Enable use of CID extension." \
1758 -c "client hello, adding CID extension" \
1759 -s "found CID extension" \
1760 -s "Use of CID extension negotiated" \
1761 -s "server hello, adding CID extension" \
1762 -c "found CID extension" \
1763 -c "Use of CID extension negotiated" \
1764 -s "Copy CIDs into SSL transform" \
1765 -c "Copy CIDs into SSL transform" \
1766 -c "Peer CID (length 2 Bytes): de ad" \
1767 -s "Peer CID (length 2 Bytes): be ef" \
1768 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001769 -c "Use of Connection ID has been negotiated" \
1770 -c "ignoring unexpected CID" \
1771 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001772
Hanno Beckera0e20d02019-05-15 14:03:01 +01001773requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001774run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001775 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1776 "$P_CLI debug_level=3 dtls=1 cid=1" \
1777 0 \
1778 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001779 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001780 -c "client hello, adding CID extension" \
1781 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001782 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001783 -s "server hello, adding CID extension" \
1784 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001785 -c "Use of CID extension negotiated" \
1786 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001787 -c "Copy CIDs into SSL transform" \
1788 -c "Peer CID (length 4 Bytes): de ad be ef" \
1789 -s "Peer CID (length 0 Bytes):" \
1790 -s "Use of Connection ID has been negotiated" \
1791 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001792
Hanno Beckera0e20d02019-05-15 14:03:01 +01001793requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001794run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001795 "$P_SRV debug_level=3 dtls=1 cid=1" \
1796 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1797 0 \
1798 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001799 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001800 -c "client hello, adding CID extension" \
1801 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001802 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001803 -s "server hello, adding CID extension" \
1804 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001805 -c "Use of CID extension negotiated" \
1806 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001807 -c "Copy CIDs into SSL transform" \
1808 -s "Peer CID (length 4 Bytes): de ad be ef" \
1809 -c "Peer CID (length 0 Bytes):" \
1810 -s "Use of Connection ID has been negotiated" \
1811 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001812
Hanno Beckera0e20d02019-05-15 14:03:01 +01001813requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001814run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001815 "$P_SRV debug_level=3 dtls=1 cid=1" \
1816 "$P_CLI debug_level=3 dtls=1 cid=1" \
1817 0 \
1818 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001819 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001820 -c "client hello, adding CID extension" \
1821 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001822 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001823 -s "server hello, adding CID extension" \
1824 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001825 -c "Use of CID extension negotiated" \
1826 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001827 -c "Copy CIDs into SSL transform" \
1828 -S "Use of Connection ID has been negotiated" \
1829 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001830
Hanno Beckera0e20d02019-05-15 14:03:01 +01001831requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001832run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001833 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1834 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1835 0 \
1836 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001837 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001838 -c "client hello, adding CID extension" \
1839 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001840 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001841 -s "server hello, adding CID extension" \
1842 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001843 -c "Use of CID extension negotiated" \
1844 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001845 -c "Copy CIDs into SSL transform" \
1846 -c "Peer CID (length 2 Bytes): de ad" \
1847 -s "Peer CID (length 2 Bytes): be ef" \
1848 -s "Use of Connection ID has been negotiated" \
1849 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001850
Hanno Beckera0e20d02019-05-15 14:03:01 +01001851requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001852run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001853 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1854 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1855 0 \
1856 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001857 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001858 -c "client hello, adding CID extension" \
1859 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001860 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001861 -s "server hello, adding CID extension" \
1862 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001863 -c "Use of CID extension negotiated" \
1864 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001865 -c "Copy CIDs into SSL transform" \
1866 -c "Peer CID (length 4 Bytes): de ad be ef" \
1867 -s "Peer CID (length 0 Bytes):" \
1868 -s "Use of Connection ID has been negotiated" \
1869 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001870
Hanno Beckera0e20d02019-05-15 14:03:01 +01001871requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001872run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001873 "$P_SRV debug_level=3 dtls=1 cid=1" \
1874 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1875 0 \
1876 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001877 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001878 -c "client hello, adding CID extension" \
1879 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001880 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001881 -s "server hello, adding CID extension" \
1882 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001883 -c "Use of CID extension negotiated" \
1884 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001885 -c "Copy CIDs into SSL transform" \
1886 -s "Peer CID (length 4 Bytes): de ad be ef" \
1887 -c "Peer CID (length 0 Bytes):" \
1888 -s "Use of Connection ID has been negotiated" \
1889 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001890
Hanno Beckera0e20d02019-05-15 14:03:01 +01001891requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001892run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001893 "$P_SRV debug_level=3 dtls=1 cid=1" \
1894 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1895 0 \
1896 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001897 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001898 -c "client hello, adding CID extension" \
1899 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001900 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001901 -s "server hello, adding CID extension" \
1902 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001903 -c "Use of CID extension negotiated" \
1904 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001905 -c "Copy CIDs into SSL transform" \
1906 -S "Use of Connection ID has been negotiated" \
1907 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001908
Hanno Beckera0e20d02019-05-15 14:03:01 +01001909requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001910run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001911 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1912 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1913 0 \
1914 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001915 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001916 -c "client hello, adding CID extension" \
1917 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001918 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001919 -s "server hello, adding CID extension" \
1920 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001921 -c "Use of CID extension negotiated" \
1922 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001923 -c "Copy CIDs into SSL transform" \
1924 -c "Peer CID (length 2 Bytes): de ad" \
1925 -s "Peer CID (length 2 Bytes): be ef" \
1926 -s "Use of Connection ID has been negotiated" \
1927 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001928
Hanno Beckera0e20d02019-05-15 14:03:01 +01001929requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001930run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001931 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1932 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1933 0 \
1934 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001935 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001936 -c "client hello, adding CID extension" \
1937 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001938 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001939 -s "server hello, adding CID extension" \
1940 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001941 -c "Use of CID extension negotiated" \
1942 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001943 -c "Copy CIDs into SSL transform" \
1944 -c "Peer CID (length 4 Bytes): de ad be ef" \
1945 -s "Peer CID (length 0 Bytes):" \
1946 -s "Use of Connection ID has been negotiated" \
1947 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001948
Hanno Beckera0e20d02019-05-15 14:03:01 +01001949requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001950run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001951 "$P_SRV debug_level=3 dtls=1 cid=1" \
1952 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1953 0 \
1954 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001955 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001956 -c "client hello, adding CID extension" \
1957 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001958 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001959 -s "server hello, adding CID extension" \
1960 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001961 -c "Use of CID extension negotiated" \
1962 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001963 -c "Copy CIDs into SSL transform" \
1964 -s "Peer CID (length 4 Bytes): de ad be ef" \
1965 -c "Peer CID (length 0 Bytes):" \
1966 -s "Use of Connection ID has been negotiated" \
1967 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001968
Hanno Beckera0e20d02019-05-15 14:03:01 +01001969requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001970run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001971 "$P_SRV debug_level=3 dtls=1 cid=1" \
1972 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1973 0 \
1974 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001975 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001976 -c "client hello, adding CID extension" \
1977 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001978 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001979 -s "server hello, adding CID extension" \
1980 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001981 -c "Use of CID extension negotiated" \
1982 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001983 -c "Copy CIDs into SSL transform" \
1984 -S "Use of Connection ID has been negotiated" \
1985 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001986
Hanno Beckera0e20d02019-05-15 14:03:01 +01001987requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker9bae30d2019-04-23 11:52:44 +01001988requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01001989run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001990 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1991 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1992 0 \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01001993 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1994 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1995 -s "(initial handshake) Use of Connection ID has been negotiated" \
1996 -c "(initial handshake) Use of Connection ID has been negotiated" \
1997 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1998 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1999 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2000 -c "(after renegotiation) Use of Connection ID has been negotiated"
2001
Hanno Beckera0e20d02019-05-15 14:03:01 +01002002requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002003requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002004run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002005 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2006 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2007 0 \
2008 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2009 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2010 -s "(initial handshake) Use of Connection ID has been negotiated" \
2011 -c "(initial handshake) Use of Connection ID has been negotiated" \
2012 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2013 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2014 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2015 -c "(after renegotiation) Use of Connection ID has been negotiated"
2016
Hanno Beckera0e20d02019-05-15 14:03:01 +01002017requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002018requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002019run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
2020 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
2021 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2022 0 \
2023 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2024 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2025 -s "(initial handshake) Use of Connection ID has been negotiated" \
2026 -c "(initial handshake) Use of Connection ID has been negotiated" \
2027 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2028 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2029 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2030 -c "(after renegotiation) Use of Connection ID has been negotiated"
2031
Hanno Beckera0e20d02019-05-15 14:03:01 +01002032requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002033requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002034run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002035 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002036 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2037 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2038 0 \
2039 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2040 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2041 -s "(initial handshake) Use of Connection ID has been negotiated" \
2042 -c "(initial handshake) Use of Connection ID has been negotiated" \
2043 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2044 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2045 -s "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002046 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2047 -c "ignoring unexpected CID" \
2048 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002049
Hanno Beckera0e20d02019-05-15 14:03:01 +01002050requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002051requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2052run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002053 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2054 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2055 0 \
2056 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2057 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2058 -s "(initial handshake) Use of Connection ID has been negotiated" \
2059 -c "(initial handshake) Use of Connection ID has been negotiated" \
2060 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2061 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2062 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2063 -S "(after renegotiation) Use of Connection ID has been negotiated"
2064
Hanno Beckera0e20d02019-05-15 14:03:01 +01002065requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002066requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002067run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
2068 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2069 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2070 0 \
2071 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2072 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2073 -s "(initial handshake) Use of Connection ID has been negotiated" \
2074 -c "(initial handshake) Use of Connection ID has been negotiated" \
2075 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2076 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2077 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2078 -S "(after renegotiation) Use of Connection ID has been negotiated"
2079
Hanno Beckera0e20d02019-05-15 14:03:01 +01002080requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002081requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002082run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002083 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002084 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2085 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2086 0 \
2087 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2088 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2089 -s "(initial handshake) Use of Connection ID has been negotiated" \
2090 -c "(initial handshake) Use of Connection ID has been negotiated" \
2091 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2092 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2093 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002094 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2095 -c "ignoring unexpected CID" \
2096 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002097
Hanno Beckera0e20d02019-05-15 14:03:01 +01002098requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002099requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2100run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002101 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2102 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2103 0 \
2104 -S "(initial handshake) Use of Connection ID has been negotiated" \
2105 -C "(initial handshake) Use of Connection ID has been negotiated" \
2106 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2107 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2108 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2109 -s "(after renegotiation) Use of Connection ID has been negotiated"
2110
Hanno Beckera0e20d02019-05-15 14:03:01 +01002111requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002112requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002113run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2114 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2115 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2116 0 \
2117 -S "(initial handshake) Use of Connection ID has been negotiated" \
2118 -C "(initial handshake) Use of Connection ID has been negotiated" \
2119 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2120 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2121 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2122 -s "(after renegotiation) Use of Connection ID has been negotiated"
2123
Hanno Beckera0e20d02019-05-15 14:03:01 +01002124requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002125requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002126run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002127 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002128 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2129 "$P_CLI debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2130 0 \
2131 -S "(initial handshake) Use of Connection ID has been negotiated" \
2132 -C "(initial handshake) Use of Connection ID has been negotiated" \
2133 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2134 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2135 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002136 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2137 -c "ignoring unexpected CID" \
2138 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002139
Hanno Beckera0e20d02019-05-15 14:03:01 +01002140requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002141requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2142run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002143 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2144 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2145 0 \
2146 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2147 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2148 -s "(initial handshake) Use of Connection ID has been negotiated" \
2149 -c "(initial handshake) Use of Connection ID has been negotiated" \
2150 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2151 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2152 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2153 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2154 -s "(after renegotiation) Use of Connection ID was not offered by client"
2155
Hanno Beckera0e20d02019-05-15 14:03:01 +01002156requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002157requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002158run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002159 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002160 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2161 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2162 0 \
2163 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2164 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2165 -s "(initial handshake) Use of Connection ID has been negotiated" \
2166 -c "(initial handshake) Use of Connection ID has been negotiated" \
2167 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2168 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2169 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2170 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002171 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2172 -c "ignoring unexpected CID" \
2173 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002174
Hanno Beckera0e20d02019-05-15 14:03:01 +01002175requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002176requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2177run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2178 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2179 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2180 0 \
2181 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2182 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2183 -s "(initial handshake) Use of Connection ID has been negotiated" \
2184 -c "(initial handshake) Use of Connection ID has been negotiated" \
2185 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2186 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2187 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2188 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2189 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2190
Hanno Beckera0e20d02019-05-15 14:03:01 +01002191requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002192requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2193run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002194 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002195 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2196 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2197 0 \
2198 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2199 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2200 -s "(initial handshake) Use of Connection ID has been negotiated" \
2201 -c "(initial handshake) Use of Connection ID has been negotiated" \
2202 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2203 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2204 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2205 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002206 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2207 -c "ignoring unexpected CID" \
2208 -s "ignoring unexpected CID"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002209
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002210# Tests for Encrypt-then-MAC extension
2211
2212run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002213 "$P_SRV debug_level=3 \
2214 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002215 "$P_CLI debug_level=3" \
2216 0 \
2217 -c "client hello, adding encrypt_then_mac extension" \
2218 -s "found encrypt then mac extension" \
2219 -s "server hello, adding encrypt then mac extension" \
2220 -c "found encrypt_then_mac extension" \
2221 -c "using encrypt then mac" \
2222 -s "using encrypt then mac"
2223
2224run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002225 "$P_SRV debug_level=3 etm=0 \
2226 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002227 "$P_CLI debug_level=3 etm=1" \
2228 0 \
2229 -c "client hello, adding encrypt_then_mac extension" \
2230 -s "found encrypt then mac extension" \
2231 -S "server hello, adding encrypt then mac extension" \
2232 -C "found encrypt_then_mac extension" \
2233 -C "using encrypt then mac" \
2234 -S "using encrypt then mac"
2235
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002236run_test "Encrypt then MAC: client enabled, aead cipher" \
2237 "$P_SRV debug_level=3 etm=1 \
2238 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2239 "$P_CLI debug_level=3 etm=1" \
2240 0 \
2241 -c "client hello, adding encrypt_then_mac extension" \
2242 -s "found encrypt then mac extension" \
2243 -S "server hello, adding encrypt then mac extension" \
2244 -C "found encrypt_then_mac extension" \
2245 -C "using encrypt then mac" \
2246 -S "using encrypt then mac"
2247
2248run_test "Encrypt then MAC: client enabled, stream cipher" \
2249 "$P_SRV debug_level=3 etm=1 \
2250 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002251 "$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 +01002252 0 \
2253 -c "client hello, adding encrypt_then_mac extension" \
2254 -s "found encrypt then mac extension" \
2255 -S "server hello, adding encrypt then mac extension" \
2256 -C "found encrypt_then_mac extension" \
2257 -C "using encrypt then mac" \
2258 -S "using encrypt then mac"
2259
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002260run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002261 "$P_SRV debug_level=3 etm=1 \
2262 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002263 "$P_CLI debug_level=3 etm=0" \
2264 0 \
2265 -C "client hello, adding encrypt_then_mac extension" \
2266 -S "found encrypt then mac extension" \
2267 -S "server hello, adding encrypt then mac extension" \
2268 -C "found encrypt_then_mac extension" \
2269 -C "using encrypt then mac" \
2270 -S "using encrypt then mac"
2271
Janos Follathe2681a42016-03-07 15:57:05 +00002272requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002273run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002274 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002275 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002276 "$P_CLI debug_level=3 force_version=ssl3" \
2277 0 \
2278 -C "client hello, adding encrypt_then_mac extension" \
2279 -S "found encrypt then mac extension" \
2280 -S "server hello, adding encrypt then mac extension" \
2281 -C "found encrypt_then_mac extension" \
2282 -C "using encrypt then mac" \
2283 -S "using encrypt then mac"
2284
Janos Follathe2681a42016-03-07 15:57:05 +00002285requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002286run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002287 "$P_SRV debug_level=3 force_version=ssl3 \
2288 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002289 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002290 0 \
2291 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002292 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002293 -S "server hello, adding encrypt then mac extension" \
2294 -C "found encrypt_then_mac extension" \
2295 -C "using encrypt then mac" \
2296 -S "using encrypt then mac"
2297
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002298# Tests for Extended Master Secret extension
2299
2300run_test "Extended Master Secret: default" \
2301 "$P_SRV debug_level=3" \
2302 "$P_CLI debug_level=3" \
2303 0 \
2304 -c "client hello, adding extended_master_secret extension" \
2305 -s "found extended master secret extension" \
2306 -s "server hello, adding extended master secret extension" \
2307 -c "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002308 -c "session hash for extended master secret" \
2309 -s "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002310
2311run_test "Extended Master Secret: client enabled, server disabled" \
2312 "$P_SRV debug_level=3 extended_ms=0" \
2313 "$P_CLI debug_level=3 extended_ms=1" \
2314 0 \
2315 -c "client hello, adding extended_master_secret extension" \
2316 -s "found extended master secret extension" \
2317 -S "server hello, adding extended master secret extension" \
2318 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002319 -C "session hash for extended master secret" \
2320 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002321
2322run_test "Extended Master Secret: client disabled, server enabled" \
2323 "$P_SRV debug_level=3 extended_ms=1" \
2324 "$P_CLI debug_level=3 extended_ms=0" \
2325 0 \
2326 -C "client hello, adding extended_master_secret extension" \
2327 -S "found extended master secret extension" \
2328 -S "server hello, adding extended master secret extension" \
2329 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002330 -C "session hash for extended master secret" \
2331 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002332
Janos Follathe2681a42016-03-07 15:57:05 +00002333requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002334run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002335 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002336 "$P_CLI debug_level=3 force_version=ssl3" \
2337 0 \
2338 -C "client hello, adding extended_master_secret extension" \
2339 -S "found extended master secret extension" \
2340 -S "server hello, adding extended master secret extension" \
2341 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002342 -C "session hash for extended master secret" \
2343 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002344
Janos Follathe2681a42016-03-07 15:57:05 +00002345requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002346run_test "Extended Master Secret: client enabled, server SSLv3" \
2347 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002348 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002349 0 \
2350 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002351 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002352 -S "server hello, adding extended master secret extension" \
2353 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002354 -C "session hash for extended master secret" \
2355 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002356
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002357# Tests for FALLBACK_SCSV
2358
2359run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002360 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002361 "$P_CLI debug_level=3 force_version=tls1_1" \
2362 0 \
2363 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002364 -S "received FALLBACK_SCSV" \
2365 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002366 -C "is a fatal alert message (msg 86)"
2367
2368run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002369 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002370 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2371 0 \
2372 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002373 -S "received FALLBACK_SCSV" \
2374 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002375 -C "is a fatal alert message (msg 86)"
2376
2377run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002378 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002379 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002380 1 \
2381 -c "adding FALLBACK_SCSV" \
2382 -s "received FALLBACK_SCSV" \
2383 -s "inapropriate fallback" \
2384 -c "is a fatal alert message (msg 86)"
2385
2386run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002387 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002388 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002389 0 \
2390 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002391 -s "received FALLBACK_SCSV" \
2392 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002393 -C "is a fatal alert message (msg 86)"
2394
2395requires_openssl_with_fallback_scsv
2396run_test "Fallback SCSV: default, openssl server" \
2397 "$O_SRV" \
2398 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2399 0 \
2400 -C "adding FALLBACK_SCSV" \
2401 -C "is a fatal alert message (msg 86)"
2402
2403requires_openssl_with_fallback_scsv
2404run_test "Fallback SCSV: enabled, openssl server" \
2405 "$O_SRV" \
2406 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
2407 1 \
2408 -c "adding FALLBACK_SCSV" \
2409 -c "is a fatal alert message (msg 86)"
2410
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002411requires_openssl_with_fallback_scsv
2412run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002413 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002414 "$O_CLI -tls1_1" \
2415 0 \
2416 -S "received FALLBACK_SCSV" \
2417 -S "inapropriate fallback"
2418
2419requires_openssl_with_fallback_scsv
2420run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002421 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002422 "$O_CLI -tls1_1 -fallback_scsv" \
2423 1 \
2424 -s "received FALLBACK_SCSV" \
2425 -s "inapropriate fallback"
2426
2427requires_openssl_with_fallback_scsv
2428run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002429 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002430 "$O_CLI -fallback_scsv" \
2431 0 \
2432 -s "received FALLBACK_SCSV" \
2433 -S "inapropriate fallback"
2434
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002435# Test sending and receiving empty application data records
2436
2437run_test "Encrypt then MAC: empty application data record" \
2438 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2439 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2440 0 \
2441 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2442 -s "dumping 'input payload after decrypt' (0 bytes)" \
2443 -c "0 bytes written in 1 fragments"
2444
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002445run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002446 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2447 "$P_CLI auth_mode=none etm=0 request_size=0" \
2448 0 \
2449 -s "dumping 'input payload after decrypt' (0 bytes)" \
2450 -c "0 bytes written in 1 fragments"
2451
2452run_test "Encrypt then MAC, DTLS: empty application data record" \
2453 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2454 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2455 0 \
2456 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2457 -s "dumping 'input payload after decrypt' (0 bytes)" \
2458 -c "0 bytes written in 1 fragments"
2459
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002460run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002461 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2462 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2463 0 \
2464 -s "dumping 'input payload after decrypt' (0 bytes)" \
2465 -c "0 bytes written in 1 fragments"
2466
Gilles Peskined50177f2017-05-16 17:53:03 +02002467## ClientHello generated with
2468## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2469## then manually twiddling the ciphersuite list.
2470## The ClientHello content is spelled out below as a hex string as
2471## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2472## The expected response is an inappropriate_fallback alert.
2473requires_openssl_with_fallback_scsv
2474run_test "Fallback SCSV: beginning of list" \
2475 "$P_SRV debug_level=2" \
2476 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2477 0 \
2478 -s "received FALLBACK_SCSV" \
2479 -s "inapropriate fallback"
2480
2481requires_openssl_with_fallback_scsv
2482run_test "Fallback SCSV: end of list" \
2483 "$P_SRV debug_level=2" \
2484 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2485 0 \
2486 -s "received FALLBACK_SCSV" \
2487 -s "inapropriate fallback"
2488
2489## Here the expected response is a valid ServerHello prefix, up to the random.
2490requires_openssl_with_fallback_scsv
2491run_test "Fallback SCSV: not in list" \
2492 "$P_SRV debug_level=2" \
2493 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2494 0 \
2495 -S "received FALLBACK_SCSV" \
2496 -S "inapropriate fallback"
2497
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002498# Tests for CBC 1/n-1 record splitting
2499
2500run_test "CBC Record splitting: TLS 1.2, no splitting" \
2501 "$P_SRV" \
2502 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2503 request_size=123 force_version=tls1_2" \
2504 0 \
2505 -s "Read from client: 123 bytes read" \
2506 -S "Read from client: 1 bytes read" \
2507 -S "122 bytes read"
2508
2509run_test "CBC Record splitting: TLS 1.1, no splitting" \
2510 "$P_SRV" \
2511 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2512 request_size=123 force_version=tls1_1" \
2513 0 \
2514 -s "Read from client: 123 bytes read" \
2515 -S "Read from client: 1 bytes read" \
2516 -S "122 bytes read"
2517
2518run_test "CBC Record splitting: TLS 1.0, splitting" \
2519 "$P_SRV" \
2520 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2521 request_size=123 force_version=tls1" \
2522 0 \
2523 -S "Read from client: 123 bytes read" \
2524 -s "Read from client: 1 bytes read" \
2525 -s "122 bytes read"
2526
Janos Follathe2681a42016-03-07 15:57:05 +00002527requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002528run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002529 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002530 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2531 request_size=123 force_version=ssl3" \
2532 0 \
2533 -S "Read from client: 123 bytes read" \
2534 -s "Read from client: 1 bytes read" \
2535 -s "122 bytes read"
2536
2537run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002538 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002539 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2540 request_size=123 force_version=tls1" \
2541 0 \
2542 -s "Read from client: 123 bytes read" \
2543 -S "Read from client: 1 bytes read" \
2544 -S "122 bytes read"
2545
2546run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2547 "$P_SRV" \
2548 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2549 request_size=123 force_version=tls1 recsplit=0" \
2550 0 \
2551 -s "Read from client: 123 bytes read" \
2552 -S "Read from client: 1 bytes read" \
2553 -S "122 bytes read"
2554
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002555run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2556 "$P_SRV nbio=2" \
2557 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2558 request_size=123 force_version=tls1" \
2559 0 \
2560 -S "Read from client: 123 bytes read" \
2561 -s "Read from client: 1 bytes read" \
2562 -s "122 bytes read"
2563
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002564# Tests for Session Tickets
2565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002566run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002567 "$P_SRV debug_level=3 tickets=1" \
2568 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002569 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002570 -c "client hello, adding session ticket extension" \
2571 -s "found session ticket extension" \
2572 -s "server hello, adding session ticket extension" \
2573 -c "found session_ticket extension" \
2574 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002575 -S "session successfully restored from cache" \
2576 -s "session successfully restored from ticket" \
2577 -s "a session has been resumed" \
2578 -c "a session has been resumed"
2579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002580run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002581 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2582 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002583 0 \
2584 -c "client hello, adding session ticket extension" \
2585 -s "found session ticket extension" \
2586 -s "server hello, adding session ticket extension" \
2587 -c "found session_ticket extension" \
2588 -c "parse new session ticket" \
2589 -S "session successfully restored from cache" \
2590 -s "session successfully restored from ticket" \
2591 -s "a session has been resumed" \
2592 -c "a session has been resumed"
2593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002594run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002595 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2596 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002597 0 \
2598 -c "client hello, adding session ticket extension" \
2599 -s "found session ticket extension" \
2600 -s "server hello, adding session ticket extension" \
2601 -c "found session_ticket extension" \
2602 -c "parse new session ticket" \
2603 -S "session successfully restored from cache" \
2604 -S "session successfully restored from ticket" \
2605 -S "a session has been resumed" \
2606 -C "a session has been resumed"
2607
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002608run_test "Session resume using tickets: session copy" \
2609 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2610 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2611 0 \
2612 -c "client hello, adding session ticket extension" \
2613 -s "found session ticket extension" \
2614 -s "server hello, adding session ticket extension" \
2615 -c "found session_ticket extension" \
2616 -c "parse new session ticket" \
2617 -S "session successfully restored from cache" \
2618 -s "session successfully restored from ticket" \
2619 -s "a session has been resumed" \
2620 -c "a session has been resumed"
2621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002622run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002623 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002624 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002625 0 \
2626 -c "client hello, adding session ticket extension" \
2627 -c "found session_ticket extension" \
2628 -c "parse new session ticket" \
2629 -c "a session has been resumed"
2630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002631run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002632 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002633 "( $O_CLI -sess_out $SESSION; \
2634 $O_CLI -sess_in $SESSION; \
2635 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002636 0 \
2637 -s "found session ticket extension" \
2638 -s "server hello, adding session ticket extension" \
2639 -S "session successfully restored from cache" \
2640 -s "session successfully restored from ticket" \
2641 -s "a session has been resumed"
2642
Hanno Becker1d739932018-08-21 13:55:22 +01002643# Tests for Session Tickets with DTLS
2644
2645run_test "Session resume using tickets, DTLS: basic" \
2646 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002647 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002648 0 \
2649 -c "client hello, adding session ticket extension" \
2650 -s "found session ticket extension" \
2651 -s "server hello, adding session ticket extension" \
2652 -c "found session_ticket extension" \
2653 -c "parse new session ticket" \
2654 -S "session successfully restored from cache" \
2655 -s "session successfully restored from ticket" \
2656 -s "a session has been resumed" \
2657 -c "a session has been resumed"
2658
2659run_test "Session resume using tickets, DTLS: cache disabled" \
2660 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002661 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002662 0 \
2663 -c "client hello, adding session ticket extension" \
2664 -s "found session ticket extension" \
2665 -s "server hello, adding session ticket extension" \
2666 -c "found session_ticket extension" \
2667 -c "parse new session ticket" \
2668 -S "session successfully restored from cache" \
2669 -s "session successfully restored from ticket" \
2670 -s "a session has been resumed" \
2671 -c "a session has been resumed"
2672
2673run_test "Session resume using tickets, DTLS: timeout" \
2674 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002675 "$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 +01002676 0 \
2677 -c "client hello, adding session ticket extension" \
2678 -s "found session ticket extension" \
2679 -s "server hello, adding session ticket extension" \
2680 -c "found session_ticket extension" \
2681 -c "parse new session ticket" \
2682 -S "session successfully restored from cache" \
2683 -S "session successfully restored from ticket" \
2684 -S "a session has been resumed" \
2685 -C "a session has been resumed"
2686
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002687run_test "Session resume using tickets, DTLS: session copy" \
2688 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002689 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1 reco_mode=0" \
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002690 0 \
2691 -c "client hello, adding session ticket extension" \
2692 -s "found session ticket extension" \
2693 -s "server hello, adding session ticket extension" \
2694 -c "found session_ticket extension" \
2695 -c "parse new session ticket" \
2696 -S "session successfully restored from cache" \
2697 -s "session successfully restored from ticket" \
2698 -s "a session has been resumed" \
2699 -c "a session has been resumed"
2700
Hanno Becker1d739932018-08-21 13:55:22 +01002701run_test "Session resume using tickets, DTLS: openssl server" \
2702 "$O_SRV -dtls1" \
2703 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2704 0 \
2705 -c "client hello, adding session ticket extension" \
2706 -c "found session_ticket extension" \
2707 -c "parse new session ticket" \
2708 -c "a session has been resumed"
2709
2710run_test "Session resume using tickets, DTLS: openssl client" \
2711 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2712 "( $O_CLI -dtls1 -sess_out $SESSION; \
2713 $O_CLI -dtls1 -sess_in $SESSION; \
2714 rm -f $SESSION )" \
2715 0 \
2716 -s "found session ticket extension" \
2717 -s "server hello, adding session ticket extension" \
2718 -S "session successfully restored from cache" \
2719 -s "session successfully restored from ticket" \
2720 -s "a session has been resumed"
2721
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002722# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002724run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002725 "$P_SRV debug_level=3 tickets=0" \
2726 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002727 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002728 -c "client hello, adding session ticket extension" \
2729 -s "found session ticket extension" \
2730 -S "server hello, adding session ticket extension" \
2731 -C "found session_ticket extension" \
2732 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002733 -s "session successfully restored from cache" \
2734 -S "session successfully restored from ticket" \
2735 -s "a session has been resumed" \
2736 -c "a session has been resumed"
2737
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002738run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002739 "$P_SRV debug_level=3 tickets=1" \
2740 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002741 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002742 -C "client hello, adding session ticket extension" \
2743 -S "found session ticket extension" \
2744 -S "server hello, adding session ticket extension" \
2745 -C "found session_ticket extension" \
2746 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002747 -s "session successfully restored from cache" \
2748 -S "session successfully restored from ticket" \
2749 -s "a session has been resumed" \
2750 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002751
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002752run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002753 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2754 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002755 0 \
2756 -S "session successfully restored from cache" \
2757 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002758 -S "a session has been resumed" \
2759 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002760
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002761run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002762 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2763 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002764 0 \
2765 -s "session successfully restored from cache" \
2766 -S "session successfully restored from ticket" \
2767 -s "a session has been resumed" \
2768 -c "a session has been resumed"
2769
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002770run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002771 "$P_SRV debug_level=3 tickets=0" \
2772 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002773 0 \
2774 -s "session successfully restored from cache" \
2775 -S "session successfully restored from ticket" \
2776 -s "a session has been resumed" \
2777 -c "a session has been resumed"
2778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002779run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002780 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2781 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002782 0 \
2783 -S "session successfully restored from cache" \
2784 -S "session successfully restored from ticket" \
2785 -S "a session has been resumed" \
2786 -C "a session has been resumed"
2787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002788run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002789 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2790 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002791 0 \
2792 -s "session successfully restored from cache" \
2793 -S "session successfully restored from ticket" \
2794 -s "a session has been resumed" \
2795 -c "a session has been resumed"
2796
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002797run_test "Session resume using cache: session copy" \
2798 "$P_SRV debug_level=3 tickets=0" \
2799 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2800 0 \
2801 -s "session successfully restored from cache" \
2802 -S "session successfully restored from ticket" \
2803 -s "a session has been resumed" \
2804 -c "a session has been resumed"
2805
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002806run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002807 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002808 "( $O_CLI -sess_out $SESSION; \
2809 $O_CLI -sess_in $SESSION; \
2810 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002811 0 \
2812 -s "found session ticket extension" \
2813 -S "server hello, adding session ticket extension" \
2814 -s "session successfully restored from cache" \
2815 -S "session successfully restored from ticket" \
2816 -s "a session has been resumed"
2817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002818run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002819 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002820 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002821 0 \
2822 -C "found session_ticket extension" \
2823 -C "parse new session ticket" \
2824 -c "a session has been resumed"
2825
Hanno Becker1d739932018-08-21 13:55:22 +01002826# Tests for Session Resume based on session-ID and cache, DTLS
2827
2828run_test "Session resume using cache, DTLS: tickets enabled on client" \
2829 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002830 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002831 0 \
2832 -c "client hello, adding session ticket extension" \
2833 -s "found session ticket extension" \
2834 -S "server hello, adding session ticket extension" \
2835 -C "found session_ticket extension" \
2836 -C "parse new session ticket" \
2837 -s "session successfully restored from cache" \
2838 -S "session successfully restored from ticket" \
2839 -s "a session has been resumed" \
2840 -c "a session has been resumed"
2841
2842run_test "Session resume using cache, DTLS: tickets enabled on server" \
2843 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002844 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002845 0 \
2846 -C "client hello, adding session ticket extension" \
2847 -S "found session ticket extension" \
2848 -S "server hello, adding session ticket extension" \
2849 -C "found session_ticket extension" \
2850 -C "parse new session ticket" \
2851 -s "session successfully restored from cache" \
2852 -S "session successfully restored from ticket" \
2853 -s "a session has been resumed" \
2854 -c "a session has been resumed"
2855
2856run_test "Session resume using cache, DTLS: cache_max=0" \
2857 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002858 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002859 0 \
2860 -S "session successfully restored from cache" \
2861 -S "session successfully restored from ticket" \
2862 -S "a session has been resumed" \
2863 -C "a session has been resumed"
2864
2865run_test "Session resume using cache, DTLS: cache_max=1" \
2866 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002867 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002868 0 \
2869 -s "session successfully restored from cache" \
2870 -S "session successfully restored from ticket" \
2871 -s "a session has been resumed" \
2872 -c "a session has been resumed"
2873
2874run_test "Session resume using cache, DTLS: timeout > delay" \
2875 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002876 "$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 +01002877 0 \
2878 -s "session successfully restored from cache" \
2879 -S "session successfully restored from ticket" \
2880 -s "a session has been resumed" \
2881 -c "a session has been resumed"
2882
2883run_test "Session resume using cache, DTLS: timeout < delay" \
2884 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002885 "$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 +01002886 0 \
2887 -S "session successfully restored from cache" \
2888 -S "session successfully restored from ticket" \
2889 -S "a session has been resumed" \
2890 -C "a session has been resumed"
2891
2892run_test "Session resume using cache, DTLS: no timeout" \
2893 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002894 "$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 +01002895 0 \
2896 -s "session successfully restored from cache" \
2897 -S "session successfully restored from ticket" \
2898 -s "a session has been resumed" \
2899 -c "a session has been resumed"
2900
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002901run_test "Session resume using cache, DTLS: session copy" \
2902 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002903 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_mode=0" \
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002904 0 \
2905 -s "session successfully restored from cache" \
2906 -S "session successfully restored from ticket" \
2907 -s "a session has been resumed" \
2908 -c "a session has been resumed"
2909
Hanno Becker1d739932018-08-21 13:55:22 +01002910run_test "Session resume using cache, DTLS: openssl client" \
2911 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2912 "( $O_CLI -dtls1 -sess_out $SESSION; \
2913 $O_CLI -dtls1 -sess_in $SESSION; \
2914 rm -f $SESSION )" \
2915 0 \
2916 -s "found session ticket extension" \
2917 -S "server hello, adding session ticket extension" \
2918 -s "session successfully restored from cache" \
2919 -S "session successfully restored from ticket" \
2920 -s "a session has been resumed"
2921
2922run_test "Session resume using cache, DTLS: openssl server" \
2923 "$O_SRV -dtls1" \
2924 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2925 0 \
2926 -C "found session_ticket extension" \
2927 -C "parse new session ticket" \
2928 -c "a session has been resumed"
2929
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002930# Tests for Max Fragment Length extension
2931
Angus Grattonc4dd0732018-04-11 16:28:39 +10002932if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
2933 printf "${CONFIG_H} defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n"
Hanno Becker6428f8d2017-09-22 16:58:50 +01002934 exit 1
2935fi
2936
Angus Grattonc4dd0732018-04-11 16:28:39 +10002937if [ $MAX_CONTENT_LEN -ne 16384 ]; then
2938 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
2939fi
2940
Hanno Becker4aed27e2017-09-18 15:00:34 +01002941requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002942run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002943 "$P_SRV debug_level=3" \
2944 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002945 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002946 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
2947 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
2948 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
2949 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002950 -C "client hello, adding max_fragment_length extension" \
2951 -S "found max fragment length extension" \
2952 -S "server hello, max_fragment_length extension" \
2953 -C "found max_fragment_length extension"
2954
Hanno Becker4aed27e2017-09-18 15:00:34 +01002955requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002956run_test "Max fragment length: enabled, default, larger message" \
2957 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002958 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002959 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002960 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
2961 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
2962 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
2963 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002964 -C "client hello, adding max_fragment_length extension" \
2965 -S "found max fragment length extension" \
2966 -S "server hello, max_fragment_length extension" \
2967 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002968 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2969 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002970 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002971
2972requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2973run_test "Max fragment length, DTLS: enabled, default, larger message" \
2974 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002975 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002976 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002977 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
2978 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
2979 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
2980 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002981 -C "client hello, adding max_fragment_length extension" \
2982 -S "found max fragment length extension" \
2983 -S "server hello, max_fragment_length extension" \
2984 -C "found max_fragment_length extension" \
2985 -c "fragment larger than.*maximum "
2986
Angus Grattonc4dd0732018-04-11 16:28:39 +10002987# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
2988# (session fragment length will be 16384 regardless of mbedtls
2989# content length configuration.)
2990
Hanno Beckerc5266962017-09-18 15:01:50 +01002991requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2992run_test "Max fragment length: disabled, larger message" \
2993 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002994 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002995 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002996 -C "Maximum input fragment length is 16384" \
2997 -C "Maximum output fragment length is 16384" \
2998 -S "Maximum input fragment length is 16384" \
2999 -S "Maximum output fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003000 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3001 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003002 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003003
3004requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3005run_test "Max fragment length DTLS: disabled, larger message" \
3006 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003007 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003008 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003009 -C "Maximum input fragment length is 16384" \
3010 -C "Maximum output fragment length is 16384" \
3011 -S "Maximum input fragment length is 16384" \
3012 -S "Maximum output fragment length is 16384" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003013 -c "fragment larger than.*maximum "
3014
3015requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003016run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003017 "$P_SRV debug_level=3" \
3018 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003019 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003020 -c "Maximum input fragment length is 4096" \
3021 -c "Maximum output fragment length is 4096" \
3022 -s "Maximum input fragment length is 4096" \
3023 -s "Maximum output fragment length is 4096" \
3024 -c "client hello, adding max_fragment_length extension" \
3025 -s "found max fragment length extension" \
3026 -s "server hello, max_fragment_length extension" \
3027 -c "found max_fragment_length extension"
3028
3029requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3030run_test "Max fragment length: client 512, server 1024" \
3031 "$P_SRV debug_level=3 max_frag_len=1024" \
3032 "$P_CLI debug_level=3 max_frag_len=512" \
3033 0 \
3034 -c "Maximum input fragment length is 512" \
3035 -c "Maximum output fragment length is 512" \
3036 -s "Maximum input fragment length is 512" \
3037 -s "Maximum output fragment length is 512" \
3038 -c "client hello, adding max_fragment_length extension" \
3039 -s "found max fragment length extension" \
3040 -s "server hello, max_fragment_length extension" \
3041 -c "found max_fragment_length extension"
3042
3043requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3044run_test "Max fragment length: client 512, server 2048" \
3045 "$P_SRV debug_level=3 max_frag_len=2048" \
3046 "$P_CLI debug_level=3 max_frag_len=512" \
3047 0 \
3048 -c "Maximum input fragment length is 512" \
3049 -c "Maximum output fragment length is 512" \
3050 -s "Maximum input fragment length is 512" \
3051 -s "Maximum output fragment length is 512" \
3052 -c "client hello, adding max_fragment_length extension" \
3053 -s "found max fragment length extension" \
3054 -s "server hello, max_fragment_length extension" \
3055 -c "found max_fragment_length extension"
3056
3057requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3058run_test "Max fragment length: client 512, server 4096" \
3059 "$P_SRV debug_level=3 max_frag_len=4096" \
3060 "$P_CLI debug_level=3 max_frag_len=512" \
3061 0 \
3062 -c "Maximum input fragment length is 512" \
3063 -c "Maximum output fragment length is 512" \
3064 -s "Maximum input fragment length is 512" \
3065 -s "Maximum output fragment length is 512" \
3066 -c "client hello, adding max_fragment_length extension" \
3067 -s "found max fragment length extension" \
3068 -s "server hello, max_fragment_length extension" \
3069 -c "found max_fragment_length extension"
3070
3071requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3072run_test "Max fragment length: client 1024, server 512" \
3073 "$P_SRV debug_level=3 max_frag_len=512" \
3074 "$P_CLI debug_level=3 max_frag_len=1024" \
3075 0 \
3076 -c "Maximum input fragment length is 1024" \
3077 -c "Maximum output fragment length is 1024" \
3078 -s "Maximum input fragment length is 1024" \
3079 -s "Maximum output fragment length is 512" \
3080 -c "client hello, adding max_fragment_length extension" \
3081 -s "found max fragment length extension" \
3082 -s "server hello, max_fragment_length extension" \
3083 -c "found max_fragment_length extension"
3084
3085requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3086run_test "Max fragment length: client 1024, server 2048" \
3087 "$P_SRV debug_level=3 max_frag_len=2048" \
3088 "$P_CLI debug_level=3 max_frag_len=1024" \
3089 0 \
3090 -c "Maximum input fragment length is 1024" \
3091 -c "Maximum output fragment length is 1024" \
3092 -s "Maximum input fragment length is 1024" \
3093 -s "Maximum output fragment length is 1024" \
3094 -c "client hello, adding max_fragment_length extension" \
3095 -s "found max fragment length extension" \
3096 -s "server hello, max_fragment_length extension" \
3097 -c "found max_fragment_length extension"
3098
3099requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3100run_test "Max fragment length: client 1024, server 4096" \
3101 "$P_SRV debug_level=3 max_frag_len=4096" \
3102 "$P_CLI debug_level=3 max_frag_len=1024" \
3103 0 \
3104 -c "Maximum input fragment length is 1024" \
3105 -c "Maximum output fragment length is 1024" \
3106 -s "Maximum input fragment length is 1024" \
3107 -s "Maximum output fragment length is 1024" \
3108 -c "client hello, adding max_fragment_length extension" \
3109 -s "found max fragment length extension" \
3110 -s "server hello, max_fragment_length extension" \
3111 -c "found max_fragment_length extension"
3112
3113requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3114run_test "Max fragment length: client 2048, server 512" \
3115 "$P_SRV debug_level=3 max_frag_len=512" \
3116 "$P_CLI debug_level=3 max_frag_len=2048" \
3117 0 \
3118 -c "Maximum input fragment length is 2048" \
3119 -c "Maximum output fragment length is 2048" \
3120 -s "Maximum input fragment length is 2048" \
3121 -s "Maximum output fragment length is 512" \
3122 -c "client hello, adding max_fragment_length extension" \
3123 -s "found max fragment length extension" \
3124 -s "server hello, max_fragment_length extension" \
3125 -c "found max_fragment_length extension"
3126
3127requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3128run_test "Max fragment length: client 2048, server 1024" \
3129 "$P_SRV debug_level=3 max_frag_len=1024" \
3130 "$P_CLI debug_level=3 max_frag_len=2048" \
3131 0 \
3132 -c "Maximum input fragment length is 2048" \
3133 -c "Maximum output fragment length is 2048" \
3134 -s "Maximum input fragment length is 2048" \
3135 -s "Maximum output fragment length is 1024" \
3136 -c "client hello, adding max_fragment_length extension" \
3137 -s "found max fragment length extension" \
3138 -s "server hello, max_fragment_length extension" \
3139 -c "found max_fragment_length extension"
3140
3141requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3142run_test "Max fragment length: client 2048, server 4096" \
3143 "$P_SRV debug_level=3 max_frag_len=4096" \
3144 "$P_CLI debug_level=3 max_frag_len=2048" \
3145 0 \
3146 -c "Maximum input fragment length is 2048" \
3147 -c "Maximum output fragment length is 2048" \
3148 -s "Maximum input fragment length is 2048" \
3149 -s "Maximum output fragment length is 2048" \
3150 -c "client hello, adding max_fragment_length extension" \
3151 -s "found max fragment length extension" \
3152 -s "server hello, max_fragment_length extension" \
3153 -c "found max_fragment_length extension"
3154
3155requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3156run_test "Max fragment length: client 4096, server 512" \
3157 "$P_SRV debug_level=3 max_frag_len=512" \
3158 "$P_CLI debug_level=3 max_frag_len=4096" \
3159 0 \
3160 -c "Maximum input fragment length is 4096" \
3161 -c "Maximum output fragment length is 4096" \
3162 -s "Maximum input fragment length is 4096" \
3163 -s "Maximum output fragment length is 512" \
3164 -c "client hello, adding max_fragment_length extension" \
3165 -s "found max fragment length extension" \
3166 -s "server hello, max_fragment_length extension" \
3167 -c "found max_fragment_length extension"
3168
3169requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3170run_test "Max fragment length: client 4096, server 1024" \
3171 "$P_SRV debug_level=3 max_frag_len=1024" \
3172 "$P_CLI debug_level=3 max_frag_len=4096" \
3173 0 \
3174 -c "Maximum input fragment length is 4096" \
3175 -c "Maximum output fragment length is 4096" \
3176 -s "Maximum input fragment length is 4096" \
3177 -s "Maximum output fragment length is 1024" \
3178 -c "client hello, adding max_fragment_length extension" \
3179 -s "found max fragment length extension" \
3180 -s "server hello, max_fragment_length extension" \
3181 -c "found max_fragment_length extension"
3182
3183requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3184run_test "Max fragment length: client 4096, server 2048" \
3185 "$P_SRV debug_level=3 max_frag_len=2048" \
3186 "$P_CLI debug_level=3 max_frag_len=4096" \
3187 0 \
3188 -c "Maximum input fragment length is 4096" \
3189 -c "Maximum output fragment length is 4096" \
3190 -s "Maximum input fragment length is 4096" \
3191 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003192 -c "client hello, adding max_fragment_length extension" \
3193 -s "found max fragment length extension" \
3194 -s "server hello, max_fragment_length extension" \
3195 -c "found max_fragment_length extension"
3196
Hanno Becker4aed27e2017-09-18 15:00:34 +01003197requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003198run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003199 "$P_SRV debug_level=3 max_frag_len=4096" \
3200 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003201 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003202 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3203 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3204 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3205 -s "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003206 -C "client hello, adding max_fragment_length extension" \
3207 -S "found max fragment length extension" \
3208 -S "server hello, max_fragment_length extension" \
3209 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003210
Hanno Becker4aed27e2017-09-18 15:00:34 +01003211requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003212requires_gnutls
3213run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003214 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003215 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003216 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003217 -c "Maximum input fragment length is 4096" \
3218 -c "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003219 -c "client hello, adding max_fragment_length extension" \
3220 -c "found max_fragment_length extension"
3221
Hanno Becker4aed27e2017-09-18 15:00:34 +01003222requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003223run_test "Max fragment length: client, message just fits" \
3224 "$P_SRV debug_level=3" \
3225 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3226 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003227 -c "Maximum input fragment length is 2048" \
3228 -c "Maximum output fragment length is 2048" \
3229 -s "Maximum input fragment length is 2048" \
3230 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003231 -c "client hello, adding max_fragment_length extension" \
3232 -s "found max fragment length extension" \
3233 -s "server hello, max_fragment_length extension" \
3234 -c "found max_fragment_length extension" \
3235 -c "2048 bytes written in 1 fragments" \
3236 -s "2048 bytes read"
3237
Hanno Becker4aed27e2017-09-18 15:00:34 +01003238requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003239run_test "Max fragment length: client, larger message" \
3240 "$P_SRV debug_level=3" \
3241 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3242 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003243 -c "Maximum input fragment length is 2048" \
3244 -c "Maximum output fragment length is 2048" \
3245 -s "Maximum input fragment length is 2048" \
3246 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003247 -c "client hello, adding max_fragment_length extension" \
3248 -s "found max fragment length extension" \
3249 -s "server hello, max_fragment_length extension" \
3250 -c "found max_fragment_length extension" \
3251 -c "2345 bytes written in 2 fragments" \
3252 -s "2048 bytes read" \
3253 -s "297 bytes read"
3254
Hanno Becker4aed27e2017-09-18 15:00:34 +01003255requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003256run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003257 "$P_SRV debug_level=3 dtls=1" \
3258 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3259 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003260 -c "Maximum input fragment length is 2048" \
3261 -c "Maximum output fragment length is 2048" \
3262 -s "Maximum input fragment length is 2048" \
3263 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003264 -c "client hello, adding max_fragment_length extension" \
3265 -s "found max fragment length extension" \
3266 -s "server hello, max_fragment_length extension" \
3267 -c "found max_fragment_length extension" \
3268 -c "fragment larger than.*maximum"
3269
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003270# Tests for renegotiation
3271
Hanno Becker6a243642017-10-12 15:18:45 +01003272# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003273run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003274 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003275 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003276 0 \
3277 -C "client hello, adding renegotiation extension" \
3278 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3279 -S "found renegotiation extension" \
3280 -s "server hello, secure renegotiation extension" \
3281 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003282 -C "=> renegotiate" \
3283 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003284 -S "write hello request"
3285
Hanno Becker6a243642017-10-12 15:18:45 +01003286requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003287run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003288 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003289 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003290 0 \
3291 -c "client hello, adding renegotiation extension" \
3292 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3293 -s "found renegotiation extension" \
3294 -s "server hello, secure renegotiation extension" \
3295 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003296 -c "=> renegotiate" \
3297 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003298 -S "write hello request"
3299
Hanno Becker6a243642017-10-12 15:18:45 +01003300requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003301run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003302 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003303 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003304 0 \
3305 -c "client hello, adding renegotiation extension" \
3306 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3307 -s "found renegotiation extension" \
3308 -s "server hello, secure renegotiation extension" \
3309 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003310 -c "=> renegotiate" \
3311 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003312 -s "write hello request"
3313
Janos Follathb0f148c2017-10-05 12:29:42 +01003314# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3315# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3316# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003317requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003318run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3319 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3320 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3321 0 \
3322 -c "client hello, adding renegotiation extension" \
3323 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3324 -s "found renegotiation extension" \
3325 -s "server hello, secure renegotiation extension" \
3326 -c "found renegotiation extension" \
3327 -c "=> renegotiate" \
3328 -s "=> renegotiate" \
3329 -S "write hello request" \
3330 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3331
3332# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3333# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3334# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003335requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003336run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3337 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3338 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3339 0 \
3340 -c "client hello, adding renegotiation extension" \
3341 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3342 -s "found renegotiation extension" \
3343 -s "server hello, secure renegotiation extension" \
3344 -c "found renegotiation extension" \
3345 -c "=> renegotiate" \
3346 -s "=> renegotiate" \
3347 -s "write hello request" \
3348 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3349
Hanno Becker6a243642017-10-12 15:18:45 +01003350requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003351run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003352 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003353 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003354 0 \
3355 -c "client hello, adding renegotiation extension" \
3356 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3357 -s "found renegotiation extension" \
3358 -s "server hello, secure renegotiation extension" \
3359 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003360 -c "=> renegotiate" \
3361 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003362 -s "write hello request"
3363
Hanno Becker6a243642017-10-12 15:18:45 +01003364requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andrzej Kurek8ea68722020-04-03 06:40:47 -04003365requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3366run_test "Renegotiation with max fragment length: client 2048, server 512" \
3367 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1 max_frag_len=512" \
3368 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 max_frag_len=2048 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
3369 0 \
3370 -c "Maximum input fragment length is 2048" \
3371 -c "Maximum output fragment length is 2048" \
3372 -s "Maximum input fragment length is 2048" \
3373 -s "Maximum output fragment length is 512" \
3374 -c "client hello, adding max_fragment_length extension" \
3375 -s "found max fragment length extension" \
3376 -s "server hello, max_fragment_length extension" \
3377 -c "found max_fragment_length extension" \
3378 -c "client hello, adding renegotiation extension" \
3379 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3380 -s "found renegotiation extension" \
3381 -s "server hello, secure renegotiation extension" \
3382 -c "found renegotiation extension" \
3383 -c "=> renegotiate" \
3384 -s "=> renegotiate" \
3385 -s "write hello request"
3386
3387requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003388run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003389 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003390 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003391 1 \
3392 -c "client hello, adding renegotiation extension" \
3393 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3394 -S "found renegotiation extension" \
3395 -s "server hello, secure renegotiation extension" \
3396 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003397 -c "=> renegotiate" \
3398 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003399 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003400 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003401 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003402
Hanno Becker6a243642017-10-12 15:18:45 +01003403requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003404run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003405 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003406 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003407 0 \
3408 -C "client hello, adding renegotiation extension" \
3409 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3410 -S "found renegotiation extension" \
3411 -s "server hello, secure renegotiation extension" \
3412 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003413 -C "=> renegotiate" \
3414 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003415 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003416 -S "SSL - An unexpected message was received from our peer" \
3417 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003418
Hanno Becker6a243642017-10-12 15:18:45 +01003419requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003420run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003421 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003422 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003423 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003424 0 \
3425 -C "client hello, adding renegotiation extension" \
3426 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3427 -S "found renegotiation extension" \
3428 -s "server hello, secure renegotiation extension" \
3429 -c "found renegotiation extension" \
3430 -C "=> renegotiate" \
3431 -S "=> renegotiate" \
3432 -s "write hello request" \
3433 -S "SSL - An unexpected message was received from our peer" \
3434 -S "failed"
3435
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003436# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003437requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003438run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003439 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003440 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003441 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003442 0 \
3443 -C "client hello, adding renegotiation extension" \
3444 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3445 -S "found renegotiation extension" \
3446 -s "server hello, secure renegotiation extension" \
3447 -c "found renegotiation extension" \
3448 -C "=> renegotiate" \
3449 -S "=> renegotiate" \
3450 -s "write hello request" \
3451 -S "SSL - An unexpected message was received from our peer" \
3452 -S "failed"
3453
Hanno Becker6a243642017-10-12 15:18:45 +01003454requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003455run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003456 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003457 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003458 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003459 0 \
3460 -C "client hello, adding renegotiation extension" \
3461 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3462 -S "found renegotiation extension" \
3463 -s "server hello, secure renegotiation extension" \
3464 -c "found renegotiation extension" \
3465 -C "=> renegotiate" \
3466 -S "=> renegotiate" \
3467 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003468 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003469
Hanno Becker6a243642017-10-12 15:18:45 +01003470requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003471run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003472 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003473 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003474 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003475 0 \
3476 -c "client hello, adding renegotiation extension" \
3477 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3478 -s "found renegotiation extension" \
3479 -s "server hello, secure renegotiation extension" \
3480 -c "found renegotiation extension" \
3481 -c "=> renegotiate" \
3482 -s "=> renegotiate" \
3483 -s "write hello request" \
3484 -S "SSL - An unexpected message was received from our peer" \
3485 -S "failed"
3486
Hanno Becker6a243642017-10-12 15:18:45 +01003487requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003488run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003489 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003490 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3491 0 \
3492 -C "client hello, adding renegotiation extension" \
3493 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3494 -S "found renegotiation extension" \
3495 -s "server hello, secure renegotiation extension" \
3496 -c "found renegotiation extension" \
3497 -S "record counter limit reached: renegotiate" \
3498 -C "=> renegotiate" \
3499 -S "=> renegotiate" \
3500 -S "write hello request" \
3501 -S "SSL - An unexpected message was received from our peer" \
3502 -S "failed"
3503
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003504# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003505requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003506run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003507 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003508 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003509 0 \
3510 -c "client hello, adding renegotiation extension" \
3511 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3512 -s "found renegotiation extension" \
3513 -s "server hello, secure renegotiation extension" \
3514 -c "found renegotiation extension" \
3515 -s "record counter limit reached: renegotiate" \
3516 -c "=> renegotiate" \
3517 -s "=> renegotiate" \
3518 -s "write hello request" \
3519 -S "SSL - An unexpected message was received from our peer" \
3520 -S "failed"
3521
Hanno Becker6a243642017-10-12 15:18:45 +01003522requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003523run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003524 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003525 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003526 0 \
3527 -c "client hello, adding renegotiation extension" \
3528 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3529 -s "found renegotiation extension" \
3530 -s "server hello, secure renegotiation extension" \
3531 -c "found renegotiation extension" \
3532 -s "record counter limit reached: renegotiate" \
3533 -c "=> renegotiate" \
3534 -s "=> renegotiate" \
3535 -s "write hello request" \
3536 -S "SSL - An unexpected message was received from our peer" \
3537 -S "failed"
3538
Hanno Becker6a243642017-10-12 15:18:45 +01003539requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003540run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003541 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003542 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3543 0 \
3544 -C "client hello, adding renegotiation extension" \
3545 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3546 -S "found renegotiation extension" \
3547 -s "server hello, secure renegotiation extension" \
3548 -c "found renegotiation extension" \
3549 -S "record counter limit reached: renegotiate" \
3550 -C "=> renegotiate" \
3551 -S "=> renegotiate" \
3552 -S "write hello request" \
3553 -S "SSL - An unexpected message was received from our peer" \
3554 -S "failed"
3555
Hanno Becker6a243642017-10-12 15:18:45 +01003556requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003557run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003558 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003559 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003560 0 \
3561 -c "client hello, adding renegotiation extension" \
3562 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3563 -s "found renegotiation extension" \
3564 -s "server hello, secure renegotiation extension" \
3565 -c "found renegotiation extension" \
3566 -c "=> renegotiate" \
3567 -s "=> renegotiate" \
3568 -S "write hello request"
3569
Hanno Becker6a243642017-10-12 15:18:45 +01003570requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003571run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003572 "$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 +02003573 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003574 0 \
3575 -c "client hello, adding renegotiation extension" \
3576 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3577 -s "found renegotiation extension" \
3578 -s "server hello, secure renegotiation extension" \
3579 -c "found renegotiation extension" \
3580 -c "=> renegotiate" \
3581 -s "=> renegotiate" \
3582 -s "write hello request"
3583
Hanno Becker6a243642017-10-12 15:18:45 +01003584requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003585run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003586 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003587 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003588 0 \
3589 -c "client hello, adding renegotiation extension" \
3590 -c "found renegotiation extension" \
3591 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003592 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003593 -C "error" \
3594 -c "HTTP/1.0 200 [Oo][Kk]"
3595
Paul Bakker539d9722015-02-08 16:18:35 +01003596requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003597requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003598run_test "Renegotiation: gnutls server strict, client-initiated" \
3599 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003600 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003601 0 \
3602 -c "client hello, adding renegotiation extension" \
3603 -c "found renegotiation extension" \
3604 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003605 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003606 -C "error" \
3607 -c "HTTP/1.0 200 [Oo][Kk]"
3608
Paul Bakker539d9722015-02-08 16:18:35 +01003609requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003610requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003611run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3612 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3613 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
3614 1 \
3615 -c "client hello, adding renegotiation extension" \
3616 -C "found renegotiation extension" \
3617 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003618 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003619 -c "error" \
3620 -C "HTTP/1.0 200 [Oo][Kk]"
3621
Paul Bakker539d9722015-02-08 16:18:35 +01003622requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003623requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003624run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3625 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3626 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3627 allow_legacy=0" \
3628 1 \
3629 -c "client hello, adding renegotiation extension" \
3630 -C "found renegotiation extension" \
3631 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003632 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003633 -c "error" \
3634 -C "HTTP/1.0 200 [Oo][Kk]"
3635
Paul Bakker539d9722015-02-08 16:18:35 +01003636requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003637requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003638run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3639 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3640 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3641 allow_legacy=1" \
3642 0 \
3643 -c "client hello, adding renegotiation extension" \
3644 -C "found renegotiation extension" \
3645 -c "=> renegotiate" \
3646 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003647 -C "error" \
3648 -c "HTTP/1.0 200 [Oo][Kk]"
3649
Hanno Becker6a243642017-10-12 15:18:45 +01003650requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003651run_test "Renegotiation: DTLS, client-initiated" \
3652 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3653 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3654 0 \
3655 -c "client hello, adding renegotiation extension" \
3656 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3657 -s "found renegotiation extension" \
3658 -s "server hello, secure renegotiation extension" \
3659 -c "found renegotiation extension" \
3660 -c "=> renegotiate" \
3661 -s "=> renegotiate" \
3662 -S "write hello request"
3663
Hanno Becker6a243642017-10-12 15:18:45 +01003664requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003665run_test "Renegotiation: DTLS, server-initiated" \
3666 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003667 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3668 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003669 0 \
3670 -c "client hello, adding renegotiation extension" \
3671 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3672 -s "found renegotiation extension" \
3673 -s "server hello, secure renegotiation extension" \
3674 -c "found renegotiation extension" \
3675 -c "=> renegotiate" \
3676 -s "=> renegotiate" \
3677 -s "write hello request"
3678
Hanno Becker6a243642017-10-12 15:18:45 +01003679requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003680run_test "Renegotiation: DTLS, renego_period overflow" \
3681 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3682 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3683 0 \
3684 -c "client hello, adding renegotiation extension" \
3685 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3686 -s "found renegotiation extension" \
3687 -s "server hello, secure renegotiation extension" \
3688 -s "record counter limit reached: renegotiate" \
3689 -c "=> renegotiate" \
3690 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003691 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003692
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003693requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003694requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003695run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3696 "$G_SRV -u --mtu 4096" \
3697 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
3698 0 \
3699 -c "client hello, adding renegotiation extension" \
3700 -c "found renegotiation extension" \
3701 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003702 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003703 -C "error" \
3704 -s "Extra-header:"
3705
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003706# Test for the "secure renegotation" extension only (no actual renegotiation)
3707
Paul Bakker539d9722015-02-08 16:18:35 +01003708requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003709run_test "Renego ext: gnutls server strict, client default" \
3710 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
3711 "$P_CLI debug_level=3" \
3712 0 \
3713 -c "found renegotiation extension" \
3714 -C "error" \
3715 -c "HTTP/1.0 200 [Oo][Kk]"
3716
Paul Bakker539d9722015-02-08 16:18:35 +01003717requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003718run_test "Renego ext: gnutls server unsafe, client default" \
3719 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3720 "$P_CLI debug_level=3" \
3721 0 \
3722 -C "found renegotiation extension" \
3723 -C "error" \
3724 -c "HTTP/1.0 200 [Oo][Kk]"
3725
Paul Bakker539d9722015-02-08 16:18:35 +01003726requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003727run_test "Renego ext: gnutls server unsafe, client break legacy" \
3728 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3729 "$P_CLI debug_level=3 allow_legacy=-1" \
3730 1 \
3731 -C "found renegotiation extension" \
3732 -c "error" \
3733 -C "HTTP/1.0 200 [Oo][Kk]"
3734
Paul Bakker539d9722015-02-08 16:18:35 +01003735requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003736run_test "Renego ext: gnutls client strict, server default" \
3737 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003738 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003739 0 \
3740 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3741 -s "server hello, secure renegotiation extension"
3742
Paul Bakker539d9722015-02-08 16:18:35 +01003743requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003744run_test "Renego ext: gnutls client unsafe, server default" \
3745 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003746 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003747 0 \
3748 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3749 -S "server hello, secure renegotiation extension"
3750
Paul Bakker539d9722015-02-08 16:18:35 +01003751requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003752run_test "Renego ext: gnutls client unsafe, server break legacy" \
3753 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003754 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003755 1 \
3756 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3757 -S "server hello, secure renegotiation extension"
3758
Janos Follath0b242342016-02-17 10:11:21 +00003759# Tests for silently dropping trailing extra bytes in .der certificates
3760
3761requires_gnutls
3762run_test "DER format: no trailing bytes" \
3763 "$P_SRV crt_file=data_files/server5-der0.crt \
3764 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003765 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003766 0 \
3767 -c "Handshake was completed" \
3768
3769requires_gnutls
3770run_test "DER format: with a trailing zero byte" \
3771 "$P_SRV crt_file=data_files/server5-der1a.crt \
3772 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003773 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003774 0 \
3775 -c "Handshake was completed" \
3776
3777requires_gnutls
3778run_test "DER format: with a trailing random byte" \
3779 "$P_SRV crt_file=data_files/server5-der1b.crt \
3780 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003781 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003782 0 \
3783 -c "Handshake was completed" \
3784
3785requires_gnutls
3786run_test "DER format: with 2 trailing random bytes" \
3787 "$P_SRV crt_file=data_files/server5-der2.crt \
3788 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003789 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003790 0 \
3791 -c "Handshake was completed" \
3792
3793requires_gnutls
3794run_test "DER format: with 4 trailing random bytes" \
3795 "$P_SRV crt_file=data_files/server5-der4.crt \
3796 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003797 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003798 0 \
3799 -c "Handshake was completed" \
3800
3801requires_gnutls
3802run_test "DER format: with 8 trailing random bytes" \
3803 "$P_SRV crt_file=data_files/server5-der8.crt \
3804 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003805 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003806 0 \
3807 -c "Handshake was completed" \
3808
3809requires_gnutls
3810run_test "DER format: with 9 trailing random bytes" \
3811 "$P_SRV crt_file=data_files/server5-der9.crt \
3812 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003813 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003814 0 \
3815 -c "Handshake was completed" \
3816
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03003817# Tests for auth_mode, there are duplicated tests using ca callback for authentication
3818# When updating these tests, modify the matching authentication tests accordingly
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003820run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003821 "$P_SRV crt_file=data_files/server5-badsign.crt \
3822 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003823 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003824 1 \
3825 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003826 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003827 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003828 -c "X509 - Certificate verification failed"
3829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003830run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003831 "$P_SRV crt_file=data_files/server5-badsign.crt \
3832 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003833 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003834 0 \
3835 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003836 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003837 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003838 -C "X509 - Certificate verification failed"
3839
Hanno Beckere6706e62017-05-15 16:05:15 +01003840run_test "Authentication: server goodcert, client optional, no trusted CA" \
3841 "$P_SRV" \
3842 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3843 0 \
3844 -c "x509_verify_cert() returned" \
3845 -c "! The certificate is not correctly signed by the trusted CA" \
3846 -c "! Certificate verification flags"\
3847 -C "! mbedtls_ssl_handshake returned" \
3848 -C "X509 - Certificate verification failed" \
3849 -C "SSL - No CA Chain is set, but required to operate"
3850
3851run_test "Authentication: server goodcert, client required, no trusted CA" \
3852 "$P_SRV" \
3853 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3854 1 \
3855 -c "x509_verify_cert() returned" \
3856 -c "! The certificate is not correctly signed by the trusted CA" \
3857 -c "! Certificate verification flags"\
3858 -c "! mbedtls_ssl_handshake returned" \
3859 -c "SSL - No CA Chain is set, but required to operate"
3860
3861# The purpose of the next two tests is to test the client's behaviour when receiving a server
3862# certificate with an unsupported elliptic curve. This should usually not happen because
3863# the client informs the server about the supported curves - it does, though, in the
3864# corner case of a static ECDH suite, because the server doesn't check the curve on that
3865# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3866# different means to have the server ignoring the client's supported curve list.
3867
3868requires_config_enabled MBEDTLS_ECP_C
3869run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3870 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3871 crt_file=data_files/server5.ku-ka.crt" \
3872 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3873 1 \
3874 -c "bad certificate (EC key curve)"\
3875 -c "! Certificate verification flags"\
3876 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3877
3878requires_config_enabled MBEDTLS_ECP_C
3879run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3880 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3881 crt_file=data_files/server5.ku-ka.crt" \
3882 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3883 1 \
3884 -c "bad certificate (EC key curve)"\
3885 -c "! Certificate verification flags"\
3886 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003888run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003889 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003890 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003891 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003892 0 \
3893 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003894 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003895 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003896 -C "X509 - Certificate verification failed"
3897
Simon Butcher99000142016-10-13 17:21:01 +01003898run_test "Authentication: client SHA256, server required" \
3899 "$P_SRV auth_mode=required" \
3900 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3901 key_file=data_files/server6.key \
3902 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3903 0 \
3904 -c "Supported Signature Algorithm found: 4," \
3905 -c "Supported Signature Algorithm found: 5,"
3906
3907run_test "Authentication: client SHA384, server required" \
3908 "$P_SRV auth_mode=required" \
3909 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3910 key_file=data_files/server6.key \
3911 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3912 0 \
3913 -c "Supported Signature Algorithm found: 4," \
3914 -c "Supported Signature Algorithm found: 5,"
3915
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003916requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3917run_test "Authentication: client has no cert, server required (SSLv3)" \
3918 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3919 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3920 key_file=data_files/server5.key" \
3921 1 \
3922 -S "skip write certificate request" \
3923 -C "skip parse certificate request" \
3924 -c "got a certificate request" \
3925 -c "got no certificate to send" \
3926 -S "x509_verify_cert() returned" \
3927 -s "client has no certificate" \
3928 -s "! mbedtls_ssl_handshake returned" \
3929 -c "! mbedtls_ssl_handshake returned" \
3930 -s "No client certification received from the client, but required by the authentication mode"
3931
3932run_test "Authentication: client has no cert, server required (TLS)" \
3933 "$P_SRV debug_level=3 auth_mode=required" \
3934 "$P_CLI debug_level=3 crt_file=none \
3935 key_file=data_files/server5.key" \
3936 1 \
3937 -S "skip write certificate request" \
3938 -C "skip parse certificate request" \
3939 -c "got a certificate request" \
3940 -c "= write certificate$" \
3941 -C "skip write certificate$" \
3942 -S "x509_verify_cert() returned" \
3943 -s "client has no certificate" \
3944 -s "! mbedtls_ssl_handshake returned" \
3945 -c "! mbedtls_ssl_handshake returned" \
3946 -s "No client certification received from the client, but required by the authentication mode"
3947
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003948run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003949 "$P_SRV debug_level=3 auth_mode=required" \
3950 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003951 key_file=data_files/server5.key" \
3952 1 \
3953 -S "skip write certificate request" \
3954 -C "skip parse certificate request" \
3955 -c "got a certificate request" \
3956 -C "skip write certificate" \
3957 -C "skip write certificate verify" \
3958 -S "skip parse certificate verify" \
3959 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003960 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003961 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003962 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003963 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003964 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003965# We don't check that the client receives the alert because it might
3966# detect that its write end of the connection is closed and abort
3967# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003968
Janos Follath89baba22017-04-10 14:34:35 +01003969run_test "Authentication: client cert not trusted, server required" \
3970 "$P_SRV debug_level=3 auth_mode=required" \
3971 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3972 key_file=data_files/server5.key" \
3973 1 \
3974 -S "skip write certificate request" \
3975 -C "skip parse certificate request" \
3976 -c "got a certificate request" \
3977 -C "skip write certificate" \
3978 -C "skip write certificate verify" \
3979 -S "skip parse certificate verify" \
3980 -s "x509_verify_cert() returned" \
3981 -s "! The certificate is not correctly signed by the trusted CA" \
3982 -s "! mbedtls_ssl_handshake returned" \
3983 -c "! mbedtls_ssl_handshake returned" \
3984 -s "X509 - Certificate verification failed"
3985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003986run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003987 "$P_SRV debug_level=3 auth_mode=optional" \
3988 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003989 key_file=data_files/server5.key" \
3990 0 \
3991 -S "skip write certificate request" \
3992 -C "skip parse certificate request" \
3993 -c "got a certificate request" \
3994 -C "skip write certificate" \
3995 -C "skip write certificate verify" \
3996 -S "skip parse certificate verify" \
3997 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003998 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003999 -S "! mbedtls_ssl_handshake returned" \
4000 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004001 -S "X509 - Certificate verification failed"
4002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004003run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004004 "$P_SRV debug_level=3 auth_mode=none" \
4005 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004006 key_file=data_files/server5.key" \
4007 0 \
4008 -s "skip write certificate request" \
4009 -C "skip parse certificate request" \
4010 -c "got no certificate request" \
4011 -c "skip write certificate" \
4012 -c "skip write certificate verify" \
4013 -s "skip parse certificate verify" \
4014 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004015 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004016 -S "! mbedtls_ssl_handshake returned" \
4017 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004018 -S "X509 - Certificate verification failed"
4019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004020run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004021 "$P_SRV debug_level=3 auth_mode=optional" \
4022 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004023 0 \
4024 -S "skip write certificate request" \
4025 -C "skip parse certificate request" \
4026 -c "got a certificate request" \
4027 -C "skip write certificate$" \
4028 -C "got no certificate to send" \
4029 -S "SSLv3 client has no certificate" \
4030 -c "skip write certificate verify" \
4031 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004032 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004033 -S "! mbedtls_ssl_handshake returned" \
4034 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004035 -S "X509 - Certificate verification failed"
4036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004037run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004038 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004039 "$O_CLI" \
4040 0 \
4041 -S "skip write certificate request" \
4042 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004043 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004044 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004045 -S "X509 - Certificate verification failed"
4046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004047run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004048 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004049 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004050 0 \
4051 -C "skip parse certificate request" \
4052 -c "got a certificate request" \
4053 -C "skip write certificate$" \
4054 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004055 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004056
Gilles Peskinefd8332e2017-05-03 16:25:07 +02004057run_test "Authentication: client no cert, openssl server required" \
4058 "$O_SRV -Verify 10" \
4059 "$P_CLI debug_level=3 crt_file=none key_file=none" \
4060 1 \
4061 -C "skip parse certificate request" \
4062 -c "got a certificate request" \
4063 -C "skip write certificate$" \
4064 -c "skip write certificate verify" \
4065 -c "! mbedtls_ssl_handshake returned"
4066
Janos Follathe2681a42016-03-07 15:57:05 +00004067requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004068run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004069 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004070 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004071 0 \
4072 -S "skip write certificate request" \
4073 -C "skip parse certificate request" \
4074 -c "got a certificate request" \
4075 -C "skip write certificate$" \
4076 -c "skip write certificate verify" \
4077 -c "got no certificate to send" \
4078 -s "SSLv3 client has no certificate" \
4079 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004080 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004081 -S "! mbedtls_ssl_handshake returned" \
4082 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004083 -S "X509 - Certificate verification failed"
4084
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02004085# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
4086# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004087
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004088MAX_IM_CA='8'
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02004089MAX_IM_CA_CONFIG=$( ../scripts/config.py get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004090
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004091if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01004092 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004093 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004094 printf "test value of ${MAX_IM_CA}. \n"
4095 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004096 printf "The tests assume this value and if it changes, the tests in this\n"
4097 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004098 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004099
4100 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004101fi
4102
Angus Grattonc4dd0732018-04-11 16:28:39 +10004103requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004104run_test "Authentication: server max_int chain, client default" \
4105 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4106 key_file=data_files/dir-maxpath/09.key" \
4107 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4108 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004109 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004110
Angus Grattonc4dd0732018-04-11 16:28:39 +10004111requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004112run_test "Authentication: server max_int+1 chain, client default" \
4113 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4114 key_file=data_files/dir-maxpath/10.key" \
4115 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4116 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004117 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004118
Angus Grattonc4dd0732018-04-11 16:28:39 +10004119requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004120run_test "Authentication: server max_int+1 chain, client optional" \
4121 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4122 key_file=data_files/dir-maxpath/10.key" \
4123 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4124 auth_mode=optional" \
4125 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004126 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004127
Angus Grattonc4dd0732018-04-11 16:28:39 +10004128requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004129run_test "Authentication: server max_int+1 chain, client none" \
4130 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4131 key_file=data_files/dir-maxpath/10.key" \
4132 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4133 auth_mode=none" \
4134 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004135 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004136
Angus Grattonc4dd0732018-04-11 16:28:39 +10004137requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004138run_test "Authentication: client max_int+1 chain, server default" \
4139 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4140 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4141 key_file=data_files/dir-maxpath/10.key" \
4142 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004143 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004144
Angus Grattonc4dd0732018-04-11 16:28:39 +10004145requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004146run_test "Authentication: client max_int+1 chain, server optional" \
4147 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4148 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4149 key_file=data_files/dir-maxpath/10.key" \
4150 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004151 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004152
Angus Grattonc4dd0732018-04-11 16:28:39 +10004153requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004154run_test "Authentication: client max_int+1 chain, server required" \
4155 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4156 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4157 key_file=data_files/dir-maxpath/10.key" \
4158 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004159 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004160
Angus Grattonc4dd0732018-04-11 16:28:39 +10004161requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004162run_test "Authentication: client max_int chain, server required" \
4163 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4164 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4165 key_file=data_files/dir-maxpath/09.key" \
4166 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004167 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004168
Janos Follath89baba22017-04-10 14:34:35 +01004169# Tests for CA list in CertificateRequest messages
4170
4171run_test "Authentication: send CA list in CertificateRequest (default)" \
4172 "$P_SRV debug_level=3 auth_mode=required" \
4173 "$P_CLI crt_file=data_files/server6.crt \
4174 key_file=data_files/server6.key" \
4175 0 \
4176 -s "requested DN"
4177
4178run_test "Authentication: do not send CA list in CertificateRequest" \
4179 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4180 "$P_CLI crt_file=data_files/server6.crt \
4181 key_file=data_files/server6.key" \
4182 0 \
4183 -S "requested DN"
4184
4185run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4186 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4187 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4188 key_file=data_files/server5.key" \
4189 1 \
4190 -S "requested DN" \
4191 -s "x509_verify_cert() returned" \
4192 -s "! The certificate is not correctly signed by the trusted CA" \
4193 -s "! mbedtls_ssl_handshake returned" \
4194 -c "! mbedtls_ssl_handshake returned" \
4195 -s "X509 - Certificate verification failed"
4196
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03004197# Tests for auth_mode, using CA callback, these are duplicated from the authentication tests
4198# When updating these tests, modify the matching authentication tests accordingly
Hanno Becker746aaf32019-03-28 15:25:23 +00004199
4200requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4201run_test "Authentication, CA callback: server badcert, client required" \
4202 "$P_SRV crt_file=data_files/server5-badsign.crt \
4203 key_file=data_files/server5.key" \
4204 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required" \
4205 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004206 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004207 -c "x509_verify_cert() returned" \
4208 -c "! The certificate is not correctly signed by the trusted CA" \
4209 -c "! mbedtls_ssl_handshake returned" \
4210 -c "X509 - Certificate verification failed"
4211
4212requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4213run_test "Authentication, CA callback: server badcert, client optional" \
4214 "$P_SRV crt_file=data_files/server5-badsign.crt \
4215 key_file=data_files/server5.key" \
4216 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional" \
4217 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004218 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004219 -c "x509_verify_cert() returned" \
4220 -c "! The certificate is not correctly signed by the trusted CA" \
4221 -C "! mbedtls_ssl_handshake returned" \
4222 -C "X509 - Certificate verification failed"
4223
4224# The purpose of the next two tests is to test the client's behaviour when receiving a server
4225# certificate with an unsupported elliptic curve. This should usually not happen because
4226# the client informs the server about the supported curves - it does, though, in the
4227# corner case of a static ECDH suite, because the server doesn't check the curve on that
4228# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
4229# different means to have the server ignoring the client's supported curve list.
4230
4231requires_config_enabled MBEDTLS_ECP_C
4232requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4233run_test "Authentication, CA callback: server ECDH p256v1, client required, p256v1 unsupported" \
4234 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4235 crt_file=data_files/server5.ku-ka.crt" \
4236 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required curves=secp521r1" \
4237 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004238 -c "use CA callback for X.509 CRT verification" \
4239 -c "bad certificate (EC key curve)" \
4240 -c "! Certificate verification flags" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004241 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
4242
4243requires_config_enabled MBEDTLS_ECP_C
4244requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4245run_test "Authentication, CA callback: server ECDH p256v1, client optional, p256v1 unsupported" \
4246 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4247 crt_file=data_files/server5.ku-ka.crt" \
4248 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional curves=secp521r1" \
4249 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004250 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004251 -c "bad certificate (EC key curve)"\
4252 -c "! Certificate verification flags"\
4253 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
4254
4255requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4256run_test "Authentication, CA callback: client SHA256, server required" \
4257 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4258 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4259 key_file=data_files/server6.key \
4260 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
4261 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004262 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004263 -c "Supported Signature Algorithm found: 4," \
4264 -c "Supported Signature Algorithm found: 5,"
4265
4266requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4267run_test "Authentication, CA callback: client SHA384, server required" \
4268 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4269 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4270 key_file=data_files/server6.key \
4271 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
4272 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004273 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004274 -c "Supported Signature Algorithm found: 4," \
4275 -c "Supported Signature Algorithm found: 5,"
4276
4277requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4278run_test "Authentication, CA callback: client badcert, server required" \
4279 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4280 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4281 key_file=data_files/server5.key" \
4282 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004283 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004284 -S "skip write certificate request" \
4285 -C "skip parse certificate request" \
4286 -c "got a certificate request" \
4287 -C "skip write certificate" \
4288 -C "skip write certificate verify" \
4289 -S "skip parse certificate verify" \
4290 -s "x509_verify_cert() returned" \
4291 -s "! The certificate is not correctly signed by the trusted CA" \
4292 -s "! mbedtls_ssl_handshake returned" \
4293 -s "send alert level=2 message=48" \
4294 -c "! mbedtls_ssl_handshake returned" \
4295 -s "X509 - Certificate verification failed"
4296# We don't check that the client receives the alert because it might
4297# detect that its write end of the connection is closed and abort
4298# before reading the alert message.
4299
4300requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4301run_test "Authentication, CA callback: client cert not trusted, server required" \
4302 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4303 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4304 key_file=data_files/server5.key" \
4305 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004306 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004307 -S "skip write certificate request" \
4308 -C "skip parse certificate request" \
4309 -c "got a certificate request" \
4310 -C "skip write certificate" \
4311 -C "skip write certificate verify" \
4312 -S "skip parse certificate verify" \
4313 -s "x509_verify_cert() returned" \
4314 -s "! The certificate is not correctly signed by the trusted CA" \
4315 -s "! mbedtls_ssl_handshake returned" \
4316 -c "! mbedtls_ssl_handshake returned" \
4317 -s "X509 - Certificate verification failed"
4318
4319requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4320run_test "Authentication, CA callback: client badcert, server optional" \
4321 "$P_SRV ca_callback=1 debug_level=3 auth_mode=optional" \
4322 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4323 key_file=data_files/server5.key" \
4324 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004325 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004326 -S "skip write certificate request" \
4327 -C "skip parse certificate request" \
4328 -c "got a certificate request" \
4329 -C "skip write certificate" \
4330 -C "skip write certificate verify" \
4331 -S "skip parse certificate verify" \
4332 -s "x509_verify_cert() returned" \
4333 -s "! The certificate is not correctly signed by the trusted CA" \
4334 -S "! mbedtls_ssl_handshake returned" \
4335 -C "! mbedtls_ssl_handshake returned" \
4336 -S "X509 - Certificate verification failed"
4337
4338requires_full_size_output_buffer
4339requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4340run_test "Authentication, CA callback: server max_int chain, client default" \
4341 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4342 key_file=data_files/dir-maxpath/09.key" \
4343 "$P_CLI ca_callback=1 debug_level=3 server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4344 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004345 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004346 -C "X509 - A fatal error occurred"
4347
4348requires_full_size_output_buffer
4349requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4350run_test "Authentication, CA callback: server max_int+1 chain, client default" \
4351 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4352 key_file=data_files/dir-maxpath/10.key" \
4353 "$P_CLI debug_level=3 ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4354 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004355 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004356 -c "X509 - A fatal error occurred"
4357
4358requires_full_size_output_buffer
4359requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4360run_test "Authentication, CA callback: server max_int+1 chain, client optional" \
4361 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4362 key_file=data_files/dir-maxpath/10.key" \
4363 "$P_CLI ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4364 debug_level=3 auth_mode=optional" \
4365 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004366 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004367 -c "X509 - A fatal error occurred"
4368
4369requires_full_size_output_buffer
4370requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4371run_test "Authentication, CA callback: client max_int+1 chain, server optional" \
4372 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4373 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4374 key_file=data_files/dir-maxpath/10.key" \
4375 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004376 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004377 -s "X509 - A fatal error occurred"
4378
4379requires_full_size_output_buffer
4380requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4381run_test "Authentication, CA callback: client max_int+1 chain, server required" \
4382 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4383 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4384 key_file=data_files/dir-maxpath/10.key" \
4385 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004386 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004387 -s "X509 - A fatal error occurred"
4388
4389requires_full_size_output_buffer
4390requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4391run_test "Authentication, CA callback: client max_int chain, server required" \
4392 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4393 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4394 key_file=data_files/dir-maxpath/09.key" \
4395 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004396 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004397 -S "X509 - A fatal error occurred"
4398
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004399# Tests for certificate selection based on SHA verson
4400
4401run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4402 "$P_SRV crt_file=data_files/server5.crt \
4403 key_file=data_files/server5.key \
4404 crt_file2=data_files/server5-sha1.crt \
4405 key_file2=data_files/server5.key" \
4406 "$P_CLI force_version=tls1_2" \
4407 0 \
4408 -c "signed using.*ECDSA with SHA256" \
4409 -C "signed using.*ECDSA with SHA1"
4410
4411run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4412 "$P_SRV crt_file=data_files/server5.crt \
4413 key_file=data_files/server5.key \
4414 crt_file2=data_files/server5-sha1.crt \
4415 key_file2=data_files/server5.key" \
4416 "$P_CLI force_version=tls1_1" \
4417 0 \
4418 -C "signed using.*ECDSA with SHA256" \
4419 -c "signed using.*ECDSA with SHA1"
4420
4421run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4422 "$P_SRV crt_file=data_files/server5.crt \
4423 key_file=data_files/server5.key \
4424 crt_file2=data_files/server5-sha1.crt \
4425 key_file2=data_files/server5.key" \
4426 "$P_CLI force_version=tls1" \
4427 0 \
4428 -C "signed using.*ECDSA with SHA256" \
4429 -c "signed using.*ECDSA with SHA1"
4430
4431run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4432 "$P_SRV crt_file=data_files/server5.crt \
4433 key_file=data_files/server5.key \
4434 crt_file2=data_files/server6.crt \
4435 key_file2=data_files/server6.key" \
4436 "$P_CLI force_version=tls1_1" \
4437 0 \
4438 -c "serial number.*09" \
4439 -c "signed using.*ECDSA with SHA256" \
4440 -C "signed using.*ECDSA with SHA1"
4441
4442run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4443 "$P_SRV crt_file=data_files/server6.crt \
4444 key_file=data_files/server6.key \
4445 crt_file2=data_files/server5.crt \
4446 key_file2=data_files/server5.key" \
4447 "$P_CLI force_version=tls1_1" \
4448 0 \
4449 -c "serial number.*0A" \
4450 -c "signed using.*ECDSA with SHA256" \
4451 -C "signed using.*ECDSA with SHA1"
4452
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004453# tests for SNI
4454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004455run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004456 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004457 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004458 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004459 0 \
4460 -S "parse ServerName extension" \
4461 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4462 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004464run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004465 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004466 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004467 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 +02004468 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004469 0 \
4470 -s "parse ServerName extension" \
4471 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4472 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004474run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004475 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004476 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004477 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 +02004478 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004479 0 \
4480 -s "parse ServerName extension" \
4481 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4482 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004484run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004485 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004486 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004487 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 +02004488 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004489 1 \
4490 -s "parse ServerName extension" \
4491 -s "ssl_sni_wrapper() returned" \
4492 -s "mbedtls_ssl_handshake returned" \
4493 -c "mbedtls_ssl_handshake returned" \
4494 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004495
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004496run_test "SNI: client auth no override: optional" \
4497 "$P_SRV debug_level=3 auth_mode=optional \
4498 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4499 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4500 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004501 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004502 -S "skip write certificate request" \
4503 -C "skip parse certificate request" \
4504 -c "got a certificate request" \
4505 -C "skip write certificate" \
4506 -C "skip write certificate verify" \
4507 -S "skip parse certificate verify"
4508
4509run_test "SNI: client auth override: none -> optional" \
4510 "$P_SRV debug_level=3 auth_mode=none \
4511 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4512 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4513 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004514 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004515 -S "skip write certificate request" \
4516 -C "skip parse certificate request" \
4517 -c "got a certificate request" \
4518 -C "skip write certificate" \
4519 -C "skip write certificate verify" \
4520 -S "skip parse certificate verify"
4521
4522run_test "SNI: client auth override: optional -> none" \
4523 "$P_SRV debug_level=3 auth_mode=optional \
4524 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4525 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4526 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004527 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004528 -s "skip write certificate request" \
4529 -C "skip parse certificate request" \
4530 -c "got no certificate request" \
4531 -c "skip write certificate" \
4532 -c "skip write certificate verify" \
4533 -s "skip parse certificate verify"
4534
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004535run_test "SNI: CA no override" \
4536 "$P_SRV debug_level=3 auth_mode=optional \
4537 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4538 ca_file=data_files/test-ca.crt \
4539 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4540 "$P_CLI debug_level=3 server_name=localhost \
4541 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4542 1 \
4543 -S "skip write certificate request" \
4544 -C "skip parse certificate request" \
4545 -c "got a certificate request" \
4546 -C "skip write certificate" \
4547 -C "skip write certificate verify" \
4548 -S "skip parse certificate verify" \
4549 -s "x509_verify_cert() returned" \
4550 -s "! The certificate is not correctly signed by the trusted CA" \
4551 -S "The certificate has been revoked (is on a CRL)"
4552
4553run_test "SNI: CA override" \
4554 "$P_SRV debug_level=3 auth_mode=optional \
4555 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4556 ca_file=data_files/test-ca.crt \
4557 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4558 "$P_CLI debug_level=3 server_name=localhost \
4559 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4560 0 \
4561 -S "skip write certificate request" \
4562 -C "skip parse certificate request" \
4563 -c "got a certificate request" \
4564 -C "skip write certificate" \
4565 -C "skip write certificate verify" \
4566 -S "skip parse certificate verify" \
4567 -S "x509_verify_cert() returned" \
4568 -S "! The certificate is not correctly signed by the trusted CA" \
4569 -S "The certificate has been revoked (is on a CRL)"
4570
4571run_test "SNI: CA override with CRL" \
4572 "$P_SRV debug_level=3 auth_mode=optional \
4573 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4574 ca_file=data_files/test-ca.crt \
4575 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4576 "$P_CLI debug_level=3 server_name=localhost \
4577 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4578 1 \
4579 -S "skip write certificate request" \
4580 -C "skip parse certificate request" \
4581 -c "got a certificate request" \
4582 -C "skip write certificate" \
4583 -C "skip write certificate verify" \
4584 -S "skip parse certificate verify" \
4585 -s "x509_verify_cert() returned" \
4586 -S "! The certificate is not correctly signed by the trusted CA" \
4587 -s "The certificate has been revoked (is on a CRL)"
4588
Andres AG1a834452016-12-07 10:01:30 +00004589# Tests for SNI and DTLS
4590
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004591run_test "SNI: DTLS, no SNI callback" \
4592 "$P_SRV debug_level=3 dtls=1 \
4593 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
4594 "$P_CLI server_name=localhost dtls=1" \
4595 0 \
4596 -S "parse ServerName extension" \
4597 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4598 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4599
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004600run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004601 "$P_SRV debug_level=3 dtls=1 \
4602 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4603 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4604 "$P_CLI server_name=localhost dtls=1" \
4605 0 \
4606 -s "parse ServerName extension" \
4607 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4608 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4609
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004610run_test "SNI: DTLS, matching cert 2" \
4611 "$P_SRV debug_level=3 dtls=1 \
4612 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4613 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4614 "$P_CLI server_name=polarssl.example dtls=1" \
4615 0 \
4616 -s "parse ServerName extension" \
4617 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4618 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4619
4620run_test "SNI: DTLS, no matching cert" \
4621 "$P_SRV debug_level=3 dtls=1 \
4622 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4623 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4624 "$P_CLI server_name=nonesuch.example dtls=1" \
4625 1 \
4626 -s "parse ServerName extension" \
4627 -s "ssl_sni_wrapper() returned" \
4628 -s "mbedtls_ssl_handshake returned" \
4629 -c "mbedtls_ssl_handshake returned" \
4630 -c "SSL - A fatal alert message was received from our peer"
4631
4632run_test "SNI: DTLS, client auth no override: optional" \
4633 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4634 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4635 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4636 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4637 0 \
4638 -S "skip write certificate request" \
4639 -C "skip parse certificate request" \
4640 -c "got a certificate request" \
4641 -C "skip write certificate" \
4642 -C "skip write certificate verify" \
4643 -S "skip parse certificate verify"
4644
4645run_test "SNI: DTLS, client auth override: none -> optional" \
4646 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4647 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4648 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4649 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4650 0 \
4651 -S "skip write certificate request" \
4652 -C "skip parse certificate request" \
4653 -c "got a certificate request" \
4654 -C "skip write certificate" \
4655 -C "skip write certificate verify" \
4656 -S "skip parse certificate verify"
4657
4658run_test "SNI: DTLS, client auth override: optional -> none" \
4659 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4660 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4661 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4662 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4663 0 \
4664 -s "skip write certificate request" \
4665 -C "skip parse certificate request" \
4666 -c "got no certificate request" \
4667 -c "skip write certificate" \
4668 -c "skip write certificate verify" \
4669 -s "skip parse certificate verify"
4670
4671run_test "SNI: DTLS, CA no override" \
4672 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4673 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4674 ca_file=data_files/test-ca.crt \
4675 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4676 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4677 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4678 1 \
4679 -S "skip write certificate request" \
4680 -C "skip parse certificate request" \
4681 -c "got a certificate request" \
4682 -C "skip write certificate" \
4683 -C "skip write certificate verify" \
4684 -S "skip parse certificate verify" \
4685 -s "x509_verify_cert() returned" \
4686 -s "! The certificate is not correctly signed by the trusted CA" \
4687 -S "The certificate has been revoked (is on a CRL)"
4688
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004689run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004690 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4691 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4692 ca_file=data_files/test-ca.crt \
4693 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4694 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4695 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4696 0 \
4697 -S "skip write certificate request" \
4698 -C "skip parse certificate request" \
4699 -c "got a certificate request" \
4700 -C "skip write certificate" \
4701 -C "skip write certificate verify" \
4702 -S "skip parse certificate verify" \
4703 -S "x509_verify_cert() returned" \
4704 -S "! The certificate is not correctly signed by the trusted CA" \
4705 -S "The certificate has been revoked (is on a CRL)"
4706
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004707run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004708 "$P_SRV debug_level=3 auth_mode=optional \
4709 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4710 ca_file=data_files/test-ca.crt \
4711 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4712 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4713 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4714 1 \
4715 -S "skip write certificate request" \
4716 -C "skip parse certificate request" \
4717 -c "got a certificate request" \
4718 -C "skip write certificate" \
4719 -C "skip write certificate verify" \
4720 -S "skip parse certificate verify" \
4721 -s "x509_verify_cert() returned" \
4722 -S "! The certificate is not correctly signed by the trusted CA" \
4723 -s "The certificate has been revoked (is on a CRL)"
4724
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004725# Tests for non-blocking I/O: exercise a variety of handshake flows
4726
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004727run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004728 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4729 "$P_CLI nbio=2 tickets=0" \
4730 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004731 -S "mbedtls_ssl_handshake returned" \
4732 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004733 -c "Read from server: .* bytes read"
4734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004735run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004736 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4737 "$P_CLI nbio=2 tickets=0" \
4738 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004739 -S "mbedtls_ssl_handshake returned" \
4740 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004741 -c "Read from server: .* bytes read"
4742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004743run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004744 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4745 "$P_CLI nbio=2 tickets=1" \
4746 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004747 -S "mbedtls_ssl_handshake returned" \
4748 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004749 -c "Read from server: .* bytes read"
4750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004751run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004752 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4753 "$P_CLI nbio=2 tickets=1" \
4754 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004755 -S "mbedtls_ssl_handshake returned" \
4756 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004757 -c "Read from server: .* bytes read"
4758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004759run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004760 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4761 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4762 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004763 -S "mbedtls_ssl_handshake returned" \
4764 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004765 -c "Read from server: .* bytes read"
4766
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004767run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004768 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4769 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4770 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004771 -S "mbedtls_ssl_handshake returned" \
4772 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004773 -c "Read from server: .* bytes read"
4774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004775run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004776 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4777 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4778 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004779 -S "mbedtls_ssl_handshake returned" \
4780 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004781 -c "Read from server: .* bytes read"
4782
Hanno Becker00076712017-11-15 16:39:08 +00004783# Tests for event-driven I/O: exercise a variety of handshake flows
4784
4785run_test "Event-driven I/O: basic handshake" \
4786 "$P_SRV event=1 tickets=0 auth_mode=none" \
4787 "$P_CLI event=1 tickets=0" \
4788 0 \
4789 -S "mbedtls_ssl_handshake returned" \
4790 -C "mbedtls_ssl_handshake returned" \
4791 -c "Read from server: .* bytes read"
4792
4793run_test "Event-driven I/O: client auth" \
4794 "$P_SRV event=1 tickets=0 auth_mode=required" \
4795 "$P_CLI event=1 tickets=0" \
4796 0 \
4797 -S "mbedtls_ssl_handshake returned" \
4798 -C "mbedtls_ssl_handshake returned" \
4799 -c "Read from server: .* bytes read"
4800
4801run_test "Event-driven I/O: ticket" \
4802 "$P_SRV event=1 tickets=1 auth_mode=none" \
4803 "$P_CLI event=1 tickets=1" \
4804 0 \
4805 -S "mbedtls_ssl_handshake returned" \
4806 -C "mbedtls_ssl_handshake returned" \
4807 -c "Read from server: .* bytes read"
4808
4809run_test "Event-driven I/O: ticket + client auth" \
4810 "$P_SRV event=1 tickets=1 auth_mode=required" \
4811 "$P_CLI event=1 tickets=1" \
4812 0 \
4813 -S "mbedtls_ssl_handshake returned" \
4814 -C "mbedtls_ssl_handshake returned" \
4815 -c "Read from server: .* bytes read"
4816
4817run_test "Event-driven I/O: ticket + client auth + resume" \
4818 "$P_SRV event=1 tickets=1 auth_mode=required" \
4819 "$P_CLI event=1 tickets=1 reconnect=1" \
4820 0 \
4821 -S "mbedtls_ssl_handshake returned" \
4822 -C "mbedtls_ssl_handshake returned" \
4823 -c "Read from server: .* bytes read"
4824
4825run_test "Event-driven I/O: ticket + resume" \
4826 "$P_SRV event=1 tickets=1 auth_mode=none" \
4827 "$P_CLI event=1 tickets=1 reconnect=1" \
4828 0 \
4829 -S "mbedtls_ssl_handshake returned" \
4830 -C "mbedtls_ssl_handshake returned" \
4831 -c "Read from server: .* bytes read"
4832
4833run_test "Event-driven I/O: session-id resume" \
4834 "$P_SRV event=1 tickets=0 auth_mode=none" \
4835 "$P_CLI event=1 tickets=0 reconnect=1" \
4836 0 \
4837 -S "mbedtls_ssl_handshake returned" \
4838 -C "mbedtls_ssl_handshake returned" \
4839 -c "Read from server: .* bytes read"
4840
Hanno Becker6a33f592018-03-13 11:38:46 +00004841run_test "Event-driven I/O, DTLS: basic handshake" \
4842 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4843 "$P_CLI dtls=1 event=1 tickets=0" \
4844 0 \
4845 -c "Read from server: .* bytes read"
4846
4847run_test "Event-driven I/O, DTLS: client auth" \
4848 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4849 "$P_CLI dtls=1 event=1 tickets=0" \
4850 0 \
4851 -c "Read from server: .* bytes read"
4852
4853run_test "Event-driven I/O, DTLS: ticket" \
4854 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4855 "$P_CLI dtls=1 event=1 tickets=1" \
4856 0 \
4857 -c "Read from server: .* bytes read"
4858
4859run_test "Event-driven I/O, DTLS: ticket + client auth" \
4860 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4861 "$P_CLI dtls=1 event=1 tickets=1" \
4862 0 \
4863 -c "Read from server: .* bytes read"
4864
4865run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4866 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004867 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004868 0 \
4869 -c "Read from server: .* bytes read"
4870
4871run_test "Event-driven I/O, DTLS: ticket + resume" \
4872 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004873 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004874 0 \
4875 -c "Read from server: .* bytes read"
4876
4877run_test "Event-driven I/O, DTLS: session-id resume" \
4878 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004879 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004880 0 \
4881 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004882
4883# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4884# During session resumption, the client will send its ApplicationData record
4885# within the same datagram as the Finished messages. In this situation, the
4886# server MUST NOT idle on the underlying transport after handshake completion,
4887# because the ApplicationData request has already been queued internally.
4888run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004889 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004890 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004891 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004892 0 \
4893 -c "Read from server: .* bytes read"
4894
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004895# Tests for version negotiation
4896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004897run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004898 "$P_SRV" \
4899 "$P_CLI" \
4900 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004901 -S "mbedtls_ssl_handshake returned" \
4902 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004903 -s "Protocol is TLSv1.2" \
4904 -c "Protocol is TLSv1.2"
4905
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004906run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004907 "$P_SRV" \
4908 "$P_CLI max_version=tls1_1" \
4909 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004910 -S "mbedtls_ssl_handshake returned" \
4911 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004912 -s "Protocol is TLSv1.1" \
4913 -c "Protocol is TLSv1.1"
4914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004915run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004916 "$P_SRV max_version=tls1_1" \
4917 "$P_CLI" \
4918 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004919 -S "mbedtls_ssl_handshake returned" \
4920 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004921 -s "Protocol is TLSv1.1" \
4922 -c "Protocol is TLSv1.1"
4923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004924run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004925 "$P_SRV max_version=tls1_1" \
4926 "$P_CLI max_version=tls1_1" \
4927 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004928 -S "mbedtls_ssl_handshake returned" \
4929 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004930 -s "Protocol is TLSv1.1" \
4931 -c "Protocol is TLSv1.1"
4932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004933run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004934 "$P_SRV min_version=tls1_1" \
4935 "$P_CLI max_version=tls1_1" \
4936 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004937 -S "mbedtls_ssl_handshake returned" \
4938 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004939 -s "Protocol is TLSv1.1" \
4940 -c "Protocol is TLSv1.1"
4941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004942run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004943 "$P_SRV max_version=tls1_1" \
4944 "$P_CLI min_version=tls1_1" \
4945 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004946 -S "mbedtls_ssl_handshake returned" \
4947 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004948 -s "Protocol is TLSv1.1" \
4949 -c "Protocol is TLSv1.1"
4950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004951run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004952 "$P_SRV max_version=tls1_1" \
4953 "$P_CLI min_version=tls1_2" \
4954 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004955 -s "mbedtls_ssl_handshake returned" \
4956 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004957 -c "SSL - Handshake protocol not within min/max boundaries"
4958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004959run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004960 "$P_SRV min_version=tls1_2" \
4961 "$P_CLI max_version=tls1_1" \
4962 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004963 -s "mbedtls_ssl_handshake returned" \
4964 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004965 -s "SSL - Handshake protocol not within min/max boundaries"
4966
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004967# Tests for ALPN extension
4968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004969run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004970 "$P_SRV debug_level=3" \
4971 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004972 0 \
4973 -C "client hello, adding alpn extension" \
4974 -S "found alpn extension" \
4975 -C "got an alert message, type: \\[2:120]" \
4976 -S "server hello, adding alpn extension" \
4977 -C "found alpn extension " \
4978 -C "Application Layer Protocol is" \
4979 -S "Application Layer Protocol is"
4980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004981run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004982 "$P_SRV debug_level=3" \
4983 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004984 0 \
4985 -c "client hello, adding alpn extension" \
4986 -s "found alpn extension" \
4987 -C "got an alert message, type: \\[2:120]" \
4988 -S "server hello, adding alpn extension" \
4989 -C "found alpn extension " \
4990 -c "Application Layer Protocol is (none)" \
4991 -S "Application Layer Protocol is"
4992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004993run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004994 "$P_SRV debug_level=3 alpn=abc,1234" \
4995 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004996 0 \
4997 -C "client hello, adding alpn extension" \
4998 -S "found alpn extension" \
4999 -C "got an alert message, type: \\[2:120]" \
5000 -S "server hello, adding alpn extension" \
5001 -C "found alpn extension " \
5002 -C "Application Layer Protocol is" \
5003 -s "Application Layer Protocol is (none)"
5004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005005run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005006 "$P_SRV debug_level=3 alpn=abc,1234" \
5007 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005008 0 \
5009 -c "client hello, adding alpn extension" \
5010 -s "found alpn extension" \
5011 -C "got an alert message, type: \\[2:120]" \
5012 -s "server hello, adding alpn extension" \
5013 -c "found alpn extension" \
5014 -c "Application Layer Protocol is abc" \
5015 -s "Application Layer Protocol is abc"
5016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005017run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005018 "$P_SRV debug_level=3 alpn=abc,1234" \
5019 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005020 0 \
5021 -c "client hello, adding alpn extension" \
5022 -s "found alpn extension" \
5023 -C "got an alert message, type: \\[2:120]" \
5024 -s "server hello, adding alpn extension" \
5025 -c "found alpn extension" \
5026 -c "Application Layer Protocol is abc" \
5027 -s "Application Layer Protocol is abc"
5028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005029run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005030 "$P_SRV debug_level=3 alpn=abc,1234" \
5031 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005032 0 \
5033 -c "client hello, adding alpn extension" \
5034 -s "found alpn extension" \
5035 -C "got an alert message, type: \\[2:120]" \
5036 -s "server hello, adding alpn extension" \
5037 -c "found alpn extension" \
5038 -c "Application Layer Protocol is 1234" \
5039 -s "Application Layer Protocol is 1234"
5040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005041run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005042 "$P_SRV debug_level=3 alpn=abc,123" \
5043 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005044 1 \
5045 -c "client hello, adding alpn extension" \
5046 -s "found alpn extension" \
5047 -c "got an alert message, type: \\[2:120]" \
5048 -S "server hello, adding alpn extension" \
5049 -C "found alpn extension" \
5050 -C "Application Layer Protocol is 1234" \
5051 -S "Application Layer Protocol is 1234"
5052
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02005053
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005054# Tests for keyUsage in leaf certificates, part 1:
5055# server-side certificate/suite selection
5056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005057run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005058 "$P_SRV key_file=data_files/server2.key \
5059 crt_file=data_files/server2.ku-ds.crt" \
5060 "$P_CLI" \
5061 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02005062 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005063
5064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005065run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005066 "$P_SRV key_file=data_files/server2.key \
5067 crt_file=data_files/server2.ku-ke.crt" \
5068 "$P_CLI" \
5069 0 \
5070 -c "Ciphersuite is TLS-RSA-WITH-"
5071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005072run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005073 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005074 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005075 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005076 1 \
5077 -C "Ciphersuite is "
5078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005079run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005080 "$P_SRV key_file=data_files/server5.key \
5081 crt_file=data_files/server5.ku-ds.crt" \
5082 "$P_CLI" \
5083 0 \
5084 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
5085
5086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005087run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005088 "$P_SRV key_file=data_files/server5.key \
5089 crt_file=data_files/server5.ku-ka.crt" \
5090 "$P_CLI" \
5091 0 \
5092 -c "Ciphersuite is TLS-ECDH-"
5093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005094run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005095 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005096 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005097 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005098 1 \
5099 -C "Ciphersuite is "
5100
5101# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005102# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005104run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005105 "$O_SRV -key data_files/server2.key \
5106 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005107 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005108 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5109 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005110 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005111 -C "Processing of the Certificate handshake message failed" \
5112 -c "Ciphersuite is TLS-"
5113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005114run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005115 "$O_SRV -key data_files/server2.key \
5116 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005117 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005118 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5119 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005120 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005121 -C "Processing of the Certificate handshake message failed" \
5122 -c "Ciphersuite is TLS-"
5123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005124run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005125 "$O_SRV -key data_files/server2.key \
5126 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005127 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005128 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5129 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005130 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005131 -C "Processing of the Certificate handshake message failed" \
5132 -c "Ciphersuite is TLS-"
5133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005134run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005135 "$O_SRV -key data_files/server2.key \
5136 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005137 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005138 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5139 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005140 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005141 -c "Processing of the Certificate handshake message failed" \
5142 -C "Ciphersuite is TLS-"
5143
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01005144run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
5145 "$O_SRV -key data_files/server2.key \
5146 -cert data_files/server2.ku-ke.crt" \
5147 "$P_CLI debug_level=1 auth_mode=optional \
5148 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5149 0 \
5150 -c "bad certificate (usage extensions)" \
5151 -C "Processing of the Certificate handshake message failed" \
5152 -c "Ciphersuite is TLS-" \
5153 -c "! Usage does not match the keyUsage extension"
5154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005155run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005156 "$O_SRV -key data_files/server2.key \
5157 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005158 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005159 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5160 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005161 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005162 -C "Processing of the Certificate handshake message failed" \
5163 -c "Ciphersuite is TLS-"
5164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005165run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005166 "$O_SRV -key data_files/server2.key \
5167 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005168 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005169 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5170 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005171 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005172 -c "Processing of the Certificate handshake message failed" \
5173 -C "Ciphersuite is TLS-"
5174
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01005175run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
5176 "$O_SRV -key data_files/server2.key \
5177 -cert data_files/server2.ku-ds.crt" \
5178 "$P_CLI debug_level=1 auth_mode=optional \
5179 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5180 0 \
5181 -c "bad certificate (usage extensions)" \
5182 -C "Processing of the Certificate handshake message failed" \
5183 -c "Ciphersuite is TLS-" \
5184 -c "! Usage does not match the keyUsage extension"
5185
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005186# Tests for keyUsage in leaf certificates, part 3:
5187# server-side checking of client cert
5188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005189run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005190 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005191 "$O_CLI -key data_files/server2.key \
5192 -cert data_files/server2.ku-ds.crt" \
5193 0 \
5194 -S "bad certificate (usage extensions)" \
5195 -S "Processing of the Certificate handshake message failed"
5196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005197run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005198 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005199 "$O_CLI -key data_files/server2.key \
5200 -cert data_files/server2.ku-ke.crt" \
5201 0 \
5202 -s "bad certificate (usage extensions)" \
5203 -S "Processing of the Certificate handshake message failed"
5204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005205run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005206 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005207 "$O_CLI -key data_files/server2.key \
5208 -cert data_files/server2.ku-ke.crt" \
5209 1 \
5210 -s "bad certificate (usage extensions)" \
5211 -s "Processing of the Certificate handshake message failed"
5212
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005213run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005214 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005215 "$O_CLI -key data_files/server5.key \
5216 -cert data_files/server5.ku-ds.crt" \
5217 0 \
5218 -S "bad certificate (usage extensions)" \
5219 -S "Processing of the Certificate handshake message failed"
5220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005221run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005222 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005223 "$O_CLI -key data_files/server5.key \
5224 -cert data_files/server5.ku-ka.crt" \
5225 0 \
5226 -s "bad certificate (usage extensions)" \
5227 -S "Processing of the Certificate handshake message failed"
5228
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005229# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
5230
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005231run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005232 "$P_SRV key_file=data_files/server5.key \
5233 crt_file=data_files/server5.eku-srv.crt" \
5234 "$P_CLI" \
5235 0
5236
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005237run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005238 "$P_SRV key_file=data_files/server5.key \
5239 crt_file=data_files/server5.eku-srv.crt" \
5240 "$P_CLI" \
5241 0
5242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005243run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005244 "$P_SRV key_file=data_files/server5.key \
5245 crt_file=data_files/server5.eku-cs_any.crt" \
5246 "$P_CLI" \
5247 0
5248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005249run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005250 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005251 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005252 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005253 1
5254
5255# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005257run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005258 "$O_SRV -key data_files/server5.key \
5259 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005260 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005261 0 \
5262 -C "bad certificate (usage extensions)" \
5263 -C "Processing of the Certificate handshake message failed" \
5264 -c "Ciphersuite is TLS-"
5265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005266run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005267 "$O_SRV -key data_files/server5.key \
5268 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005269 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005270 0 \
5271 -C "bad certificate (usage extensions)" \
5272 -C "Processing of the Certificate handshake message failed" \
5273 -c "Ciphersuite is TLS-"
5274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005275run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005276 "$O_SRV -key data_files/server5.key \
5277 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005278 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005279 0 \
5280 -C "bad certificate (usage extensions)" \
5281 -C "Processing of the Certificate handshake message failed" \
5282 -c "Ciphersuite is TLS-"
5283
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005284run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005285 "$O_SRV -key data_files/server5.key \
5286 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005287 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005288 1 \
5289 -c "bad certificate (usage extensions)" \
5290 -c "Processing of the Certificate handshake message failed" \
5291 -C "Ciphersuite is TLS-"
5292
5293# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005295run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005296 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005297 "$O_CLI -key data_files/server5.key \
5298 -cert data_files/server5.eku-cli.crt" \
5299 0 \
5300 -S "bad certificate (usage extensions)" \
5301 -S "Processing of the Certificate handshake message failed"
5302
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005303run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005304 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005305 "$O_CLI -key data_files/server5.key \
5306 -cert data_files/server5.eku-srv_cli.crt" \
5307 0 \
5308 -S "bad certificate (usage extensions)" \
5309 -S "Processing of the Certificate handshake message failed"
5310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005311run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005312 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005313 "$O_CLI -key data_files/server5.key \
5314 -cert data_files/server5.eku-cs_any.crt" \
5315 0 \
5316 -S "bad certificate (usage extensions)" \
5317 -S "Processing of the Certificate handshake message failed"
5318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005319run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005320 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005321 "$O_CLI -key data_files/server5.key \
5322 -cert data_files/server5.eku-cs.crt" \
5323 0 \
5324 -s "bad certificate (usage extensions)" \
5325 -S "Processing of the Certificate handshake message failed"
5326
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005327run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005328 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005329 "$O_CLI -key data_files/server5.key \
5330 -cert data_files/server5.eku-cs.crt" \
5331 1 \
5332 -s "bad certificate (usage extensions)" \
5333 -s "Processing of the Certificate handshake message failed"
5334
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005335# Tests for DHM parameters loading
5336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005337run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005338 "$P_SRV" \
5339 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5340 debug_level=3" \
5341 0 \
5342 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005343 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005344
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005345run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005346 "$P_SRV dhm_file=data_files/dhparams.pem" \
5347 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5348 debug_level=3" \
5349 0 \
5350 -c "value of 'DHM: P ' (1024 bits)" \
5351 -c "value of 'DHM: G ' (2 bits)"
5352
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005353# Tests for DHM client-side size checking
5354
5355run_test "DHM size: server default, client default, OK" \
5356 "$P_SRV" \
5357 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5358 debug_level=1" \
5359 0 \
5360 -C "DHM prime too short:"
5361
5362run_test "DHM size: server default, client 2048, OK" \
5363 "$P_SRV" \
5364 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5365 debug_level=1 dhmlen=2048" \
5366 0 \
5367 -C "DHM prime too short:"
5368
5369run_test "DHM size: server 1024, client default, OK" \
5370 "$P_SRV dhm_file=data_files/dhparams.pem" \
5371 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5372 debug_level=1" \
5373 0 \
5374 -C "DHM prime too short:"
5375
5376run_test "DHM size: server 1000, client default, rejected" \
5377 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5378 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5379 debug_level=1" \
5380 1 \
5381 -c "DHM prime too short:"
5382
5383run_test "DHM size: server default, client 2049, rejected" \
5384 "$P_SRV" \
5385 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5386 debug_level=1 dhmlen=2049" \
5387 1 \
5388 -c "DHM prime too short:"
5389
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005390# Tests for PSK callback
5391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005392run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005393 "$P_SRV psk=abc123 psk_identity=foo" \
5394 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5395 psk_identity=foo psk=abc123" \
5396 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005397 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005398 -S "SSL - Unknown identity received" \
5399 -S "SSL - Verification of the message MAC failed"
5400
Hanno Beckerf7027512018-10-23 15:27:39 +01005401requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5402run_test "PSK callback: opaque psk on client, no callback" \
5403 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5404 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005405 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005406 0 \
5407 -c "skip PMS generation for opaque PSK"\
5408 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005409 -C "session hash for extended master secret"\
5410 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005411 -S "SSL - None of the common ciphersuites is usable" \
5412 -S "SSL - Unknown identity received" \
5413 -S "SSL - Verification of the message MAC failed"
5414
5415requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5416run_test "PSK callback: opaque psk on client, no callback, SHA-384" \
5417 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5418 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005419 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005420 0 \
5421 -c "skip PMS generation for opaque PSK"\
5422 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005423 -C "session hash for extended master secret"\
5424 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005425 -S "SSL - None of the common ciphersuites is usable" \
5426 -S "SSL - Unknown identity received" \
5427 -S "SSL - Verification of the message MAC failed"
5428
5429requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5430run_test "PSK callback: opaque psk on client, no callback, EMS" \
5431 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5432 "$P_CLI extended_ms=1 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005433 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005434 0 \
5435 -c "skip PMS generation for opaque PSK"\
5436 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005437 -c "session hash for extended master secret"\
5438 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005439 -S "SSL - None of the common ciphersuites is usable" \
5440 -S "SSL - Unknown identity received" \
5441 -S "SSL - Verification of the message MAC failed"
5442
5443requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5444run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \
5445 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5446 "$P_CLI extended_ms=1 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005447 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005448 0 \
5449 -c "skip PMS generation for opaque PSK"\
5450 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005451 -c "session hash for extended master secret"\
5452 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005453 -S "SSL - None of the common ciphersuites is usable" \
5454 -S "SSL - Unknown identity received" \
5455 -S "SSL - Verification of the message MAC failed"
5456
Hanno Becker28c79dc2018-10-26 13:15:08 +01005457requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5458run_test "PSK callback: raw psk on client, static opaque on server, no callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005459 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005460 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5461 psk_identity=foo psk=abc123" \
5462 0 \
5463 -C "skip PMS generation for opaque PSK"\
5464 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005465 -C "session hash for extended master secret"\
5466 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005467 -S "SSL - None of the common ciphersuites is usable" \
5468 -S "SSL - Unknown identity received" \
5469 -S "SSL - Verification of the message MAC failed"
5470
5471requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5472run_test "PSK callback: raw psk on client, static opaque on server, no callback, SHA-384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005473 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005474 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5475 psk_identity=foo psk=abc123" \
5476 0 \
5477 -C "skip PMS generation for opaque PSK"\
5478 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005479 -C "session hash for extended master secret"\
5480 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005481 -S "SSL - None of the common ciphersuites is usable" \
5482 -S "SSL - Unknown identity received" \
5483 -S "SSL - Verification of the message MAC failed"
5484
5485requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5486run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005487 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005488 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5489 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5490 psk_identity=foo psk=abc123 extended_ms=1" \
5491 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005492 -c "session hash for extended master secret"\
5493 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005494 -C "skip PMS generation for opaque PSK"\
5495 -s "skip PMS generation for opaque PSK"\
5496 -S "SSL - None of the common ciphersuites is usable" \
5497 -S "SSL - Unknown identity received" \
5498 -S "SSL - Verification of the message MAC failed"
5499
5500requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5501run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS, SHA384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005502 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005503 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5504 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5505 psk_identity=foo psk=abc123 extended_ms=1" \
5506 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005507 -c "session hash for extended master secret"\
5508 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005509 -C "skip PMS generation for opaque PSK"\
5510 -s "skip PMS generation for opaque PSK"\
5511 -S "SSL - None of the common ciphersuites is usable" \
5512 -S "SSL - Unknown identity received" \
5513 -S "SSL - Verification of the message MAC failed"
5514
5515requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5516run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005517 "$P_SRV extended_ms=0 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005518 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5519 psk_identity=def psk=beef" \
5520 0 \
5521 -C "skip PMS generation for opaque PSK"\
5522 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005523 -C "session hash for extended master secret"\
5524 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005525 -S "SSL - None of the common ciphersuites is usable" \
5526 -S "SSL - Unknown identity received" \
5527 -S "SSL - Verification of the message MAC failed"
5528
5529requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5530run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, SHA-384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005531 "$P_SRV extended_ms=0 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005532 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5533 psk_identity=def psk=beef" \
5534 0 \
5535 -C "skip PMS generation for opaque PSK"\
5536 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005537 -C "session hash for extended master secret"\
5538 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005539 -S "SSL - None of the common ciphersuites is usable" \
5540 -S "SSL - Unknown identity received" \
5541 -S "SSL - Verification of the message MAC failed"
5542
5543requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5544run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005545 "$P_SRV debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005546 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5547 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5548 psk_identity=abc psk=dead extended_ms=1" \
5549 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005550 -c "session hash for extended master secret"\
5551 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005552 -C "skip PMS generation for opaque PSK"\
5553 -s "skip PMS generation for opaque PSK"\
5554 -S "SSL - None of the common ciphersuites is usable" \
5555 -S "SSL - Unknown identity received" \
5556 -S "SSL - Verification of the message MAC failed"
5557
5558requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5559run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS, SHA384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005560 "$P_SRV debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005561 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5562 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5563 psk_identity=abc psk=dead extended_ms=1" \
5564 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005565 -c "session hash for extended master secret"\
5566 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005567 -C "skip PMS generation for opaque PSK"\
5568 -s "skip PMS generation for opaque PSK"\
5569 -S "SSL - None of the common ciphersuites is usable" \
5570 -S "SSL - Unknown identity received" \
5571 -S "SSL - Verification of the message MAC failed"
5572
5573requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5574run_test "PSK callback: raw psk on client, mismatching static raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005575 "$P_SRV extended_ms=0 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005576 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5577 psk_identity=def psk=beef" \
5578 0 \
5579 -C "skip PMS generation for opaque PSK"\
5580 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005581 -C "session hash for extended master secret"\
5582 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005583 -S "SSL - None of the common ciphersuites is usable" \
5584 -S "SSL - Unknown identity received" \
5585 -S "SSL - Verification of the message MAC failed"
5586
5587requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5588run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005589 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005590 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5591 psk_identity=def psk=beef" \
5592 0 \
5593 -C "skip PMS generation for opaque PSK"\
5594 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005595 -C "session hash for extended master secret"\
5596 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005597 -S "SSL - None of the common ciphersuites is usable" \
5598 -S "SSL - Unknown identity received" \
5599 -S "SSL - Verification of the message MAC failed"
5600
5601requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5602run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, raw PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005603 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005604 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5605 psk_identity=def psk=beef" \
5606 0 \
5607 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005608 -C "session hash for extended master secret"\
5609 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005610 -S "SSL - None of the common ciphersuites is usable" \
5611 -S "SSL - Unknown identity received" \
5612 -S "SSL - Verification of the message MAC failed"
5613
5614requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5615run_test "PSK callback: raw psk on client, id-matching but wrong raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005616 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=def psk=abc123 debug_level=3 psk_list=abc,dead,def,beef min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005617 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5618 psk_identity=def psk=beef" \
5619 0 \
5620 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005621 -C "session hash for extended master secret"\
5622 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005623 -S "SSL - None of the common ciphersuites is usable" \
5624 -S "SSL - Unknown identity received" \
5625 -S "SSL - Verification of the message MAC failed"
5626
5627requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5628run_test "PSK callback: raw psk on client, matching opaque PSK on server, wrong opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005629 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=def psk=beef debug_level=3 psk_list=abc,dead,def,abc123 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005630 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5631 psk_identity=def psk=beef" \
5632 1 \
5633 -s "SSL - Verification of the message MAC failed"
5634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005635run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005636 "$P_SRV" \
5637 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5638 psk_identity=foo psk=abc123" \
5639 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005640 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005641 -S "SSL - Unknown identity received" \
5642 -S "SSL - Verification of the message MAC failed"
5643
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005644run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005645 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5646 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5647 psk_identity=foo psk=abc123" \
5648 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005649 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005650 -s "SSL - Unknown identity received" \
5651 -S "SSL - Verification of the message MAC failed"
5652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005653run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005654 "$P_SRV psk_list=abc,dead,def,beef" \
5655 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5656 psk_identity=abc psk=dead" \
5657 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005658 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005659 -S "SSL - Unknown identity received" \
5660 -S "SSL - Verification of the message MAC failed"
5661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005662run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005663 "$P_SRV psk_list=abc,dead,def,beef" \
5664 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5665 psk_identity=def psk=beef" \
5666 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005667 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005668 -S "SSL - Unknown identity received" \
5669 -S "SSL - Verification of the message MAC failed"
5670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005671run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005672 "$P_SRV psk_list=abc,dead,def,beef" \
5673 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5674 psk_identity=ghi psk=beef" \
5675 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005676 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005677 -s "SSL - Unknown identity received" \
5678 -S "SSL - Verification of the message MAC failed"
5679
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005680run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005681 "$P_SRV psk_list=abc,dead,def,beef" \
5682 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5683 psk_identity=abc psk=beef" \
5684 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005685 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005686 -S "SSL - Unknown identity received" \
5687 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005688
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005689# Tests for EC J-PAKE
5690
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005691requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005692run_test "ECJPAKE: client not configured" \
5693 "$P_SRV debug_level=3" \
5694 "$P_CLI debug_level=3" \
5695 0 \
5696 -C "add ciphersuite: c0ff" \
5697 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005698 -S "found ecjpake kkpp extension" \
5699 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005700 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005701 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005702 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005703 -S "None of the common ciphersuites is usable"
5704
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005705requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005706run_test "ECJPAKE: server not configured" \
5707 "$P_SRV debug_level=3" \
5708 "$P_CLI debug_level=3 ecjpake_pw=bla \
5709 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5710 1 \
5711 -c "add ciphersuite: c0ff" \
5712 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005713 -s "found ecjpake kkpp extension" \
5714 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005715 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005716 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005717 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005718 -s "None of the common ciphersuites is usable"
5719
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005720requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005721run_test "ECJPAKE: working, TLS" \
5722 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5723 "$P_CLI debug_level=3 ecjpake_pw=bla \
5724 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005725 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005726 -c "add ciphersuite: c0ff" \
5727 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005728 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005729 -s "found ecjpake kkpp extension" \
5730 -S "skip ecjpake kkpp extension" \
5731 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005732 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005733 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005734 -S "None of the common ciphersuites is usable" \
5735 -S "SSL - Verification of the message MAC failed"
5736
Janos Follath74537a62016-09-02 13:45:28 +01005737server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005738requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005739run_test "ECJPAKE: password mismatch, TLS" \
5740 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5741 "$P_CLI debug_level=3 ecjpake_pw=bad \
5742 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5743 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005744 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005745 -s "SSL - Verification of the message MAC failed"
5746
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005747requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005748run_test "ECJPAKE: working, DTLS" \
5749 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5750 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5751 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5752 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005753 -c "re-using cached ecjpake parameters" \
5754 -S "SSL - Verification of the message MAC failed"
5755
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005756requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005757run_test "ECJPAKE: working, DTLS, no cookie" \
5758 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5759 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5760 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5761 0 \
5762 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005763 -S "SSL - Verification of the message MAC failed"
5764
Janos Follath74537a62016-09-02 13:45:28 +01005765server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005766requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005767run_test "ECJPAKE: password mismatch, DTLS" \
5768 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5769 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5770 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5771 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005772 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005773 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005774
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005775# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005776requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005777run_test "ECJPAKE: working, DTLS, nolog" \
5778 "$P_SRV dtls=1 ecjpake_pw=bla" \
5779 "$P_CLI dtls=1 ecjpake_pw=bla \
5780 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5781 0
5782
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005783# Tests for ciphersuites per version
5784
Janos Follathe2681a42016-03-07 15:57:05 +00005785requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005786requires_config_enabled MBEDTLS_CAMELLIA_C
5787requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005788run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005789 "$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 +02005790 "$P_CLI force_version=ssl3" \
5791 0 \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005792 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005793
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005794requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5795requires_config_enabled MBEDTLS_CAMELLIA_C
5796requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005797run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005798 "$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 +01005799 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005800 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005801 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005802
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005803requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5804requires_config_enabled MBEDTLS_CAMELLIA_C
5805requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005806run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005807 "$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 +02005808 "$P_CLI force_version=tls1_1" \
5809 0 \
5810 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5811
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005812requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5813requires_config_enabled MBEDTLS_CAMELLIA_C
5814requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005815run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005816 "$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 +02005817 "$P_CLI force_version=tls1_2" \
5818 0 \
5819 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5820
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005821# Test for ClientHello without extensions
5822
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005823requires_gnutls
Manuel Pégourié-Gonnardbc4da292020-01-30 12:45:14 +01005824run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard77cbeff2020-01-30 10:58:57 +01005825 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005826 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005827 0 \
5828 -s "dumping 'client hello extensions' (0 bytes)"
5829
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005830# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005831
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005832run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005833 "$P_SRV" \
5834 "$P_CLI request_size=100" \
5835 0 \
5836 -s "Read from client: 100 bytes read$"
5837
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005838run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005839 "$P_SRV" \
5840 "$P_CLI request_size=500" \
5841 0 \
5842 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005843
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005844# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005845
Janos Follathe2681a42016-03-07 15:57:05 +00005846requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005847run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005848 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005849 "$P_CLI request_size=1 force_version=ssl3 \
5850 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5851 0 \
5852 -s "Read from client: 1 bytes read"
5853
Janos Follathe2681a42016-03-07 15:57:05 +00005854requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005855run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005856 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005857 "$P_CLI request_size=1 force_version=ssl3 \
5858 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5859 0 \
5860 -s "Read from client: 1 bytes read"
5861
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005862run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005863 "$P_SRV" \
5864 "$P_CLI request_size=1 force_version=tls1 \
5865 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5866 0 \
5867 -s "Read from client: 1 bytes read"
5868
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005869run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005870 "$P_SRV" \
5871 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5872 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5873 0 \
5874 -s "Read from client: 1 bytes read"
5875
Hanno Becker32c55012017-11-10 08:42:54 +00005876requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005877run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005878 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005879 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005880 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005881 0 \
5882 -s "Read from client: 1 bytes read"
5883
Hanno Becker32c55012017-11-10 08:42:54 +00005884requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005885run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005886 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005887 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005888 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005889 0 \
5890 -s "Read from client: 1 bytes read"
5891
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005892run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005893 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005894 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005895 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5896 0 \
5897 -s "Read from client: 1 bytes read"
5898
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005899run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005900 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5901 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005902 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005903 0 \
5904 -s "Read from client: 1 bytes read"
5905
5906requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005907run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005908 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005909 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005910 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005911 0 \
5912 -s "Read from client: 1 bytes read"
5913
Hanno Becker8501f982017-11-10 08:59:04 +00005914requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005915run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005916 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5917 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5918 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005919 0 \
5920 -s "Read from client: 1 bytes read"
5921
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005922run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005923 "$P_SRV" \
5924 "$P_CLI request_size=1 force_version=tls1_1 \
5925 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5926 0 \
5927 -s "Read from client: 1 bytes read"
5928
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005929run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005930 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005931 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005932 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005933 0 \
5934 -s "Read from client: 1 bytes read"
5935
5936requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005937run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005938 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005939 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005940 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005941 0 \
5942 -s "Read from client: 1 bytes read"
5943
5944requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005945run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005946 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005947 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005948 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005949 0 \
5950 -s "Read from client: 1 bytes read"
5951
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005952run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005953 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005954 "$P_CLI request_size=1 force_version=tls1_1 \
5955 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5956 0 \
5957 -s "Read from client: 1 bytes read"
5958
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005959run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005960 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005961 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005962 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005963 0 \
5964 -s "Read from client: 1 bytes read"
5965
Hanno Becker8501f982017-11-10 08:59:04 +00005966requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005967run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005968 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005969 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005970 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005971 0 \
5972 -s "Read from client: 1 bytes read"
5973
Hanno Becker32c55012017-11-10 08:42:54 +00005974requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005975run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005976 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005977 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005978 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005979 0 \
5980 -s "Read from client: 1 bytes read"
5981
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005982run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005983 "$P_SRV" \
5984 "$P_CLI request_size=1 force_version=tls1_2 \
5985 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5986 0 \
5987 -s "Read from client: 1 bytes read"
5988
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005989run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005990 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005991 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005992 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005993 0 \
5994 -s "Read from client: 1 bytes read"
5995
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005996run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005997 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005998 "$P_CLI request_size=1 force_version=tls1_2 \
5999 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006000 0 \
6001 -s "Read from client: 1 bytes read"
6002
Hanno Becker32c55012017-11-10 08:42:54 +00006003requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006004run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006005 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006006 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006007 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006008 0 \
6009 -s "Read from client: 1 bytes read"
6010
Hanno Becker8501f982017-11-10 08:59:04 +00006011requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006012run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006013 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006014 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006015 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006016 0 \
6017 -s "Read from client: 1 bytes read"
6018
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006019run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006020 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006021 "$P_CLI request_size=1 force_version=tls1_2 \
6022 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6023 0 \
6024 -s "Read from client: 1 bytes read"
6025
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006026run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006027 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006028 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006029 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00006030 0 \
6031 -s "Read from client: 1 bytes read"
6032
Hanno Becker32c55012017-11-10 08:42:54 +00006033requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006034run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006035 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006036 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006037 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006038 0 \
6039 -s "Read from client: 1 bytes read"
6040
Hanno Becker8501f982017-11-10 08:59:04 +00006041requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006042run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006043 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006044 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006045 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006046 0 \
6047 -s "Read from client: 1 bytes read"
6048
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006049run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006050 "$P_SRV" \
6051 "$P_CLI request_size=1 force_version=tls1_2 \
6052 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6053 0 \
6054 -s "Read from client: 1 bytes read"
6055
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006056run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006057 "$P_SRV" \
6058 "$P_CLI request_size=1 force_version=tls1_2 \
6059 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6060 0 \
6061 -s "Read from client: 1 bytes read"
6062
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006063# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00006064
6065requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006066run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006067 "$P_SRV dtls=1 force_version=dtls1" \
6068 "$P_CLI dtls=1 request_size=1 \
6069 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6070 0 \
6071 -s "Read from client: 1 bytes read"
6072
6073requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006074run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00006075 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
6076 "$P_CLI dtls=1 request_size=1 \
6077 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6078 0 \
6079 -s "Read from client: 1 bytes read"
6080
6081requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6082requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006083run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006084 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
6085 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00006086 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6087 0 \
6088 -s "Read from client: 1 bytes read"
6089
6090requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6091requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006092run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006093 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006094 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006095 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00006096 0 \
6097 -s "Read from client: 1 bytes read"
6098
6099requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006100run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00006101 "$P_SRV dtls=1 force_version=dtls1_2" \
6102 "$P_CLI dtls=1 request_size=1 \
6103 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6104 0 \
6105 -s "Read from client: 1 bytes read"
6106
6107requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006108run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006109 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006110 "$P_CLI dtls=1 request_size=1 \
6111 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6112 0 \
6113 -s "Read from client: 1 bytes read"
6114
6115requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6116requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006117run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006118 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00006119 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006120 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00006121 0 \
6122 -s "Read from client: 1 bytes read"
6123
6124requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6125requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006126run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006127 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006128 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006129 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00006130 0 \
6131 -s "Read from client: 1 bytes read"
6132
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006133# Tests for small server packets
6134
6135requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6136run_test "Small server packet SSLv3 BlockCipher" \
6137 "$P_SRV response_size=1 min_version=ssl3" \
6138 "$P_CLI force_version=ssl3 \
6139 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6140 0 \
6141 -c "Read from server: 1 bytes read"
6142
6143requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6144run_test "Small server packet SSLv3 StreamCipher" \
6145 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6146 "$P_CLI force_version=ssl3 \
6147 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6148 0 \
6149 -c "Read from server: 1 bytes read"
6150
6151run_test "Small server packet TLS 1.0 BlockCipher" \
6152 "$P_SRV response_size=1" \
6153 "$P_CLI force_version=tls1 \
6154 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6155 0 \
6156 -c "Read from server: 1 bytes read"
6157
6158run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
6159 "$P_SRV response_size=1" \
6160 "$P_CLI force_version=tls1 etm=0 \
6161 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6162 0 \
6163 -c "Read from server: 1 bytes read"
6164
6165requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6166run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
6167 "$P_SRV response_size=1 trunc_hmac=1" \
6168 "$P_CLI force_version=tls1 \
6169 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6170 0 \
6171 -c "Read from server: 1 bytes read"
6172
6173requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6174run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
6175 "$P_SRV response_size=1 trunc_hmac=1" \
6176 "$P_CLI force_version=tls1 \
6177 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6178 0 \
6179 -c "Read from server: 1 bytes read"
6180
6181run_test "Small server packet TLS 1.0 StreamCipher" \
6182 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6183 "$P_CLI force_version=tls1 \
6184 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6185 0 \
6186 -c "Read from server: 1 bytes read"
6187
6188run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
6189 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6190 "$P_CLI force_version=tls1 \
6191 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6192 0 \
6193 -c "Read from server: 1 bytes read"
6194
6195requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6196run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
6197 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6198 "$P_CLI force_version=tls1 \
6199 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6200 0 \
6201 -c "Read from server: 1 bytes read"
6202
6203requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6204run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6205 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6206 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6207 trunc_hmac=1 etm=0" \
6208 0 \
6209 -c "Read from server: 1 bytes read"
6210
6211run_test "Small server packet TLS 1.1 BlockCipher" \
6212 "$P_SRV response_size=1" \
6213 "$P_CLI force_version=tls1_1 \
6214 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6215 0 \
6216 -c "Read from server: 1 bytes read"
6217
6218run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
6219 "$P_SRV response_size=1" \
6220 "$P_CLI force_version=tls1_1 \
6221 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
6222 0 \
6223 -c "Read from server: 1 bytes read"
6224
6225requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6226run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
6227 "$P_SRV response_size=1 trunc_hmac=1" \
6228 "$P_CLI force_version=tls1_1 \
6229 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6230 0 \
6231 -c "Read from server: 1 bytes read"
6232
6233requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6234run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6235 "$P_SRV response_size=1 trunc_hmac=1" \
6236 "$P_CLI force_version=tls1_1 \
6237 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6238 0 \
6239 -c "Read from server: 1 bytes read"
6240
6241run_test "Small server packet TLS 1.1 StreamCipher" \
6242 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6243 "$P_CLI force_version=tls1_1 \
6244 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6245 0 \
6246 -c "Read from server: 1 bytes read"
6247
6248run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
6249 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6250 "$P_CLI force_version=tls1_1 \
6251 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6252 0 \
6253 -c "Read from server: 1 bytes read"
6254
6255requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6256run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
6257 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6258 "$P_CLI force_version=tls1_1 \
6259 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6260 0 \
6261 -c "Read from server: 1 bytes read"
6262
6263requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6264run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6265 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6266 "$P_CLI force_version=tls1_1 \
6267 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6268 0 \
6269 -c "Read from server: 1 bytes read"
6270
6271run_test "Small server packet TLS 1.2 BlockCipher" \
6272 "$P_SRV response_size=1" \
6273 "$P_CLI force_version=tls1_2 \
6274 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6275 0 \
6276 -c "Read from server: 1 bytes read"
6277
6278run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
6279 "$P_SRV response_size=1" \
6280 "$P_CLI force_version=tls1_2 \
6281 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
6282 0 \
6283 -c "Read from server: 1 bytes read"
6284
6285run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
6286 "$P_SRV response_size=1" \
6287 "$P_CLI force_version=tls1_2 \
6288 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6289 0 \
6290 -c "Read from server: 1 bytes read"
6291
6292requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6293run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
6294 "$P_SRV response_size=1 trunc_hmac=1" \
6295 "$P_CLI force_version=tls1_2 \
6296 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6297 0 \
6298 -c "Read from server: 1 bytes read"
6299
6300requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6301run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6302 "$P_SRV response_size=1 trunc_hmac=1" \
6303 "$P_CLI force_version=tls1_2 \
6304 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6305 0 \
6306 -c "Read from server: 1 bytes read"
6307
6308run_test "Small server packet TLS 1.2 StreamCipher" \
6309 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6310 "$P_CLI force_version=tls1_2 \
6311 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6312 0 \
6313 -c "Read from server: 1 bytes read"
6314
6315run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
6316 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6317 "$P_CLI force_version=tls1_2 \
6318 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6319 0 \
6320 -c "Read from server: 1 bytes read"
6321
6322requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6323run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
6324 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6325 "$P_CLI force_version=tls1_2 \
6326 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6327 0 \
6328 -c "Read from server: 1 bytes read"
6329
6330requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6331run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6332 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6333 "$P_CLI force_version=tls1_2 \
6334 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6335 0 \
6336 -c "Read from server: 1 bytes read"
6337
6338run_test "Small server packet TLS 1.2 AEAD" \
6339 "$P_SRV response_size=1" \
6340 "$P_CLI force_version=tls1_2 \
6341 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6342 0 \
6343 -c "Read from server: 1 bytes read"
6344
6345run_test "Small server packet TLS 1.2 AEAD shorter tag" \
6346 "$P_SRV response_size=1" \
6347 "$P_CLI force_version=tls1_2 \
6348 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6349 0 \
6350 -c "Read from server: 1 bytes read"
6351
6352# Tests for small server packets in DTLS
6353
6354requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6355run_test "Small server packet DTLS 1.0" \
6356 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
6357 "$P_CLI dtls=1 \
6358 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6359 0 \
6360 -c "Read from server: 1 bytes read"
6361
6362requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6363run_test "Small server packet DTLS 1.0, without EtM" \
6364 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
6365 "$P_CLI dtls=1 \
6366 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6367 0 \
6368 -c "Read from server: 1 bytes read"
6369
6370requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6371requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6372run_test "Small server packet DTLS 1.0, truncated hmac" \
6373 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
6374 "$P_CLI dtls=1 trunc_hmac=1 \
6375 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6376 0 \
6377 -c "Read from server: 1 bytes read"
6378
6379requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6380requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6381run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
6382 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
6383 "$P_CLI dtls=1 \
6384 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
6385 0 \
6386 -c "Read from server: 1 bytes read"
6387
6388requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6389run_test "Small server packet DTLS 1.2" \
6390 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
6391 "$P_CLI dtls=1 \
6392 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6393 0 \
6394 -c "Read from server: 1 bytes read"
6395
6396requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6397run_test "Small server packet DTLS 1.2, without EtM" \
6398 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
6399 "$P_CLI dtls=1 \
6400 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6401 0 \
6402 -c "Read from server: 1 bytes read"
6403
6404requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6405requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6406run_test "Small server packet DTLS 1.2, truncated hmac" \
6407 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
6408 "$P_CLI dtls=1 \
6409 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6410 0 \
6411 -c "Read from server: 1 bytes read"
6412
6413requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6414requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6415run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
6416 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
6417 "$P_CLI dtls=1 \
6418 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
6419 0 \
6420 -c "Read from server: 1 bytes read"
6421
Janos Follath00efff72016-05-06 13:48:23 +01006422# A test for extensions in SSLv3
6423
6424requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6425run_test "SSLv3 with extensions, server side" \
6426 "$P_SRV min_version=ssl3 debug_level=3" \
6427 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
6428 0 \
6429 -S "dumping 'client hello extensions'" \
6430 -S "server hello, total extension length:"
6431
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006432# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006433
Angus Grattonc4dd0732018-04-11 16:28:39 +10006434# How many fragments do we expect to write $1 bytes?
6435fragments_for_write() {
6436 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
6437}
6438
Janos Follathe2681a42016-03-07 15:57:05 +00006439requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006440run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01006441 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006442 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006443 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6444 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006445 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6446 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006447
Janos Follathe2681a42016-03-07 15:57:05 +00006448requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006449run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006450 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006451 "$P_CLI request_size=16384 force_version=ssl3 \
6452 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6453 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006454 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6455 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006456
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006457run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006458 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006459 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006460 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6461 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006462 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6463 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006464
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006465run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006466 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006467 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
6468 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6469 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006470 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006471
Hanno Becker32c55012017-11-10 08:42:54 +00006472requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006473run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006474 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006475 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006476 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006477 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006478 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6479 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006480
Hanno Becker32c55012017-11-10 08:42:54 +00006481requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006482run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006483 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006484 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006485 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006486 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006487 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006488
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006489run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006490 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006491 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006492 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6493 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006494 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006495
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006496run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006497 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6498 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006499 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006500 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006501 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006502
6503requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006504run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006505 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006506 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006507 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006508 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006509 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006510
Hanno Becker278fc7a2017-11-10 09:16:28 +00006511requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006512run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006513 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006514 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006515 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006516 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006517 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6518 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006519
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006520run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006521 "$P_SRV" \
6522 "$P_CLI request_size=16384 force_version=tls1_1 \
6523 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6524 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006525 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6526 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006527
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006528run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006529 "$P_SRV" \
6530 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6531 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006532 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006533 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006534
Hanno Becker32c55012017-11-10 08:42:54 +00006535requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006536run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006537 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006538 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006539 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006540 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006541 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006542
Hanno Becker32c55012017-11-10 08:42:54 +00006543requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006544run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006545 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006546 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006547 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006548 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006549 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006550
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006551run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006552 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6553 "$P_CLI request_size=16384 force_version=tls1_1 \
6554 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6555 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006556 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6557 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006558
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006559run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006560 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006561 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006562 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006563 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006564 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6565 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006566
Hanno Becker278fc7a2017-11-10 09:16:28 +00006567requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006568run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006569 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006570 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006571 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006572 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006573 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006574
Hanno Becker278fc7a2017-11-10 09:16:28 +00006575requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006576run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006577 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006578 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006579 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006580 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006581 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6582 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006583
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006584run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006585 "$P_SRV" \
6586 "$P_CLI request_size=16384 force_version=tls1_2 \
6587 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6588 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006589 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6590 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006591
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006592run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006593 "$P_SRV" \
6594 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6595 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6596 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006597 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006598
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006599run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006600 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006601 "$P_CLI request_size=16384 force_version=tls1_2 \
6602 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006603 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006604 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6605 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006606
Hanno Becker32c55012017-11-10 08:42:54 +00006607requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006608run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006609 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006610 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006611 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006612 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006613 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006614
Hanno Becker278fc7a2017-11-10 09:16:28 +00006615requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006616run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006617 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006618 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006619 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006620 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006621 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6622 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006623
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006624run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006625 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006626 "$P_CLI request_size=16384 force_version=tls1_2 \
6627 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6628 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006629 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6630 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006631
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006632run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006633 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006634 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006635 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6636 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006637 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006638
Hanno Becker32c55012017-11-10 08:42:54 +00006639requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006640run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006641 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006642 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006643 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006644 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006645 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006646
Hanno Becker278fc7a2017-11-10 09:16:28 +00006647requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006648run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006649 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006650 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006651 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006652 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006653 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6654 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006655
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006656run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006657 "$P_SRV" \
6658 "$P_CLI request_size=16384 force_version=tls1_2 \
6659 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6660 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006661 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6662 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006663
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006664run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006665 "$P_SRV" \
6666 "$P_CLI request_size=16384 force_version=tls1_2 \
6667 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6668 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006669 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6670 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006671
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006672# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006673requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6674run_test "Large server packet SSLv3 StreamCipher" \
6675 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6676 "$P_CLI force_version=ssl3 \
6677 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6678 0 \
6679 -c "Read from server: 16384 bytes read"
6680
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006681# Checking next 4 tests logs for 1n-1 split against BEAST too
6682requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6683run_test "Large server packet SSLv3 BlockCipher" \
6684 "$P_SRV response_size=16384 min_version=ssl3" \
6685 "$P_CLI force_version=ssl3 recsplit=0 \
6686 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6687 0 \
6688 -c "Read from server: 1 bytes read"\
6689 -c "16383 bytes read"\
6690 -C "Read from server: 16384 bytes read"
6691
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006692run_test "Large server packet TLS 1.0 BlockCipher" \
6693 "$P_SRV response_size=16384" \
6694 "$P_CLI force_version=tls1 recsplit=0 \
6695 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6696 0 \
6697 -c "Read from server: 1 bytes read"\
6698 -c "16383 bytes read"\
6699 -C "Read from server: 16384 bytes read"
6700
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006701run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6702 "$P_SRV response_size=16384" \
6703 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6704 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6705 0 \
6706 -c "Read from server: 1 bytes read"\
6707 -c "16383 bytes read"\
6708 -C "Read from server: 16384 bytes read"
6709
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006710requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6711run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6712 "$P_SRV response_size=16384" \
6713 "$P_CLI force_version=tls1 recsplit=0 \
6714 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6715 trunc_hmac=1" \
6716 0 \
6717 -c "Read from server: 1 bytes read"\
6718 -c "16383 bytes read"\
6719 -C "Read from server: 16384 bytes read"
6720
6721requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6722run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6723 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6724 "$P_CLI force_version=tls1 \
6725 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6726 trunc_hmac=1" \
6727 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006728 -s "16384 bytes written in 1 fragments" \
6729 -c "Read from server: 16384 bytes read"
6730
6731run_test "Large server packet TLS 1.0 StreamCipher" \
6732 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6733 "$P_CLI force_version=tls1 \
6734 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6735 0 \
6736 -s "16384 bytes written in 1 fragments" \
6737 -c "Read from server: 16384 bytes read"
6738
6739run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6740 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6741 "$P_CLI force_version=tls1 \
6742 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6743 0 \
6744 -s "16384 bytes written in 1 fragments" \
6745 -c "Read from server: 16384 bytes read"
6746
6747requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6748run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6749 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6750 "$P_CLI force_version=tls1 \
6751 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6752 0 \
6753 -s "16384 bytes written in 1 fragments" \
6754 -c "Read from server: 16384 bytes read"
6755
6756requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6757run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6758 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6759 "$P_CLI force_version=tls1 \
6760 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6761 0 \
6762 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006763 -c "Read from server: 16384 bytes read"
6764
6765run_test "Large server packet TLS 1.1 BlockCipher" \
6766 "$P_SRV response_size=16384" \
6767 "$P_CLI force_version=tls1_1 \
6768 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6769 0 \
6770 -c "Read from server: 16384 bytes read"
6771
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006772run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6773 "$P_SRV response_size=16384" \
6774 "$P_CLI force_version=tls1_1 etm=0 \
6775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006776 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006777 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006778 -c "Read from server: 16384 bytes read"
6779
6780requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6781run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6782 "$P_SRV response_size=16384" \
6783 "$P_CLI force_version=tls1_1 \
6784 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6785 trunc_hmac=1" \
6786 0 \
6787 -c "Read from server: 16384 bytes read"
6788
6789requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006790run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6791 "$P_SRV response_size=16384 trunc_hmac=1" \
6792 "$P_CLI force_version=tls1_1 \
6793 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6794 0 \
6795 -s "16384 bytes written in 1 fragments" \
6796 -c "Read from server: 16384 bytes read"
6797
6798run_test "Large server packet TLS 1.1 StreamCipher" \
6799 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6800 "$P_CLI force_version=tls1_1 \
6801 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6802 0 \
6803 -c "Read from server: 16384 bytes read"
6804
6805run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6806 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6807 "$P_CLI force_version=tls1_1 \
6808 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6809 0 \
6810 -s "16384 bytes written in 1 fragments" \
6811 -c "Read from server: 16384 bytes read"
6812
6813requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006814run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6815 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6816 "$P_CLI force_version=tls1_1 \
6817 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6818 trunc_hmac=1" \
6819 0 \
6820 -c "Read from server: 16384 bytes read"
6821
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006822run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6823 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6824 "$P_CLI force_version=tls1_1 \
6825 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6826 0 \
6827 -s "16384 bytes written in 1 fragments" \
6828 -c "Read from server: 16384 bytes read"
6829
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006830run_test "Large server packet TLS 1.2 BlockCipher" \
6831 "$P_SRV response_size=16384" \
6832 "$P_CLI force_version=tls1_2 \
6833 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6834 0 \
6835 -c "Read from server: 16384 bytes read"
6836
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006837run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6838 "$P_SRV response_size=16384" \
6839 "$P_CLI force_version=tls1_2 etm=0 \
6840 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6841 0 \
6842 -s "16384 bytes written in 1 fragments" \
6843 -c "Read from server: 16384 bytes read"
6844
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006845run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6846 "$P_SRV response_size=16384" \
6847 "$P_CLI force_version=tls1_2 \
6848 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6849 0 \
6850 -c "Read from server: 16384 bytes read"
6851
6852requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6853run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6854 "$P_SRV response_size=16384" \
6855 "$P_CLI force_version=tls1_2 \
6856 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6857 trunc_hmac=1" \
6858 0 \
6859 -c "Read from server: 16384 bytes read"
6860
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006861run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6862 "$P_SRV response_size=16384 trunc_hmac=1" \
6863 "$P_CLI force_version=tls1_2 \
6864 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6865 0 \
6866 -s "16384 bytes written in 1 fragments" \
6867 -c "Read from server: 16384 bytes read"
6868
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006869run_test "Large server packet TLS 1.2 StreamCipher" \
6870 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6871 "$P_CLI force_version=tls1_2 \
6872 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6873 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006874 -s "16384 bytes written in 1 fragments" \
6875 -c "Read from server: 16384 bytes read"
6876
6877run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6878 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6879 "$P_CLI force_version=tls1_2 \
6880 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6881 0 \
6882 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006883 -c "Read from server: 16384 bytes read"
6884
6885requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6886run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6887 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6888 "$P_CLI force_version=tls1_2 \
6889 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6890 trunc_hmac=1" \
6891 0 \
6892 -c "Read from server: 16384 bytes read"
6893
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006894requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6895run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6896 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6897 "$P_CLI force_version=tls1_2 \
6898 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6899 0 \
6900 -s "16384 bytes written in 1 fragments" \
6901 -c "Read from server: 16384 bytes read"
6902
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006903run_test "Large server packet TLS 1.2 AEAD" \
6904 "$P_SRV response_size=16384" \
6905 "$P_CLI force_version=tls1_2 \
6906 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6907 0 \
6908 -c "Read from server: 16384 bytes read"
6909
6910run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6911 "$P_SRV response_size=16384" \
6912 "$P_CLI force_version=tls1_2 \
6913 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6914 0 \
6915 -c "Read from server: 16384 bytes read"
6916
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006917# Tests for restartable ECC
6918
6919requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6920run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006921 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006922 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006923 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006924 debug_level=1" \
6925 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006926 -C "x509_verify_cert.*4b00" \
6927 -C "mbedtls_pk_verify.*4b00" \
6928 -C "mbedtls_ecdh_make_public.*4b00" \
6929 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006930
6931requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6932run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006933 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006934 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006935 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006936 debug_level=1 ec_max_ops=0" \
6937 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006938 -C "x509_verify_cert.*4b00" \
6939 -C "mbedtls_pk_verify.*4b00" \
6940 -C "mbedtls_ecdh_make_public.*4b00" \
6941 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006942
6943requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6944run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006945 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006946 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006947 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006948 debug_level=1 ec_max_ops=65535" \
6949 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006950 -C "x509_verify_cert.*4b00" \
6951 -C "mbedtls_pk_verify.*4b00" \
6952 -C "mbedtls_ecdh_make_public.*4b00" \
6953 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006954
6955requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6956run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006957 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006958 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006959 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006960 debug_level=1 ec_max_ops=1000" \
6961 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006962 -c "x509_verify_cert.*4b00" \
6963 -c "mbedtls_pk_verify.*4b00" \
6964 -c "mbedtls_ecdh_make_public.*4b00" \
6965 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006966
6967requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006968run_test "EC restart: TLS, max_ops=1000, badsign" \
6969 "$P_SRV auth_mode=required \
6970 crt_file=data_files/server5-badsign.crt \
6971 key_file=data_files/server5.key" \
6972 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6973 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6974 debug_level=1 ec_max_ops=1000" \
6975 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006976 -c "x509_verify_cert.*4b00" \
6977 -C "mbedtls_pk_verify.*4b00" \
6978 -C "mbedtls_ecdh_make_public.*4b00" \
6979 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006980 -c "! The certificate is not correctly signed by the trusted CA" \
6981 -c "! mbedtls_ssl_handshake returned" \
6982 -c "X509 - Certificate verification failed"
6983
6984requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6985run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
6986 "$P_SRV auth_mode=required \
6987 crt_file=data_files/server5-badsign.crt \
6988 key_file=data_files/server5.key" \
6989 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6990 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6991 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6992 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006993 -c "x509_verify_cert.*4b00" \
6994 -c "mbedtls_pk_verify.*4b00" \
6995 -c "mbedtls_ecdh_make_public.*4b00" \
6996 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006997 -c "! The certificate is not correctly signed by the trusted CA" \
6998 -C "! mbedtls_ssl_handshake returned" \
6999 -C "X509 - Certificate verification failed"
7000
7001requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7002run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
7003 "$P_SRV auth_mode=required \
7004 crt_file=data_files/server5-badsign.crt \
7005 key_file=data_files/server5.key" \
7006 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7007 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7008 debug_level=1 ec_max_ops=1000 auth_mode=none" \
7009 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007010 -C "x509_verify_cert.*4b00" \
7011 -c "mbedtls_pk_verify.*4b00" \
7012 -c "mbedtls_ecdh_make_public.*4b00" \
7013 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007014 -C "! The certificate is not correctly signed by the trusted CA" \
7015 -C "! mbedtls_ssl_handshake returned" \
7016 -C "X509 - Certificate verification failed"
7017
7018requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007019run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007020 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007021 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007022 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007023 dtls=1 debug_level=1 ec_max_ops=1000" \
7024 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007025 -c "x509_verify_cert.*4b00" \
7026 -c "mbedtls_pk_verify.*4b00" \
7027 -c "mbedtls_ecdh_make_public.*4b00" \
7028 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007029
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007030requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7031run_test "EC restart: TLS, max_ops=1000 no client auth" \
7032 "$P_SRV" \
7033 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7034 debug_level=1 ec_max_ops=1000" \
7035 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007036 -c "x509_verify_cert.*4b00" \
7037 -c "mbedtls_pk_verify.*4b00" \
7038 -c "mbedtls_ecdh_make_public.*4b00" \
7039 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007040
7041requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7042run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
7043 "$P_SRV psk=abc123" \
7044 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
7045 psk=abc123 debug_level=1 ec_max_ops=1000" \
7046 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007047 -C "x509_verify_cert.*4b00" \
7048 -C "mbedtls_pk_verify.*4b00" \
7049 -C "mbedtls_ecdh_make_public.*4b00" \
7050 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007051
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007052# Tests of asynchronous private key support in SSL
7053
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007054requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007055run_test "SSL async private: sign, delay=0" \
7056 "$P_SRV \
7057 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007058 "$P_CLI" \
7059 0 \
7060 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007061 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007062
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007063requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007064run_test "SSL async private: sign, delay=1" \
7065 "$P_SRV \
7066 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007067 "$P_CLI" \
7068 0 \
7069 -s "Async sign callback: using key slot " \
7070 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007071 -s "Async resume (slot [0-9]): sign done, status=0"
7072
Gilles Peskine12d0cc12018-04-26 15:06:56 +02007073requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7074run_test "SSL async private: sign, delay=2" \
7075 "$P_SRV \
7076 async_operations=s async_private_delay1=2 async_private_delay2=2" \
7077 "$P_CLI" \
7078 0 \
7079 -s "Async sign callback: using key slot " \
7080 -U "Async sign callback: using key slot " \
7081 -s "Async resume (slot [0-9]): call 1 more times." \
7082 -s "Async resume (slot [0-9]): call 0 more times." \
7083 -s "Async resume (slot [0-9]): sign done, status=0"
7084
Gilles Peskined3268832018-04-26 06:23:59 +02007085# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
7086# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
7087requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7088requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7089run_test "SSL async private: sign, RSA, TLS 1.1" \
7090 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
7091 async_operations=s async_private_delay1=0 async_private_delay2=0" \
7092 "$P_CLI force_version=tls1_1" \
7093 0 \
7094 -s "Async sign callback: using key slot " \
7095 -s "Async resume (slot [0-9]): sign done, status=0"
7096
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007097requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02007098run_test "SSL async private: sign, SNI" \
7099 "$P_SRV debug_level=3 \
7100 async_operations=s async_private_delay1=0 async_private_delay2=0 \
7101 crt_file=data_files/server5.crt key_file=data_files/server5.key \
7102 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
7103 "$P_CLI server_name=polarssl.example" \
7104 0 \
7105 -s "Async sign callback: using key slot " \
7106 -s "Async resume (slot [0-9]): sign done, status=0" \
7107 -s "parse ServerName extension" \
7108 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
7109 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
7110
7111requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007112run_test "SSL async private: decrypt, delay=0" \
7113 "$P_SRV \
7114 async_operations=d async_private_delay1=0 async_private_delay2=0" \
7115 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7116 0 \
7117 -s "Async decrypt callback: using key slot " \
7118 -s "Async resume (slot [0-9]): decrypt done, status=0"
7119
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007120requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007121run_test "SSL async private: decrypt, delay=1" \
7122 "$P_SRV \
7123 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7124 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7125 0 \
7126 -s "Async decrypt callback: using key slot " \
7127 -s "Async resume (slot [0-9]): call 0 more times." \
7128 -s "Async resume (slot [0-9]): decrypt done, status=0"
7129
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007130requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007131run_test "SSL async private: decrypt RSA-PSK, delay=0" \
7132 "$P_SRV psk=abc123 \
7133 async_operations=d async_private_delay1=0 async_private_delay2=0" \
7134 "$P_CLI psk=abc123 \
7135 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
7136 0 \
7137 -s "Async decrypt callback: using key slot " \
7138 -s "Async resume (slot [0-9]): decrypt done, status=0"
7139
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007140requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007141run_test "SSL async private: decrypt RSA-PSK, delay=1" \
7142 "$P_SRV psk=abc123 \
7143 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7144 "$P_CLI psk=abc123 \
7145 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
7146 0 \
7147 -s "Async decrypt callback: using key slot " \
7148 -s "Async resume (slot [0-9]): call 0 more times." \
7149 -s "Async resume (slot [0-9]): decrypt done, status=0"
7150
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007151requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007152run_test "SSL async private: sign callback not present" \
7153 "$P_SRV \
7154 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7155 "$P_CLI; [ \$? -eq 1 ] &&
7156 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7157 0 \
7158 -S "Async sign callback" \
7159 -s "! mbedtls_ssl_handshake returned" \
7160 -s "The own private key or pre-shared key is not set, but needed" \
7161 -s "Async resume (slot [0-9]): decrypt done, status=0" \
7162 -s "Successful connection"
7163
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007164requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007165run_test "SSL async private: decrypt callback not present" \
7166 "$P_SRV debug_level=1 \
7167 async_operations=s async_private_delay1=1 async_private_delay2=1" \
7168 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
7169 [ \$? -eq 1 ] && $P_CLI" \
7170 0 \
7171 -S "Async decrypt callback" \
7172 -s "! mbedtls_ssl_handshake returned" \
7173 -s "got no RSA private key" \
7174 -s "Async resume (slot [0-9]): sign done, status=0" \
7175 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007176
7177# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007178requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007179run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007180 "$P_SRV \
7181 async_operations=s async_private_delay1=1 \
7182 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7183 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007184 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7185 0 \
7186 -s "Async sign callback: using key slot 0," \
7187 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007188 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007189
7190# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007191requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007192run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007193 "$P_SRV \
7194 async_operations=s async_private_delay2=1 \
7195 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7196 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007197 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7198 0 \
7199 -s "Async sign callback: using key slot 0," \
7200 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007201 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007202
7203# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007204requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02007205run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007206 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02007207 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007208 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7209 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007210 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7211 0 \
7212 -s "Async sign callback: using key slot 1," \
7213 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007214 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007215
7216# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007217requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007218run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007219 "$P_SRV \
7220 async_operations=s async_private_delay1=1 \
7221 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7222 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007223 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7224 0 \
7225 -s "Async sign callback: no key matches this certificate."
7226
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007227requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007228run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007229 "$P_SRV \
7230 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7231 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007232 "$P_CLI" \
7233 1 \
7234 -s "Async sign callback: injected error" \
7235 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02007236 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007237 -s "! mbedtls_ssl_handshake returned"
7238
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007239requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007240run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007241 "$P_SRV \
7242 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7243 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007244 "$P_CLI" \
7245 1 \
7246 -s "Async sign callback: using key slot " \
7247 -S "Async resume" \
7248 -s "Async cancel"
7249
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007250requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007251run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007252 "$P_SRV \
7253 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7254 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007255 "$P_CLI" \
7256 1 \
7257 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007258 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02007259 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007260 -s "! mbedtls_ssl_handshake returned"
7261
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007262requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007263run_test "SSL async private: decrypt, error in start" \
7264 "$P_SRV \
7265 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7266 async_private_error=1" \
7267 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7268 1 \
7269 -s "Async decrypt callback: injected error" \
7270 -S "Async resume" \
7271 -S "Async cancel" \
7272 -s "! mbedtls_ssl_handshake returned"
7273
7274requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7275run_test "SSL async private: decrypt, cancel after start" \
7276 "$P_SRV \
7277 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7278 async_private_error=2" \
7279 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7280 1 \
7281 -s "Async decrypt callback: using key slot " \
7282 -S "Async resume" \
7283 -s "Async cancel"
7284
7285requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7286run_test "SSL async private: decrypt, error in resume" \
7287 "$P_SRV \
7288 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7289 async_private_error=3" \
7290 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7291 1 \
7292 -s "Async decrypt callback: using key slot " \
7293 -s "Async resume callback: decrypt done but injected error" \
7294 -S "Async cancel" \
7295 -s "! mbedtls_ssl_handshake returned"
7296
7297requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007298run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007299 "$P_SRV \
7300 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7301 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007302 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
7303 0 \
7304 -s "Async cancel" \
7305 -s "! mbedtls_ssl_handshake returned" \
7306 -s "Async resume" \
7307 -s "Successful connection"
7308
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007309requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007310run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007311 "$P_SRV \
7312 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7313 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007314 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
7315 0 \
7316 -s "! mbedtls_ssl_handshake returned" \
7317 -s "Async resume" \
7318 -s "Successful connection"
7319
7320# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007321requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007322run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007323 "$P_SRV \
7324 async_operations=s async_private_delay1=1 async_private_error=-2 \
7325 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7326 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007327 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
7328 [ \$? -eq 1 ] &&
7329 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7330 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02007331 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007332 -S "Async resume" \
7333 -s "Async cancel" \
7334 -s "! mbedtls_ssl_handshake returned" \
7335 -s "Async sign callback: no key matches this certificate." \
7336 -s "Successful connection"
7337
7338# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007339requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007340run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007341 "$P_SRV \
7342 async_operations=s async_private_delay1=1 async_private_error=-3 \
7343 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7344 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007345 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
7346 [ \$? -eq 1 ] &&
7347 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7348 0 \
7349 -s "Async resume" \
7350 -s "! mbedtls_ssl_handshake returned" \
7351 -s "Async sign callback: no key matches this certificate." \
7352 -s "Successful connection"
7353
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007354requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007355requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007356run_test "SSL async private: renegotiation: client-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007357 "$P_SRV \
7358 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007359 exchanges=2 renegotiation=1" \
7360 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
7361 0 \
7362 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007363 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007364
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007365requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007366requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007367run_test "SSL async private: renegotiation: server-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007368 "$P_SRV \
7369 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007370 exchanges=2 renegotiation=1 renegotiate=1" \
7371 "$P_CLI exchanges=2 renegotiation=1" \
7372 0 \
7373 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007374 -s "Async resume (slot [0-9]): sign done, status=0"
7375
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007376requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007377requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007378run_test "SSL async private: renegotiation: client-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007379 "$P_SRV \
7380 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7381 exchanges=2 renegotiation=1" \
7382 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
7383 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7384 0 \
7385 -s "Async decrypt callback: using key slot " \
7386 -s "Async resume (slot [0-9]): decrypt done, status=0"
7387
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007388requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007389requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007390run_test "SSL async private: renegotiation: server-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007391 "$P_SRV \
7392 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7393 exchanges=2 renegotiation=1 renegotiate=1" \
7394 "$P_CLI exchanges=2 renegotiation=1 \
7395 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7396 0 \
7397 -s "Async decrypt callback: using key slot " \
7398 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007399
Ron Eldor58093c82018-06-28 13:22:05 +03007400# Tests for ECC extensions (rfc 4492)
7401
Ron Eldor643df7c2018-06-28 16:17:00 +03007402requires_config_enabled MBEDTLS_AES_C
7403requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7404requires_config_enabled MBEDTLS_SHA256_C
7405requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007406run_test "Force a non ECC ciphersuite in the client side" \
7407 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03007408 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03007409 0 \
7410 -C "client hello, adding supported_elliptic_curves extension" \
7411 -C "client hello, adding supported_point_formats extension" \
7412 -S "found supported elliptic curves extension" \
7413 -S "found supported point formats extension"
7414
Ron Eldor643df7c2018-06-28 16:17:00 +03007415requires_config_enabled MBEDTLS_AES_C
7416requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7417requires_config_enabled MBEDTLS_SHA256_C
7418requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007419run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03007420 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03007421 "$P_CLI debug_level=3" \
7422 0 \
7423 -C "found supported_point_formats extension" \
7424 -S "server hello, supported_point_formats extension"
7425
Ron Eldor643df7c2018-06-28 16:17:00 +03007426requires_config_enabled MBEDTLS_AES_C
7427requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7428requires_config_enabled MBEDTLS_SHA256_C
7429requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007430run_test "Force an ECC ciphersuite in the client side" \
7431 "$P_SRV debug_level=3" \
7432 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7433 0 \
7434 -c "client hello, adding supported_elliptic_curves extension" \
7435 -c "client hello, adding supported_point_formats extension" \
7436 -s "found supported elliptic curves extension" \
7437 -s "found supported point formats extension"
7438
Ron Eldor643df7c2018-06-28 16:17:00 +03007439requires_config_enabled MBEDTLS_AES_C
7440requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7441requires_config_enabled MBEDTLS_SHA256_C
7442requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007443run_test "Force an ECC ciphersuite in the server side" \
7444 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7445 "$P_CLI debug_level=3" \
7446 0 \
7447 -c "found supported_point_formats extension" \
7448 -s "server hello, supported_point_formats extension"
7449
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007450# Tests for DTLS HelloVerifyRequest
7451
7452run_test "DTLS cookie: enabled" \
7453 "$P_SRV dtls=1 debug_level=2" \
7454 "$P_CLI dtls=1 debug_level=2" \
7455 0 \
7456 -s "cookie verification failed" \
7457 -s "cookie verification passed" \
7458 -S "cookie verification skipped" \
7459 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007460 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007461 -S "SSL - The requested feature is not available"
7462
7463run_test "DTLS cookie: disabled" \
7464 "$P_SRV dtls=1 debug_level=2 cookies=0" \
7465 "$P_CLI dtls=1 debug_level=2" \
7466 0 \
7467 -S "cookie verification failed" \
7468 -S "cookie verification passed" \
7469 -s "cookie verification skipped" \
7470 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007471 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007472 -S "SSL - The requested feature is not available"
7473
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007474run_test "DTLS cookie: default (failing)" \
7475 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
7476 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
7477 1 \
7478 -s "cookie verification failed" \
7479 -S "cookie verification passed" \
7480 -S "cookie verification skipped" \
7481 -C "received hello verify request" \
7482 -S "hello verification requested" \
7483 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007484
7485requires_ipv6
7486run_test "DTLS cookie: enabled, IPv6" \
7487 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
7488 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
7489 0 \
7490 -s "cookie verification failed" \
7491 -s "cookie verification passed" \
7492 -S "cookie verification skipped" \
7493 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007494 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007495 -S "SSL - The requested feature is not available"
7496
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007497run_test "DTLS cookie: enabled, nbio" \
7498 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7499 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7500 0 \
7501 -s "cookie verification failed" \
7502 -s "cookie verification passed" \
7503 -S "cookie verification skipped" \
7504 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007505 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007506 -S "SSL - The requested feature is not available"
7507
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007508# Tests for client reconnecting from the same port with DTLS
7509
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007510not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007511run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007512 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7513 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007514 0 \
7515 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007516 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007517 -S "Client initiated reconnection from same port"
7518
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007519not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007520run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007521 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7522 "$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 +02007523 0 \
7524 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007525 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007526 -s "Client initiated reconnection from same port"
7527
Paul Bakker362689d2016-05-13 10:33:25 +01007528not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
7529run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007530 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7531 "$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 +02007532 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007533 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007534 -s "Client initiated reconnection from same port"
7535
Paul Bakker362689d2016-05-13 10:33:25 +01007536only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
7537run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7538 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7539 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7540 0 \
7541 -S "The operation timed out" \
7542 -s "Client initiated reconnection from same port"
7543
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007544run_test "DTLS client reconnect from same port: no cookies" \
7545 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007546 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7547 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007548 -s "The operation timed out" \
7549 -S "Client initiated reconnection from same port"
7550
Manuel Pégourié-Gonnardbaad2de2020-03-13 11:11:02 +01007551run_test "DTLS client reconnect from same port: attacker-injected" \
7552 -p "$P_PXY inject_clihlo=1" \
7553 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
7554 "$P_CLI dtls=1 exchanges=2" \
7555 0 \
7556 -s "possible client reconnect from the same port" \
7557 -S "Client initiated reconnection from same port"
7558
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007559# Tests for various cases of client authentication with DTLS
7560# (focused on handshake flows and message parsing)
7561
7562run_test "DTLS client auth: required" \
7563 "$P_SRV dtls=1 auth_mode=required" \
7564 "$P_CLI dtls=1" \
7565 0 \
7566 -s "Verifying peer X.509 certificate... ok"
7567
7568run_test "DTLS client auth: optional, client has no cert" \
7569 "$P_SRV dtls=1 auth_mode=optional" \
7570 "$P_CLI dtls=1 crt_file=none key_file=none" \
7571 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007572 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007573
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007574run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007575 "$P_SRV dtls=1 auth_mode=none" \
7576 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7577 0 \
7578 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007579 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007580
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007581run_test "DTLS wrong PSK: badmac alert" \
7582 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7583 "$P_CLI dtls=1 psk=abc124" \
7584 1 \
7585 -s "SSL - Verification of the message MAC failed" \
7586 -c "SSL - A fatal alert message was received from our peer"
7587
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007588# Tests for receiving fragmented handshake messages with DTLS
7589
7590requires_gnutls
7591run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7592 "$G_SRV -u --mtu 2048 -a" \
7593 "$P_CLI dtls=1 debug_level=2" \
7594 0 \
7595 -C "found fragmented DTLS handshake message" \
7596 -C "error"
7597
7598requires_gnutls
7599run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7600 "$G_SRV -u --mtu 512" \
7601 "$P_CLI dtls=1 debug_level=2" \
7602 0 \
7603 -c "found fragmented DTLS handshake message" \
7604 -C "error"
7605
7606requires_gnutls
7607run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7608 "$G_SRV -u --mtu 128" \
7609 "$P_CLI dtls=1 debug_level=2" \
7610 0 \
7611 -c "found fragmented DTLS handshake message" \
7612 -C "error"
7613
7614requires_gnutls
7615run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7616 "$G_SRV -u --mtu 128" \
7617 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7618 0 \
7619 -c "found fragmented DTLS handshake message" \
7620 -C "error"
7621
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007622requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007623requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007624run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7625 "$G_SRV -u --mtu 256" \
7626 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
7627 0 \
7628 -c "found fragmented DTLS handshake message" \
7629 -c "client hello, adding renegotiation extension" \
7630 -c "found renegotiation extension" \
7631 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007632 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007633 -C "error" \
7634 -s "Extra-header:"
7635
7636requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007637requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007638run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7639 "$G_SRV -u --mtu 256" \
7640 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
7641 0 \
7642 -c "found fragmented DTLS handshake message" \
7643 -c "client hello, adding renegotiation extension" \
7644 -c "found renegotiation extension" \
7645 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007646 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007647 -C "error" \
7648 -s "Extra-header:"
7649
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007650run_test "DTLS reassembly: no fragmentation (openssl server)" \
7651 "$O_SRV -dtls1 -mtu 2048" \
7652 "$P_CLI dtls=1 debug_level=2" \
7653 0 \
7654 -C "found fragmented DTLS handshake message" \
7655 -C "error"
7656
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007657run_test "DTLS reassembly: some fragmentation (openssl server)" \
7658 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007659 "$P_CLI dtls=1 debug_level=2" \
7660 0 \
7661 -c "found fragmented DTLS handshake message" \
7662 -C "error"
7663
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007664run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007665 "$O_SRV -dtls1 -mtu 256" \
7666 "$P_CLI dtls=1 debug_level=2" \
7667 0 \
7668 -c "found fragmented DTLS handshake message" \
7669 -C "error"
7670
7671run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7672 "$O_SRV -dtls1 -mtu 256" \
7673 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7674 0 \
7675 -c "found fragmented DTLS handshake message" \
7676 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007677
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007678# Tests for sending fragmented handshake messages with DTLS
7679#
7680# Use client auth when we need the client to send large messages,
7681# and use large cert chains on both sides too (the long chains we have all use
7682# both RSA and ECDSA, but ideally we should have long chains with either).
7683# Sizes reached (UDP payload):
7684# - 2037B for server certificate
7685# - 1542B for client certificate
7686# - 1013B for newsessionticket
7687# - all others below 512B
7688# All those tests assume MAX_CONTENT_LEN is at least 2048
7689
7690requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7691requires_config_enabled MBEDTLS_RSA_C
7692requires_config_enabled MBEDTLS_ECDSA_C
7693requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7694run_test "DTLS fragmenting: none (for reference)" \
7695 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7696 crt_file=data_files/server7_int-ca.crt \
7697 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007698 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007699 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007700 "$P_CLI dtls=1 debug_level=2 \
7701 crt_file=data_files/server8_int-ca2.crt \
7702 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007703 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007704 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007705 0 \
7706 -S "found fragmented DTLS handshake message" \
7707 -C "found fragmented DTLS handshake message" \
7708 -C "error"
7709
7710requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7711requires_config_enabled MBEDTLS_RSA_C
7712requires_config_enabled MBEDTLS_ECDSA_C
7713requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007714run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007715 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7716 crt_file=data_files/server7_int-ca.crt \
7717 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007718 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007719 max_frag_len=1024" \
7720 "$P_CLI dtls=1 debug_level=2 \
7721 crt_file=data_files/server8_int-ca2.crt \
7722 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007723 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007724 max_frag_len=2048" \
7725 0 \
7726 -S "found fragmented DTLS handshake message" \
7727 -c "found fragmented DTLS handshake message" \
7728 -C "error"
7729
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007730# With the MFL extension, the server has no way of forcing
7731# the client to not exceed a certain MTU; hence, the following
7732# test can't be replicated with an MTU proxy such as the one
7733# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007734requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7735requires_config_enabled MBEDTLS_RSA_C
7736requires_config_enabled MBEDTLS_ECDSA_C
7737requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007738run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007739 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7740 crt_file=data_files/server7_int-ca.crt \
7741 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007742 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007743 max_frag_len=512" \
7744 "$P_CLI dtls=1 debug_level=2 \
7745 crt_file=data_files/server8_int-ca2.crt \
7746 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007747 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007748 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007749 0 \
7750 -S "found fragmented DTLS handshake message" \
7751 -c "found fragmented DTLS handshake message" \
7752 -C "error"
7753
7754requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7755requires_config_enabled MBEDTLS_RSA_C
7756requires_config_enabled MBEDTLS_ECDSA_C
7757requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007758run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007759 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7760 crt_file=data_files/server7_int-ca.crt \
7761 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007762 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007763 max_frag_len=2048" \
7764 "$P_CLI dtls=1 debug_level=2 \
7765 crt_file=data_files/server8_int-ca2.crt \
7766 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007767 hs_timeout=2500-60000 \
7768 max_frag_len=1024" \
7769 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007770 -S "found fragmented DTLS handshake message" \
7771 -c "found fragmented DTLS handshake message" \
7772 -C "error"
7773
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007774# While not required by the standard defining the MFL extension
7775# (according to which it only applies to records, not to datagrams),
7776# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7777# as otherwise there wouldn't be any means to communicate MTU restrictions
7778# to the peer.
7779# The next test checks that no datagrams significantly larger than the
7780# negotiated MFL are sent.
7781requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7782requires_config_enabled MBEDTLS_RSA_C
7783requires_config_enabled MBEDTLS_ECDSA_C
7784requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7785run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007786 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007787 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7788 crt_file=data_files/server7_int-ca.crt \
7789 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007790 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007791 max_frag_len=2048" \
7792 "$P_CLI dtls=1 debug_level=2 \
7793 crt_file=data_files/server8_int-ca2.crt \
7794 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007795 hs_timeout=2500-60000 \
7796 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007797 0 \
7798 -S "found fragmented DTLS handshake message" \
7799 -c "found fragmented DTLS handshake message" \
7800 -C "error"
7801
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007802requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7803requires_config_enabled MBEDTLS_RSA_C
7804requires_config_enabled MBEDTLS_ECDSA_C
7805requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007806run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007807 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7808 crt_file=data_files/server7_int-ca.crt \
7809 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007810 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007811 max_frag_len=2048" \
7812 "$P_CLI dtls=1 debug_level=2 \
7813 crt_file=data_files/server8_int-ca2.crt \
7814 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007815 hs_timeout=2500-60000 \
7816 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007817 0 \
7818 -s "found fragmented DTLS handshake message" \
7819 -c "found fragmented DTLS handshake message" \
7820 -C "error"
7821
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007822# While not required by the standard defining the MFL extension
7823# (according to which it only applies to records, not to datagrams),
7824# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7825# as otherwise there wouldn't be any means to communicate MTU restrictions
7826# to the peer.
7827# The next test checks that no datagrams significantly larger than the
7828# negotiated MFL are sent.
7829requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7830requires_config_enabled MBEDTLS_RSA_C
7831requires_config_enabled MBEDTLS_ECDSA_C
7832requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7833run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007834 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007835 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7836 crt_file=data_files/server7_int-ca.crt \
7837 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007838 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007839 max_frag_len=2048" \
7840 "$P_CLI dtls=1 debug_level=2 \
7841 crt_file=data_files/server8_int-ca2.crt \
7842 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007843 hs_timeout=2500-60000 \
7844 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007845 0 \
7846 -s "found fragmented DTLS handshake message" \
7847 -c "found fragmented DTLS handshake message" \
7848 -C "error"
7849
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007850requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7851requires_config_enabled MBEDTLS_RSA_C
7852requires_config_enabled MBEDTLS_ECDSA_C
7853run_test "DTLS fragmenting: none (for reference) (MTU)" \
7854 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7855 crt_file=data_files/server7_int-ca.crt \
7856 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007857 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007858 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007859 "$P_CLI dtls=1 debug_level=2 \
7860 crt_file=data_files/server8_int-ca2.crt \
7861 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007862 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007863 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007864 0 \
7865 -S "found fragmented DTLS handshake message" \
7866 -C "found fragmented DTLS handshake message" \
7867 -C "error"
7868
7869requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7870requires_config_enabled MBEDTLS_RSA_C
7871requires_config_enabled MBEDTLS_ECDSA_C
7872run_test "DTLS fragmenting: client (MTU)" \
7873 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7874 crt_file=data_files/server7_int-ca.crt \
7875 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007876 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007877 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007878 "$P_CLI dtls=1 debug_level=2 \
7879 crt_file=data_files/server8_int-ca2.crt \
7880 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007881 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007882 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007883 0 \
7884 -s "found fragmented DTLS handshake message" \
7885 -C "found fragmented DTLS handshake message" \
7886 -C "error"
7887
7888requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7889requires_config_enabled MBEDTLS_RSA_C
7890requires_config_enabled MBEDTLS_ECDSA_C
7891run_test "DTLS fragmenting: server (MTU)" \
7892 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7893 crt_file=data_files/server7_int-ca.crt \
7894 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007895 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007896 mtu=512" \
7897 "$P_CLI dtls=1 debug_level=2 \
7898 crt_file=data_files/server8_int-ca2.crt \
7899 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007900 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007901 mtu=2048" \
7902 0 \
7903 -S "found fragmented DTLS handshake message" \
7904 -c "found fragmented DTLS handshake message" \
7905 -C "error"
7906
7907requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7908requires_config_enabled MBEDTLS_RSA_C
7909requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007910run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007911 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007912 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7913 crt_file=data_files/server7_int-ca.crt \
7914 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007915 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007916 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007917 "$P_CLI dtls=1 debug_level=2 \
7918 crt_file=data_files/server8_int-ca2.crt \
7919 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007920 hs_timeout=2500-60000 \
7921 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007922 0 \
7923 -s "found fragmented DTLS handshake message" \
7924 -c "found fragmented DTLS handshake message" \
7925 -C "error"
7926
Andrzej Kurek77826052018-10-11 07:34:08 -04007927# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007928requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7929requires_config_enabled MBEDTLS_RSA_C
7930requires_config_enabled MBEDTLS_ECDSA_C
7931requires_config_enabled MBEDTLS_SHA256_C
7932requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7933requires_config_enabled MBEDTLS_AES_C
7934requires_config_enabled MBEDTLS_GCM_C
7935run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007936 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007937 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7938 crt_file=data_files/server7_int-ca.crt \
7939 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007940 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007941 mtu=512" \
7942 "$P_CLI dtls=1 debug_level=2 \
7943 crt_file=data_files/server8_int-ca2.crt \
7944 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007945 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7946 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007947 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007948 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007949 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007950 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007951 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007952
Andrzej Kurek7311c782018-10-11 06:49:41 -04007953# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007954# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007955# The ratio of max/min timeout should ideally equal 4 to accept two
7956# retransmissions, but in some cases (like both the server and client using
7957# fragmentation and auto-reduction) an extra retransmission might occur,
7958# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007959not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007960requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7961requires_config_enabled MBEDTLS_RSA_C
7962requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007963requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7964requires_config_enabled MBEDTLS_AES_C
7965requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02007966run_test "DTLS fragmenting: proxy MTU: auto-reduction (not valgrind)" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007967 -p "$P_PXY mtu=508" \
7968 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7969 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007970 key_file=data_files/server7.key \
7971 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007972 "$P_CLI dtls=1 debug_level=2 \
7973 crt_file=data_files/server8_int-ca2.crt \
7974 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007975 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7976 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007977 0 \
7978 -s "found fragmented DTLS handshake message" \
7979 -c "found fragmented DTLS handshake message" \
7980 -C "error"
7981
Andrzej Kurek77826052018-10-11 07:34:08 -04007982# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007983only_with_valgrind
7984requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7985requires_config_enabled MBEDTLS_RSA_C
7986requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007987requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7988requires_config_enabled MBEDTLS_AES_C
7989requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02007990run_test "DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)" \
Hanno Becker108992e2018-08-29 17:04:18 +01007991 -p "$P_PXY mtu=508" \
7992 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7993 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007994 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01007995 hs_timeout=250-10000" \
7996 "$P_CLI dtls=1 debug_level=2 \
7997 crt_file=data_files/server8_int-ca2.crt \
7998 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007999 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01008000 hs_timeout=250-10000" \
8001 0 \
8002 -s "found fragmented DTLS handshake message" \
8003 -c "found fragmented DTLS handshake message" \
8004 -C "error"
8005
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008006# 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 +02008007# OTOH the client might resend if the server is to slow to reset after sending
8008# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008009not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008010requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8011requires_config_enabled MBEDTLS_RSA_C
8012requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008013run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008014 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008015 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8016 crt_file=data_files/server7_int-ca.crt \
8017 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008018 hs_timeout=10000-60000 \
8019 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008020 "$P_CLI dtls=1 debug_level=2 \
8021 crt_file=data_files/server8_int-ca2.crt \
8022 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008023 hs_timeout=10000-60000 \
8024 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008025 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008026 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008027 -s "found fragmented DTLS handshake message" \
8028 -c "found fragmented DTLS handshake message" \
8029 -C "error"
8030
Andrzej Kurek77826052018-10-11 07:34:08 -04008031# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008032# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
8033# OTOH the client might resend if the server is to slow to reset after sending
8034# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008035not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008036requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8037requires_config_enabled MBEDTLS_RSA_C
8038requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008039requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8040requires_config_enabled MBEDTLS_AES_C
8041requires_config_enabled MBEDTLS_GCM_C
8042run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008043 -p "$P_PXY mtu=512" \
8044 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8045 crt_file=data_files/server7_int-ca.crt \
8046 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008047 hs_timeout=10000-60000 \
8048 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008049 "$P_CLI dtls=1 debug_level=2 \
8050 crt_file=data_files/server8_int-ca2.crt \
8051 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008052 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8053 hs_timeout=10000-60000 \
8054 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008055 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008056 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008057 -s "found fragmented DTLS handshake message" \
8058 -c "found fragmented DTLS handshake message" \
8059 -C "error"
8060
Andrzej Kurek7311c782018-10-11 06:49:41 -04008061not_with_valgrind # spurious autoreduction due to timeout
8062requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8063requires_config_enabled MBEDTLS_RSA_C
8064requires_config_enabled MBEDTLS_ECDSA_C
8065run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008066 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008067 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8068 crt_file=data_files/server7_int-ca.crt \
8069 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008070 hs_timeout=10000-60000 \
8071 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008072 "$P_CLI dtls=1 debug_level=2 \
8073 crt_file=data_files/server8_int-ca2.crt \
8074 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008075 hs_timeout=10000-60000 \
8076 mtu=1024 nbio=2" \
8077 0 \
8078 -S "autoreduction" \
8079 -s "found fragmented DTLS handshake message" \
8080 -c "found fragmented DTLS handshake message" \
8081 -C "error"
8082
Andrzej Kurek77826052018-10-11 07:34:08 -04008083# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008084not_with_valgrind # spurious autoreduction due to timeout
8085requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8086requires_config_enabled MBEDTLS_RSA_C
8087requires_config_enabled MBEDTLS_ECDSA_C
8088requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8089requires_config_enabled MBEDTLS_AES_C
8090requires_config_enabled MBEDTLS_GCM_C
8091run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
8092 -p "$P_PXY mtu=512" \
8093 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8094 crt_file=data_files/server7_int-ca.crt \
8095 key_file=data_files/server7.key \
8096 hs_timeout=10000-60000 \
8097 mtu=512 nbio=2" \
8098 "$P_CLI dtls=1 debug_level=2 \
8099 crt_file=data_files/server8_int-ca2.crt \
8100 key_file=data_files/server8.key \
8101 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8102 hs_timeout=10000-60000 \
8103 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008104 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008105 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008106 -s "found fragmented DTLS handshake message" \
8107 -c "found fragmented DTLS handshake message" \
8108 -C "error"
8109
Andrzej Kurek77826052018-10-11 07:34:08 -04008110# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01008111# This ensures things still work after session_reset().
8112# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008113# Since we don't support reading fragmented ClientHello yet,
8114# up the MTU to 1450 (larger than ClientHello with session ticket,
8115# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008116# An autoreduction on the client-side might happen if the server is
8117# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02008118# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008119# resumed listening, which would result in a spurious autoreduction.
8120not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008121requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8122requires_config_enabled MBEDTLS_RSA_C
8123requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008124requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8125requires_config_enabled MBEDTLS_AES_C
8126requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008127run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
8128 -p "$P_PXY mtu=1450" \
8129 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8130 crt_file=data_files/server7_int-ca.crt \
8131 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008132 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008133 mtu=1450" \
8134 "$P_CLI dtls=1 debug_level=2 \
8135 crt_file=data_files/server8_int-ca2.crt \
8136 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008137 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008138 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01008139 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008140 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008141 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008142 -s "found fragmented DTLS handshake message" \
8143 -c "found fragmented DTLS handshake message" \
8144 -C "error"
8145
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008146# An autoreduction on the client-side might happen if the server is
8147# slow to reset, therefore omitting '-C "autoreduction"' below.
8148not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008149requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8150requires_config_enabled MBEDTLS_RSA_C
8151requires_config_enabled MBEDTLS_ECDSA_C
8152requires_config_enabled MBEDTLS_SHA256_C
8153requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8154requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8155requires_config_enabled MBEDTLS_CHACHAPOLY_C
8156run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
8157 -p "$P_PXY mtu=512" \
8158 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8159 crt_file=data_files/server7_int-ca.crt \
8160 key_file=data_files/server7.key \
8161 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008162 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008163 mtu=512" \
8164 "$P_CLI dtls=1 debug_level=2 \
8165 crt_file=data_files/server8_int-ca2.crt \
8166 key_file=data_files/server8.key \
8167 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008168 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008169 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008170 mtu=512" \
8171 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008172 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008173 -s "found fragmented DTLS handshake message" \
8174 -c "found fragmented DTLS handshake message" \
8175 -C "error"
8176
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008177# An autoreduction on the client-side might happen if the server is
8178# slow to reset, therefore omitting '-C "autoreduction"' below.
8179not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008180requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8181requires_config_enabled MBEDTLS_RSA_C
8182requires_config_enabled MBEDTLS_ECDSA_C
8183requires_config_enabled MBEDTLS_SHA256_C
8184requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8185requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8186requires_config_enabled MBEDTLS_AES_C
8187requires_config_enabled MBEDTLS_GCM_C
8188run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
8189 -p "$P_PXY mtu=512" \
8190 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8191 crt_file=data_files/server7_int-ca.crt \
8192 key_file=data_files/server7.key \
8193 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008194 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008195 mtu=512" \
8196 "$P_CLI dtls=1 debug_level=2 \
8197 crt_file=data_files/server8_int-ca2.crt \
8198 key_file=data_files/server8.key \
8199 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008200 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008201 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008202 mtu=512" \
8203 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008204 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008205 -s "found fragmented DTLS handshake message" \
8206 -c "found fragmented DTLS handshake message" \
8207 -C "error"
8208
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008209# An autoreduction on the client-side might happen if the server is
8210# slow to reset, therefore omitting '-C "autoreduction"' below.
8211not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008212requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8213requires_config_enabled MBEDTLS_RSA_C
8214requires_config_enabled MBEDTLS_ECDSA_C
8215requires_config_enabled MBEDTLS_SHA256_C
8216requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8217requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8218requires_config_enabled MBEDTLS_AES_C
8219requires_config_enabled MBEDTLS_CCM_C
8220run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008221 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008222 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8223 crt_file=data_files/server7_int-ca.crt \
8224 key_file=data_files/server7.key \
8225 exchanges=2 renegotiation=1 \
8226 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008227 hs_timeout=10000-60000 \
8228 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008229 "$P_CLI dtls=1 debug_level=2 \
8230 crt_file=data_files/server8_int-ca2.crt \
8231 key_file=data_files/server8.key \
8232 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008233 hs_timeout=10000-60000 \
8234 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008235 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008236 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008237 -s "found fragmented DTLS handshake message" \
8238 -c "found fragmented DTLS handshake message" \
8239 -C "error"
8240
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008241# An autoreduction on the client-side might happen if the server is
8242# slow to reset, therefore omitting '-C "autoreduction"' below.
8243not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008244requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8245requires_config_enabled MBEDTLS_RSA_C
8246requires_config_enabled MBEDTLS_ECDSA_C
8247requires_config_enabled MBEDTLS_SHA256_C
8248requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8249requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8250requires_config_enabled MBEDTLS_AES_C
8251requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
8252requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
8253run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008254 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008255 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8256 crt_file=data_files/server7_int-ca.crt \
8257 key_file=data_files/server7.key \
8258 exchanges=2 renegotiation=1 \
8259 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008260 hs_timeout=10000-60000 \
8261 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008262 "$P_CLI dtls=1 debug_level=2 \
8263 crt_file=data_files/server8_int-ca2.crt \
8264 key_file=data_files/server8.key \
8265 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008266 hs_timeout=10000-60000 \
8267 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008268 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008269 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008270 -s "found fragmented DTLS handshake message" \
8271 -c "found fragmented DTLS handshake message" \
8272 -C "error"
8273
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008274# An autoreduction on the client-side might happen if the server is
8275# slow to reset, therefore omitting '-C "autoreduction"' below.
8276not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008277requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8278requires_config_enabled MBEDTLS_RSA_C
8279requires_config_enabled MBEDTLS_ECDSA_C
8280requires_config_enabled MBEDTLS_SHA256_C
8281requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8282requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8283requires_config_enabled MBEDTLS_AES_C
8284requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
8285run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008286 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008287 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8288 crt_file=data_files/server7_int-ca.crt \
8289 key_file=data_files/server7.key \
8290 exchanges=2 renegotiation=1 \
8291 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008292 hs_timeout=10000-60000 \
8293 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008294 "$P_CLI dtls=1 debug_level=2 \
8295 crt_file=data_files/server8_int-ca2.crt \
8296 key_file=data_files/server8.key \
8297 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008298 hs_timeout=10000-60000 \
8299 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008300 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008301 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008302 -s "found fragmented DTLS handshake message" \
8303 -c "found fragmented DTLS handshake message" \
8304 -C "error"
8305
Andrzej Kurek77826052018-10-11 07:34:08 -04008306# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008307requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8308requires_config_enabled MBEDTLS_RSA_C
8309requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008310requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8311requires_config_enabled MBEDTLS_AES_C
8312requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008313client_needs_more_time 2
8314run_test "DTLS fragmenting: proxy MTU + 3d" \
8315 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008316 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008317 crt_file=data_files/server7_int-ca.crt \
8318 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008319 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008320 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008321 crt_file=data_files/server8_int-ca2.crt \
8322 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008323 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008324 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008325 0 \
8326 -s "found fragmented DTLS handshake message" \
8327 -c "found fragmented DTLS handshake message" \
8328 -C "error"
8329
Andrzej Kurek77826052018-10-11 07:34:08 -04008330# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008331requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8332requires_config_enabled MBEDTLS_RSA_C
8333requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008334requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8335requires_config_enabled MBEDTLS_AES_C
8336requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008337client_needs_more_time 2
8338run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
8339 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
8340 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8341 crt_file=data_files/server7_int-ca.crt \
8342 key_file=data_files/server7.key \
8343 hs_timeout=250-10000 mtu=512 nbio=2" \
8344 "$P_CLI dtls=1 debug_level=2 \
8345 crt_file=data_files/server8_int-ca2.crt \
8346 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008347 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008348 hs_timeout=250-10000 mtu=512 nbio=2" \
8349 0 \
8350 -s "found fragmented DTLS handshake message" \
8351 -c "found fragmented DTLS handshake message" \
8352 -C "error"
8353
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008354# interop tests for DTLS fragmentating with reliable connection
8355#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008356# here and below we just want to test that the we fragment in a way that
8357# pleases other implementations, so we don't need the peer to fragment
8358requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8359requires_config_enabled MBEDTLS_RSA_C
8360requires_config_enabled MBEDTLS_ECDSA_C
8361requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008362requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008363run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
8364 "$G_SRV -u" \
8365 "$P_CLI dtls=1 debug_level=2 \
8366 crt_file=data_files/server8_int-ca2.crt \
8367 key_file=data_files/server8.key \
8368 mtu=512 force_version=dtls1_2" \
8369 0 \
8370 -c "fragmenting handshake message" \
8371 -C "error"
8372
8373requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8374requires_config_enabled MBEDTLS_RSA_C
8375requires_config_enabled MBEDTLS_ECDSA_C
8376requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008377requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008378run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
8379 "$G_SRV -u" \
8380 "$P_CLI dtls=1 debug_level=2 \
8381 crt_file=data_files/server8_int-ca2.crt \
8382 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008383 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008384 0 \
8385 -c "fragmenting handshake message" \
8386 -C "error"
8387
Hanno Beckerb9a00862018-08-28 10:20:22 +01008388# We use --insecure for the GnuTLS client because it expects
8389# the hostname / IP it connects to to be the name used in the
8390# certificate obtained from the server. Here, however, it
8391# connects to 127.0.0.1 while our test certificates use 'localhost'
8392# as the server name in the certificate. This will make the
8393# certifiate validation fail, but passing --insecure makes
8394# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008395requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8396requires_config_enabled MBEDTLS_RSA_C
8397requires_config_enabled MBEDTLS_ECDSA_C
8398requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008399requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008400requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008401run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008402 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008403 crt_file=data_files/server7_int-ca.crt \
8404 key_file=data_files/server7.key \
8405 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008406 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008407 0 \
8408 -s "fragmenting handshake message"
8409
Hanno Beckerb9a00862018-08-28 10:20:22 +01008410# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008411requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8412requires_config_enabled MBEDTLS_RSA_C
8413requires_config_enabled MBEDTLS_ECDSA_C
8414requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008415requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008416requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008417run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008418 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008419 crt_file=data_files/server7_int-ca.crt \
8420 key_file=data_files/server7.key \
8421 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008422 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008423 0 \
8424 -s "fragmenting handshake message"
8425
8426requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8427requires_config_enabled MBEDTLS_RSA_C
8428requires_config_enabled MBEDTLS_ECDSA_C
8429requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8430run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
8431 "$O_SRV -dtls1_2 -verify 10" \
8432 "$P_CLI dtls=1 debug_level=2 \
8433 crt_file=data_files/server8_int-ca2.crt \
8434 key_file=data_files/server8.key \
8435 mtu=512 force_version=dtls1_2" \
8436 0 \
8437 -c "fragmenting handshake message" \
8438 -C "error"
8439
8440requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8441requires_config_enabled MBEDTLS_RSA_C
8442requires_config_enabled MBEDTLS_ECDSA_C
8443requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8444run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
8445 "$O_SRV -dtls1 -verify 10" \
8446 "$P_CLI dtls=1 debug_level=2 \
8447 crt_file=data_files/server8_int-ca2.crt \
8448 key_file=data_files/server8.key \
8449 mtu=512 force_version=dtls1" \
8450 0 \
8451 -c "fragmenting handshake message" \
8452 -C "error"
8453
8454requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8455requires_config_enabled MBEDTLS_RSA_C
8456requires_config_enabled MBEDTLS_ECDSA_C
8457requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8458run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
8459 "$P_SRV dtls=1 debug_level=2 \
8460 crt_file=data_files/server7_int-ca.crt \
8461 key_file=data_files/server7.key \
8462 mtu=512 force_version=dtls1_2" \
8463 "$O_CLI -dtls1_2" \
8464 0 \
8465 -s "fragmenting handshake message"
8466
8467requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8468requires_config_enabled MBEDTLS_RSA_C
8469requires_config_enabled MBEDTLS_ECDSA_C
8470requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8471run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8472 "$P_SRV dtls=1 debug_level=2 \
8473 crt_file=data_files/server7_int-ca.crt \
8474 key_file=data_files/server7.key \
8475 mtu=512 force_version=dtls1" \
8476 "$O_CLI -dtls1" \
8477 0 \
8478 -s "fragmenting handshake message"
8479
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008480# interop tests for DTLS fragmentating with unreliable connection
8481#
8482# again we just want to test that the we fragment in a way that
8483# pleases other implementations, so we don't need the peer to fragment
8484requires_gnutls_next
8485requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8486requires_config_enabled MBEDTLS_RSA_C
8487requires_config_enabled MBEDTLS_ECDSA_C
8488requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008489client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008490run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8491 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8492 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008493 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008494 crt_file=data_files/server8_int-ca2.crt \
8495 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008496 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008497 0 \
8498 -c "fragmenting handshake message" \
8499 -C "error"
8500
8501requires_gnutls_next
8502requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8503requires_config_enabled MBEDTLS_RSA_C
8504requires_config_enabled MBEDTLS_ECDSA_C
8505requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008506client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008507run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8508 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8509 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008510 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008511 crt_file=data_files/server8_int-ca2.crt \
8512 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008513 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008514 0 \
8515 -c "fragmenting handshake message" \
8516 -C "error"
8517
k-stachowiak17a38d32019-02-18 15:29:56 +01008518requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008519requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8520requires_config_enabled MBEDTLS_RSA_C
8521requires_config_enabled MBEDTLS_ECDSA_C
8522requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8523client_needs_more_time 4
8524run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8525 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8526 "$P_SRV dtls=1 debug_level=2 \
8527 crt_file=data_files/server7_int-ca.crt \
8528 key_file=data_files/server7.key \
8529 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008530 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008531 0 \
8532 -s "fragmenting handshake message"
8533
k-stachowiak17a38d32019-02-18 15:29:56 +01008534requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008535requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8536requires_config_enabled MBEDTLS_RSA_C
8537requires_config_enabled MBEDTLS_ECDSA_C
8538requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8539client_needs_more_time 4
8540run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8541 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8542 "$P_SRV dtls=1 debug_level=2 \
8543 crt_file=data_files/server7_int-ca.crt \
8544 key_file=data_files/server7.key \
8545 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008546 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008547 0 \
8548 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008549
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008550## Interop test with OpenSSL might trigger a bug in recent versions (including
8551## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008552## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008553## They should be re-enabled once a fixed version of OpenSSL is available
8554## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008555skip_next_test
8556requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8557requires_config_enabled MBEDTLS_RSA_C
8558requires_config_enabled MBEDTLS_ECDSA_C
8559requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8560client_needs_more_time 4
8561run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8562 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8563 "$O_SRV -dtls1_2 -verify 10" \
8564 "$P_CLI dtls=1 debug_level=2 \
8565 crt_file=data_files/server8_int-ca2.crt \
8566 key_file=data_files/server8.key \
8567 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8568 0 \
8569 -c "fragmenting handshake message" \
8570 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008571
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008572skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008573requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8574requires_config_enabled MBEDTLS_RSA_C
8575requires_config_enabled MBEDTLS_ECDSA_C
8576requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008577client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008578run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8579 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008580 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008581 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008582 crt_file=data_files/server8_int-ca2.crt \
8583 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008584 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008585 0 \
8586 -c "fragmenting handshake message" \
8587 -C "error"
8588
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008589skip_next_test
8590requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8591requires_config_enabled MBEDTLS_RSA_C
8592requires_config_enabled MBEDTLS_ECDSA_C
8593requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8594client_needs_more_time 4
8595run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8596 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8597 "$P_SRV dtls=1 debug_level=2 \
8598 crt_file=data_files/server7_int-ca.crt \
8599 key_file=data_files/server7.key \
8600 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8601 "$O_CLI -dtls1_2" \
8602 0 \
8603 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008604
8605# -nbio is added to prevent s_client from blocking in case of duplicated
8606# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008607skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008608requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8609requires_config_enabled MBEDTLS_RSA_C
8610requires_config_enabled MBEDTLS_ECDSA_C
8611requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008612client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008613run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8614 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008615 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008616 crt_file=data_files/server7_int-ca.crt \
8617 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008618 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008619 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008620 0 \
8621 -s "fragmenting handshake message"
8622
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008623# Tests for specific things with "unreliable" UDP connection
8624
8625not_with_valgrind # spurious resend due to timeout
8626run_test "DTLS proxy: reference" \
8627 -p "$P_PXY" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008628 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
8629 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008630 0 \
8631 -C "replayed record" \
8632 -S "replayed record" \
Hanno Beckerb2a86c32019-07-19 15:43:09 +01008633 -C "Buffer record from epoch" \
8634 -S "Buffer record from epoch" \
8635 -C "ssl_buffer_message" \
8636 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008637 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008638 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008639 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008640 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008641 -c "HTTP/1.0 200 OK"
8642
8643not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008644run_test "DTLS proxy: duplicate every packet" \
8645 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008646 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
8647 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008648 0 \
8649 -c "replayed record" \
8650 -s "replayed record" \
8651 -c "record from another epoch" \
8652 -s "record from another epoch" \
8653 -S "resend" \
8654 -s "Extra-header:" \
8655 -c "HTTP/1.0 200 OK"
8656
8657run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8658 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008659 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8660 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008661 0 \
8662 -c "replayed record" \
8663 -S "replayed record" \
8664 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008665 -s "record from another epoch" \
8666 -c "resend" \
8667 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008668 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008669 -c "HTTP/1.0 200 OK"
8670
8671run_test "DTLS proxy: multiple records in same datagram" \
8672 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008673 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8674 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008675 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008676 -c "next record in same datagram" \
8677 -s "next record in same datagram"
8678
8679run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8680 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008681 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8682 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008683 0 \
8684 -c "next record in same datagram" \
8685 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008686
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008687run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8688 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008689 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8690 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008691 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008692 -c "discarding invalid record (mac)" \
8693 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008694 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008695 -c "HTTP/1.0 200 OK" \
8696 -S "too many records with bad MAC" \
8697 -S "Verification of the message MAC failed"
8698
8699run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8700 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008701 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8702 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008703 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008704 -C "discarding invalid record (mac)" \
8705 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008706 -S "Extra-header:" \
8707 -C "HTTP/1.0 200 OK" \
8708 -s "too many records with bad MAC" \
8709 -s "Verification of the message MAC failed"
8710
8711run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8712 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008713 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8714 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008715 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008716 -c "discarding invalid record (mac)" \
8717 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008718 -s "Extra-header:" \
8719 -c "HTTP/1.0 200 OK" \
8720 -S "too many records with bad MAC" \
8721 -S "Verification of the message MAC failed"
8722
8723run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8724 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008725 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8726 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008727 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008728 -c "discarding invalid record (mac)" \
8729 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008730 -s "Extra-header:" \
8731 -c "HTTP/1.0 200 OK" \
8732 -s "too many records with bad MAC" \
8733 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008734
8735run_test "DTLS proxy: delay ChangeCipherSpec" \
8736 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008737 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8738 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008739 0 \
8740 -c "record from another epoch" \
8741 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008742 -s "Extra-header:" \
8743 -c "HTTP/1.0 200 OK"
8744
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008745# Tests for reordering support with DTLS
8746
Hanno Becker56cdfd12018-08-17 13:42:15 +01008747run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8748 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008749 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8750 hs_timeout=2500-60000" \
8751 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8752 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008753 0 \
8754 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008755 -c "Next handshake message has been buffered - load"\
8756 -S "Buffering HS message" \
8757 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008758 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008759 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008760 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008761 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008762
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008763run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8764 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008765 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8766 hs_timeout=2500-60000" \
8767 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8768 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008769 0 \
8770 -c "Buffering HS message" \
8771 -c "found fragmented DTLS handshake message"\
8772 -c "Next handshake message 1 not or only partially bufffered" \
8773 -c "Next handshake message has been buffered - load"\
8774 -S "Buffering HS message" \
8775 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008776 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008777 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008778 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008779 -S "Remember CCS message"
8780
Hanno Beckera1adcca2018-08-24 14:41:07 +01008781# The client buffers the ServerKeyExchange before receiving the fragmented
8782# Certificate message; at the time of writing, together these are aroudn 1200b
8783# in size, so that the bound below ensures that the certificate can be reassembled
8784# while keeping the ServerKeyExchange.
8785requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8786run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008787 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008788 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8789 hs_timeout=2500-60000" \
8790 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8791 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008792 0 \
8793 -c "Buffering HS message" \
8794 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008795 -C "attempt to make space by freeing buffered messages" \
8796 -S "Buffering HS message" \
8797 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008798 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008799 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008800 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008801 -S "Remember CCS message"
8802
8803# The size constraints ensure that the delayed certificate message can't
8804# be reassembled while keeping the ServerKeyExchange message, but it can
8805# when dropping it first.
8806requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8807requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8808run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8809 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008810 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8811 hs_timeout=2500-60000" \
8812 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8813 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008814 0 \
8815 -c "Buffering HS message" \
8816 -c "attempt to make space by freeing buffered future messages" \
8817 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008818 -S "Buffering HS message" \
8819 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008820 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008821 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008822 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008823 -S "Remember CCS message"
8824
Hanno Becker56cdfd12018-08-17 13:42:15 +01008825run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8826 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008827 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8828 hs_timeout=2500-60000" \
8829 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8830 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008831 0 \
8832 -C "Buffering HS message" \
8833 -C "Next handshake message has been buffered - load"\
8834 -s "Buffering HS message" \
8835 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008836 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008837 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008838 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008839 -S "Remember CCS message"
8840
8841run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8842 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008843 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8844 hs_timeout=2500-60000" \
8845 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8846 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008847 0 \
8848 -C "Buffering HS message" \
8849 -C "Next handshake message has been buffered - load"\
8850 -S "Buffering HS message" \
8851 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008852 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008853 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008854 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008855 -S "Remember CCS message"
8856
8857run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8858 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008859 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8860 hs_timeout=2500-60000" \
8861 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8862 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008863 0 \
8864 -C "Buffering HS message" \
8865 -C "Next handshake message has been buffered - load"\
8866 -S "Buffering HS message" \
8867 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008868 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008869 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008870 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008871 -s "Remember CCS message"
8872
Hanno Beckera1adcca2018-08-24 14:41:07 +01008873run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008874 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008875 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8876 hs_timeout=2500-60000" \
8877 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8878 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008879 0 \
8880 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008881 -s "Found buffered record from current epoch - load" \
8882 -c "Buffer record from epoch 1" \
8883 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008884
Hanno Beckera1adcca2018-08-24 14:41:07 +01008885# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8886# from the server are delayed, so that the encrypted Finished message
8887# is received and buffered. When the fragmented NewSessionTicket comes
8888# in afterwards, the encrypted Finished message must be freed in order
8889# to make space for the NewSessionTicket to be reassembled.
8890# This works only in very particular circumstances:
8891# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8892# of the NewSessionTicket, but small enough to also allow buffering of
8893# the encrypted Finished message.
8894# - The MTU setting on the server must be so small that the NewSessionTicket
8895# needs to be fragmented.
8896# - All messages sent by the server must be small enough to be either sent
8897# without fragmentation or be reassembled within the bounds of
8898# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8899# handshake, omitting CRTs.
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02008900requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8901requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008902run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8903 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02008904 "$P_SRV mtu=140 response_size=90 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008905 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8906 0 \
8907 -s "Buffer record from epoch 1" \
8908 -s "Found buffered record from current epoch - load" \
8909 -c "Buffer record from epoch 1" \
8910 -C "Found buffered record from current epoch - load" \
8911 -c "Enough space available after freeing future epoch record"
8912
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008913# Tests for "randomly unreliable connection": try a variety of flows and peers
8914
8915client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008916run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8917 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008918 "$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 +02008919 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008920 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008921 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8922 0 \
8923 -s "Extra-header:" \
8924 -c "HTTP/1.0 200 OK"
8925
Janos Follath74537a62016-09-02 13:45:28 +01008926client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008927run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8928 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008929 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8930 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008931 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8932 0 \
8933 -s "Extra-header:" \
8934 -c "HTTP/1.0 200 OK"
8935
Janos Follath74537a62016-09-02 13:45:28 +01008936client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008937run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8938 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008939 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8940 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008941 0 \
8942 -s "Extra-header:" \
8943 -c "HTTP/1.0 200 OK"
8944
Janos Follath74537a62016-09-02 13:45:28 +01008945client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008946run_test "DTLS proxy: 3d, FS, client auth" \
8947 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008948 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8949 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008950 0 \
8951 -s "Extra-header:" \
8952 -c "HTTP/1.0 200 OK"
8953
Janos Follath74537a62016-09-02 13:45:28 +01008954client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008955run_test "DTLS proxy: 3d, FS, ticket" \
8956 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008957 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8958 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008959 0 \
8960 -s "Extra-header:" \
8961 -c "HTTP/1.0 200 OK"
8962
Janos Follath74537a62016-09-02 13:45:28 +01008963client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008964run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8965 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008966 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8967 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008968 0 \
8969 -s "Extra-header:" \
8970 -c "HTTP/1.0 200 OK"
8971
Janos Follath74537a62016-09-02 13:45:28 +01008972client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008973run_test "DTLS proxy: 3d, max handshake, nbio" \
8974 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008975 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008976 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008977 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008978 0 \
8979 -s "Extra-header:" \
8980 -c "HTTP/1.0 200 OK"
8981
Janos Follath74537a62016-09-02 13:45:28 +01008982client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008983run_test "DTLS proxy: 3d, min handshake, resumption" \
8984 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008985 "$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 +02008986 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008987 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01008988 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008989 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8990 0 \
8991 -s "a session has been resumed" \
8992 -c "a session has been resumed" \
8993 -s "Extra-header:" \
8994 -c "HTTP/1.0 200 OK"
8995
Janos Follath74537a62016-09-02 13:45:28 +01008996client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008997run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8998 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008999 "$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 +02009000 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009001 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01009002 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02009003 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
9004 0 \
9005 -s "a session has been resumed" \
9006 -c "a session has been resumed" \
9007 -s "Extra-header:" \
9008 -c "HTTP/1.0 200 OK"
9009
Janos Follath74537a62016-09-02 13:45:28 +01009010client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009011requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009012run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02009013 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009014 "$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 +02009015 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009016 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009017 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02009018 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9019 0 \
9020 -c "=> renegotiate" \
9021 -s "=> renegotiate" \
9022 -s "Extra-header:" \
9023 -c "HTTP/1.0 200 OK"
9024
Janos Follath74537a62016-09-02 13:45:28 +01009025client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009026requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009027run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
9028 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009029 "$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 +02009030 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009031 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009032 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009033 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9034 0 \
9035 -c "=> renegotiate" \
9036 -s "=> renegotiate" \
9037 -s "Extra-header:" \
9038 -c "HTTP/1.0 200 OK"
9039
Janos Follath74537a62016-09-02 13:45:28 +01009040client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009041requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009042run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009043 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009044 "$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 +02009045 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009046 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009047 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009048 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009049 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9050 0 \
9051 -c "=> renegotiate" \
9052 -s "=> renegotiate" \
9053 -s "Extra-header:" \
9054 -c "HTTP/1.0 200 OK"
9055
Janos Follath74537a62016-09-02 13:45:28 +01009056client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009057requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009058run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009059 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009060 "$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 +02009061 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009062 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009063 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009064 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009065 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9066 0 \
9067 -c "=> renegotiate" \
9068 -s "=> renegotiate" \
9069 -s "Extra-header:" \
9070 -c "HTTP/1.0 200 OK"
9071
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009072## Interop tests with OpenSSL might trigger a bug in recent versions (including
9073## all versions installed on the CI machines), reported here:
9074## Bug report: https://github.com/openssl/openssl/issues/6902
9075## They should be re-enabled once a fixed version of OpenSSL is available
9076## (this should happen in some 1.1.1_ release according to the ticket).
9077skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01009078client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009079not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009080run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009081 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9082 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009083 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009084 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009085 -c "HTTP/1.0 200 OK"
9086
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009087skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01009088client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009089not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009090run_test "DTLS proxy: 3d, openssl server, fragmentation" \
9091 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9092 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009093 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009094 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009095 -c "HTTP/1.0 200 OK"
9096
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009097skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01009098client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009099not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009100run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
9101 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9102 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009103 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009104 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009105 -c "HTTP/1.0 200 OK"
9106
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00009107requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01009108client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009109not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009110run_test "DTLS proxy: 3d, gnutls server" \
9111 -p "$P_PXY drop=5 delay=5 duplicate=5" \
9112 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009113 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009114 0 \
9115 -s "Extra-header:" \
9116 -c "Extra-header:"
9117
k-stachowiak17a38d32019-02-18 15:29:56 +01009118requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01009119client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009120not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009121run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
9122 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01009123 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009124 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009125 0 \
9126 -s "Extra-header:" \
9127 -c "Extra-header:"
9128
k-stachowiak17a38d32019-02-18 15:29:56 +01009129requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01009130client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009131not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009132run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
9133 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01009134 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009135 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009136 0 \
9137 -s "Extra-header:" \
9138 -c "Extra-header:"
9139
Ron Eldorf75e2522019-05-14 20:38:49 +03009140requires_config_enabled MBEDTLS_SSL_EXPORT_KEYS
9141run_test "export keys functionality" \
9142 "$P_SRV eap_tls=1 debug_level=3" \
9143 "$P_CLI eap_tls=1 debug_level=3" \
9144 0 \
9145 -s "exported maclen is " \
9146 -s "exported keylen is " \
9147 -s "exported ivlen is " \
9148 -c "exported maclen is " \
9149 -c "exported keylen is " \
9150 -c "exported ivlen is "
9151
Piotr Nowicki0937ed22019-11-26 16:32:40 +01009152# Test heap memory usage after handshake
9153requires_config_enabled MBEDTLS_MEMORY_DEBUG
9154requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C
9155requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
9156run_tests_memory_after_hanshake
9157
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01009158# Final report
9159
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009160echo "------------------------------------------------------------------------"
9161
9162if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01009163 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009164else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01009165 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009166fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02009167PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02009168echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009169
9170exit $FAILS