blob: 38bfed728764c2b8c2cb95a4597af775318d047a [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 Ameroa258ccd2019-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
Angus Grattonc4dd0732018-04-11 16:28:39 +100028if cd $( dirname $0 ); then :; else
29 echo "cd $( dirname $0 ) failed" >&2
30 exit 1
31fi
32
Antonin Décimod5f47592019-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
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020042O_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 +010043O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020044G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010045G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020046TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010047
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020048# alternative versions of OpenSSL and GnuTLS (no default path)
49
50if [ -n "${OPENSSL_LEGACY:-}" ]; then
51 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
52 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
53else
54 O_LEGACY_SRV=false
55 O_LEGACY_CLI=false
56fi
57
Hanno Becker58e9dc32018-08-17 15:53:21 +010058if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020059 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
60else
61 G_NEXT_SRV=false
62fi
63
Hanno Becker58e9dc32018-08-17 15:53:21 +010064if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020065 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
66else
67 G_NEXT_CLI=false
68fi
69
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010070TESTS=0
71FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020072SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010073
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000074CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020075
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010076MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020078EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010079
Paul Bakkere20310a2016-05-10 11:18:17 +010080SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010081RUN_TEST_NUMBER=''
82
Paul Bakkeracaac852016-05-10 11:47:13 +010083PRESERVE_LOGS=0
84
Gilles Peskinef93c7d32017-04-14 17:55:28 +020085# Pick a "unique" server port in the range 10000-19999, and a proxy
86# port which is this plus 10000. Each port number may be independently
87# overridden by a command line option.
88SRV_PORT=$(($$ % 10000 + 10000))
89PXY_PORT=$((SRV_PORT + 10000))
90
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010091print_usage() {
92 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010093 printf " -h|--help\tPrint this help.\n"
94 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
96 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010097 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010098 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010099 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200100 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
101 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100102 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100103}
104
105get_options() {
106 while [ $# -gt 0 ]; do
107 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100108 -f|--filter)
109 shift; FILTER=$1
110 ;;
111 -e|--exclude)
112 shift; EXCLUDE=$1
113 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100114 -m|--memcheck)
115 MEMCHECK=1
116 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100117 -n|--number)
118 shift; RUN_TEST_NUMBER=$1
119 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100120 -s|--show-numbers)
121 SHOW_TEST_NUMBER=1
122 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100123 -p|--preserve-logs)
124 PRESERVE_LOGS=1
125 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200126 --port)
127 shift; SRV_PORT=$1
128 ;;
129 --proxy-port)
130 shift; PXY_PORT=$1
131 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100132 --seed)
133 shift; SEED="$1"
134 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100135 -h|--help)
136 print_usage
137 exit 0
138 ;;
139 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200140 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100141 print_usage
142 exit 1
143 ;;
144 esac
145 shift
146 done
147}
148
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100149# Skip next test; use this macro to skip tests which are legitimate
150# in theory and expected to be re-introduced at some point, but
151# aren't expected to succeed at the moment due to problems outside
152# our control (such as bugs in other TLS implementations).
153skip_next_test() {
154 SKIP_NEXT="YES"
155}
156
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100157# skip next test if the flag is not enabled in config.h
158requires_config_enabled() {
159 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
160 SKIP_NEXT="YES"
161 fi
162}
163
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200164# skip next test if the flag is enabled in config.h
165requires_config_disabled() {
166 if grep "^#define $1" $CONFIG_H > /dev/null; then
167 SKIP_NEXT="YES"
168 fi
169}
170
Hanno Becker91900362019-07-03 13:22:59 +0100171requires_ciphersuite_enabled() {
172 if [ -z "$($P_CLI --help | grep "$1")" ]; then
173 SKIP_NEXT="YES"
174 fi
175}
176
Hanno Becker7c48dd12018-08-28 16:09:22 +0100177get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100178 # This function uses the query_config command line option to query the
179 # required Mbed TLS compile time configuration from the ssl_server2
180 # program. The command will always return a success value if the
181 # configuration is defined and the value will be printed to stdout.
182 #
183 # Note that if the configuration is not defined or is defined to nothing,
184 # the output of this function will be an empty string.
185 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100186}
187
188requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100189 VAL="$( get_config_value_or_default "$1" )"
190 if [ -z "$VAL" ]; then
191 # Should never happen
192 echo "Mbed TLS configuration $1 is not defined"
193 exit 1
194 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100195 SKIP_NEXT="YES"
196 fi
197}
198
199requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100200 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100201 if [ -z "$VAL" ]; then
202 # Should never happen
203 echo "Mbed TLS configuration $1 is not defined"
204 exit 1
205 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100206 SKIP_NEXT="YES"
207 fi
208}
209
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200210# skip next test if OpenSSL doesn't support FALLBACK_SCSV
211requires_openssl_with_fallback_scsv() {
212 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
213 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
214 then
215 OPENSSL_HAS_FBSCSV="YES"
216 else
217 OPENSSL_HAS_FBSCSV="NO"
218 fi
219 fi
220 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
221 SKIP_NEXT="YES"
222 fi
223}
224
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200225# skip next test if GnuTLS isn't available
226requires_gnutls() {
227 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200228 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200229 GNUTLS_AVAILABLE="YES"
230 else
231 GNUTLS_AVAILABLE="NO"
232 fi
233 fi
234 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
235 SKIP_NEXT="YES"
236 fi
237}
238
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200239# skip next test if GnuTLS-next isn't available
240requires_gnutls_next() {
241 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
242 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
243 GNUTLS_NEXT_AVAILABLE="YES"
244 else
245 GNUTLS_NEXT_AVAILABLE="NO"
246 fi
247 fi
248 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
249 SKIP_NEXT="YES"
250 fi
251}
252
253# skip next test if OpenSSL-legacy isn't available
254requires_openssl_legacy() {
255 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
256 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
257 OPENSSL_LEGACY_AVAILABLE="YES"
258 else
259 OPENSSL_LEGACY_AVAILABLE="NO"
260 fi
261 fi
262 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
263 SKIP_NEXT="YES"
264 fi
265}
266
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200267# skip next test if IPv6 isn't available on this host
268requires_ipv6() {
269 if [ -z "${HAS_IPV6:-}" ]; then
270 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
271 SRV_PID=$!
272 sleep 1
273 kill $SRV_PID >/dev/null 2>&1
274 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
275 HAS_IPV6="NO"
276 else
277 HAS_IPV6="YES"
278 fi
279 rm -r $SRV_OUT
280 fi
281
282 if [ "$HAS_IPV6" = "NO" ]; then
283 SKIP_NEXT="YES"
284 fi
285}
286
Andrzej Kurekb4593462018-10-11 08:43:30 -0400287# skip next test if it's i686 or uname is not available
288requires_not_i686() {
289 if [ -z "${IS_I686:-}" ]; then
290 IS_I686="YES"
291 if which "uname" >/dev/null 2>&1; then
292 if [ -z "$(uname -a | grep i686)" ]; then
293 IS_I686="NO"
294 fi
295 fi
296 fi
297 if [ "$IS_I686" = "YES" ]; then
298 SKIP_NEXT="YES"
299 fi
300}
301
Angus Grattonc4dd0732018-04-11 16:28:39 +1000302# Calculate the input & output maximum content lengths set in the config
303MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
304MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
305MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
306
307if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
308 MAX_CONTENT_LEN="$MAX_IN_LEN"
309fi
310if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
311 MAX_CONTENT_LEN="$MAX_OUT_LEN"
312fi
313
314# skip the next test if the SSL output buffer is less than 16KB
315requires_full_size_output_buffer() {
316 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
317 SKIP_NEXT="YES"
318 fi
319}
320
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200321# skip the next test if valgrind is in use
322not_with_valgrind() {
323 if [ "$MEMCHECK" -gt 0 ]; then
324 SKIP_NEXT="YES"
325 fi
326}
327
Paul Bakker362689d2016-05-13 10:33:25 +0100328# skip the next test if valgrind is NOT in use
329only_with_valgrind() {
330 if [ "$MEMCHECK" -eq 0 ]; then
331 SKIP_NEXT="YES"
332 fi
333}
334
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200335# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100336client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200337 CLI_DELAY_FACTOR=$1
338}
339
Janos Follath74537a62016-09-02 13:45:28 +0100340# wait for the given seconds after the client finished in the next test
341server_needs_more_time() {
342 SRV_DELAY_SECONDS=$1
343}
344
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100345# print_name <name>
346print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100347 TESTS=$(( $TESTS + 1 ))
348 LINE=""
349
350 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
351 LINE="$TESTS "
352 fi
353
354 LINE="$LINE$1"
355 printf "$LINE "
356 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100357 for i in `seq 1 $LEN`; do printf '.'; done
358 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100359
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100360}
361
362# fail <message>
363fail() {
364 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100365 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100366
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200367 mv $SRV_OUT o-srv-${TESTS}.log
368 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200369 if [ -n "$PXY_CMD" ]; then
370 mv $PXY_OUT o-pxy-${TESTS}.log
371 fi
372 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100373
Azim Khan19d13732018-03-29 11:04:20 +0100374 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 +0200375 echo " ! server output:"
376 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200377 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200378 echo " ! client output:"
379 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200380 if [ -n "$PXY_CMD" ]; then
381 echo " ! ========================================================"
382 echo " ! proxy output:"
383 cat o-pxy-${TESTS}.log
384 fi
385 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200386 fi
387
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200388 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100389}
390
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100391# is_polar <cmd_line>
392is_polar() {
393 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
394}
395
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200396# openssl s_server doesn't have -www with DTLS
397check_osrv_dtls() {
398 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
399 NEEDS_INPUT=1
400 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
401 else
402 NEEDS_INPUT=0
403 fi
404}
405
406# provide input to commands that need it
407provide_input() {
408 if [ $NEEDS_INPUT -eq 0 ]; then
409 return
410 fi
411
412 while true; do
413 echo "HTTP/1.0 200 OK"
414 sleep 1
415 done
416}
417
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100418# has_mem_err <log_file_name>
419has_mem_err() {
420 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
421 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
422 then
423 return 1 # false: does not have errors
424 else
425 return 0 # true: has errors
426 fi
427}
428
Gilles Peskine418b5362017-12-14 18:58:42 +0100429# Wait for process $2 to be listening on port $1
430if type lsof >/dev/null 2>/dev/null; then
431 wait_server_start() {
432 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200433 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100434 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200435 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100436 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200437 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100438 # Make a tight loop, server normally takes less than 1s to start.
439 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
440 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
441 echo "SERVERSTART TIMEOUT"
442 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
443 break
444 fi
445 # Linux and *BSD support decimal arguments to sleep. On other
446 # OSes this may be a tight loop.
447 sleep 0.1 2>/dev/null || true
448 done
449 }
450else
Gilles Peskinea9312652018-06-29 15:48:13 +0200451 echo "Warning: lsof not available, wait_server_start = sleep"
Gilles Peskine418b5362017-12-14 18:58:42 +0100452 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200453 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100454 }
455fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200456
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100457# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100458# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100459# acceptable bounds
460check_server_hello_time() {
461 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100462 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100463 # Get the Unix timestamp for now
464 CUR_TIME=$(date +'%s')
465 THRESHOLD_IN_SECS=300
466
467 # Check if the ServerHello time was printed
468 if [ -z "$SERVER_HELLO_TIME" ]; then
469 return 1
470 fi
471
472 # Check the time in ServerHello is within acceptable bounds
473 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
474 # The time in ServerHello is at least 5 minutes before now
475 return 1
476 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100477 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100478 return 1
479 else
480 return 0
481 fi
482}
483
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200484# wait for client to terminate and set CLI_EXIT
485# must be called right after starting the client
486wait_client_done() {
487 CLI_PID=$!
488
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200489 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
490 CLI_DELAY_FACTOR=1
491
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200492 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200493 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200494
495 wait $CLI_PID
496 CLI_EXIT=$?
497
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200498 kill $DOG_PID >/dev/null 2>&1
499 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200500
501 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100502
503 sleep $SRV_DELAY_SECONDS
504 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200505}
506
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200507# check if the given command uses dtls and sets global variable DTLS
508detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200509 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200510 DTLS=1
511 else
512 DTLS=0
513 fi
514}
515
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100516# Strip off a particular parameter from the command line
517# and return its value.
518# Parameter 1: Command line parameter to strip off
519# ENV I/O: CMD command line to search and modify
520extract_cmdline_argument() {
521 __ARG=$(echo "$CMD" | sed -n "s/^.* $1=\([^ ]*\).*$/\1/p")
522 CMD=$(echo "$CMD" | sed "s/$1=\([^ ]*\)//")
523}
524
525# Check compatibility of the ssl_client2/ssl_server2 command-line
526# with a particular compile-time configurable option.
527# Parameter 1: Command-line argument (e.g. extended_ms)
528# Parameter 2: Corresponding compile-time configuration
529# (e.g. MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET)
530# ENV I/O: CMD command line to search and modify
531# SKIP_NEXT set to "YES" on a mismatch
532check_cmdline_param_compat() {
533 __VAL="$( get_config_value_or_default "$2" )"
534 if [ ! -z "$__VAL" ]; then
535 extract_cmdline_argument "$1"
536 if [ ! -z "$__ARG" ] && [ "$__ARG" != "$__VAL" ]; then
537 SKIP_NEXT="YES"
538 fi
539 fi
540}
541
Hanno Beckera43f85c2019-09-05 14:51:20 +0100542check_cmdline_check_tls_dtls() {
Hanno Becker73b72d12019-07-26 12:00:38 +0100543 detect_dtls "$CMD"
544 if [ "$DTLS" = "0" ]; then
545 requires_config_disabled MBEDTLS_SSL_PROTO_NO_TLS
Hanno Beckera43f85c2019-09-05 14:51:20 +0100546 elif [ "$DTLS" = "1" ]; then
547 requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Hanno Becker73b72d12019-07-26 12:00:38 +0100548 fi
549}
550
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100551check_cmdline_authmode_compat() {
552 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_AUTHMODE" )"
553 if [ ! -z "$__VAL" ]; then
554 extract_cmdline_argument "auth_mode"
555 if [ "$__ARG" = "none" ] && [ "$__VAL" != "0" ]; then
556 SKIP_NEXT="YES";
557 elif [ "$__ARG" = "optional" ] && [ "$__VAL" != "1" ]; then
558 SKIP_NEXT="YES"
559 elif [ "$__ARG" = "required" ] && [ "$__VAL" != "2" ]; then
560 SKIP_NEXT="YES"
561 fi
562 fi
563}
564
Hanno Beckerb0b2b672019-06-12 16:58:10 +0100565check_cmdline_legacy_renego_compat() {
566 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_ALLOW_LEGACY_RENEGOTIATION" )"
567 if [ ! -z "$__VAL" ]; then
568 extract_cmdline_argument "allow_legacy"
569 if [ "$__ARG" = "-1" ] && [ "$__VAL" != "2" ]; then
570 SKIP_NEXT="YES";
571 elif [ "$__ARG" = "0" ] && [ "$__VAL" != "0" ]; then
572 SKIP_NEXT="YES"
573 elif [ "$__ARG" = "1" ] && [ "$__VAL" != "1" ]; then
574 SKIP_NEXT="YES"
575 fi
576 fi
577}
578
Hanno Beckerd82a0302019-07-05 11:40:52 +0100579check_cmdline_min_minor_version_compat() {
580 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MIN_MINOR_VER" )"
581 if [ ! -z "$__VAL" ]; then
582 extract_cmdline_argument "min_version"
583 if [ "$__ARG" = "ssl3" ] && [ "$__VAL" != "0" ]; then
584 SKIP_NEXT="YES";
585 elif [ "$__ARG" = "tls1" ] && [ "$__VAL" != "1" ]; then
586 SKIP_NEXT="YES"
587 elif [ "$__ARG" = "tls1_1" ] && [ "$__VAL" != "2" ]; then
588 SKIP_NEXT="YES"
589 elif [ "$__ARG" = "tls1_2" ] && [ "$__VAL" != "3" ]; then
590 SKIP_NEXT="YES"
591 fi
592 fi
593}
594
595check_cmdline_max_minor_version_compat() {
596 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MAX_MINOR_VER" )"
597 if [ ! -z "$__VAL" ]; then
598 extract_cmdline_argument "max_version"
599 if [ "$__ARG" = "ssl3" ] && [ "$__VAL" != "0" ]; then
600 SKIP_NEXT="YES";
601 elif [ "$__ARG" = "tls1" ] && [ "$__VAL" != "1" ]; then
602 SKIP_NEXT="YES"
603 elif [ "$__ARG" = "tls1_1" ] && [ "$__VAL" != "2" ]; then
604 SKIP_NEXT="YES"
605 elif [ "$__ARG" = "tls1_2" ] && [ "$__VAL" != "3" ]; then
606 SKIP_NEXT="YES"
607 fi
608 fi
609}
610
611check_cmdline_force_version_compat() {
612 __VAL_MAX="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MAX_MINOR_VER" )"
613 __VAL_MIN="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MIN_MINOR_VER" )"
614 if [ ! -z "$__VAL_MIN" ]; then
615
616 # SSL cli/srv cmd line
617
618 extract_cmdline_argument "force_version"
619 if [ "$__ARG" = "ssl3" ] && \
620 ( [ "$__VAL_MIN" != "0" ] || [ "$__VAL_MAX" != "0" ] ); then
621 SKIP_NEXT="YES";
622 elif [ "$__ARG" = "tls1" ] && \
623 ( [ "$__VAL_MIN" != "1" ] || [ "$__VAL_MAX" != "1" ] ); then
624 SKIP_NEXT="YES"
625 elif ( [ "$__ARG" = "tls1_1" ] || [ "$__ARG" = "dtls1" ] ) && \
626 ( [ "$__VAL_MIN" != "2" ] || [ "$__VAL_MAX" != "2" ] ); then
627 SKIP_NEXT="YES"
628 elif ( [ "$__ARG" = "tls1_2" ] || [ "$__ARG" = "dtls1_2" ] ) && \
629 ( [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ] ); then
630 echo "FORCE SKIP"
631 SKIP_NEXT="YES"
632 fi
633
634 # OpenSSL cmd line
635
636 if echo "$CMD" | grep -e "-tls1\($\|[^_]\)" > /dev/null; then
637 if [ "$__VAL_MIN" != "1" ] || [ "$__VAL_MAX" != "1" ]; then
638 SKIP_NEXT="YES"
639 fi
640 fi
641
642 if echo "$CMD" | grep -e "-\(dtls1\($\|[^_]\)\|tls1_1\)" > /dev/null; then
643 if [ "$__VAL_MIN" != "2" ] || [ "$__VAL_MAX" != "2" ]; then
644 SKIP_NEXT="YES"
645 fi
646 fi
647
648 if echo "$CMD" | grep -e "-\(dtls1_2\($\|[^_]\)\|tls1_2\)" > /dev/null; then
649 if [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ]; then
650 SKIP_NEXT="YES"
651 fi
652 fi
653
654 fi
655}
656
Hanno Becker69c6cde2019-09-02 14:34:23 +0100657check_cmdline_crt_key_files_compat() {
658
659 # test-ca2.crt
660 if echo "$CMD" | grep -e "test-ca2" > /dev/null; then
661 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
662 fi
663
664 # Variants of server5.key and server5.crt
665 if echo "$CMD" | grep -e "server5" > /dev/null; then
666 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
667 fi
668
669 # Variants of server6.key and server6.crt
670 if echo "$CMD" | grep -e "server6" > /dev/null; then
671 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
672 fi
673
674}
675
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100676# Go through all options that can be hardcoded at compile-time and
677# detect whether the command line configures them in a conflicting
678# way. If so, skip the test. Otherwise, remove the corresponding
679# entry.
680# Parameter 1: Command line to inspect
681# Output: Modified command line
682# ENV I/O: SKIP_TEST set to 1 on mismatch.
683check_cmdline_compat() {
684 CMD="$1"
685
Hanno Becker69c6cde2019-09-02 14:34:23 +0100686 # Check that if we're specifying particular certificate and/or
687 # ECC key files, the corresponding curve is enabled.
688 check_cmdline_crt_key_files_compat
689
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100690 # ExtendedMasterSecret configuration
691 check_cmdline_param_compat "extended_ms" \
692 "MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET"
693 check_cmdline_param_compat "enforce_extended_master_secret" \
694 "MBEDTLS_SSL_CONF_ENFORCE_EXTENDED_MASTER_SECRET"
Hanno Becker7f376f42019-06-12 16:20:48 +0100695
696 # DTLS anti replay protection configuration
697 check_cmdline_param_compat "anti_replay" \
698 "MBEDTLS_SSL_CONF_ANTI_REPLAY"
699
Hanno Beckerde671542019-06-12 16:30:46 +0100700 # DTLS bad MAC limit
701 check_cmdline_param_compat "badmac_limit" \
702 "MBEDTLS_SSL_CONF_BADMAC_LIMIT"
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100703
Hanno Beckera43f85c2019-09-05 14:51:20 +0100704 # Skip tests relying on TLS/DTLS in configs that disable it.
705 check_cmdline_check_tls_dtls
Hanno Becker73b72d12019-07-26 12:00:38 +0100706
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100707 # Authentication mode
708 check_cmdline_authmode_compat
Hanno Beckerb0b2b672019-06-12 16:58:10 +0100709
710 # Legacy renegotiation
711 check_cmdline_legacy_renego_compat
Hanno Beckerd82a0302019-07-05 11:40:52 +0100712
713 # Version configuration
714 check_cmdline_min_minor_version_compat
715 check_cmdline_max_minor_version_compat
716 check_cmdline_force_version_compat
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100717}
718
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200719# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100720# Options: -s pattern pattern that must be present in server output
721# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100722# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100723# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100724# -S pattern pattern that must be absent in server output
725# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100726# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100727# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100728run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100729 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200730 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100731
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100732 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
733 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200734 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100735 return
736 fi
737
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100738 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100739
Paul Bakkerb7584a52016-05-10 10:50:43 +0100740 # Do we only run numbered tests?
741 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
742 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
743 else
744 SKIP_NEXT="YES"
745 fi
746
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200747 # does this test use a proxy?
748 if [ "X$1" = "X-p" ]; then
749 PXY_CMD="$2"
750 shift 2
751 else
752 PXY_CMD=""
753 fi
754
755 # get commands and client output
756 SRV_CMD="$1"
757 CLI_CMD="$2"
758 CLI_EXPECT="$3"
759 shift 3
760
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100761 check_cmdline_compat "$SRV_CMD"
762 SRV_CMD="$CMD"
763
764 check_cmdline_compat "$CLI_CMD"
765 CLI_CMD="$CMD"
766
Hanno Becker7a11e722019-05-10 14:38:42 +0100767 # Check if test uses files
768 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
769 if [ ! -z "$TEST_USES_FILES" ]; then
770 requires_config_enabled MBEDTLS_FS_IO
771 fi
772
773 # should we skip?
774 if [ "X$SKIP_NEXT" = "XYES" ]; then
775 SKIP_NEXT="NO"
776 echo "SKIP"
777 SKIPS=$(( $SKIPS + 1 ))
778 return
779 fi
780
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200781 # fix client port
782 if [ -n "$PXY_CMD" ]; then
783 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
784 else
785 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
786 fi
787
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200788 # update DTLS variable
789 detect_dtls "$SRV_CMD"
790
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100791 # prepend valgrind to our commands if active
792 if [ "$MEMCHECK" -gt 0 ]; then
793 if is_polar "$SRV_CMD"; then
794 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
795 fi
796 if is_polar "$CLI_CMD"; then
797 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
798 fi
799 fi
800
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200801 TIMES_LEFT=2
802 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200803 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200804
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200805 # run the commands
806 if [ -n "$PXY_CMD" ]; then
807 echo "$PXY_CMD" > $PXY_OUT
808 $PXY_CMD >> $PXY_OUT 2>&1 &
809 PXY_PID=$!
810 # assume proxy starts faster than server
811 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200812
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200813 check_osrv_dtls
814 echo "$SRV_CMD" > $SRV_OUT
815 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
816 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100817 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200818
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200819 echo "$CLI_CMD" > $CLI_OUT
820 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
821 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100822
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100823 sleep 0.05
824
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200825 # terminate the server (and the proxy)
826 kill $SRV_PID
827 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100828
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200829 if [ -n "$PXY_CMD" ]; then
830 kill $PXY_PID >/dev/null 2>&1
831 wait $PXY_PID
832 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100833
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200834 # retry only on timeouts
835 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
836 printf "RETRY "
837 else
838 TIMES_LEFT=0
839 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200840 done
841
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100842 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200843 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100844 # expected client exit to incorrectly succeed in case of catastrophic
845 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100846 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200847 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100848 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100849 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100850 return
851 fi
852 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100853 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200854 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100855 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100856 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100857 return
858 fi
859 fi
860
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100861 # check server exit code
862 if [ $? != 0 ]; then
863 fail "server fail"
864 return
865 fi
866
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100867 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100868 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
869 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100870 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200871 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100872 return
873 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100874
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100875 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200876 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100877 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100878 while [ $# -gt 0 ]
879 do
880 case $1 in
881 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100882 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 +0100883 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100884 return
885 fi
886 ;;
887
888 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100889 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 +0100890 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100891 return
892 fi
893 ;;
894
895 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100896 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 +0100897 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100898 return
899 fi
900 ;;
901
902 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100903 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 +0100904 fail "pattern '$2' MUST NOT be present in the Client output"
905 return
906 fi
907 ;;
908
909 # The filtering in the following two options (-u and -U) do the following
910 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100911 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100912 # - keep one of each non-unique line
913 # - count how many lines remain
914 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
915 # if there were no duplicates.
916 "-U")
917 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
918 fail "lines following pattern '$2' must be unique in Server output"
919 return
920 fi
921 ;;
922
923 "-u")
924 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
925 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100926 return
927 fi
928 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100929 "-F")
930 if ! $2 "$SRV_OUT"; then
931 fail "function call to '$2' failed on Server output"
932 return
933 fi
934 ;;
935 "-f")
936 if ! $2 "$CLI_OUT"; then
937 fail "function call to '$2' failed on Client output"
938 return
939 fi
940 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100941
942 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200943 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100944 exit 1
945 esac
946 shift 2
947 done
948
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100949 # check valgrind's results
950 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200951 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100952 fail "Server has memory errors"
953 return
954 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200955 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100956 fail "Client has memory errors"
957 return
958 fi
959 fi
960
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100961 # if we're here, everything is ok
962 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100963 if [ "$PRESERVE_LOGS" -gt 0 ]; then
964 mv $SRV_OUT o-srv-${TESTS}.log
965 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100966 if [ -n "$PXY_CMD" ]; then
967 mv $PXY_OUT o-pxy-${TESTS}.log
968 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100969 fi
970
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200971 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100972}
973
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100974cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200975 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200976 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
977 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
978 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
979 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100980 exit 1
981}
982
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100983#
984# MAIN
985#
986
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100987get_options "$@"
988
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100989# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100990P_SRV_BIN="${P_SRV%%[ ]*}"
991P_CLI_BIN="${P_CLI%%[ ]*}"
992P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100993if [ ! -x "$P_SRV_BIN" ]; then
994 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100995 exit 1
996fi
Hanno Becker17c04932017-10-10 14:44:53 +0100997if [ ! -x "$P_CLI_BIN" ]; then
998 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100999 exit 1
1000fi
Hanno Becker17c04932017-10-10 14:44:53 +01001001if [ ! -x "$P_PXY_BIN" ]; then
1002 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001003 exit 1
1004fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +01001005if [ "$MEMCHECK" -gt 0 ]; then
1006 if which valgrind >/dev/null 2>&1; then :; else
1007 echo "Memcheck not possible. Valgrind not found"
1008 exit 1
1009 fi
1010fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001011if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1012 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001013 exit 1
1014fi
1015
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001016# used by watchdog
1017MAIN_PID="$$"
1018
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001019# We use somewhat arbitrary delays for tests:
1020# - how long do we wait for the server to start (when lsof not available)?
1021# - how long do we allow for the client to finish?
1022# (not to check performance, just to avoid waiting indefinitely)
1023# Things are slower with valgrind, so give extra time here.
1024#
1025# Note: without lsof, there is a trade-off between the running time of this
1026# script and the risk of spurious errors because we didn't wait long enough.
1027# The watchdog delay on the other hand doesn't affect normal running time of
1028# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001029if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001030 START_DELAY=6
1031 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001032else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001033 START_DELAY=2
1034 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001035fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001036
1037# some particular tests need more time:
1038# - for the client, we multiply the usual watchdog limit by a factor
1039# - for the server, we sleep for a number of seconds after the client exits
1040# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001041CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001042SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001043
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001044# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001045# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001046P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1047P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001048P_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 +02001049O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001050O_CLI="$O_CLI -connect localhost:+SRV_PORT"
1051G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001052G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001053
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001054if [ -n "${OPENSSL_LEGACY:-}" ]; then
1055 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1056 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1057fi
1058
Hanno Becker58e9dc32018-08-17 15:53:21 +01001059if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001060 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1061fi
1062
Hanno Becker58e9dc32018-08-17 15:53:21 +01001063if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001064 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001065fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001066
Gilles Peskine62469d92017-05-10 10:13:59 +02001067# Allow SHA-1, because many of our test certificates use it
1068P_SRV="$P_SRV allow_sha1=1"
1069P_CLI="$P_CLI allow_sha1=1"
1070
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001071# Also pick a unique name for intermediate files
1072SRV_OUT="srv_out.$$"
1073CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001074PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001075SESSION="session.$$"
1076
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001077SKIP_NEXT="NO"
1078
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001079trap cleanup INT TERM HUP
1080
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001081# Basic test
1082
Hanno Becker91900362019-07-03 13:22:59 +01001083run_test "Default" \
1084 "$P_SRV debug_level=3" \
1085 "$P_CLI" \
1086 0
1087
1088run_test "Default, DTLS" \
1089 "$P_SRV dtls=1" \
1090 "$P_CLI dtls=1" \
1091 0
1092
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001093# Checks that:
1094# - things work with all ciphersuites active (used with config-full in all.sh)
1095# - the expected (highest security) parameters are selected
1096# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Hanno Becker91900362019-07-03 13:22:59 +01001097requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1098requires_config_enabled MBEDTLS_SHA512_C
1099requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1100requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1101run_test "Default, choose highest security suite and hash" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001102 "$P_SRV debug_level=3" \
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03001103 "$P_CLI" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001104 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001105 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001106 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001107 -s "client hello v3, signature_algorithm ext: 6" \
1108 -s "ECDHE curve: secp521r1" \
1109 -S "error" \
1110 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001111
Hanno Becker91900362019-07-03 13:22:59 +01001112requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1113requires_config_enabled MBEDTLS_SHA512_C
1114requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1115requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1116run_test "Default, choose highest security suite and hash, DTLS" \
1117 "$P_SRV debug_level=3 dtls=1" \
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001118 "$P_CLI dtls=1" \
1119 0 \
1120 -s "Protocol is DTLSv1.2" \
Hanno Becker91900362019-07-03 13:22:59 +01001121 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
1122 -s "client hello v3, signature_algorithm ext: 6" \
1123 -s "ECDHE curve: secp521r1"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001124
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001125# Test current time in ServerHello
1126requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001127run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001128 "$P_SRV debug_level=3" \
1129 "$P_CLI debug_level=3" \
1130 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001131 -f "check_server_hello_time" \
1132 -F "check_server_hello_time"
1133
Simon Butcher8e004102016-10-14 00:48:33 +01001134# Test for uniqueness of IVs in AEAD ciphersuites
1135run_test "Unique IV in GCM" \
1136 "$P_SRV exchanges=20 debug_level=4" \
1137 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1138 0 \
1139 -u "IV used" \
1140 -U "IV used"
1141
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001142# Tests for rc4 option
1143
Simon Butchera410af52016-05-19 22:12:18 +01001144requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001145run_test "RC4: server disabled, client enabled" \
1146 "$P_SRV" \
1147 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1148 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001149 -s "SSL - The server has no ciphersuites in common"
1150
Simon Butchera410af52016-05-19 22:12:18 +01001151requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001152run_test "RC4: server half, client enabled" \
1153 "$P_SRV arc4=1" \
1154 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1155 1 \
1156 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001157
1158run_test "RC4: server enabled, client disabled" \
1159 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1160 "$P_CLI" \
1161 1 \
1162 -s "SSL - The server has no ciphersuites in common"
1163
1164run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001165 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001166 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1167 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001168 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001169 -S "SSL - The server has no ciphersuites in common"
1170
Hanno Beckerd26bb202018-08-17 09:54:10 +01001171# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1172
1173requires_gnutls
1174requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1175run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1176 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001177 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001178 0
1179
1180requires_gnutls
1181requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1182run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1183 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001184 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001185 0
1186
Gilles Peskinebc70a182017-05-09 15:59:24 +02001187# Tests for SHA-1 support
1188
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001189requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001190requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001191requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001192run_test "SHA-1 forbidden by default in server certificate" \
1193 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1194 "$P_CLI debug_level=2 allow_sha1=0" \
1195 1 \
1196 -c "The certificate is signed with an unacceptable hash"
1197
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001198requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1199run_test "SHA-1 forbidden by default in server certificate" \
1200 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1201 "$P_CLI debug_level=2 allow_sha1=0" \
1202 0
1203
Gilles Peskinebc70a182017-05-09 15:59:24 +02001204run_test "SHA-1 explicitly allowed in server certificate" \
1205 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1206 "$P_CLI allow_sha1=1" \
1207 0
1208
1209run_test "SHA-256 allowed by default in server certificate" \
1210 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1211 "$P_CLI allow_sha1=0" \
1212 0
1213
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001214requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001215requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001216requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001217run_test "SHA-1 forbidden by default in client certificate" \
1218 "$P_SRV auth_mode=required allow_sha1=0" \
1219 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1220 1 \
1221 -s "The certificate is signed with an unacceptable hash"
1222
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001223requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1224run_test "SHA-1 forbidden by default in client certificate" \
1225 "$P_SRV auth_mode=required allow_sha1=0" \
1226 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1227 0
1228
Gilles Peskinebc70a182017-05-09 15:59:24 +02001229run_test "SHA-1 explicitly allowed in client certificate" \
1230 "$P_SRV auth_mode=required allow_sha1=1" \
1231 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1232 0
1233
1234run_test "SHA-256 allowed by default in client certificate" \
1235 "$P_SRV auth_mode=required allow_sha1=0" \
1236 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1237 0
1238
Hanno Becker7ae8a762018-08-14 15:43:35 +01001239# Tests for datagram packing
1240run_test "DTLS: multiple records in same datagram, client and server" \
1241 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1242 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1243 0 \
1244 -c "next record in same datagram" \
1245 -s "next record in same datagram"
1246
1247run_test "DTLS: multiple records in same datagram, client only" \
1248 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1249 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1250 0 \
1251 -s "next record in same datagram" \
1252 -C "next record in same datagram"
1253
1254run_test "DTLS: multiple records in same datagram, server only" \
1255 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1256 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1257 0 \
1258 -S "next record in same datagram" \
1259 -c "next record in same datagram"
1260
1261run_test "DTLS: multiple records in same datagram, neither client nor server" \
1262 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1263 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1264 0 \
1265 -S "next record in same datagram" \
1266 -C "next record in same datagram"
1267
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001268# Tests for Truncated HMAC extension
1269
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001270run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001271 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001272 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001273 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001274 -s "dumping 'expected mac' (20 bytes)" \
1275 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001276
Hanno Becker32c55012017-11-10 08:42:54 +00001277requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001278run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001279 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001280 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001281 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001282 -s "dumping 'expected mac' (20 bytes)" \
1283 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001284
Hanno Becker32c55012017-11-10 08:42:54 +00001285requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001286run_test "Truncated HMAC: client enabled, server default" \
1287 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001288 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001289 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001290 -s "dumping 'expected mac' (20 bytes)" \
1291 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001292
Hanno Becker32c55012017-11-10 08:42:54 +00001293requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001294run_test "Truncated HMAC: client enabled, server disabled" \
1295 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001296 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001297 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001298 -s "dumping 'expected mac' (20 bytes)" \
1299 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001300
Hanno Becker32c55012017-11-10 08:42:54 +00001301requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001302run_test "Truncated HMAC: client disabled, server enabled" \
1303 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001304 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001305 0 \
1306 -s "dumping 'expected mac' (20 bytes)" \
1307 -S "dumping 'expected mac' (10 bytes)"
1308
1309requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001310run_test "Truncated HMAC: client enabled, server enabled" \
1311 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001312 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001313 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001314 -S "dumping 'expected mac' (20 bytes)" \
1315 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001316
Hanno Becker4c4f4102017-11-10 09:16:05 +00001317run_test "Truncated HMAC, DTLS: client default, server default" \
1318 "$P_SRV dtls=1 debug_level=4" \
1319 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1320 0 \
1321 -s "dumping 'expected mac' (20 bytes)" \
1322 -S "dumping 'expected mac' (10 bytes)"
1323
1324requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1325run_test "Truncated HMAC, DTLS: client disabled, server default" \
1326 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001327 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001328 0 \
1329 -s "dumping 'expected mac' (20 bytes)" \
1330 -S "dumping 'expected mac' (10 bytes)"
1331
1332requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1333run_test "Truncated HMAC, DTLS: client enabled, server default" \
1334 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001335 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001336 0 \
1337 -s "dumping 'expected mac' (20 bytes)" \
1338 -S "dumping 'expected mac' (10 bytes)"
1339
1340requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1341run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1342 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001343 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001344 0 \
1345 -s "dumping 'expected mac' (20 bytes)" \
1346 -S "dumping 'expected mac' (10 bytes)"
1347
1348requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1349run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1350 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001351 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001352 0 \
1353 -s "dumping 'expected mac' (20 bytes)" \
1354 -S "dumping 'expected mac' (10 bytes)"
1355
1356requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1357run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1358 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001359 "$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 +01001360 0 \
1361 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001362 -s "dumping 'expected mac' (10 bytes)"
1363
Jarno Lamsafa45e602019-06-04 11:33:23 +03001364# Tests for Context serialization
1365
1366requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001367run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001368 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001369 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001370 0 \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001371 -c "Deserializing connection..." \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001372 -S "Deserializing connection..."
1373
1374requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001375run_test "Context serialization, client serializes, ChaChaPoly" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001376 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001377 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001378 0 \
1379 -c "Deserializing connection..." \
1380 -S "Deserializing connection..."
1381
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001382requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001383run_test "Context serialization, client serializes, GCM" \
1384 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1385 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001386 0 \
1387 -c "Deserializing connection..." \
1388 -S "Deserializing connection..."
Jarno Lamsacc281b82019-06-04 15:21:13 +03001389
Jarno Lamsafa45e602019-06-04 11:33:23 +03001390requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001391requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1392run_test "Context serialization, client serializes, with CID" \
1393 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1394 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1395 0 \
1396 -c "Deserializing connection..." \
1397 -S "Deserializing connection..."
1398
1399requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001400run_test "Context serialization, server serializes, CCM" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001401 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001402 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001403 0 \
1404 -C "Deserializing connection..." \
1405 -s "Deserializing connection..."
1406
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001407requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001408run_test "Context serialization, server serializes, ChaChaPoly" \
1409 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1410 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1411 0 \
1412 -C "Deserializing connection..." \
1413 -s "Deserializing connection..."
1414
1415requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1416run_test "Context serialization, server serializes, GCM" \
1417 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1418 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001419 0 \
1420 -C "Deserializing connection..." \
Jarno Lamsacc281b82019-06-04 15:21:13 +03001421 -s "Deserializing connection..."
Jarno Lamsafa45e602019-06-04 11:33:23 +03001422
1423requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001424requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1425run_test "Context serialization, server serializes, with CID" \
1426 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1427 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1428 0 \
1429 -C "Deserializing connection..." \
1430 -s "Deserializing connection..."
1431
1432requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001433run_test "Context serialization, both serialize, CCM" \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001434 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001435 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1436 0 \
1437 -c "Deserializing connection..." \
1438 -s "Deserializing connection..."
1439
1440requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1441run_test "Context serialization, both serialize, ChaChaPoly" \
1442 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1443 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1444 0 \
1445 -c "Deserializing connection..." \
1446 -s "Deserializing connection..."
1447
1448requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1449run_test "Context serialization, both serialize, GCM" \
1450 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1451 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001452 0 \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001453 -c "Deserializing connection..." \
1454 -s "Deserializing connection..."
1455
1456requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001457requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1458run_test "Context serialization, both serialize, with CID" \
1459 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1460 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1461 0 \
1462 -c "Deserializing connection..." \
1463 -s "Deserializing connection..."
1464
1465requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001466run_test "Context serialization, re-init, client serializes, CCM" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001467 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001468 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1469 0 \
1470 -c "Deserializing connection..." \
1471 -S "Deserializing connection..."
1472
1473requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1474run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1475 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1476 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1477 0 \
1478 -c "Deserializing connection..." \
1479 -S "Deserializing connection..."
1480
1481requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1482run_test "Context serialization, re-init, client serializes, GCM" \
1483 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1484 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001485 0 \
1486 -c "Deserializing connection..." \
1487 -S "Deserializing connection..."
1488
1489requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001490requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1491run_test "Context serialization, re-init, client serializes, with CID" \
1492 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1493 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1494 0 \
1495 -c "Deserializing connection..." \
1496 -S "Deserializing connection..."
1497
1498requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001499run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001500 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001501 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1502 0 \
1503 -C "Deserializing connection..." \
1504 -s "Deserializing connection..."
1505
1506requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1507run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1508 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1509 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1510 0 \
1511 -C "Deserializing connection..." \
1512 -s "Deserializing connection..."
1513
1514requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1515run_test "Context serialization, re-init, server serializes, GCM" \
1516 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1517 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001518 0 \
1519 -C "Deserializing connection..." \
1520 -s "Deserializing connection..."
1521
1522requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001523requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1524run_test "Context serialization, re-init, server serializes, with CID" \
1525 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1526 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1527 0 \
1528 -C "Deserializing connection..." \
1529 -s "Deserializing connection..."
1530
1531requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001532run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001533 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001534 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1535 0 \
1536 -c "Deserializing connection..." \
1537 -s "Deserializing connection..."
1538
1539requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1540run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1541 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1542 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1543 0 \
1544 -c "Deserializing connection..." \
1545 -s "Deserializing connection..."
1546
1547requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1548run_test "Context serialization, re-init, both serialize, GCM" \
1549 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1550 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001551 0 \
1552 -c "Deserializing connection..." \
1553 -s "Deserializing connection..."
1554
Hanno Beckere80c1b02019-08-30 11:18:59 +01001555requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1556requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1557run_test "Context serialization, re-init, both serialize, with CID" \
1558 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1559 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001560 0 \
1561 -c "Deserializing connection..." \
Hanno Becker73455992019-04-25 17:01:43 +01001562 -s "Deserializing connection..."
Hanno Beckerc008cb52019-04-26 14:17:56 +01001563
Hanno Becker4eb05872019-04-26 16:00:29 +01001564# Tests for DTLS Connection ID extension
Hanno Beckercf2a5652019-04-26 16:13:31 +01001565
Hanno Becker5e2cd142019-04-26 16:23:52 +01001566# So far, the CID API isn't implemented, so we can't
1567# grep for output witnessing its use. This needs to be
Hanno Becker6a3ff282019-04-26 17:19:46 +01001568# changed once the CID extension is implemented.
Hanno Beckerad8e2c92019-05-08 13:19:53 +01001569
Hanno Becker2dcdc922019-04-09 18:08:47 +01001570requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckera5a2b082019-05-15 14:03:01 +01001571run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001572 "$P_SRV debug_level=3 dtls=1 cid=0" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001573 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1574 0 \
1575 -s "Disable use of CID extension." \
1576 -s "found CID extension" \
Hanno Becker73455992019-04-25 17:01:43 +01001577 -s "Client sent CID extension, but CID disabled" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001578 -c "Enable use of CID extension." \
1579 -c "client hello, adding CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001580 -S "server hello, adding CID extension" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001581 -C "found CID extension" \
1582 -S "Copy CIDs into SSL transform" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001583 -C "Copy CIDs into SSL transform" \
1584 -c "Use of Connection ID was rejected by the server"
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001585
1586requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1587run_test "Connection ID: Cli disabled, Srv enabled" \
1588 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1589 "$P_CLI debug_level=3 dtls=1 cid=0" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001590 0 \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001591 -c "Disable use of CID extension." \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001592 -C "client hello, adding CID extension" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001593 -S "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001594 -s "Enable use of CID extension." \
1595 -S "server hello, adding CID extension" \
1596 -C "found CID extension" \
1597 -S "Copy CIDs into SSL transform" \
1598 -C "Copy CIDs into SSL transform" \
1599 -s "Use of Connection ID was not offered by client"
1600
1601requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1602run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
1603 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1604 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1605 0 \
1606 -c "Enable use of CID extension." \
1607 -s "Enable use of CID extension." \
1608 -c "client hello, adding CID extension" \
1609 -s "found CID extension" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001610 -s "Use of CID extension negotiated" \
1611 -s "server hello, adding CID extension" \
1612 -c "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001613 -c "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001614 -s "Copy CIDs into SSL transform" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001615 -c "Copy CIDs into SSL transform" \
1616 -c "Peer CID (length 2 Bytes): de ad" \
1617 -s "Peer CID (length 2 Bytes): be ef" \
1618 -s "Use of Connection ID has been negotiated" \
1619 -c "Use of Connection ID has been negotiated"
1620
1621requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1622run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
1623 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
1624 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1625 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1626 0 \
1627 -c "Enable use of CID extension." \
1628 -s "Enable use of CID extension." \
1629 -c "client hello, adding CID extension" \
1630 -s "found CID extension" \
1631 -s "Use of CID extension negotiated" \
1632 -s "server hello, adding CID extension" \
1633 -c "found CID extension" \
1634 -c "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001635 -s "Copy CIDs into SSL transform" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001636 -c "Copy CIDs into SSL transform" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001637 -c "Peer CID (length 2 Bytes): de ad" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001638 -s "Peer CID (length 2 Bytes): be ef" \
1639 -s "Use of Connection ID has been negotiated" \
1640 -c "Use of Connection ID has been negotiated" \
1641 -c "ignoring unexpected CID" \
1642 -s "ignoring unexpected CID"
1643
1644requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1645run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1646 -p "$P_PXY mtu=800" \
1647 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1648 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1649 0 \
1650 -c "Enable use of CID extension." \
1651 -s "Enable use of CID extension." \
1652 -c "client hello, adding CID extension" \
1653 -s "found CID extension" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001654 -s "Use of CID extension negotiated" \
1655 -s "server hello, adding CID extension" \
1656 -c "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001657 -c "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001658 -s "Copy CIDs into SSL transform" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001659 -c "Copy CIDs into SSL transform" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001660 -c "Peer CID (length 2 Bytes): de ad" \
1661 -s "Peer CID (length 2 Bytes): be ef" \
1662 -s "Use of Connection ID has been negotiated" \
1663 -c "Use of Connection ID has been negotiated"
Hanno Becker73455992019-04-25 17:01:43 +01001664
Hanno Beckerc008cb52019-04-26 14:17:56 +01001665requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1666run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001667 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001668 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1669 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001670 0 \
1671 -c "Enable use of CID extension." \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001672 -s "Enable use of CID extension." \
1673 -c "client hello, adding CID extension" \
1674 -s "found CID extension" \
1675 -s "Use of CID extension negotiated" \
1676 -s "server hello, adding CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001677 -c "found CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001678 -c "Use of CID extension negotiated" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001679 -s "Copy CIDs into SSL transform" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001680 -c "Copy CIDs into SSL transform" \
1681 -c "Peer CID (length 2 Bytes): de ad" \
1682 -s "Peer CID (length 2 Bytes): be ef" \
1683 -s "Use of Connection ID has been negotiated" \
Hanno Becker73455992019-04-25 17:01:43 +01001684 -c "Use of Connection ID has been negotiated" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001685 -c "ignoring unexpected CID" \
1686 -s "ignoring unexpected CID"
Hanno Becker4eb05872019-04-26 16:00:29 +01001687
Hanno Beckercf2a5652019-04-26 16:13:31 +01001688requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1689run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001690 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1691 "$P_CLI debug_level=3 dtls=1 cid=1" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001692 0 \
1693 -c "Enable use of CID extension." \
1694 -s "Enable use of CID extension." \
1695 -c "client hello, adding CID extension" \
1696 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001697 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001698 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001699 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001700 -c "Use of CID extension negotiated" \
1701 -s "Copy CIDs into SSL transform" \
1702 -c "Copy CIDs into SSL transform" \
1703 -c "Peer CID (length 4 Bytes): de ad be ef" \
Hanno Becker73455992019-04-25 17:01:43 +01001704 -s "Peer CID (length 0 Bytes):" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001705 -s "Use of Connection ID has been negotiated" \
1706 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001707
Hanno Beckercf2a5652019-04-26 16:13:31 +01001708requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1709run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001710 "$P_SRV debug_level=3 dtls=1 cid=1" \
1711 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001712 0 \
1713 -c "Enable use of CID extension." \
1714 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001715 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001716 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001717 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001718 -s "server hello, adding CID extension" \
1719 -c "found CID extension" \
1720 -c "Use of CID extension negotiated" \
1721 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001722 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001723 -s "Peer CID (length 4 Bytes): de ad be ef" \
1724 -c "Peer CID (length 0 Bytes):" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001725 -s "Use of Connection ID has been negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001726 -c "Use of Connection ID has been negotiated"
1727
Hanno Becker5e2cd142019-04-26 16:23:52 +01001728requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1729run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001730 "$P_SRV debug_level=3 dtls=1 cid=1" \
1731 "$P_CLI debug_level=3 dtls=1 cid=1" \
1732 0 \
1733 -c "Enable use of CID extension." \
1734 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001735 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001736 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001737 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001738 -s "server hello, adding CID extension" \
1739 -c "found CID extension" \
1740 -c "Use of CID extension negotiated" \
1741 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001742 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001743 -S "Use of Connection ID has been negotiated" \
1744 -C "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001745
Hanno Beckercf2a5652019-04-26 16:13:31 +01001746requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1747run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001748 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1749 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001750 0 \
1751 -c "Enable use of CID extension." \
1752 -s "Enable use of CID extension." \
1753 -c "client hello, adding CID extension" \
1754 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001755 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001756 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001757 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001758 -c "Use of CID extension negotiated" \
1759 -s "Copy CIDs into SSL transform" \
1760 -c "Copy CIDs into SSL transform" \
1761 -c "Peer CID (length 2 Bytes): de ad" \
Hanno Becker73455992019-04-25 17:01:43 +01001762 -s "Peer CID (length 2 Bytes): be ef" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001763 -s "Use of Connection ID has been negotiated" \
1764 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001765
Hanno Beckercf2a5652019-04-26 16:13:31 +01001766requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1767run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001768 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1769 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001770 0 \
1771 -c "Enable use of CID extension." \
1772 -s "Enable use of CID extension." \
1773 -c "client hello, adding CID extension" \
1774 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001775 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001776 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001777 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001778 -c "Use of CID extension negotiated" \
1779 -s "Copy CIDs into SSL transform" \
1780 -c "Copy CIDs into SSL transform" \
1781 -c "Peer CID (length 4 Bytes): de ad be ef" \
Hanno Becker73455992019-04-25 17:01:43 +01001782 -s "Peer CID (length 0 Bytes):" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001783 -s "Use of Connection ID has been negotiated" \
1784 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001785
Hanno Beckercf2a5652019-04-26 16:13:31 +01001786requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1787run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001788 "$P_SRV debug_level=3 dtls=1 cid=1" \
1789 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001790 0 \
1791 -c "Enable use of CID extension." \
1792 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001793 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001794 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001795 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001796 -s "server hello, adding CID extension" \
1797 -c "found CID extension" \
1798 -c "Use of CID extension negotiated" \
1799 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001800 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001801 -s "Peer CID (length 4 Bytes): de ad be ef" \
1802 -c "Peer CID (length 0 Bytes):" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001803 -s "Use of Connection ID has been negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001804 -c "Use of Connection ID has been negotiated"
1805
Hanno Becker5e2cd142019-04-26 16:23:52 +01001806requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1807run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001808 "$P_SRV debug_level=3 dtls=1 cid=1" \
1809 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1810 0 \
1811 -c "Enable use of CID extension." \
1812 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001813 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001814 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001815 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001816 -s "server hello, adding CID extension" \
1817 -c "found CID extension" \
1818 -c "Use of CID extension negotiated" \
1819 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001820 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001821 -S "Use of Connection ID has been negotiated" \
1822 -C "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001823
Hanno Beckercf2a5652019-04-26 16:13:31 +01001824requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1825run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001826 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1827 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001828 0 \
1829 -c "Enable use of CID extension." \
1830 -s "Enable use of CID extension." \
1831 -c "client hello, adding CID extension" \
1832 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001833 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001834 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001835 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001836 -c "Use of CID extension negotiated" \
1837 -s "Copy CIDs into SSL transform" \
1838 -c "Copy CIDs into SSL transform" \
1839 -c "Peer CID (length 2 Bytes): de ad" \
Hanno Becker73455992019-04-25 17:01:43 +01001840 -s "Peer CID (length 2 Bytes): be ef" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001841 -s "Use of Connection ID has been negotiated" \
1842 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001843
Hanno Beckercf2a5652019-04-26 16:13:31 +01001844requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1845run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001846 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1847 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001848 0 \
1849 -c "Enable use of CID extension." \
1850 -s "Enable use of CID extension." \
1851 -c "client hello, adding CID extension" \
1852 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001853 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001854 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001855 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001856 -c "Use of CID extension negotiated" \
1857 -s "Copy CIDs into SSL transform" \
1858 -c "Copy CIDs into SSL transform" \
1859 -c "Peer CID (length 4 Bytes): de ad be ef" \
Hanno Becker73455992019-04-25 17:01:43 +01001860 -s "Peer CID (length 0 Bytes):" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001861 -s "Use of Connection ID has been negotiated" \
1862 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001863
Hanno Beckercf2a5652019-04-26 16:13:31 +01001864requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1865run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001866 "$P_SRV debug_level=3 dtls=1 cid=1" \
1867 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001868 0 \
1869 -c "Enable use of CID extension." \
1870 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001871 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001872 -s "found CID extension" \
Hanno Becker963cb352019-04-23 11:52:44 +01001873 -s "Use of CID extension negotiated" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001874 -s "server hello, adding CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001875 -c "found CID extension" \
1876 -c "Use of CID extension negotiated" \
1877 -s "Copy CIDs into SSL transform" \
Hanno Becker96870292019-05-03 17:30:59 +01001878 -c "Copy CIDs into SSL transform" \
1879 -s "Peer CID (length 4 Bytes): de ad be ef" \
1880 -c "Peer CID (length 0 Bytes):" \
1881 -s "Use of Connection ID has been negotiated" \
1882 -c "Use of Connection ID has been negotiated"
1883
1884requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1885run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
1886 "$P_SRV debug_level=3 dtls=1 cid=1" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001887 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
Hanno Becker96870292019-05-03 17:30:59 +01001888 0 \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001889 -c "Enable use of CID extension." \
Hanno Becker96870292019-05-03 17:30:59 +01001890 -s "Enable use of CID extension." \
1891 -c "client hello, adding CID extension" \
1892 -s "found CID extension" \
1893 -s "Use of CID extension negotiated" \
1894 -s "server hello, adding CID extension" \
1895 -c "found CID extension" \
1896 -c "Use of CID extension negotiated" \
1897 -s "Copy CIDs into SSL transform" \
1898 -c "Copy CIDs into SSL transform" \
1899 -S "Use of Connection ID has been negotiated" \
1900 -C "Use of Connection ID has been negotiated"
1901
Hanno Beckera5a2b082019-05-15 14:03:01 +01001902requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001903requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01001904run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
1905 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1906 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1907 0 \
1908 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1909 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1910 -s "(initial handshake) Use of Connection ID has been negotiated" \
1911 -c "(initial handshake) Use of Connection ID has been negotiated" \
1912 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1913 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1914 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1915 -c "(after renegotiation) Use of Connection ID has been negotiated"
1916
Hanno Beckera5a2b082019-05-15 14:03:01 +01001917requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01001918requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001919run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001920 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001921 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1922 0 \
1923 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1924 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1925 -s "(initial handshake) Use of Connection ID has been negotiated" \
1926 -c "(initial handshake) Use of Connection ID has been negotiated" \
1927 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1928 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1929 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1930 -c "(after renegotiation) Use of Connection ID has been negotiated"
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001931
1932requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1933requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001934run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001935 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001936 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1937 0 \
Hanno Becker96870292019-05-03 17:30:59 +01001938 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1939 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1940 -s "(initial handshake) Use of Connection ID has been negotiated" \
1941 -c "(initial handshake) Use of Connection ID has been negotiated" \
1942 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1943 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1944 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1945 -c "(after renegotiation) Use of Connection ID has been negotiated"
1946
1947requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1948requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
1949run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001950 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker96870292019-05-03 17:30:59 +01001951 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
Hanno Becker84bbc512019-05-08 16:20:46 +01001952 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1953 0 \
1954 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1955 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1956 -s "(initial handshake) Use of Connection ID has been negotiated" \
1957 -c "(initial handshake) Use of Connection ID has been negotiated" \
1958 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1959 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1960 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1961 -c "(after renegotiation) Use of Connection ID has been negotiated" \
1962 -c "ignoring unexpected CID" \
1963 -s "ignoring unexpected CID"
1964
Hanno Beckera5a2b082019-05-15 14:03:01 +01001965requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01001966requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001967run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001968 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001969 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
1970 0 \
1971 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1972 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1973 -s "(initial handshake) Use of Connection ID has been negotiated" \
1974 -c "(initial handshake) Use of Connection ID has been negotiated" \
1975 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1976 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1977 -C "(after renegotiation) Use of Connection ID has been negotiated" \
1978 -S "(after renegotiation) Use of Connection ID has been negotiated"
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001979
1980requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1981requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001982run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001983 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001984 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
1985 0 \
Hanno Becker96870292019-05-03 17:30:59 +01001986 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1987 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1988 -s "(initial handshake) Use of Connection ID has been negotiated" \
1989 -c "(initial handshake) Use of Connection ID has been negotiated" \
1990 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1991 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1992 -C "(after renegotiation) Use of Connection ID has been negotiated" \
1993 -S "(after renegotiation) Use of Connection ID has been negotiated"
1994
1995requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckera5a2b082019-05-15 14:03:01 +01001996requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker96870292019-05-03 17:30:59 +01001997run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Becker84bbc512019-05-08 16:20:46 +01001998 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
1999 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2000 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2001 0 \
2002 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2003 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2004 -s "(initial handshake) Use of Connection ID has been negotiated" \
2005 -c "(initial handshake) Use of Connection ID has been negotiated" \
2006 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2007 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2008 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01002009 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Becker84bbc512019-05-08 16:20:46 +01002010 -c "ignoring unexpected CID" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002011 -s "ignoring unexpected CID"
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002012
Hanno Becker04ca04c2019-05-08 13:31:15 +01002013requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2014requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2015run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
2016 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2017 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2018 0 \
2019 -S "(initial handshake) Use of Connection ID has been negotiated" \
2020 -C "(initial handshake) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002021 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2022 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2023 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002024 -s "(after renegotiation) Use of Connection ID has been negotiated"
Hanno Beckera5a2b082019-05-15 14:03:01 +01002025
Hanno Becker04ca04c2019-05-08 13:31:15 +01002026requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2027requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker96870292019-05-03 17:30:59 +01002028run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2029 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2030 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2031 0 \
2032 -S "(initial handshake) Use of Connection ID has been negotiated" \
2033 -C "(initial handshake) Use of Connection ID has been negotiated" \
2034 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2035 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2036 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2037 -s "(after renegotiation) Use of Connection ID has been negotiated"
2038
2039requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2040requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckera5a2b082019-05-15 14:03:01 +01002041run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002042 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002043 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002044 "$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" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002045 0 \
2046 -S "(initial handshake) Use of Connection ID has been negotiated" \
2047 -C "(initial handshake) Use of Connection ID has been negotiated" \
2048 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2049 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2050 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2051 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2052 -c "ignoring unexpected CID" \
2053 -s "ignoring unexpected CID"
2054
2055requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002056requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2057run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
2058 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002059 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01002060 0 \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002061 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2062 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2063 -s "(initial handshake) Use of Connection ID has been negotiated" \
2064 -c "(initial handshake) Use of Connection ID has been negotiated" \
2065 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2066 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2067 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2068 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2069 -s "(after renegotiation) Use of Connection ID was not offered by client"
2070
2071requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2072requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2073run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
2074 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
2075 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01002076 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002077 0 \
2078 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002079 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
Hanno Becker96870292019-05-03 17:30:59 +01002080 -s "(initial handshake) Use of Connection ID has been negotiated" \
2081 -c "(initial handshake) Use of Connection ID has been negotiated" \
2082 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2083 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2084 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2085 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2086 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2087 -c "ignoring unexpected CID" \
2088 -s "ignoring unexpected CID"
2089
2090requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002091requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2092run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2093 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01002094 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002095 0 \
2096 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2097 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002098 -s "(initial handshake) Use of Connection ID has been negotiated" \
2099 -c "(initial handshake) Use of Connection ID has been negotiated" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002100 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2101 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2102 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2103 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2104 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2105
2106requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2107requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2108run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
2109 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002110 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2111 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002112 0 \
2113 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2114 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2115 -s "(initial handshake) Use of Connection ID has been negotiated" \
2116 -c "(initial handshake) Use of Connection ID has been negotiated" \
2117 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2118 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2119 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2120 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002121 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2122 -c "ignoring unexpected CID" \
2123 -s "ignoring unexpected CID"
2124
2125# Tests for Encrypt-then-MAC extension
2126
2127run_test "Encrypt then MAC: default" \
2128 "$P_SRV debug_level=3 \
2129 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2130 "$P_CLI debug_level=3" \
2131 0 \
2132 -c "client hello, adding encrypt_then_mac extension" \
2133 -s "found encrypt then mac extension" \
2134 -s "server hello, adding encrypt then mac extension" \
2135 -c "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002136 -c "using encrypt then mac" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002137 -s "using encrypt then mac"
2138
2139run_test "Encrypt then MAC: client enabled, server disabled" \
2140 "$P_SRV debug_level=3 etm=0 \
2141 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2142 "$P_CLI debug_level=3 etm=1" \
2143 0 \
2144 -c "client hello, adding encrypt_then_mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002145 -s "found encrypt then mac extension" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002146 -S "server hello, adding encrypt then mac extension" \
2147 -C "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002148 -C "using encrypt then mac" \
2149 -S "using encrypt then mac"
2150
2151run_test "Encrypt then MAC: client enabled, aead cipher" \
2152 "$P_SRV debug_level=3 etm=1 \
2153 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2154 "$P_CLI debug_level=3 etm=1" \
2155 0 \
2156 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathe2681a42016-03-07 15:57:05 +00002157 -s "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002158 -S "server hello, adding encrypt then mac extension" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002159 -C "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002160 -C "using encrypt then mac" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002161 -S "using encrypt then mac"
2162
2163run_test "Encrypt then MAC: client enabled, stream cipher" \
2164 "$P_SRV debug_level=3 etm=1 \
2165 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2166 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2167 0 \
2168 -c "client hello, adding encrypt_then_mac extension" \
2169 -s "found encrypt then mac extension" \
Janos Follathe2681a42016-03-07 15:57:05 +00002170 -S "server hello, adding encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002171 -C "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002172 -C "using encrypt then mac" \
2173 -S "using encrypt then mac"
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002174
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002175run_test "Encrypt then MAC: client disabled, server enabled" \
2176 "$P_SRV debug_level=3 etm=1 \
Janos Follath00efff72016-05-06 13:48:23 +01002177 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002178 "$P_CLI debug_level=3 etm=0" \
2179 0 \
2180 -C "client hello, adding encrypt_then_mac extension" \
2181 -S "found encrypt then mac extension" \
2182 -S "server hello, adding encrypt then mac extension" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002183 -C "found encrypt_then_mac extension" \
2184 -C "using encrypt then mac" \
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002185 -S "using encrypt then mac"
2186
2187requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2188run_test "Encrypt then MAC: client SSLv3, server enabled" \
2189 "$P_SRV debug_level=3 min_version=ssl3 \
2190 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2191 "$P_CLI debug_level=3 force_version=ssl3" \
2192 0 \
2193 -C "client hello, adding encrypt_then_mac extension" \
2194 -S "found encrypt then mac extension" \
2195 -S "server hello, adding encrypt then mac extension" \
2196 -C "found encrypt_then_mac extension" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002197 -C "using encrypt then mac" \
2198 -S "using encrypt then mac"
2199
2200requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2201run_test "Encrypt then MAC: client enabled, server SSLv3" \
2202 "$P_SRV debug_level=3 force_version=ssl3 \
2203 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2204 "$P_CLI debug_level=3 min_version=ssl3" \
2205 0 \
2206 -c "client hello, adding encrypt_then_mac extension" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002207 -S "found encrypt then mac extension" \
2208 -S "server hello, adding encrypt then mac extension" \
2209 -C "found encrypt_then_mac extension" \
2210 -C "using encrypt then mac" \
2211 -S "using encrypt then mac"
2212
2213# Tests for Extended Master Secret extension
2214
2215run_test "Extended Master Secret: default (not enforcing)" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002216 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0 " \
2217 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01002218 0 \
2219 -c "client hello, adding extended_master_secret extension" \
2220 -s "found extended master secret extension" \
2221 -s "server hello, adding extended master secret extension" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002222 -c "found extended_master_secret extension" \
2223 -c "session hash for extended master secret" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002224 -s "session hash for extended master secret"
2225
Jarno Lamsa41b35912019-06-10 15:51:11 +03002226run_test "Extended Master Secret: both enabled, both enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002227 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2228 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002229 0 \
2230 -c "client hello, adding extended_master_secret extension" \
2231 -s "found extended master secret extension" \
2232 -s "server hello, adding extended master secret extension" \
2233 -c "found extended_master_secret extension" \
2234 -c "session hash for extended master secret" \
2235 -s "session hash for extended master secret"
2236
Jarno Lamsa20095af2019-06-11 17:16:58 +03002237run_test "Extended Master Secret: both enabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002238 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2239 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002240 0 \
2241 -c "client hello, adding extended_master_secret extension" \
2242 -s "found extended master secret extension" \
2243 -s "server hello, adding extended master secret extension" \
2244 -c "found extended_master_secret extension" \
2245 -c "session hash for extended master secret" \
2246 -s "session hash for extended master secret"
2247
2248run_test "Extended Master Secret: both enabled, server enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002249 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2250 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002251 0 \
2252 -c "client hello, adding extended_master_secret extension" \
2253 -s "found extended master secret extension" \
2254 -s "server hello, adding extended master secret extension" \
2255 -c "found extended_master_secret extension" \
2256 -c "session hash for extended master secret" \
2257 -s "session hash for extended master secret"
2258
2259run_test "Extended Master Secret: client enabled, server disabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002260 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002261 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2262 1 \
2263 -c "client hello, adding extended_master_secret extension" \
2264 -s "found extended master secret extension" \
2265 -S "server hello, adding extended master secret extension" \
2266 -C "found extended_master_secret extension" \
2267 -c "Peer not offering extended master secret, while it is enforced"
2268
Jarno Lamsa20095af2019-06-11 17:16:58 +03002269run_test "Extended Master Secret enforced: client disabled, server enabled, server enforcing" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002270 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002271 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002272 1 \
2273 -C "client hello, adding extended_master_secret extension" \
2274 -S "found extended master secret extension" \
2275 -S "server hello, adding extended master secret extension" \
2276 -C "found extended_master_secret extension" \
2277 -s "Peer not offering extended master secret, while it is enforced"
2278
Jarno Lamsa20095af2019-06-11 17:16:58 +03002279run_test "Extended Master Secret: client enabled, server disabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002280 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2281 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002282 0 \
2283 -c "client hello, adding extended_master_secret extension" \
2284 -s "found extended master secret extension" \
2285 -S "server hello, adding extended master secret extension" \
2286 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002287 -C "session hash for extended master secret" \
2288 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002289
Jarno Lamsa20095af2019-06-11 17:16:58 +03002290run_test "Extended Master Secret: client disabled, server enabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002291 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2292 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002293 0 \
2294 -C "client hello, adding extended_master_secret extension" \
2295 -S "found extended master secret extension" \
2296 -S "server hello, adding extended master secret extension" \
2297 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002298 -C "session hash for extended master secret" \
2299 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002300
Jarno Lamsa20095af2019-06-11 17:16:58 +03002301run_test "Extended Master Secret: client disabled, server disabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002302 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2303 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002304 0 \
2305 -C "client hello, adding extended_master_secret extension" \
2306 -S "found extended master secret extension" \
2307 -S "server hello, adding extended master secret extension" \
2308 -C "found extended_master_secret extension" \
2309 -C "session hash for extended master secret" \
2310 -S "session hash for extended master secret"
2311
Janos Follathe2681a42016-03-07 15:57:05 +00002312requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002313run_test "Extended Master Secret: client SSLv3, server enabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002314 "$P_SRV debug_level=3 min_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2315 "$P_CLI debug_level=3 force_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002316 0 \
2317 -C "client hello, adding extended_master_secret extension" \
2318 -S "found extended master secret extension" \
2319 -S "server hello, adding extended master secret extension" \
2320 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002321 -C "session hash for extended master secret" \
2322 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002323
Janos Follathe2681a42016-03-07 15:57:05 +00002324requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002325run_test "Extended Master Secret: client enabled, server SSLv3" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002326 "$P_SRV debug_level=3 force_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2327 "$P_CLI debug_level=3 min_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002328 0 \
2329 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002330 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002331 -S "server hello, adding extended master secret extension" \
2332 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002333 -C "session hash for extended master secret" \
2334 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002335
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002336# Tests for FALLBACK_SCSV
2337
2338run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002339 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002340 "$P_CLI debug_level=3 force_version=tls1_1" \
2341 0 \
2342 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002343 -S "received FALLBACK_SCSV" \
2344 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002345 -C "is a fatal alert message (msg 86)"
2346
2347run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002348 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002349 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2350 0 \
2351 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002352 -S "received FALLBACK_SCSV" \
2353 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002354 -C "is a fatal alert message (msg 86)"
2355
2356run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002357 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002358 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002359 1 \
2360 -c "adding FALLBACK_SCSV" \
2361 -s "received FALLBACK_SCSV" \
2362 -s "inapropriate fallback" \
2363 -c "is a fatal alert message (msg 86)"
2364
2365run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002366 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002367 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002368 0 \
2369 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002370 -s "received FALLBACK_SCSV" \
2371 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002372 -C "is a fatal alert message (msg 86)"
2373
2374requires_openssl_with_fallback_scsv
2375run_test "Fallback SCSV: default, openssl server" \
2376 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002377 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002378 0 \
2379 -C "adding FALLBACK_SCSV" \
2380 -C "is a fatal alert message (msg 86)"
2381
2382requires_openssl_with_fallback_scsv
2383run_test "Fallback SCSV: enabled, openssl server" \
2384 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002385 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002386 1 \
2387 -c "adding FALLBACK_SCSV" \
2388 -c "is a fatal alert message (msg 86)"
2389
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002390requires_openssl_with_fallback_scsv
2391run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002392 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002393 "$O_CLI -tls1_1" \
2394 0 \
2395 -S "received FALLBACK_SCSV" \
2396 -S "inapropriate fallback"
2397
2398requires_openssl_with_fallback_scsv
2399run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002400 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002401 "$O_CLI -tls1_1 -fallback_scsv" \
2402 1 \
2403 -s "received FALLBACK_SCSV" \
2404 -s "inapropriate fallback"
2405
2406requires_openssl_with_fallback_scsv
2407run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002408 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002409 "$O_CLI -fallback_scsv" \
2410 0 \
2411 -s "received FALLBACK_SCSV" \
2412 -S "inapropriate fallback"
2413
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002414# Test sending and receiving empty application data records
2415
2416run_test "Encrypt then MAC: empty application data record" \
2417 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2418 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2419 0 \
2420 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2421 -s "dumping 'input payload after decrypt' (0 bytes)" \
2422 -c "0 bytes written in 1 fragments"
2423
2424run_test "Default, no Encrypt then MAC: empty application data record" \
2425 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2426 "$P_CLI auth_mode=none etm=0 request_size=0" \
2427 0 \
2428 -s "dumping 'input payload after decrypt' (0 bytes)" \
2429 -c "0 bytes written in 1 fragments"
2430
2431run_test "Encrypt then MAC, DTLS: empty application data record" \
2432 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2433 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2434 0 \
2435 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2436 -s "dumping 'input payload after decrypt' (0 bytes)" \
2437 -c "0 bytes written in 1 fragments"
2438
2439run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
2440 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2441 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2442 0 \
2443 -s "dumping 'input payload after decrypt' (0 bytes)" \
2444 -c "0 bytes written in 1 fragments"
2445
Gilles Peskined50177f2017-05-16 17:53:03 +02002446## ClientHello generated with
2447## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2448## then manually twiddling the ciphersuite list.
2449## The ClientHello content is spelled out below as a hex string as
2450## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2451## The expected response is an inappropriate_fallback alert.
2452requires_openssl_with_fallback_scsv
2453run_test "Fallback SCSV: beginning of list" \
2454 "$P_SRV debug_level=2" \
2455 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2456 0 \
2457 -s "received FALLBACK_SCSV" \
2458 -s "inapropriate fallback"
2459
2460requires_openssl_with_fallback_scsv
2461run_test "Fallback SCSV: end of list" \
2462 "$P_SRV debug_level=2" \
2463 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2464 0 \
2465 -s "received FALLBACK_SCSV" \
2466 -s "inapropriate fallback"
2467
2468## Here the expected response is a valid ServerHello prefix, up to the random.
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02002469## Due to the way the clienthello was generated, this currently needs the
2470## server to have support for session tickets.
2471requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Gilles Peskined50177f2017-05-16 17:53:03 +02002472requires_openssl_with_fallback_scsv
2473run_test "Fallback SCSV: not in list" \
2474 "$P_SRV debug_level=2" \
2475 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2476 0 \
2477 -S "received FALLBACK_SCSV" \
2478 -S "inapropriate fallback"
2479
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002480# Tests for CBC 1/n-1 record splitting
2481
2482run_test "CBC Record splitting: TLS 1.2, no splitting" \
2483 "$P_SRV" \
2484 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2485 request_size=123 force_version=tls1_2" \
2486 0 \
2487 -s "Read from client: 123 bytes read" \
2488 -S "Read from client: 1 bytes read" \
2489 -S "122 bytes read"
2490
2491run_test "CBC Record splitting: TLS 1.1, no splitting" \
2492 "$P_SRV" \
2493 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2494 request_size=123 force_version=tls1_1" \
2495 0 \
2496 -s "Read from client: 123 bytes read" \
2497 -S "Read from client: 1 bytes read" \
2498 -S "122 bytes read"
2499
2500run_test "CBC Record splitting: TLS 1.0, splitting" \
2501 "$P_SRV" \
2502 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2503 request_size=123 force_version=tls1" \
2504 0 \
2505 -S "Read from client: 123 bytes read" \
2506 -s "Read from client: 1 bytes read" \
2507 -s "122 bytes read"
2508
Janos Follathe2681a42016-03-07 15:57:05 +00002509requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002510run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002511 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002512 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2513 request_size=123 force_version=ssl3" \
2514 0 \
2515 -S "Read from client: 123 bytes read" \
2516 -s "Read from client: 1 bytes read" \
2517 -s "122 bytes read"
2518
2519run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002520 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002521 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2522 request_size=123 force_version=tls1" \
2523 0 \
2524 -s "Read from client: 123 bytes read" \
2525 -S "Read from client: 1 bytes read" \
2526 -S "122 bytes read"
2527
2528run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2529 "$P_SRV" \
2530 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2531 request_size=123 force_version=tls1 recsplit=0" \
2532 0 \
2533 -s "Read from client: 123 bytes read" \
2534 -S "Read from client: 1 bytes read" \
2535 -S "122 bytes read"
2536
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002537run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2538 "$P_SRV nbio=2" \
2539 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-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
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002546# Tests for Session Tickets
2547
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002548requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002549requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002550run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002551 "$P_SRV debug_level=3 tickets=1" \
2552 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002553 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002554 -c "client hello, adding session ticket extension" \
2555 -s "found session ticket extension" \
2556 -s "server hello, adding session ticket extension" \
2557 -c "found session_ticket extension" \
2558 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002559 -S "session successfully restored from cache" \
2560 -s "session successfully restored from ticket" \
2561 -s "a session has been resumed" \
2562 -c "a session has been resumed"
2563
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002564requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002565requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002566run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002567 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2568 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002569 0 \
2570 -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" \
2575 -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
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002580requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002581requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002582run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002583 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2584 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002585 0 \
2586 -c "client hello, adding session ticket extension" \
2587 -s "found session ticket extension" \
2588 -s "server hello, adding session ticket extension" \
2589 -c "found session_ticket extension" \
2590 -c "parse new session ticket" \
2591 -S "session successfully restored from cache" \
2592 -S "session successfully restored from ticket" \
2593 -S "a session has been resumed" \
2594 -C "a session has been resumed"
2595
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002596requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002597requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002598run_test "Session resume using tickets: session copy" \
2599 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2600 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2601 0 \
2602 -c "client hello, adding session ticket extension" \
2603 -s "found session ticket extension" \
2604 -s "server hello, adding session ticket extension" \
2605 -c "found session_ticket extension" \
2606 -c "parse new session ticket" \
2607 -S "session successfully restored from cache" \
2608 -s "session successfully restored from ticket" \
2609 -s "a session has been resumed" \
2610 -c "a session has been resumed"
2611
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002612requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002613requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002614run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002615 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002616 "$P_CLI debug_level=3 tickets=1 reconnect=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002617 0 \
2618 -c "client hello, adding session ticket extension" \
2619 -c "found session_ticket extension" \
2620 -c "parse new session ticket" \
2621 -c "a session has been resumed"
2622
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002623requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002624requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002625run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002626 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002627 "( $O_CLI -sess_out $SESSION; \
2628 $O_CLI -sess_in $SESSION; \
2629 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002630 0 \
2631 -s "found session ticket extension" \
2632 -s "server hello, adding session ticket extension" \
2633 -S "session successfully restored from cache" \
2634 -s "session successfully restored from ticket" \
2635 -s "a session has been resumed"
2636
Hanno Becker1d739932018-08-21 13:55:22 +01002637# Tests for Session Tickets with DTLS
2638
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002639requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002640requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002641run_test "Session resume using tickets, DTLS: basic" \
2642 "$P_SRV debug_level=3 dtls=1 tickets=1" \
2643 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2644 0 \
2645 -c "client hello, adding session ticket extension" \
2646 -s "found session ticket extension" \
2647 -s "server hello, adding session ticket extension" \
2648 -c "found session_ticket extension" \
2649 -c "parse new session ticket" \
2650 -S "session successfully restored from cache" \
2651 -s "session successfully restored from ticket" \
2652 -s "a session has been resumed" \
2653 -c "a session has been resumed"
2654
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002655requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002656requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002657run_test "Session resume using tickets, DTLS: cache disabled" \
2658 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2659 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2660 0 \
2661 -c "client hello, adding session ticket extension" \
2662 -s "found session ticket extension" \
2663 -s "server hello, adding session ticket extension" \
2664 -c "found session_ticket extension" \
2665 -c "parse new session ticket" \
2666 -S "session successfully restored from cache" \
2667 -s "session successfully restored from ticket" \
2668 -s "a session has been resumed" \
2669 -c "a session has been resumed"
2670
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002671requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002672requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002673run_test "Session resume using tickets, DTLS: timeout" \
2674 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
2675 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \
2676 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
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002687requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002688requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002689run_test "Session resume using tickets, DTLS: session copy" \
2690 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2691 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_mode=0" \
2692 0 \
2693 -c "client hello, adding session ticket extension" \
2694 -s "found session ticket extension" \
2695 -s "server hello, adding session ticket extension" \
2696 -c "found session_ticket extension" \
2697 -c "parse new session ticket" \
2698 -S "session successfully restored from cache" \
2699 -s "session successfully restored from ticket" \
2700 -s "a session has been resumed" \
2701 -c "a session has been resumed"
2702
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002703requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002704requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002705run_test "Session resume using tickets, DTLS: openssl server" \
2706 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002707 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 ca_file=data_files/test-ca2.crt" \
Hanno Becker1d739932018-08-21 13:55:22 +01002708 0 \
2709 -c "client hello, adding session ticket extension" \
2710 -c "found session_ticket extension" \
2711 -c "parse new session ticket" \
2712 -c "a session has been resumed"
2713
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002714requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002715requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002716run_test "Session resume using tickets, DTLS: openssl client" \
2717 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2718 "( $O_CLI -dtls1 -sess_out $SESSION; \
2719 $O_CLI -dtls1 -sess_in $SESSION; \
2720 rm -f $SESSION )" \
2721 0 \
2722 -s "found session ticket extension" \
2723 -s "server hello, adding session ticket extension" \
2724 -S "session successfully restored from cache" \
2725 -s "session successfully restored from ticket" \
2726 -s "a session has been resumed"
2727
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002728# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002729
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002730requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002731requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002732requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002733run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002734 "$P_SRV debug_level=3 tickets=0" \
2735 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002736 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002737 -c "client hello, adding session ticket extension" \
2738 -s "found session ticket extension" \
2739 -S "server hello, adding session ticket extension" \
2740 -C "found session_ticket extension" \
2741 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002742 -s "session successfully restored from cache" \
2743 -S "session successfully restored from ticket" \
2744 -s "a session has been resumed" \
2745 -c "a session has been resumed"
2746
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002747requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002748requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002749requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002750run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002751 "$P_SRV debug_level=3 tickets=1" \
2752 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002753 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002754 -C "client hello, adding session ticket extension" \
2755 -S "found session ticket extension" \
2756 -S "server hello, adding session ticket extension" \
2757 -C "found session_ticket extension" \
2758 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002759 -s "session successfully restored from cache" \
2760 -S "session successfully restored from ticket" \
2761 -s "a session has been resumed" \
2762 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002763
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002764requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2765requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002766run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002767 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2768 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002769 0 \
2770 -S "session successfully restored from cache" \
2771 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002772 -S "a session has been resumed" \
2773 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002774
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002775requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2776requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002777run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002778 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2779 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002780 0 \
2781 -s "session successfully restored from cache" \
2782 -S "session successfully restored from ticket" \
2783 -s "a session has been resumed" \
2784 -c "a session has been resumed"
2785
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002786requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2787requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002788run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002789 "$P_SRV debug_level=3 tickets=0" \
2790 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +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
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002797requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2798requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002799run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002800 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2801 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002802 0 \
2803 -S "session successfully restored from cache" \
2804 -S "session successfully restored from ticket" \
2805 -S "a session has been resumed" \
2806 -C "a session has been resumed"
2807
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002808requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2809requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002810run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002811 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2812 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002813 0 \
2814 -s "session successfully restored from cache" \
2815 -S "session successfully restored from ticket" \
2816 -s "a session has been resumed" \
2817 -c "a session has been resumed"
2818
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002819requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2820requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002821run_test "Session resume using cache: session copy" \
2822 "$P_SRV debug_level=3 tickets=0" \
2823 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2824 0 \
2825 -s "session successfully restored from cache" \
2826 -S "session successfully restored from ticket" \
2827 -s "a session has been resumed" \
2828 -c "a session has been resumed"
2829
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002830requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2831requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002832run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002833 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002834 "( $O_CLI -sess_out $SESSION; \
2835 $O_CLI -sess_in $SESSION; \
2836 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002837 0 \
2838 -s "found session ticket extension" \
2839 -S "server hello, adding session ticket extension" \
2840 -s "session successfully restored from cache" \
2841 -S "session successfully restored from ticket" \
2842 -s "a session has been resumed"
2843
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002844requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2845requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002846run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002847 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002848 "$P_CLI debug_level=3 tickets=0 reconnect=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002849 0 \
2850 -C "found session_ticket extension" \
2851 -C "parse new session ticket" \
2852 -c "a session has been resumed"
2853
Hanno Becker1d739932018-08-21 13:55:22 +01002854# Tests for Session Resume based on session-ID and cache, DTLS
2855
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002856requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002857requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002858requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002859run_test "Session resume using cache, DTLS: tickets enabled on client" \
2860 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2861 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2862 0 \
2863 -c "client hello, adding session ticket extension" \
2864 -s "found session ticket extension" \
2865 -S "server hello, adding session ticket extension" \
2866 -C "found session_ticket extension" \
2867 -C "parse new session ticket" \
2868 -s "session successfully restored from cache" \
2869 -S "session successfully restored from ticket" \
2870 -s "a session has been resumed" \
2871 -c "a session has been resumed"
2872
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002873requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002874requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002875requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002876run_test "Session resume using cache, DTLS: tickets enabled on server" \
2877 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2878 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2879 0 \
2880 -C "client hello, adding session ticket extension" \
2881 -S "found session ticket extension" \
2882 -S "server hello, adding session ticket extension" \
2883 -C "found session_ticket extension" \
2884 -C "parse new session ticket" \
2885 -s "session successfully restored from cache" \
2886 -S "session successfully restored from ticket" \
2887 -s "a session has been resumed" \
2888 -c "a session has been resumed"
2889
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002890requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2891requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002892run_test "Session resume using cache, DTLS: cache_max=0" \
2893 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
2894 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2895 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
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002901requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2902requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002903run_test "Session resume using cache, DTLS: cache_max=1" \
2904 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
2905 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2906 0 \
2907 -s "session successfully restored from cache" \
2908 -S "session successfully restored from ticket" \
2909 -s "a session has been resumed" \
2910 -c "a session has been resumed"
2911
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002912requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2913requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002914run_test "Session resume using cache, DTLS: timeout > delay" \
2915 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2916 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
2917 0 \
2918 -s "session successfully restored from cache" \
2919 -S "session successfully restored from ticket" \
2920 -s "a session has been resumed" \
2921 -c "a session has been resumed"
2922
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002923requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2924requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002925run_test "Session resume using cache, DTLS: timeout < delay" \
2926 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
2927 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2928 0 \
2929 -S "session successfully restored from cache" \
2930 -S "session successfully restored from ticket" \
2931 -S "a session has been resumed" \
2932 -C "a session has been resumed"
2933
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002934requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2935requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002936run_test "Session resume using cache, DTLS: no timeout" \
2937 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
2938 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2939 0 \
2940 -s "session successfully restored from cache" \
2941 -S "session successfully restored from ticket" \
2942 -s "a session has been resumed" \
2943 -c "a session has been resumed"
2944
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002945requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2946requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002947run_test "Session resume using cache, DTLS: session copy" \
2948 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2949 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2950 0 \
2951 -s "session successfully restored from cache" \
2952 -S "session successfully restored from ticket" \
2953 -s "a session has been resumed" \
2954 -c "a session has been resumed"
2955
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002956requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2957requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002958run_test "Session resume using cache, DTLS: openssl client" \
2959 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2960 "( $O_CLI -dtls1 -sess_out $SESSION; \
2961 $O_CLI -dtls1 -sess_in $SESSION; \
2962 rm -f $SESSION )" \
2963 0 \
2964 -s "found session ticket extension" \
2965 -S "server hello, adding session ticket extension" \
2966 -s "session successfully restored from cache" \
2967 -S "session successfully restored from ticket" \
2968 -s "a session has been resumed"
2969
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002970requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2971requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002972run_test "Session resume using cache, DTLS: openssl server" \
2973 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002974 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 ca_file=data_files/test-ca2.crt" \
Hanno Becker1d739932018-08-21 13:55:22 +01002975 0 \
2976 -C "found session_ticket extension" \
2977 -C "parse new session ticket" \
2978 -c "a session has been resumed"
2979
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002980# Tests for Max Fragment Length extension
2981
Angus Grattonc4dd0732018-04-11 16:28:39 +10002982if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
2983 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 +01002984 exit 1
2985fi
2986
Angus Grattonc4dd0732018-04-11 16:28:39 +10002987if [ $MAX_CONTENT_LEN -ne 16384 ]; then
2988 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
2989fi
2990
Hanno Becker4aed27e2017-09-18 15:00:34 +01002991requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002992run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002993 "$P_SRV debug_level=3" \
2994 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002995 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002996 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2997 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002998 -C "client hello, adding max_fragment_length extension" \
2999 -S "found max fragment length extension" \
3000 -S "server hello, max_fragment_length extension" \
3001 -C "found max_fragment_length extension"
3002
Hanno Becker4aed27e2017-09-18 15:00:34 +01003003requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003004run_test "Max fragment length: enabled, default, larger message" \
3005 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003006 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003007 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003008 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3009 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003010 -C "client hello, adding max_fragment_length extension" \
3011 -S "found max fragment length extension" \
3012 -S "server hello, max_fragment_length extension" \
3013 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003014 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3015 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003016 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003017
3018requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3019run_test "Max fragment length, DTLS: enabled, default, larger message" \
3020 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003021 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003022 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003023 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3024 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003025 -C "client hello, adding max_fragment_length extension" \
3026 -S "found max fragment length extension" \
3027 -S "server hello, max_fragment_length extension" \
3028 -C "found max_fragment_length extension" \
3029 -c "fragment larger than.*maximum "
3030
Angus Grattonc4dd0732018-04-11 16:28:39 +10003031# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3032# (session fragment length will be 16384 regardless of mbedtls
3033# content length configuration.)
3034
Hanno Beckerc5266962017-09-18 15:01:50 +01003035requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3036run_test "Max fragment length: disabled, larger message" \
3037 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003038 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003039 0 \
3040 -C "Maximum fragment length is 16384" \
3041 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003042 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3043 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003044 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003045
3046requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3047run_test "Max fragment length DTLS: disabled, larger message" \
3048 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003049 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003050 1 \
3051 -C "Maximum fragment length is 16384" \
3052 -S "Maximum fragment length is 16384" \
3053 -c "fragment larger than.*maximum "
3054
3055requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003056run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003057 "$P_SRV debug_level=3" \
3058 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003059 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003060 -c "Maximum fragment length is 4096" \
3061 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003062 -c "client hello, adding max_fragment_length extension" \
3063 -s "found max fragment length extension" \
3064 -s "server hello, max_fragment_length extension" \
3065 -c "found max_fragment_length extension"
3066
Hanno Becker4aed27e2017-09-18 15:00:34 +01003067requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003068run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003069 "$P_SRV debug_level=3 max_frag_len=4096" \
3070 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003071 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003072 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003073 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003074 -C "client hello, adding max_fragment_length extension" \
3075 -S "found max fragment length extension" \
3076 -S "server hello, max_fragment_length extension" \
3077 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003078
Hanno Becker4aed27e2017-09-18 15:00:34 +01003079requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003080requires_gnutls
3081run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003082 "$G_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003083 "$P_CLI debug_level=3 max_frag_len=4096 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003084 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003085 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003086 -c "client hello, adding max_fragment_length extension" \
3087 -c "found max_fragment_length extension"
3088
Hanno Becker4aed27e2017-09-18 15:00:34 +01003089requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003090run_test "Max fragment length: client, message just fits" \
3091 "$P_SRV debug_level=3" \
3092 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3093 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003094 -c "Maximum fragment length is 2048" \
3095 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003096 -c "client hello, adding max_fragment_length extension" \
3097 -s "found max fragment length extension" \
3098 -s "server hello, max_fragment_length extension" \
3099 -c "found max_fragment_length extension" \
3100 -c "2048 bytes written in 1 fragments" \
3101 -s "2048 bytes read"
3102
Hanno Becker4aed27e2017-09-18 15:00:34 +01003103requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003104run_test "Max fragment length: client, larger message" \
3105 "$P_SRV debug_level=3" \
3106 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3107 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003108 -c "Maximum fragment length is 2048" \
3109 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003110 -c "client hello, adding max_fragment_length extension" \
3111 -s "found max fragment length extension" \
3112 -s "server hello, max_fragment_length extension" \
3113 -c "found max_fragment_length extension" \
3114 -c "2345 bytes written in 2 fragments" \
3115 -s "2048 bytes read" \
3116 -s "297 bytes read"
3117
Hanno Becker4aed27e2017-09-18 15:00:34 +01003118requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003119run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003120 "$P_SRV debug_level=3 dtls=1" \
3121 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3122 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003123 -c "Maximum fragment length is 2048" \
3124 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003125 -c "client hello, adding max_fragment_length extension" \
3126 -s "found max fragment length extension" \
3127 -s "server hello, max_fragment_length extension" \
3128 -c "found max_fragment_length extension" \
3129 -c "fragment larger than.*maximum"
3130
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003131# Tests for renegotiation
3132
Hanno Becker6a243642017-10-12 15:18:45 +01003133# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003134run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003135 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003136 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003137 0 \
3138 -C "client hello, adding renegotiation extension" \
3139 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3140 -S "found renegotiation extension" \
3141 -s "server hello, secure renegotiation extension" \
3142 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003143 -C "=> renegotiate" \
3144 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003145 -S "write hello request"
3146
Hanno Becker6a243642017-10-12 15:18:45 +01003147requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003148run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003149 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003150 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003151 0 \
3152 -c "client hello, adding renegotiation extension" \
3153 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3154 -s "found renegotiation extension" \
3155 -s "server hello, secure renegotiation extension" \
3156 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003157 -c "=> renegotiate" \
3158 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003159 -S "write hello request"
3160
Hanno Becker6a243642017-10-12 15:18:45 +01003161requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003162run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003163 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003164 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003165 0 \
3166 -c "client hello, adding renegotiation extension" \
3167 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3168 -s "found renegotiation extension" \
3169 -s "server hello, secure renegotiation extension" \
3170 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003171 -c "=> renegotiate" \
3172 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003173 -s "write hello request"
3174
Janos Follathb0f148c2017-10-05 12:29:42 +01003175# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3176# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3177# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003178requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003179run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3180 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3181 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3182 0 \
3183 -c "client hello, adding renegotiation extension" \
3184 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3185 -s "found renegotiation extension" \
3186 -s "server hello, secure renegotiation extension" \
3187 -c "found renegotiation extension" \
3188 -c "=> renegotiate" \
3189 -s "=> renegotiate" \
3190 -S "write hello request" \
3191 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3192
3193# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3194# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3195# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003196requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003197run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3198 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3199 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3200 0 \
3201 -c "client hello, adding renegotiation extension" \
3202 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3203 -s "found renegotiation extension" \
3204 -s "server hello, secure renegotiation extension" \
3205 -c "found renegotiation extension" \
3206 -c "=> renegotiate" \
3207 -s "=> renegotiate" \
3208 -s "write hello request" \
3209 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3210
Hanno Becker6a243642017-10-12 15:18:45 +01003211requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003212run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003213 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003214 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003215 0 \
3216 -c "client hello, adding renegotiation extension" \
3217 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3218 -s "found renegotiation extension" \
3219 -s "server hello, secure renegotiation extension" \
3220 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003221 -c "=> renegotiate" \
3222 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003223 -s "write hello request"
3224
Hanno Becker6a243642017-10-12 15:18:45 +01003225requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003226run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003227 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003228 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003229 1 \
3230 -c "client hello, adding renegotiation extension" \
3231 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3232 -S "found renegotiation extension" \
3233 -s "server hello, secure renegotiation extension" \
3234 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003235 -c "=> renegotiate" \
3236 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003237 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003238 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003239 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003240
Hanno Becker6a243642017-10-12 15:18:45 +01003241requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003242run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003243 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003244 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003245 0 \
3246 -C "client hello, adding renegotiation extension" \
3247 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3248 -S "found renegotiation extension" \
3249 -s "server hello, secure renegotiation extension" \
3250 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003251 -C "=> renegotiate" \
3252 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003253 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003254 -S "SSL - An unexpected message was received from our peer" \
3255 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003256
Hanno Becker6a243642017-10-12 15:18:45 +01003257requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003258run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003259 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003260 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003261 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003262 0 \
3263 -C "client hello, adding renegotiation extension" \
3264 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3265 -S "found renegotiation extension" \
3266 -s "server hello, secure renegotiation extension" \
3267 -c "found renegotiation extension" \
3268 -C "=> renegotiate" \
3269 -S "=> renegotiate" \
3270 -s "write hello request" \
3271 -S "SSL - An unexpected message was received from our peer" \
3272 -S "failed"
3273
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003274# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003275requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003276run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003277 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003278 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003279 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003280 0 \
3281 -C "client hello, adding renegotiation extension" \
3282 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3283 -S "found renegotiation extension" \
3284 -s "server hello, secure renegotiation extension" \
3285 -c "found renegotiation extension" \
3286 -C "=> renegotiate" \
3287 -S "=> renegotiate" \
3288 -s "write hello request" \
3289 -S "SSL - An unexpected message was received from our peer" \
3290 -S "failed"
3291
Hanno Becker6a243642017-10-12 15:18:45 +01003292requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003293run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003294 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003295 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003296 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003297 0 \
3298 -C "client hello, adding renegotiation extension" \
3299 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3300 -S "found renegotiation extension" \
3301 -s "server hello, secure renegotiation extension" \
3302 -c "found renegotiation extension" \
3303 -C "=> renegotiate" \
3304 -S "=> renegotiate" \
3305 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003306 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003307
Hanno Becker6a243642017-10-12 15:18:45 +01003308requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003309run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003310 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003311 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003312 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003313 0 \
3314 -c "client hello, adding renegotiation extension" \
3315 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3316 -s "found renegotiation extension" \
3317 -s "server hello, secure renegotiation extension" \
3318 -c "found renegotiation extension" \
3319 -c "=> renegotiate" \
3320 -s "=> renegotiate" \
3321 -s "write hello request" \
3322 -S "SSL - An unexpected message was received from our peer" \
3323 -S "failed"
3324
Hanno Becker6a243642017-10-12 15:18:45 +01003325requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003326run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003327 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003328 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3329 0 \
3330 -C "client hello, adding renegotiation extension" \
3331 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3332 -S "found renegotiation extension" \
3333 -s "server hello, secure renegotiation extension" \
3334 -c "found renegotiation extension" \
3335 -S "record counter limit reached: renegotiate" \
3336 -C "=> renegotiate" \
3337 -S "=> renegotiate" \
3338 -S "write hello request" \
3339 -S "SSL - An unexpected message was received from our peer" \
3340 -S "failed"
3341
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003342# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003343requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003344run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003345 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003346 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003347 0 \
3348 -c "client hello, adding renegotiation extension" \
3349 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3350 -s "found renegotiation extension" \
3351 -s "server hello, secure renegotiation extension" \
3352 -c "found renegotiation extension" \
3353 -s "record counter limit reached: renegotiate" \
3354 -c "=> renegotiate" \
3355 -s "=> renegotiate" \
3356 -s "write hello request" \
3357 -S "SSL - An unexpected message was received from our peer" \
3358 -S "failed"
3359
Hanno Becker6a243642017-10-12 15:18:45 +01003360requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003361run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003362 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003363 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003364 0 \
3365 -c "client hello, adding renegotiation extension" \
3366 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3367 -s "found renegotiation extension" \
3368 -s "server hello, secure renegotiation extension" \
3369 -c "found renegotiation extension" \
3370 -s "record counter limit reached: renegotiate" \
3371 -c "=> renegotiate" \
3372 -s "=> renegotiate" \
3373 -s "write hello request" \
3374 -S "SSL - An unexpected message was received from our peer" \
3375 -S "failed"
3376
Hanno Becker6a243642017-10-12 15:18:45 +01003377requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003378run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003379 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003380 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3381 0 \
3382 -C "client hello, adding renegotiation extension" \
3383 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3384 -S "found renegotiation extension" \
3385 -s "server hello, secure renegotiation extension" \
3386 -c "found renegotiation extension" \
3387 -S "record counter limit reached: renegotiate" \
3388 -C "=> renegotiate" \
3389 -S "=> renegotiate" \
3390 -S "write hello request" \
3391 -S "SSL - An unexpected message was received from our peer" \
3392 -S "failed"
3393
Hanno Becker6a243642017-10-12 15:18:45 +01003394requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003395run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003396 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003397 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003398 0 \
3399 -c "client hello, adding renegotiation extension" \
3400 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3401 -s "found renegotiation extension" \
3402 -s "server hello, secure renegotiation extension" \
3403 -c "found renegotiation extension" \
3404 -c "=> renegotiate" \
3405 -s "=> renegotiate" \
3406 -S "write hello request"
3407
Hanno Becker6a243642017-10-12 15:18:45 +01003408requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003409run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003410 "$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 +02003411 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003412 0 \
3413 -c "client hello, adding renegotiation extension" \
3414 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3415 -s "found renegotiation extension" \
3416 -s "server hello, secure renegotiation extension" \
3417 -c "found renegotiation extension" \
3418 -c "=> renegotiate" \
3419 -s "=> renegotiate" \
3420 -s "write hello request"
3421
Hanno Becker6a243642017-10-12 15:18:45 +01003422requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003423run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003424 "$O_SRV -www" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003425 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003426 0 \
3427 -c "client hello, adding renegotiation extension" \
3428 -c "found renegotiation extension" \
3429 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003430 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003431 -C "error" \
3432 -c "HTTP/1.0 200 [Oo][Kk]"
3433
Paul Bakker539d9722015-02-08 16:18:35 +01003434requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003435requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003436run_test "Renegotiation: gnutls server strict, client-initiated" \
3437 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003438 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003439 0 \
3440 -c "client hello, adding renegotiation extension" \
3441 -c "found renegotiation extension" \
3442 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003443 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003444 -C "error" \
3445 -c "HTTP/1.0 200 [Oo][Kk]"
3446
Paul Bakker539d9722015-02-08 16:18:35 +01003447requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003448requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003449run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3450 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003451 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003452 1 \
3453 -c "client hello, adding renegotiation extension" \
3454 -C "found renegotiation extension" \
3455 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003456 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003457 -c "error" \
3458 -C "HTTP/1.0 200 [Oo][Kk]"
3459
Paul Bakker539d9722015-02-08 16:18:35 +01003460requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003461requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003462run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3463 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003464 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003465 allow_legacy=0" \
3466 1 \
3467 -c "client hello, adding renegotiation extension" \
3468 -C "found renegotiation extension" \
3469 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003470 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003471 -c "error" \
3472 -C "HTTP/1.0 200 [Oo][Kk]"
3473
Paul Bakker539d9722015-02-08 16:18:35 +01003474requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003475requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003476run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3477 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003478 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003479 allow_legacy=1" \
3480 0 \
3481 -c "client hello, adding renegotiation extension" \
3482 -C "found renegotiation extension" \
3483 -c "=> renegotiate" \
3484 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003485 -C "error" \
3486 -c "HTTP/1.0 200 [Oo][Kk]"
3487
Hanno Becker6a243642017-10-12 15:18:45 +01003488requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003489run_test "Renegotiation: DTLS, client-initiated" \
3490 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3491 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3492 0 \
3493 -c "client hello, adding renegotiation extension" \
3494 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3495 -s "found renegotiation extension" \
3496 -s "server hello, secure renegotiation extension" \
3497 -c "found renegotiation extension" \
3498 -c "=> renegotiate" \
3499 -s "=> renegotiate" \
3500 -S "write hello request"
3501
Hanno Becker6a243642017-10-12 15:18:45 +01003502requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003503run_test "Renegotiation: DTLS, server-initiated" \
3504 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003505 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3506 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003507 0 \
3508 -c "client hello, adding renegotiation extension" \
3509 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3510 -s "found renegotiation extension" \
3511 -s "server hello, secure renegotiation extension" \
3512 -c "found renegotiation extension" \
3513 -c "=> renegotiate" \
3514 -s "=> renegotiate" \
3515 -s "write hello request"
3516
Hanno Becker6a243642017-10-12 15:18:45 +01003517requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003518run_test "Renegotiation: DTLS, renego_period overflow" \
3519 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3520 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3521 0 \
3522 -c "client hello, adding renegotiation extension" \
3523 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3524 -s "found renegotiation extension" \
3525 -s "server hello, secure renegotiation extension" \
3526 -s "record counter limit reached: renegotiate" \
3527 -c "=> renegotiate" \
3528 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003529 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003530
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003531requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003532requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003533run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3534 "$G_SRV -u --mtu 4096" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003535 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003536 0 \
3537 -c "client hello, adding renegotiation extension" \
3538 -c "found renegotiation extension" \
3539 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003540 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003541 -C "error" \
3542 -s "Extra-header:"
3543
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003544# Test for the "secure renegotation" extension only (no actual renegotiation)
3545
Paul Bakker539d9722015-02-08 16:18:35 +01003546requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003547run_test "Renego ext: gnutls server strict, client default" \
3548 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003549 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003550 0 \
3551 -c "found renegotiation extension" \
3552 -C "error" \
3553 -c "HTTP/1.0 200 [Oo][Kk]"
3554
Paul Bakker539d9722015-02-08 16:18:35 +01003555requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003556run_test "Renego ext: gnutls server unsafe, client default" \
3557 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003558 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003559 0 \
3560 -C "found renegotiation extension" \
3561 -C "error" \
3562 -c "HTTP/1.0 200 [Oo][Kk]"
3563
Paul Bakker539d9722015-02-08 16:18:35 +01003564requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003565run_test "Renego ext: gnutls server unsafe, client break legacy" \
3566 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3567 "$P_CLI debug_level=3 allow_legacy=-1" \
3568 1 \
3569 -C "found renegotiation extension" \
3570 -c "error" \
3571 -C "HTTP/1.0 200 [Oo][Kk]"
3572
Paul Bakker539d9722015-02-08 16:18:35 +01003573requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003574run_test "Renego ext: gnutls client strict, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003575 "$P_SRV debug_level=3 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003576 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003577 0 \
3578 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3579 -s "server hello, secure renegotiation extension"
3580
Paul Bakker539d9722015-02-08 16:18:35 +01003581requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003582run_test "Renego ext: gnutls client unsafe, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003583 "$P_SRV debug_level=3 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003584 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003585 0 \
3586 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3587 -S "server hello, secure renegotiation extension"
3588
Paul Bakker539d9722015-02-08 16:18:35 +01003589requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003590run_test "Renego ext: gnutls client unsafe, server break legacy" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003591 "$P_SRV debug_level=3 allow_legacy=-1 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003592 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003593 1 \
3594 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3595 -S "server hello, secure renegotiation extension"
3596
Janos Follath0b242342016-02-17 10:11:21 +00003597# Tests for silently dropping trailing extra bytes in .der certificates
3598
3599requires_gnutls
3600run_test "DER format: no trailing bytes" \
3601 "$P_SRV crt_file=data_files/server5-der0.crt \
3602 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003603 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003604 0 \
3605 -c "Handshake was completed" \
3606
3607requires_gnutls
3608run_test "DER format: with a trailing zero byte" \
3609 "$P_SRV crt_file=data_files/server5-der1a.crt \
3610 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003611 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003612 0 \
3613 -c "Handshake was completed" \
3614
3615requires_gnutls
3616run_test "DER format: with a trailing random byte" \
3617 "$P_SRV crt_file=data_files/server5-der1b.crt \
3618 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003619 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003620 0 \
3621 -c "Handshake was completed" \
3622
3623requires_gnutls
3624run_test "DER format: with 2 trailing random bytes" \
3625 "$P_SRV crt_file=data_files/server5-der2.crt \
3626 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003627 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003628 0 \
3629 -c "Handshake was completed" \
3630
3631requires_gnutls
3632run_test "DER format: with 4 trailing random bytes" \
3633 "$P_SRV crt_file=data_files/server5-der4.crt \
3634 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003635 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003636 0 \
3637 -c "Handshake was completed" \
3638
3639requires_gnutls
3640run_test "DER format: with 8 trailing random bytes" \
3641 "$P_SRV crt_file=data_files/server5-der8.crt \
3642 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003643 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003644 0 \
3645 -c "Handshake was completed" \
3646
3647requires_gnutls
3648run_test "DER format: with 9 trailing random bytes" \
3649 "$P_SRV crt_file=data_files/server5-der9.crt \
3650 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003651 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003652 0 \
3653 -c "Handshake was completed" \
3654
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003655# Tests for auth_mode
3656
Hanno Becker4a156fc2019-06-14 17:07:06 +01003657requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003658requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003659run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003660 "$P_SRV crt_file=data_files/server5-badsign.crt \
3661 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003662 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003663 1 \
3664 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003665 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003666 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003667 -c "X509 - Certificate verification failed"
3668
Hanno Becker4a156fc2019-06-14 17:07:06 +01003669requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003670requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003671run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003672 "$P_SRV crt_file=data_files/server5-badsign.crt \
3673 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003674 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003675 0 \
3676 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003677 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003678 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003679 -C "X509 - Certificate verification failed"
3680
Hanno Becker4a156fc2019-06-14 17:07:06 +01003681requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003682requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003683run_test "Authentication: server goodcert, client optional, no trusted CA" \
3684 "$P_SRV" \
3685 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3686 0 \
3687 -c "x509_verify_cert() returned" \
3688 -c "! The certificate is not correctly signed by the trusted CA" \
3689 -c "! Certificate verification flags"\
3690 -C "! mbedtls_ssl_handshake returned" \
3691 -C "X509 - Certificate verification failed" \
3692 -C "SSL - No CA Chain is set, but required to operate"
3693
Hanno Becker4a156fc2019-06-14 17:07:06 +01003694requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003695requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003696run_test "Authentication: server goodcert, client required, no trusted CA" \
3697 "$P_SRV" \
3698 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3699 1 \
3700 -c "x509_verify_cert() returned" \
3701 -c "! The certificate is not correctly signed by the trusted CA" \
3702 -c "! Certificate verification flags"\
3703 -c "! mbedtls_ssl_handshake returned" \
3704 -c "SSL - No CA Chain is set, but required to operate"
3705
3706# The purpose of the next two tests is to test the client's behaviour when receiving a server
3707# certificate with an unsupported elliptic curve. This should usually not happen because
3708# the client informs the server about the supported curves - it does, though, in the
3709# corner case of a static ECDH suite, because the server doesn't check the curve on that
3710# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3711# different means to have the server ignoring the client's supported curve list.
3712
3713requires_config_enabled MBEDTLS_ECP_C
3714run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3715 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3716 crt_file=data_files/server5.ku-ka.crt" \
3717 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3718 1 \
3719 -c "bad certificate (EC key curve)"\
3720 -c "! Certificate verification flags"\
3721 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3722
3723requires_config_enabled MBEDTLS_ECP_C
3724run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3725 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3726 crt_file=data_files/server5.ku-ka.crt" \
3727 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3728 1 \
3729 -c "bad certificate (EC key curve)"\
3730 -c "! Certificate verification flags"\
3731 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003733run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003734 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003735 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003736 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003737 0 \
3738 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003739 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003740 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003741 -C "X509 - Certificate verification failed"
3742
Simon Butcher99000142016-10-13 17:21:01 +01003743run_test "Authentication: client SHA256, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003744 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003745 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3746 key_file=data_files/server6.key \
3747 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3748 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003749 -c "Supported Signature Algorithm found: 5,"
3750
3751run_test "Authentication: client SHA384, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003752 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003753 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3754 key_file=data_files/server6.key \
3755 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3756 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003757 -c "Supported Signature Algorithm found: 5,"
3758
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003759requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3760run_test "Authentication: client has no cert, server required (SSLv3)" \
3761 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3762 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3763 key_file=data_files/server5.key" \
3764 1 \
3765 -S "skip write certificate request" \
3766 -C "skip parse certificate request" \
3767 -c "got a certificate request" \
3768 -c "got no certificate to send" \
3769 -S "x509_verify_cert() returned" \
3770 -s "client has no certificate" \
3771 -s "! mbedtls_ssl_handshake returned" \
3772 -c "! mbedtls_ssl_handshake returned" \
3773 -s "No client certification received from the client, but required by the authentication mode"
3774
3775run_test "Authentication: client has no cert, server required (TLS)" \
3776 "$P_SRV debug_level=3 auth_mode=required" \
3777 "$P_CLI debug_level=3 crt_file=none \
3778 key_file=data_files/server5.key" \
3779 1 \
3780 -S "skip write certificate request" \
3781 -C "skip parse certificate request" \
3782 -c "got a certificate request" \
3783 -c "= write certificate$" \
3784 -C "skip write certificate$" \
3785 -S "x509_verify_cert() returned" \
3786 -s "client has no certificate" \
3787 -s "! mbedtls_ssl_handshake returned" \
3788 -c "! mbedtls_ssl_handshake returned" \
3789 -s "No client certification received from the client, but required by the authentication mode"
3790
Hanno Becker4a156fc2019-06-14 17:07:06 +01003791requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003792requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003793run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003794 "$P_SRV debug_level=3 auth_mode=required" \
3795 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003796 key_file=data_files/server5.key" \
3797 1 \
3798 -S "skip write certificate request" \
3799 -C "skip parse certificate request" \
3800 -c "got a certificate request" \
3801 -C "skip write certificate" \
3802 -C "skip write certificate verify" \
3803 -S "skip parse certificate verify" \
3804 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003805 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003806 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003807 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003808 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003809 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003810# We don't check that the client receives the alert because it might
3811# detect that its write end of the connection is closed and abort
3812# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003813
Hanno Becker4a156fc2019-06-14 17:07:06 +01003814requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003815requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01003816run_test "Authentication: client cert not trusted, server required" \
3817 "$P_SRV debug_level=3 auth_mode=required" \
3818 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3819 key_file=data_files/server5.key" \
3820 1 \
3821 -S "skip write certificate request" \
3822 -C "skip parse certificate request" \
3823 -c "got a certificate request" \
3824 -C "skip write certificate" \
3825 -C "skip write certificate verify" \
3826 -S "skip parse certificate verify" \
3827 -s "x509_verify_cert() returned" \
3828 -s "! The certificate is not correctly signed by the trusted CA" \
3829 -s "! mbedtls_ssl_handshake returned" \
3830 -c "! mbedtls_ssl_handshake returned" \
3831 -s "X509 - Certificate verification failed"
3832
Hanno Becker4a156fc2019-06-14 17:07:06 +01003833requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003834requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003835run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003836 "$P_SRV debug_level=3 auth_mode=optional" \
3837 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003838 key_file=data_files/server5.key" \
3839 0 \
3840 -S "skip write certificate request" \
3841 -C "skip parse certificate request" \
3842 -c "got a certificate request" \
3843 -C "skip write certificate" \
3844 -C "skip write certificate verify" \
3845 -S "skip parse certificate verify" \
3846 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003847 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003848 -S "! mbedtls_ssl_handshake returned" \
3849 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003850 -S "X509 - Certificate verification failed"
3851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003852run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003853 "$P_SRV debug_level=3 auth_mode=none" \
3854 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003855 key_file=data_files/server5.key" \
3856 0 \
3857 -s "skip write certificate request" \
3858 -C "skip parse certificate request" \
3859 -c "got no certificate request" \
3860 -c "skip write certificate" \
3861 -c "skip write certificate verify" \
3862 -s "skip parse certificate verify" \
3863 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003864 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003865 -S "! mbedtls_ssl_handshake returned" \
3866 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003867 -S "X509 - Certificate verification failed"
3868
Hanno Becker4a156fc2019-06-14 17:07:06 +01003869requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003870requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003871run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003872 "$P_SRV debug_level=3 auth_mode=optional" \
3873 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003874 0 \
3875 -S "skip write certificate request" \
3876 -C "skip parse certificate request" \
3877 -c "got a certificate request" \
3878 -C "skip write certificate$" \
3879 -C "got no certificate to send" \
3880 -S "SSLv3 client has no certificate" \
3881 -c "skip write certificate verify" \
3882 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003883 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003884 -S "! mbedtls_ssl_handshake returned" \
3885 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003886 -S "X509 - Certificate verification failed"
3887
Hanno Becker4a156fc2019-06-14 17:07:06 +01003888requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003889requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003890run_test "Authentication: openssl client no cert, server optional" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003891 "$P_SRV debug_level=3 auth_mode=optional ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003892 "$O_CLI" \
3893 0 \
3894 -S "skip write certificate request" \
3895 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003896 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003897 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003898 -S "X509 - Certificate verification failed"
3899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003900run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003901 "$O_SRV -verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003902 "$P_CLI debug_level=3 crt_file=none key_file=none ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003903 0 \
3904 -C "skip parse certificate request" \
3905 -c "got a certificate request" \
3906 -C "skip write certificate$" \
3907 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003908 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003909
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003910run_test "Authentication: client no cert, openssl server required" \
3911 "$O_SRV -Verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003912 "$P_CLI debug_level=3 crt_file=none key_file=none ca_file=data_files/test-ca2.crt" \
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003913 1 \
3914 -C "skip parse certificate request" \
3915 -c "got a certificate request" \
3916 -C "skip write certificate$" \
3917 -c "skip write certificate verify" \
3918 -c "! mbedtls_ssl_handshake returned"
3919
Janos Follathe2681a42016-03-07 15:57:05 +00003920requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Hanno Beckerb2c63832019-06-17 08:35:16 +01003921requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003922requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003923run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003924 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003925 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003926 0 \
3927 -S "skip write certificate request" \
3928 -C "skip parse certificate request" \
3929 -c "got a certificate request" \
3930 -C "skip write certificate$" \
3931 -c "skip write certificate verify" \
3932 -c "got no certificate to send" \
3933 -s "SSLv3 client has no certificate" \
3934 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003935 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003936 -S "! mbedtls_ssl_handshake returned" \
3937 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003938 -S "X509 - Certificate verification failed"
3939
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02003940# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
3941# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003942
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003943MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01003944MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003945
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003946if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01003947 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003948 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003949 printf "test value of ${MAX_IM_CA}. \n"
3950 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003951 printf "The tests assume this value and if it changes, the tests in this\n"
3952 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003953 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003954
3955 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003956fi
3957
Angus Grattonc4dd0732018-04-11 16:28:39 +10003958requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003959run_test "Authentication: server max_int chain, client default" \
3960 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
3961 key_file=data_files/dir-maxpath/09.key" \
3962 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
3963 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003964 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003965
Angus Grattonc4dd0732018-04-11 16:28:39 +10003966requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003967run_test "Authentication: server max_int+1 chain, client default" \
3968 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3969 key_file=data_files/dir-maxpath/10.key" \
3970 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
3971 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003972 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003973
Angus Grattonc4dd0732018-04-11 16:28:39 +10003974requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003975run_test "Authentication: server max_int+1 chain, client optional" \
3976 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3977 key_file=data_files/dir-maxpath/10.key" \
3978 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
3979 auth_mode=optional" \
3980 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003981 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003982
Angus Grattonc4dd0732018-04-11 16:28:39 +10003983requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003984run_test "Authentication: server max_int+1 chain, client none" \
3985 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3986 key_file=data_files/dir-maxpath/10.key" \
3987 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
3988 auth_mode=none" \
3989 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003990 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003991
Angus Grattonc4dd0732018-04-11 16:28:39 +10003992requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003993run_test "Authentication: client max_int+1 chain, server default" \
3994 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
3995 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
3996 key_file=data_files/dir-maxpath/10.key" \
3997 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003998 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003999
Angus Grattonc4dd0732018-04-11 16:28:39 +10004000requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004001run_test "Authentication: client max_int+1 chain, server optional" \
4002 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4003 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4004 key_file=data_files/dir-maxpath/10.key" \
4005 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004006 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004007
Angus Grattonc4dd0732018-04-11 16:28:39 +10004008requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004009run_test "Authentication: client max_int+1 chain, server required" \
4010 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4011 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4012 key_file=data_files/dir-maxpath/10.key" \
4013 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004014 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004015
Angus Grattonc4dd0732018-04-11 16:28:39 +10004016requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004017run_test "Authentication: client max_int chain, server required" \
4018 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4019 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4020 key_file=data_files/dir-maxpath/09.key" \
4021 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004022 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004023
Janos Follath89baba22017-04-10 14:34:35 +01004024# Tests for CA list in CertificateRequest messages
4025
4026run_test "Authentication: send CA list in CertificateRequest (default)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004027 "$P_SRV debug_level=3 auth_mode=required ca_file=data_files/test-ca2.crt" \
Janos Follath89baba22017-04-10 14:34:35 +01004028 "$P_CLI crt_file=data_files/server6.crt \
4029 key_file=data_files/server6.key" \
4030 0 \
4031 -s "requested DN"
4032
4033run_test "Authentication: do not send CA list in CertificateRequest" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004034 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0 ca_file=data_files/test-ca2.crt" \
Janos Follath89baba22017-04-10 14:34:35 +01004035 "$P_CLI crt_file=data_files/server6.crt \
4036 key_file=data_files/server6.key" \
4037 0 \
4038 -S "requested DN"
4039
Hanno Becker4a156fc2019-06-14 17:07:06 +01004040requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004041requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01004042run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4043 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4044 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4045 key_file=data_files/server5.key" \
4046 1 \
4047 -S "requested DN" \
4048 -s "x509_verify_cert() returned" \
4049 -s "! The certificate is not correctly signed by the trusted CA" \
4050 -s "! mbedtls_ssl_handshake returned" \
4051 -c "! mbedtls_ssl_handshake returned" \
4052 -s "X509 - Certificate verification failed"
4053
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004054# Tests for certificate selection based on SHA verson
4055
Hanno Becker4a156fc2019-06-14 17:07:06 +01004056requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004057requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004058run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4059 "$P_SRV crt_file=data_files/server5.crt \
4060 key_file=data_files/server5.key \
4061 crt_file2=data_files/server5-sha1.crt \
4062 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004063 "$P_CLI force_version=tls1_2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004064 0 \
4065 -c "signed using.*ECDSA with SHA256" \
4066 -C "signed using.*ECDSA with SHA1"
4067
Hanno Becker4a156fc2019-06-14 17:07:06 +01004068requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004069requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004070run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4071 "$P_SRV crt_file=data_files/server5.crt \
4072 key_file=data_files/server5.key \
4073 crt_file2=data_files/server5-sha1.crt \
4074 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004075 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004076 0 \
4077 -C "signed using.*ECDSA with SHA256" \
4078 -c "signed using.*ECDSA with SHA1"
4079
Hanno Becker4a156fc2019-06-14 17:07:06 +01004080requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004081requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004082run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4083 "$P_SRV crt_file=data_files/server5.crt \
4084 key_file=data_files/server5.key \
4085 crt_file2=data_files/server5-sha1.crt \
4086 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004087 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004088 0 \
4089 -C "signed using.*ECDSA with SHA256" \
4090 -c "signed using.*ECDSA with SHA1"
4091
Hanno Becker4a156fc2019-06-14 17:07:06 +01004092requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004093requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004094run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4095 "$P_SRV crt_file=data_files/server5.crt \
4096 key_file=data_files/server5.key \
4097 crt_file2=data_files/server6.crt \
4098 key_file2=data_files/server6.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004099 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004100 0 \
4101 -c "serial number.*09" \
4102 -c "signed using.*ECDSA with SHA256" \
4103 -C "signed using.*ECDSA with SHA1"
4104
Hanno Becker4a156fc2019-06-14 17:07:06 +01004105requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004106requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004107run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4108 "$P_SRV crt_file=data_files/server6.crt \
4109 key_file=data_files/server6.key \
4110 crt_file2=data_files/server5.crt \
4111 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004112 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004113 0 \
4114 -c "serial number.*0A" \
4115 -c "signed using.*ECDSA with SHA256" \
4116 -C "signed using.*ECDSA with SHA1"
4117
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004118# tests for SNI
4119
Hanno Becker4a156fc2019-06-14 17:07:06 +01004120requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004121requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004122run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004123 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004124 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004125 "$P_CLI server_name=localhost ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004126 0 \
4127 -S "parse ServerName extension" \
4128 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4129 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004130
Hanno Becker4a156fc2019-06-14 17:07:06 +01004131requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004132requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004133requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004134run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004135 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004136 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004137 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004138 "$P_CLI server_name=localhost ca_file=data_files/test-ca.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004139 0 \
4140 -s "parse ServerName extension" \
4141 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4142 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004143
Hanno Becker4a156fc2019-06-14 17:07:06 +01004144requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004145requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004146requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004147run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004148 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004149 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004150 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 +02004151 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004152 0 \
4153 -s "parse ServerName extension" \
4154 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4155 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004156
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004157requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004158run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004159 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004160 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004161 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 +02004162 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004163 1 \
4164 -s "parse ServerName extension" \
4165 -s "ssl_sni_wrapper() returned" \
4166 -s "mbedtls_ssl_handshake returned" \
4167 -c "mbedtls_ssl_handshake returned" \
4168 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004169
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004170run_test "SNI: client auth no override: optional" \
4171 "$P_SRV debug_level=3 auth_mode=optional \
4172 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4173 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4174 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004175 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004176 -S "skip write certificate request" \
4177 -C "skip parse certificate request" \
4178 -c "got a certificate request" \
4179 -C "skip write certificate" \
4180 -C "skip write certificate verify" \
4181 -S "skip parse certificate verify"
4182
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004183requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004184run_test "SNI: client auth override: none -> optional" \
4185 "$P_SRV debug_level=3 auth_mode=none \
4186 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4187 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4188 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004189 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004190 -S "skip write certificate request" \
4191 -C "skip parse certificate request" \
4192 -c "got a certificate request" \
4193 -C "skip write certificate" \
4194 -C "skip write certificate verify" \
4195 -S "skip parse certificate verify"
4196
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004197requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004198run_test "SNI: client auth override: optional -> none" \
4199 "$P_SRV debug_level=3 auth_mode=optional \
4200 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4201 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4202 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004203 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004204 -s "skip write certificate request" \
4205 -C "skip parse certificate request" \
4206 -c "got no certificate request" \
4207 -c "skip write certificate" \
4208 -c "skip write certificate verify" \
4209 -s "skip parse certificate verify"
4210
Hanno Becker4a156fc2019-06-14 17:07:06 +01004211requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004212requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004213requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004214run_test "SNI: CA no override" \
4215 "$P_SRV debug_level=3 auth_mode=optional \
4216 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4217 ca_file=data_files/test-ca.crt \
4218 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4219 "$P_CLI debug_level=3 server_name=localhost \
4220 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4221 1 \
4222 -S "skip write certificate request" \
4223 -C "skip parse certificate request" \
4224 -c "got a certificate request" \
4225 -C "skip write certificate" \
4226 -C "skip write certificate verify" \
4227 -S "skip parse certificate verify" \
4228 -s "x509_verify_cert() returned" \
4229 -s "! The certificate is not correctly signed by the trusted CA" \
4230 -S "The certificate has been revoked (is on a CRL)"
4231
Hanno Becker4a156fc2019-06-14 17:07:06 +01004232requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004233requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004234requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004235run_test "SNI: CA override" \
4236 "$P_SRV debug_level=3 auth_mode=optional \
4237 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4238 ca_file=data_files/test-ca.crt \
4239 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4240 "$P_CLI debug_level=3 server_name=localhost \
4241 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4242 0 \
4243 -S "skip write certificate request" \
4244 -C "skip parse certificate request" \
4245 -c "got a certificate request" \
4246 -C "skip write certificate" \
4247 -C "skip write certificate verify" \
4248 -S "skip parse certificate verify" \
4249 -S "x509_verify_cert() returned" \
4250 -S "! The certificate is not correctly signed by the trusted CA" \
4251 -S "The certificate has been revoked (is on a CRL)"
4252
Hanno Becker4a156fc2019-06-14 17:07:06 +01004253requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004254requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004255requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004256run_test "SNI: CA override with CRL" \
4257 "$P_SRV debug_level=3 auth_mode=optional \
4258 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4259 ca_file=data_files/test-ca.crt \
4260 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4261 "$P_CLI debug_level=3 server_name=localhost \
4262 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4263 1 \
4264 -S "skip write certificate request" \
4265 -C "skip parse certificate request" \
4266 -c "got a certificate request" \
4267 -C "skip write certificate" \
4268 -C "skip write certificate verify" \
4269 -S "skip parse certificate verify" \
4270 -s "x509_verify_cert() returned" \
4271 -S "! The certificate is not correctly signed by the trusted CA" \
4272 -s "The certificate has been revoked (is on a CRL)"
4273
Andres AG1a834452016-12-07 10:01:30 +00004274# Tests for SNI and DTLS
4275
Hanno Becker4a156fc2019-06-14 17:07:06 +01004276requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004277requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004278run_test "SNI: DTLS, no SNI callback" \
4279 "$P_SRV debug_level=3 dtls=1 \
4280 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004281 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca2.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004282 0 \
4283 -S "parse ServerName extension" \
4284 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4285 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4286
Hanno Becker4a156fc2019-06-14 17:07:06 +01004287requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004288requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004289requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004290run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004291 "$P_SRV debug_level=3 dtls=1 \
4292 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4293 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004294 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca.crt" \
Andres AG1a834452016-12-07 10:01:30 +00004295 0 \
4296 -s "parse ServerName extension" \
4297 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4298 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4299
Hanno Becker4a156fc2019-06-14 17:07:06 +01004300requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004301requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004302requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004303run_test "SNI: DTLS, matching cert 2" \
4304 "$P_SRV debug_level=3 dtls=1 \
4305 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4306 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004307 "$P_CLI server_name=polarssl.example dtls=1 ca_file=data_files/test-ca.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004308 0 \
4309 -s "parse ServerName extension" \
4310 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4311 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4312
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004313requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004314run_test "SNI: DTLS, no matching cert" \
4315 "$P_SRV debug_level=3 dtls=1 \
4316 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4317 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4318 "$P_CLI server_name=nonesuch.example dtls=1" \
4319 1 \
4320 -s "parse ServerName extension" \
4321 -s "ssl_sni_wrapper() returned" \
4322 -s "mbedtls_ssl_handshake returned" \
4323 -c "mbedtls_ssl_handshake returned" \
4324 -c "SSL - A fatal alert message was received from our peer"
4325
4326run_test "SNI: DTLS, client auth no override: optional" \
4327 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4328 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4329 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4330 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4331 0 \
4332 -S "skip write certificate request" \
4333 -C "skip parse certificate request" \
4334 -c "got a certificate request" \
4335 -C "skip write certificate" \
4336 -C "skip write certificate verify" \
4337 -S "skip parse certificate verify"
4338
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004339requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004340run_test "SNI: DTLS, client auth override: none -> optional" \
4341 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4342 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4343 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4344 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4345 0 \
4346 -S "skip write certificate request" \
4347 -C "skip parse certificate request" \
4348 -c "got a certificate request" \
4349 -C "skip write certificate" \
4350 -C "skip write certificate verify" \
4351 -S "skip parse certificate verify"
4352
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004353requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004354run_test "SNI: DTLS, client auth override: optional -> none" \
4355 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4356 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4357 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4358 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4359 0 \
4360 -s "skip write certificate request" \
4361 -C "skip parse certificate request" \
4362 -c "got no certificate request" \
4363 -c "skip write certificate" \
4364 -c "skip write certificate verify" \
4365 -s "skip parse certificate verify"
4366
Hanno Becker4a156fc2019-06-14 17:07:06 +01004367requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004368requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004369requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004370run_test "SNI: DTLS, CA no override" \
4371 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4372 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4373 ca_file=data_files/test-ca.crt \
4374 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4375 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4376 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4377 1 \
4378 -S "skip write certificate request" \
4379 -C "skip parse certificate request" \
4380 -c "got a certificate request" \
4381 -C "skip write certificate" \
4382 -C "skip write certificate verify" \
4383 -S "skip parse certificate verify" \
4384 -s "x509_verify_cert() returned" \
4385 -s "! The certificate is not correctly signed by the trusted CA" \
4386 -S "The certificate has been revoked (is on a CRL)"
4387
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004388requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004389run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004390 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4391 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4392 ca_file=data_files/test-ca.crt \
4393 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4394 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4395 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4396 0 \
4397 -S "skip write certificate request" \
4398 -C "skip parse certificate request" \
4399 -c "got a certificate request" \
4400 -C "skip write certificate" \
4401 -C "skip write certificate verify" \
4402 -S "skip parse certificate verify" \
4403 -S "x509_verify_cert() returned" \
4404 -S "! The certificate is not correctly signed by the trusted CA" \
4405 -S "The certificate has been revoked (is on a CRL)"
4406
Hanno Becker4a156fc2019-06-14 17:07:06 +01004407requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004408requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004409requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004410run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004411 "$P_SRV debug_level=3 auth_mode=optional \
4412 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4413 ca_file=data_files/test-ca.crt \
4414 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4415 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4416 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4417 1 \
4418 -S "skip write certificate request" \
4419 -C "skip parse certificate request" \
4420 -c "got a certificate request" \
4421 -C "skip write certificate" \
4422 -C "skip write certificate verify" \
4423 -S "skip parse certificate verify" \
4424 -s "x509_verify_cert() returned" \
4425 -S "! The certificate is not correctly signed by the trusted CA" \
4426 -s "The certificate has been revoked (is on a CRL)"
4427
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004428# Tests for non-blocking I/O: exercise a variety of handshake flows
4429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004430run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004431 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4432 "$P_CLI nbio=2 tickets=0" \
4433 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004434 -S "mbedtls_ssl_handshake returned" \
4435 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004436 -c "Read from server: .* bytes read"
4437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004438run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004439 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4440 "$P_CLI nbio=2 tickets=0" \
4441 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004442 -S "mbedtls_ssl_handshake returned" \
4443 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004444 -c "Read from server: .* bytes read"
4445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004446run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004447 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4448 "$P_CLI nbio=2 tickets=1" \
4449 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004450 -S "mbedtls_ssl_handshake returned" \
4451 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004452 -c "Read from server: .* bytes read"
4453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004454run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004455 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4456 "$P_CLI nbio=2 tickets=1" \
4457 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004458 -S "mbedtls_ssl_handshake returned" \
4459 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004460 -c "Read from server: .* bytes read"
4461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004462run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004463 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4464 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4465 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004466 -S "mbedtls_ssl_handshake returned" \
4467 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004468 -c "Read from server: .* bytes read"
4469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004470run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004471 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4472 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4473 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004474 -S "mbedtls_ssl_handshake returned" \
4475 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004476 -c "Read from server: .* bytes read"
4477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004478run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004479 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4480 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4481 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004482 -S "mbedtls_ssl_handshake returned" \
4483 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004484 -c "Read from server: .* bytes read"
4485
Hanno Becker00076712017-11-15 16:39:08 +00004486# Tests for event-driven I/O: exercise a variety of handshake flows
4487
4488run_test "Event-driven I/O: basic handshake" \
4489 "$P_SRV event=1 tickets=0 auth_mode=none" \
4490 "$P_CLI event=1 tickets=0" \
4491 0 \
4492 -S "mbedtls_ssl_handshake returned" \
4493 -C "mbedtls_ssl_handshake returned" \
4494 -c "Read from server: .* bytes read"
4495
4496run_test "Event-driven I/O: client auth" \
4497 "$P_SRV event=1 tickets=0 auth_mode=required" \
4498 "$P_CLI event=1 tickets=0" \
4499 0 \
4500 -S "mbedtls_ssl_handshake returned" \
4501 -C "mbedtls_ssl_handshake returned" \
4502 -c "Read from server: .* bytes read"
4503
4504run_test "Event-driven I/O: ticket" \
4505 "$P_SRV event=1 tickets=1 auth_mode=none" \
4506 "$P_CLI event=1 tickets=1" \
4507 0 \
4508 -S "mbedtls_ssl_handshake returned" \
4509 -C "mbedtls_ssl_handshake returned" \
4510 -c "Read from server: .* bytes read"
4511
4512run_test "Event-driven I/O: ticket + client auth" \
4513 "$P_SRV event=1 tickets=1 auth_mode=required" \
4514 "$P_CLI event=1 tickets=1" \
4515 0 \
4516 -S "mbedtls_ssl_handshake returned" \
4517 -C "mbedtls_ssl_handshake returned" \
4518 -c "Read from server: .* bytes read"
4519
4520run_test "Event-driven I/O: ticket + client auth + resume" \
4521 "$P_SRV event=1 tickets=1 auth_mode=required" \
4522 "$P_CLI event=1 tickets=1 reconnect=1" \
4523 0 \
4524 -S "mbedtls_ssl_handshake returned" \
4525 -C "mbedtls_ssl_handshake returned" \
4526 -c "Read from server: .* bytes read"
4527
4528run_test "Event-driven I/O: ticket + resume" \
4529 "$P_SRV event=1 tickets=1 auth_mode=none" \
4530 "$P_CLI event=1 tickets=1 reconnect=1" \
4531 0 \
4532 -S "mbedtls_ssl_handshake returned" \
4533 -C "mbedtls_ssl_handshake returned" \
4534 -c "Read from server: .* bytes read"
4535
4536run_test "Event-driven I/O: session-id resume" \
4537 "$P_SRV event=1 tickets=0 auth_mode=none" \
4538 "$P_CLI event=1 tickets=0 reconnect=1" \
4539 0 \
4540 -S "mbedtls_ssl_handshake returned" \
4541 -C "mbedtls_ssl_handshake returned" \
4542 -c "Read from server: .* bytes read"
4543
Hanno Becker6a33f592018-03-13 11:38:46 +00004544run_test "Event-driven I/O, DTLS: basic handshake" \
4545 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4546 "$P_CLI dtls=1 event=1 tickets=0" \
4547 0 \
4548 -c "Read from server: .* bytes read"
4549
4550run_test "Event-driven I/O, DTLS: client auth" \
4551 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4552 "$P_CLI dtls=1 event=1 tickets=0" \
4553 0 \
4554 -c "Read from server: .* bytes read"
4555
4556run_test "Event-driven I/O, DTLS: ticket" \
4557 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4558 "$P_CLI dtls=1 event=1 tickets=1" \
4559 0 \
4560 -c "Read from server: .* bytes read"
4561
4562run_test "Event-driven I/O, DTLS: ticket + client auth" \
4563 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4564 "$P_CLI dtls=1 event=1 tickets=1" \
4565 0 \
4566 -c "Read from server: .* bytes read"
4567
4568run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4569 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4570 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4571 0 \
4572 -c "Read from server: .* bytes read"
4573
4574run_test "Event-driven I/O, DTLS: ticket + resume" \
4575 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4576 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4577 0 \
4578 -c "Read from server: .* bytes read"
4579
4580run_test "Event-driven I/O, DTLS: session-id resume" \
4581 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4582 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4583 0 \
4584 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004585
4586# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4587# During session resumption, the client will send its ApplicationData record
4588# within the same datagram as the Finished messages. In this situation, the
4589# server MUST NOT idle on the underlying transport after handshake completion,
4590# because the ApplicationData request has already been queued internally.
4591run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004592 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004593 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4594 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4595 0 \
4596 -c "Read from server: .* bytes read"
4597
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004598# Tests for version negotiation
4599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004600run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004601 "$P_SRV" \
4602 "$P_CLI" \
4603 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004604 -S "mbedtls_ssl_handshake returned" \
4605 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004606 -s "Protocol is TLSv1.2" \
4607 -c "Protocol is TLSv1.2"
4608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004609run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004610 "$P_SRV" \
4611 "$P_CLI max_version=tls1_1" \
4612 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004613 -S "mbedtls_ssl_handshake returned" \
4614 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004615 -s "Protocol is TLSv1.1" \
4616 -c "Protocol is TLSv1.1"
4617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004618run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004619 "$P_SRV max_version=tls1_1" \
4620 "$P_CLI" \
4621 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004622 -S "mbedtls_ssl_handshake returned" \
4623 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004624 -s "Protocol is TLSv1.1" \
4625 -c "Protocol is TLSv1.1"
4626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004627run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004628 "$P_SRV max_version=tls1_1" \
4629 "$P_CLI max_version=tls1_1" \
4630 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004631 -S "mbedtls_ssl_handshake returned" \
4632 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004633 -s "Protocol is TLSv1.1" \
4634 -c "Protocol is TLSv1.1"
4635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004636run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004637 "$P_SRV min_version=tls1_1" \
4638 "$P_CLI max_version=tls1_1" \
4639 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004640 -S "mbedtls_ssl_handshake returned" \
4641 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004642 -s "Protocol is TLSv1.1" \
4643 -c "Protocol is TLSv1.1"
4644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004645run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004646 "$P_SRV max_version=tls1_1" \
4647 "$P_CLI min_version=tls1_1" \
4648 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004649 -S "mbedtls_ssl_handshake returned" \
4650 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004651 -s "Protocol is TLSv1.1" \
4652 -c "Protocol is TLSv1.1"
4653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004654run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004655 "$P_SRV max_version=tls1_1" \
4656 "$P_CLI min_version=tls1_2" \
4657 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004658 -s "mbedtls_ssl_handshake returned" \
4659 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004660 -c "SSL - Handshake protocol not within min/max boundaries"
4661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004662run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004663 "$P_SRV min_version=tls1_2" \
4664 "$P_CLI max_version=tls1_1" \
4665 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004666 -s "mbedtls_ssl_handshake returned" \
4667 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004668 -s "SSL - Handshake protocol not within min/max boundaries"
4669
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004670# Tests for ALPN extension
4671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004672run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004673 "$P_SRV debug_level=3" \
4674 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004675 0 \
4676 -C "client hello, adding alpn extension" \
4677 -S "found alpn extension" \
4678 -C "got an alert message, type: \\[2:120]" \
4679 -S "server hello, adding alpn extension" \
4680 -C "found alpn extension " \
4681 -C "Application Layer Protocol is" \
4682 -S "Application Layer Protocol is"
4683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004684run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004685 "$P_SRV debug_level=3" \
4686 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004687 0 \
4688 -c "client hello, adding alpn extension" \
4689 -s "found alpn extension" \
4690 -C "got an alert message, type: \\[2:120]" \
4691 -S "server hello, adding alpn extension" \
4692 -C "found alpn extension " \
4693 -c "Application Layer Protocol is (none)" \
4694 -S "Application Layer Protocol is"
4695
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004696run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004697 "$P_SRV debug_level=3 alpn=abc,1234" \
4698 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004699 0 \
4700 -C "client hello, adding alpn extension" \
4701 -S "found alpn extension" \
4702 -C "got an alert message, type: \\[2:120]" \
4703 -S "server hello, adding alpn extension" \
4704 -C "found alpn extension " \
4705 -C "Application Layer Protocol is" \
4706 -s "Application Layer Protocol is (none)"
4707
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004708run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004709 "$P_SRV debug_level=3 alpn=abc,1234" \
4710 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004711 0 \
4712 -c "client hello, adding alpn extension" \
4713 -s "found alpn extension" \
4714 -C "got an alert message, type: \\[2:120]" \
4715 -s "server hello, adding alpn extension" \
4716 -c "found alpn extension" \
4717 -c "Application Layer Protocol is abc" \
4718 -s "Application Layer Protocol is abc"
4719
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004720run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004721 "$P_SRV debug_level=3 alpn=abc,1234" \
4722 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004723 0 \
4724 -c "client hello, adding alpn extension" \
4725 -s "found alpn extension" \
4726 -C "got an alert message, type: \\[2:120]" \
4727 -s "server hello, adding alpn extension" \
4728 -c "found alpn extension" \
4729 -c "Application Layer Protocol is abc" \
4730 -s "Application Layer Protocol is abc"
4731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004732run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004733 "$P_SRV debug_level=3 alpn=abc,1234" \
4734 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004735 0 \
4736 -c "client hello, adding alpn extension" \
4737 -s "found alpn extension" \
4738 -C "got an alert message, type: \\[2:120]" \
4739 -s "server hello, adding alpn extension" \
4740 -c "found alpn extension" \
4741 -c "Application Layer Protocol is 1234" \
4742 -s "Application Layer Protocol is 1234"
4743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004744run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004745 "$P_SRV debug_level=3 alpn=abc,123" \
4746 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004747 1 \
4748 -c "client hello, adding alpn extension" \
4749 -s "found alpn extension" \
4750 -c "got an alert message, type: \\[2:120]" \
4751 -S "server hello, adding alpn extension" \
4752 -C "found alpn extension" \
4753 -C "Application Layer Protocol is 1234" \
4754 -S "Application Layer Protocol is 1234"
4755
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02004756
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004757# Tests for keyUsage in leaf certificates, part 1:
4758# server-side certificate/suite selection
4759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004760run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004761 "$P_SRV key_file=data_files/server2.key \
4762 crt_file=data_files/server2.ku-ds.crt" \
4763 "$P_CLI" \
4764 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02004765 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004766
4767
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004768run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004769 "$P_SRV key_file=data_files/server2.key \
4770 crt_file=data_files/server2.ku-ke.crt" \
4771 "$P_CLI" \
4772 0 \
4773 -c "Ciphersuite is TLS-RSA-WITH-"
4774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004775run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004776 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004777 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004778 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004779 1 \
4780 -C "Ciphersuite is "
4781
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004782run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004783 "$P_SRV key_file=data_files/server5.key \
4784 crt_file=data_files/server5.ku-ds.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004785 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004786 0 \
4787 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
4788
4789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004790run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004791 "$P_SRV key_file=data_files/server5.key \
4792 crt_file=data_files/server5.ku-ka.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004793 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004794 0 \
4795 -c "Ciphersuite is TLS-ECDH-"
4796
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004797run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004798 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004799 crt_file=data_files/server5.ku-ke.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004800 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004801 1 \
4802 -C "Ciphersuite is "
4803
4804# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004805# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004807run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004808 "$O_SRV -key data_files/server2.key \
4809 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004810 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004811 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4812 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004813 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004814 -C "Processing of the Certificate handshake message failed" \
4815 -c "Ciphersuite is TLS-"
4816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004817run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004818 "$O_SRV -key data_files/server2.key \
4819 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004820 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004821 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4822 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004823 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004824 -C "Processing of the Certificate handshake message failed" \
4825 -c "Ciphersuite is TLS-"
4826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004827run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004828 "$O_SRV -key data_files/server2.key \
4829 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004830 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004831 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4832 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004833 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004834 -C "Processing of the Certificate handshake message failed" \
4835 -c "Ciphersuite is TLS-"
4836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004837run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004838 "$O_SRV -key data_files/server2.key \
4839 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004840 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004841 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4842 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004843 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004844 -c "Processing of the Certificate handshake message failed" \
4845 -C "Ciphersuite is TLS-"
4846
Hanno Becker4a156fc2019-06-14 17:07:06 +01004847requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004848requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004849run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
4850 "$O_SRV -key data_files/server2.key \
4851 -cert data_files/server2.ku-ke.crt" \
4852 "$P_CLI debug_level=1 auth_mode=optional \
4853 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4854 0 \
4855 -c "bad certificate (usage extensions)" \
4856 -C "Processing of the Certificate handshake message failed" \
4857 -c "Ciphersuite is TLS-" \
4858 -c "! Usage does not match the keyUsage extension"
4859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004860run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004861 "$O_SRV -key data_files/server2.key \
4862 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004863 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004864 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4865 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004866 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004867 -C "Processing of the Certificate handshake message failed" \
4868 -c "Ciphersuite is TLS-"
4869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004870run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004871 "$O_SRV -key data_files/server2.key \
4872 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004873 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004874 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4875 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004876 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004877 -c "Processing of the Certificate handshake message failed" \
4878 -C "Ciphersuite is TLS-"
4879
Hanno Becker4a156fc2019-06-14 17:07:06 +01004880requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004881requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004882run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
4883 "$O_SRV -key data_files/server2.key \
4884 -cert data_files/server2.ku-ds.crt" \
4885 "$P_CLI debug_level=1 auth_mode=optional \
4886 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4887 0 \
4888 -c "bad certificate (usage extensions)" \
4889 -C "Processing of the Certificate handshake message failed" \
4890 -c "Ciphersuite is TLS-" \
4891 -c "! Usage does not match the keyUsage extension"
4892
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004893# Tests for keyUsage in leaf certificates, part 3:
4894# server-side checking of client cert
4895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004896run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004897 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004898 "$O_CLI -key data_files/server2.key \
4899 -cert data_files/server2.ku-ds.crt" \
4900 0 \
4901 -S "bad certificate (usage extensions)" \
4902 -S "Processing of the Certificate handshake message failed"
4903
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004904run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004905 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004906 "$O_CLI -key data_files/server2.key \
4907 -cert data_files/server2.ku-ke.crt" \
4908 0 \
4909 -s "bad certificate (usage extensions)" \
4910 -S "Processing of the Certificate handshake message failed"
4911
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004912run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004913 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004914 "$O_CLI -key data_files/server2.key \
4915 -cert data_files/server2.ku-ke.crt" \
4916 1 \
4917 -s "bad certificate (usage extensions)" \
4918 -s "Processing of the Certificate handshake message failed"
4919
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004920run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004921 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004922 "$O_CLI -key data_files/server5.key \
4923 -cert data_files/server5.ku-ds.crt" \
4924 0 \
4925 -S "bad certificate (usage extensions)" \
4926 -S "Processing of the Certificate handshake message failed"
4927
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004928run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004929 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004930 "$O_CLI -key data_files/server5.key \
4931 -cert data_files/server5.ku-ka.crt" \
4932 0 \
4933 -s "bad certificate (usage extensions)" \
4934 -S "Processing of the Certificate handshake message failed"
4935
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004936# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
4937
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004938run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004939 "$P_SRV key_file=data_files/server5.key \
4940 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004941 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004942 0
4943
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004944run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004945 "$P_SRV key_file=data_files/server5.key \
4946 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004947 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004948 0
4949
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004950run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004951 "$P_SRV key_file=data_files/server5.key \
4952 crt_file=data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004953 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004954 0
4955
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004956run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02004957 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004958 crt_file=data_files/server5.eku-cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004959 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004960 1
4961
4962# Tests for extendedKeyUsage, part 2: client-side checking of server cert
4963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004964run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004965 "$O_SRV -key data_files/server5.key \
4966 -cert data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004967 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004968 0 \
4969 -C "bad certificate (usage extensions)" \
4970 -C "Processing of the Certificate handshake message failed" \
4971 -c "Ciphersuite is TLS-"
4972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004973run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004974 "$O_SRV -key data_files/server5.key \
4975 -cert data_files/server5.eku-srv_cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004976 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004977 0 \
4978 -C "bad certificate (usage extensions)" \
4979 -C "Processing of the Certificate handshake message failed" \
4980 -c "Ciphersuite is TLS-"
4981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004982run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004983 "$O_SRV -key data_files/server5.key \
4984 -cert data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004985 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004986 0 \
4987 -C "bad certificate (usage extensions)" \
4988 -C "Processing of the Certificate handshake message failed" \
4989 -c "Ciphersuite is TLS-"
4990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004991run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004992 "$O_SRV -key data_files/server5.key \
4993 -cert data_files/server5.eku-cs.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004994 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004995 1 \
4996 -c "bad certificate (usage extensions)" \
4997 -c "Processing of the Certificate handshake message failed" \
4998 -C "Ciphersuite is TLS-"
4999
5000# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005002run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005003 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005004 "$O_CLI -key data_files/server5.key \
5005 -cert data_files/server5.eku-cli.crt" \
5006 0 \
5007 -S "bad certificate (usage extensions)" \
5008 -S "Processing of the Certificate handshake message failed"
5009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005010run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005011 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005012 "$O_CLI -key data_files/server5.key \
5013 -cert data_files/server5.eku-srv_cli.crt" \
5014 0 \
5015 -S "bad certificate (usage extensions)" \
5016 -S "Processing of the Certificate handshake message failed"
5017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005018run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005019 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005020 "$O_CLI -key data_files/server5.key \
5021 -cert data_files/server5.eku-cs_any.crt" \
5022 0 \
5023 -S "bad certificate (usage extensions)" \
5024 -S "Processing of the Certificate handshake message failed"
5025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005026run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005027 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005028 "$O_CLI -key data_files/server5.key \
5029 -cert data_files/server5.eku-cs.crt" \
5030 0 \
5031 -s "bad certificate (usage extensions)" \
5032 -S "Processing of the Certificate handshake message failed"
5033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005034run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005035 "$P_SRV debug_level=1 auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005036 "$O_CLI -key data_files/server5.key \
5037 -cert data_files/server5.eku-cs.crt" \
5038 1 \
5039 -s "bad certificate (usage extensions)" \
5040 -s "Processing of the Certificate handshake message failed"
5041
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005042# Tests for DHM parameters loading
5043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005044run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005045 "$P_SRV" \
5046 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5047 debug_level=3" \
5048 0 \
5049 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005050 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005052run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005053 "$P_SRV dhm_file=data_files/dhparams.pem" \
5054 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5055 debug_level=3" \
5056 0 \
5057 -c "value of 'DHM: P ' (1024 bits)" \
5058 -c "value of 'DHM: G ' (2 bits)"
5059
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005060# Tests for DHM client-side size checking
5061
5062run_test "DHM size: server default, client default, OK" \
5063 "$P_SRV" \
5064 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5065 debug_level=1" \
5066 0 \
5067 -C "DHM prime too short:"
5068
5069run_test "DHM size: server default, client 2048, OK" \
5070 "$P_SRV" \
5071 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5072 debug_level=1 dhmlen=2048" \
5073 0 \
5074 -C "DHM prime too short:"
5075
5076run_test "DHM size: server 1024, client default, OK" \
5077 "$P_SRV dhm_file=data_files/dhparams.pem" \
5078 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5079 debug_level=1" \
5080 0 \
5081 -C "DHM prime too short:"
5082
5083run_test "DHM size: server 1000, client default, rejected" \
5084 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5085 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5086 debug_level=1" \
5087 1 \
5088 -c "DHM prime too short:"
5089
5090run_test "DHM size: server default, client 2049, rejected" \
5091 "$P_SRV" \
5092 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5093 debug_level=1 dhmlen=2049" \
5094 1 \
5095 -c "DHM prime too short:"
5096
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005097# Tests for PSK callback
5098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005099run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005100 "$P_SRV psk=abc123 psk_identity=foo" \
5101 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5102 psk_identity=foo psk=abc123" \
5103 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005104 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005105 -S "SSL - Unknown identity received" \
5106 -S "SSL - Verification of the message MAC failed"
5107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005108run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005109 "$P_SRV" \
5110 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5111 psk_identity=foo psk=abc123" \
5112 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005113 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005114 -S "SSL - Unknown identity received" \
5115 -S "SSL - Verification of the message MAC failed"
5116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005117run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005118 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5119 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5120 psk_identity=foo psk=abc123" \
5121 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005122 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005123 -s "SSL - Unknown identity received" \
5124 -S "SSL - Verification of the message MAC failed"
5125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005126run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005127 "$P_SRV psk_list=abc,dead,def,beef" \
5128 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5129 psk_identity=abc psk=dead" \
5130 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005131 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005132 -S "SSL - Unknown identity received" \
5133 -S "SSL - Verification of the message MAC failed"
5134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005135run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005136 "$P_SRV psk_list=abc,dead,def,beef" \
5137 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5138 psk_identity=def psk=beef" \
5139 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005140 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005141 -S "SSL - Unknown identity received" \
5142 -S "SSL - Verification of the message MAC failed"
5143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005144run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005145 "$P_SRV psk_list=abc,dead,def,beef" \
5146 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5147 psk_identity=ghi psk=beef" \
5148 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005149 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005150 -s "SSL - Unknown identity received" \
5151 -S "SSL - Verification of the message MAC failed"
5152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005153run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005154 "$P_SRV psk_list=abc,dead,def,beef" \
5155 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5156 psk_identity=abc psk=beef" \
5157 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005158 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005159 -S "SSL - Unknown identity received" \
5160 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005161
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005162# Tests for EC J-PAKE
5163
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005164requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005165run_test "ECJPAKE: client not configured" \
5166 "$P_SRV debug_level=3" \
5167 "$P_CLI debug_level=3" \
5168 0 \
5169 -C "add ciphersuite: c0ff" \
5170 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005171 -S "found ecjpake kkpp extension" \
5172 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005173 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005174 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005175 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005176 -S "None of the common ciphersuites is usable"
5177
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005178requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005179run_test "ECJPAKE: server not configured" \
5180 "$P_SRV debug_level=3" \
5181 "$P_CLI debug_level=3 ecjpake_pw=bla \
5182 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5183 1 \
5184 -c "add ciphersuite: c0ff" \
5185 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005186 -s "found ecjpake kkpp extension" \
5187 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005188 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005189 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005190 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005191 -s "None of the common ciphersuites is usable"
5192
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005193requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005194run_test "ECJPAKE: working, TLS" \
5195 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5196 "$P_CLI debug_level=3 ecjpake_pw=bla \
5197 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005198 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005199 -c "add ciphersuite: c0ff" \
5200 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005201 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005202 -s "found ecjpake kkpp extension" \
5203 -S "skip ecjpake kkpp extension" \
5204 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005205 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005206 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005207 -S "None of the common ciphersuites is usable" \
5208 -S "SSL - Verification of the message MAC failed"
5209
Janos Follath74537a62016-09-02 13:45:28 +01005210server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005211requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005212run_test "ECJPAKE: password mismatch, TLS" \
5213 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5214 "$P_CLI debug_level=3 ecjpake_pw=bad \
5215 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5216 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005217 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005218 -s "SSL - Verification of the message MAC failed"
5219
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005220requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005221run_test "ECJPAKE: working, DTLS" \
5222 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5223 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5224 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5225 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005226 -c "re-using cached ecjpake parameters" \
5227 -S "SSL - Verification of the message MAC failed"
5228
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005229requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005230run_test "ECJPAKE: working, DTLS, no cookie" \
5231 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5232 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5233 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5234 0 \
5235 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005236 -S "SSL - Verification of the message MAC failed"
5237
Janos Follath74537a62016-09-02 13:45:28 +01005238server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005239requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005240run_test "ECJPAKE: password mismatch, DTLS" \
5241 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5242 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5243 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5244 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005245 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005246 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005247
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005248# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005249requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005250run_test "ECJPAKE: working, DTLS, nolog" \
5251 "$P_SRV dtls=1 ecjpake_pw=bla" \
5252 "$P_CLI dtls=1 ecjpake_pw=bla \
5253 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5254 0
5255
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005256# Tests for ciphersuites per version
5257
Janos Follathe2681a42016-03-07 15:57:05 +00005258requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005259requires_config_enabled MBEDTLS_CAMELLIA_C
5260requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005261run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005262 "$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 +02005263 "$P_CLI force_version=ssl3" \
5264 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005265 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005266
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005267requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5268requires_config_enabled MBEDTLS_CAMELLIA_C
5269requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005270run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005271 "$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 +01005272 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005273 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005274 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005275
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005276requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5277requires_config_enabled MBEDTLS_CAMELLIA_C
5278requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005279run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005280 "$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 +02005281 "$P_CLI force_version=tls1_1" \
5282 0 \
5283 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5284
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005285requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5286requires_config_enabled MBEDTLS_CAMELLIA_C
5287requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005288run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005289 "$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 +02005290 "$P_CLI force_version=tls1_2" \
5291 0 \
5292 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5293
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005294# Test for ClientHello without extensions
5295
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005296requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005297run_test "ClientHello without extensions, SHA-1 allowed" \
Ron Eldorb76e7652019-01-16 23:14:41 +02005298 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005299 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005300 0 \
5301 -s "dumping 'client hello extensions' (0 bytes)"
5302
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005303requires_gnutls
5304run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
5305 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005306 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005307 0 \
5308 -s "dumping 'client hello extensions' (0 bytes)"
5309
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005310# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005311
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005312run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005313 "$P_SRV" \
5314 "$P_CLI request_size=100" \
5315 0 \
5316 -s "Read from client: 100 bytes read$"
5317
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005318run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005319 "$P_SRV" \
5320 "$P_CLI request_size=500" \
5321 0 \
5322 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005323
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005324# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005325
Janos Follathe2681a42016-03-07 15:57:05 +00005326requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005327run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005328 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005329 "$P_CLI request_size=1 force_version=ssl3 \
5330 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5331 0 \
5332 -s "Read from client: 1 bytes read"
5333
Janos Follathe2681a42016-03-07 15:57:05 +00005334requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005335run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005336 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005337 "$P_CLI request_size=1 force_version=ssl3 \
5338 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5339 0 \
5340 -s "Read from client: 1 bytes read"
5341
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005342run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005343 "$P_SRV" \
5344 "$P_CLI request_size=1 force_version=tls1 \
5345 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5346 0 \
5347 -s "Read from client: 1 bytes read"
5348
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005349run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005350 "$P_SRV" \
5351 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5352 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5353 0 \
5354 -s "Read from client: 1 bytes read"
5355
Hanno Becker32c55012017-11-10 08:42:54 +00005356requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005357run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005358 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005359 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005360 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005361 0 \
5362 -s "Read from client: 1 bytes read"
5363
Hanno Becker32c55012017-11-10 08:42:54 +00005364requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005365run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005366 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005367 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005368 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005369 0 \
5370 -s "Read from client: 1 bytes read"
5371
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005372run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005373 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005374 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005375 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5376 0 \
5377 -s "Read from client: 1 bytes read"
5378
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005379run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005380 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5381 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005382 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005383 0 \
5384 -s "Read from client: 1 bytes read"
5385
5386requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005387run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005388 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005389 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005390 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005391 0 \
5392 -s "Read from client: 1 bytes read"
5393
Hanno Becker8501f982017-11-10 08:59:04 +00005394requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005395run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005396 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5397 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5398 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005399 0 \
5400 -s "Read from client: 1 bytes read"
5401
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005402run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005403 "$P_SRV" \
5404 "$P_CLI request_size=1 force_version=tls1_1 \
5405 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5406 0 \
5407 -s "Read from client: 1 bytes read"
5408
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005409run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005410 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005411 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005412 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005413 0 \
5414 -s "Read from client: 1 bytes read"
5415
5416requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005417run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005418 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005419 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005420 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005421 0 \
5422 -s "Read from client: 1 bytes read"
5423
5424requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005425run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005426 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005427 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005428 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005429 0 \
5430 -s "Read from client: 1 bytes read"
5431
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005432run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005433 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005434 "$P_CLI request_size=1 force_version=tls1_1 \
5435 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5436 0 \
5437 -s "Read from client: 1 bytes read"
5438
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005439run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005440 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005441 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005442 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005443 0 \
5444 -s "Read from client: 1 bytes read"
5445
Hanno Becker8501f982017-11-10 08:59:04 +00005446requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005447run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005448 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005449 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005450 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005451 0 \
5452 -s "Read from client: 1 bytes read"
5453
Hanno Becker32c55012017-11-10 08:42:54 +00005454requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005455run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005456 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005457 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005458 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005459 0 \
5460 -s "Read from client: 1 bytes read"
5461
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005462run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005463 "$P_SRV" \
5464 "$P_CLI request_size=1 force_version=tls1_2 \
5465 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5466 0 \
5467 -s "Read from client: 1 bytes read"
5468
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005469run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005470 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005471 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005472 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005473 0 \
5474 -s "Read from client: 1 bytes read"
5475
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005476run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005477 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005478 "$P_CLI request_size=1 force_version=tls1_2 \
5479 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005480 0 \
5481 -s "Read from client: 1 bytes read"
5482
Hanno Becker32c55012017-11-10 08:42:54 +00005483requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005484run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005485 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005486 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005487 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005488 0 \
5489 -s "Read from client: 1 bytes read"
5490
Hanno Becker8501f982017-11-10 08:59:04 +00005491requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005492run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005493 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005494 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005495 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005496 0 \
5497 -s "Read from client: 1 bytes read"
5498
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005499run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005500 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005501 "$P_CLI request_size=1 force_version=tls1_2 \
5502 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5503 0 \
5504 -s "Read from client: 1 bytes read"
5505
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005506run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005507 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005508 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005509 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005510 0 \
5511 -s "Read from client: 1 bytes read"
5512
Hanno Becker32c55012017-11-10 08:42:54 +00005513requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005514run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005515 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005516 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005517 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005518 0 \
5519 -s "Read from client: 1 bytes read"
5520
Hanno Becker8501f982017-11-10 08:59:04 +00005521requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005522run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005523 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005524 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005525 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005526 0 \
5527 -s "Read from client: 1 bytes read"
5528
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005529run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005530 "$P_SRV" \
5531 "$P_CLI request_size=1 force_version=tls1_2 \
5532 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5533 0 \
5534 -s "Read from client: 1 bytes read"
5535
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005536run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005537 "$P_SRV" \
5538 "$P_CLI request_size=1 force_version=tls1_2 \
5539 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5540 0 \
5541 -s "Read from client: 1 bytes read"
5542
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005543# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005544
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005545run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005546 "$P_SRV dtls=1 force_version=dtls1" \
5547 "$P_CLI dtls=1 request_size=1 \
5548 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5549 0 \
5550 -s "Read from client: 1 bytes read"
5551
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005552run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00005553 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
5554 "$P_CLI dtls=1 request_size=1 \
5555 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5556 0 \
5557 -s "Read from client: 1 bytes read"
5558
Hanno Beckere2148042017-11-10 08:59:18 +00005559requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005560run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005561 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
5562 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00005563 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5564 0 \
5565 -s "Read from client: 1 bytes read"
5566
Hanno Beckere2148042017-11-10 08:59:18 +00005567requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005568run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005569 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005570 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005571 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005572 0 \
5573 -s "Read from client: 1 bytes read"
5574
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005575run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00005576 "$P_SRV dtls=1 force_version=dtls1_2" \
5577 "$P_CLI dtls=1 request_size=1 \
5578 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5579 0 \
5580 -s "Read from client: 1 bytes read"
5581
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005582run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005583 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005584 "$P_CLI dtls=1 request_size=1 \
5585 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5586 0 \
5587 -s "Read from client: 1 bytes read"
5588
Hanno Beckere2148042017-11-10 08:59:18 +00005589requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005590run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005591 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005592 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005593 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005594 0 \
5595 -s "Read from client: 1 bytes read"
5596
Hanno Beckere2148042017-11-10 08:59:18 +00005597requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005598run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005599 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005600 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005601 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005602 0 \
5603 -s "Read from client: 1 bytes read"
5604
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005605# Tests for small server packets
5606
5607requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5608run_test "Small server packet SSLv3 BlockCipher" \
5609 "$P_SRV response_size=1 min_version=ssl3" \
5610 "$P_CLI force_version=ssl3 \
5611 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5612 0 \
5613 -c "Read from server: 1 bytes read"
5614
5615requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5616run_test "Small server packet SSLv3 StreamCipher" \
5617 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5618 "$P_CLI force_version=ssl3 \
5619 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5620 0 \
5621 -c "Read from server: 1 bytes read"
5622
5623run_test "Small server packet TLS 1.0 BlockCipher" \
5624 "$P_SRV response_size=1" \
5625 "$P_CLI force_version=tls1 \
5626 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5627 0 \
5628 -c "Read from server: 1 bytes read"
5629
5630run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
5631 "$P_SRV response_size=1" \
5632 "$P_CLI force_version=tls1 etm=0 \
5633 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5634 0 \
5635 -c "Read from server: 1 bytes read"
5636
5637requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5638run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
5639 "$P_SRV response_size=1 trunc_hmac=1" \
5640 "$P_CLI force_version=tls1 \
5641 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5642 0 \
5643 -c "Read from server: 1 bytes read"
5644
5645requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5646run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
5647 "$P_SRV response_size=1 trunc_hmac=1" \
5648 "$P_CLI force_version=tls1 \
5649 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5650 0 \
5651 -c "Read from server: 1 bytes read"
5652
5653run_test "Small server packet TLS 1.0 StreamCipher" \
5654 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5655 "$P_CLI force_version=tls1 \
5656 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5657 0 \
5658 -c "Read from server: 1 bytes read"
5659
5660run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
5661 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5662 "$P_CLI force_version=tls1 \
5663 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5664 0 \
5665 -c "Read from server: 1 bytes read"
5666
5667requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5668run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
5669 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5670 "$P_CLI force_version=tls1 \
5671 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5672 0 \
5673 -c "Read from server: 1 bytes read"
5674
5675requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5676run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5677 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5678 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5679 trunc_hmac=1 etm=0" \
5680 0 \
5681 -c "Read from server: 1 bytes read"
5682
5683run_test "Small server packet TLS 1.1 BlockCipher" \
5684 "$P_SRV response_size=1" \
5685 "$P_CLI force_version=tls1_1 \
5686 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5687 0 \
5688 -c "Read from server: 1 bytes read"
5689
5690run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
5691 "$P_SRV response_size=1" \
5692 "$P_CLI force_version=tls1_1 \
5693 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5694 0 \
5695 -c "Read from server: 1 bytes read"
5696
5697requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5698run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
5699 "$P_SRV response_size=1 trunc_hmac=1" \
5700 "$P_CLI force_version=tls1_1 \
5701 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5702 0 \
5703 -c "Read from server: 1 bytes read"
5704
5705requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5706run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5707 "$P_SRV response_size=1 trunc_hmac=1" \
5708 "$P_CLI force_version=tls1_1 \
5709 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5710 0 \
5711 -c "Read from server: 1 bytes read"
5712
5713run_test "Small server packet TLS 1.1 StreamCipher" \
5714 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5715 "$P_CLI force_version=tls1_1 \
5716 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5717 0 \
5718 -c "Read from server: 1 bytes read"
5719
5720run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
5721 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5722 "$P_CLI force_version=tls1_1 \
5723 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5724 0 \
5725 -c "Read from server: 1 bytes read"
5726
5727requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5728run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
5729 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5730 "$P_CLI force_version=tls1_1 \
5731 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5732 0 \
5733 -c "Read from server: 1 bytes read"
5734
5735requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5736run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5737 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5738 "$P_CLI force_version=tls1_1 \
5739 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5740 0 \
5741 -c "Read from server: 1 bytes read"
5742
5743run_test "Small server packet TLS 1.2 BlockCipher" \
5744 "$P_SRV response_size=1" \
5745 "$P_CLI force_version=tls1_2 \
5746 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5747 0 \
5748 -c "Read from server: 1 bytes read"
5749
5750run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5751 "$P_SRV response_size=1" \
5752 "$P_CLI force_version=tls1_2 \
5753 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5754 0 \
5755 -c "Read from server: 1 bytes read"
5756
5757run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5758 "$P_SRV response_size=1" \
5759 "$P_CLI force_version=tls1_2 \
5760 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5761 0 \
5762 -c "Read from server: 1 bytes read"
5763
5764requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5765run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5766 "$P_SRV response_size=1 trunc_hmac=1" \
5767 "$P_CLI force_version=tls1_2 \
5768 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5769 0 \
5770 -c "Read from server: 1 bytes read"
5771
5772requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5773run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5774 "$P_SRV response_size=1 trunc_hmac=1" \
5775 "$P_CLI force_version=tls1_2 \
5776 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5777 0 \
5778 -c "Read from server: 1 bytes read"
5779
5780run_test "Small server packet TLS 1.2 StreamCipher" \
5781 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5782 "$P_CLI force_version=tls1_2 \
5783 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5784 0 \
5785 -c "Read from server: 1 bytes read"
5786
5787run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
5788 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5789 "$P_CLI force_version=tls1_2 \
5790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5791 0 \
5792 -c "Read from server: 1 bytes read"
5793
5794requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5795run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
5796 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5797 "$P_CLI force_version=tls1_2 \
5798 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5799 0 \
5800 -c "Read from server: 1 bytes read"
5801
5802requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5803run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5804 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5805 "$P_CLI force_version=tls1_2 \
5806 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5807 0 \
5808 -c "Read from server: 1 bytes read"
5809
5810run_test "Small server packet TLS 1.2 AEAD" \
5811 "$P_SRV response_size=1" \
5812 "$P_CLI force_version=tls1_2 \
5813 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5814 0 \
5815 -c "Read from server: 1 bytes read"
5816
5817run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5818 "$P_SRV response_size=1" \
5819 "$P_CLI force_version=tls1_2 \
5820 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5821 0 \
5822 -c "Read from server: 1 bytes read"
5823
5824# Tests for small server packets in DTLS
5825
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005826run_test "Small server packet DTLS 1.0" \
5827 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
5828 "$P_CLI dtls=1 \
5829 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5830 0 \
5831 -c "Read from server: 1 bytes read"
5832
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005833run_test "Small server packet DTLS 1.0, without EtM" \
5834 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
5835 "$P_CLI dtls=1 \
5836 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5837 0 \
5838 -c "Read from server: 1 bytes read"
5839
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005840requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5841run_test "Small server packet DTLS 1.0, truncated hmac" \
5842 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
5843 "$P_CLI dtls=1 trunc_hmac=1 \
5844 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5845 0 \
5846 -c "Read from server: 1 bytes read"
5847
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005848requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5849run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
5850 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
5851 "$P_CLI dtls=1 \
5852 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5853 0 \
5854 -c "Read from server: 1 bytes read"
5855
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005856run_test "Small server packet DTLS 1.2" \
5857 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
5858 "$P_CLI dtls=1 \
5859 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5860 0 \
5861 -c "Read from server: 1 bytes read"
5862
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005863run_test "Small server packet DTLS 1.2, without EtM" \
5864 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5865 "$P_CLI dtls=1 \
5866 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5867 0 \
5868 -c "Read from server: 1 bytes read"
5869
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005870requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5871run_test "Small server packet DTLS 1.2, truncated hmac" \
5872 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5873 "$P_CLI dtls=1 \
5874 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5875 0 \
5876 -c "Read from server: 1 bytes read"
5877
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005878requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5879run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5880 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5881 "$P_CLI dtls=1 \
5882 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5883 0 \
5884 -c "Read from server: 1 bytes read"
5885
Janos Follath00efff72016-05-06 13:48:23 +01005886# A test for extensions in SSLv3
5887
5888requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5889run_test "SSLv3 with extensions, server side" \
5890 "$P_SRV min_version=ssl3 debug_level=3" \
5891 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
5892 0 \
5893 -S "dumping 'client hello extensions'" \
5894 -S "server hello, total extension length:"
5895
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005896# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005897
Angus Grattonc4dd0732018-04-11 16:28:39 +10005898# How many fragments do we expect to write $1 bytes?
5899fragments_for_write() {
5900 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
5901}
5902
Janos Follathe2681a42016-03-07 15:57:05 +00005903requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005904run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005905 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005906 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005907 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5908 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005909 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5910 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005911
Janos Follathe2681a42016-03-07 15:57:05 +00005912requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005913run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005914 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005915 "$P_CLI request_size=16384 force_version=ssl3 \
5916 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5917 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005918 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5919 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005920
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005921run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005922 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005923 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005924 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5925 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005926 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5927 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005928
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005929run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005930 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005931 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
5932 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5933 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005934 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005935
Hanno Becker32c55012017-11-10 08:42:54 +00005936requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005937run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005938 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005939 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005940 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005941 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005942 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5943 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005944
Hanno Becker32c55012017-11-10 08:42:54 +00005945requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005946run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005947 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005948 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005949 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005950 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005951 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005952
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005953run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005954 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005955 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005956 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5957 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005958 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005959
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005960run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005961 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5962 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005963 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005964 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005965 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005966
5967requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005968run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005969 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005970 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005971 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005972 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005973 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005974
Hanno Becker278fc7a2017-11-10 09:16:28 +00005975requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005976run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005977 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005978 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005979 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005980 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005981 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5982 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005983
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005984run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005985 "$P_SRV" \
5986 "$P_CLI request_size=16384 force_version=tls1_1 \
5987 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5988 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005989 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5990 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005991
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005992run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005993 "$P_SRV" \
5994 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
5995 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005996 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005997 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005998
Hanno Becker32c55012017-11-10 08:42:54 +00005999requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006000run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006001 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006002 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006003 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006004 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006005 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006006
Hanno Becker32c55012017-11-10 08:42:54 +00006007requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006008run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006009 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006010 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006011 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006012 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006013 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006014
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006015run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006016 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6017 "$P_CLI request_size=16384 force_version=tls1_1 \
6018 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6019 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006020 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6021 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006022
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006023run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006024 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006025 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006026 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006027 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006028 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6029 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006030
Hanno Becker278fc7a2017-11-10 09:16:28 +00006031requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006032run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006033 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006034 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006035 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006036 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006037 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006038
Hanno Becker278fc7a2017-11-10 09:16:28 +00006039requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006040run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006041 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006042 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006043 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006044 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006045 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6046 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006047
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006048run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006049 "$P_SRV" \
6050 "$P_CLI request_size=16384 force_version=tls1_2 \
6051 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6052 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006053 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6054 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006055
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006056run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006057 "$P_SRV" \
6058 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6059 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6060 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006061 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006062
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006063run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006064 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006065 "$P_CLI request_size=16384 force_version=tls1_2 \
6066 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006067 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006068 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6069 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006070
Hanno Becker32c55012017-11-10 08:42:54 +00006071requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006072run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006073 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006074 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006075 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006076 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006077 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006078
Hanno Becker278fc7a2017-11-10 09:16:28 +00006079requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006080run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006081 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006082 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006083 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006084 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006085 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6086 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006087
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006088run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006089 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006090 "$P_CLI request_size=16384 force_version=tls1_2 \
6091 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6092 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006093 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6094 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006095
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006096run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006097 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006098 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006099 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6100 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006101 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006102
Hanno Becker32c55012017-11-10 08:42:54 +00006103requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006104run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006105 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006106 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006107 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006108 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006109 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006110
Hanno Becker278fc7a2017-11-10 09:16:28 +00006111requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006112run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006113 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006114 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006115 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006116 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006117 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6118 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006119
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006120run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006121 "$P_SRV" \
6122 "$P_CLI request_size=16384 force_version=tls1_2 \
6123 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6124 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006125 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6126 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006127
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006128run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006129 "$P_SRV" \
6130 "$P_CLI request_size=16384 force_version=tls1_2 \
6131 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6132 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006133 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6134 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006135
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006136# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006137requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6138run_test "Large server packet SSLv3 StreamCipher" \
6139 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6140 "$P_CLI force_version=ssl3 \
6141 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6142 0 \
6143 -c "Read from server: 16384 bytes read"
6144
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006145# Checking next 4 tests logs for 1n-1 split against BEAST too
6146requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6147run_test "Large server packet SSLv3 BlockCipher" \
6148 "$P_SRV response_size=16384 min_version=ssl3" \
6149 "$P_CLI force_version=ssl3 recsplit=0 \
6150 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6151 0 \
6152 -c "Read from server: 1 bytes read"\
6153 -c "16383 bytes read"\
6154 -C "Read from server: 16384 bytes read"
6155
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006156run_test "Large server packet TLS 1.0 BlockCipher" \
6157 "$P_SRV response_size=16384" \
6158 "$P_CLI force_version=tls1 recsplit=0 \
6159 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6160 0 \
6161 -c "Read from server: 1 bytes read"\
6162 -c "16383 bytes read"\
6163 -C "Read from server: 16384 bytes read"
6164
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006165run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6166 "$P_SRV response_size=16384" \
6167 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6168 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6169 0 \
6170 -c "Read from server: 1 bytes read"\
6171 -c "16383 bytes read"\
6172 -C "Read from server: 16384 bytes read"
6173
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006174requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6175run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6176 "$P_SRV response_size=16384" \
6177 "$P_CLI force_version=tls1 recsplit=0 \
6178 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6179 trunc_hmac=1" \
6180 0 \
6181 -c "Read from server: 1 bytes read"\
6182 -c "16383 bytes read"\
6183 -C "Read from server: 16384 bytes read"
6184
6185requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6186run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6187 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6188 "$P_CLI force_version=tls1 \
6189 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6190 trunc_hmac=1" \
6191 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006192 -s "16384 bytes written in 1 fragments" \
6193 -c "Read from server: 16384 bytes read"
6194
6195run_test "Large server packet TLS 1.0 StreamCipher" \
6196 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6197 "$P_CLI force_version=tls1 \
6198 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6199 0 \
6200 -s "16384 bytes written in 1 fragments" \
6201 -c "Read from server: 16384 bytes read"
6202
6203run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6204 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6205 "$P_CLI force_version=tls1 \
6206 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6207 0 \
6208 -s "16384 bytes written in 1 fragments" \
6209 -c "Read from server: 16384 bytes read"
6210
6211requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6212run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6213 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6214 "$P_CLI force_version=tls1 \
6215 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6216 0 \
6217 -s "16384 bytes written in 1 fragments" \
6218 -c "Read from server: 16384 bytes read"
6219
6220requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6221run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6222 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6223 "$P_CLI force_version=tls1 \
6224 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6225 0 \
6226 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006227 -c "Read from server: 16384 bytes read"
6228
6229run_test "Large server packet TLS 1.1 BlockCipher" \
6230 "$P_SRV response_size=16384" \
6231 "$P_CLI force_version=tls1_1 \
6232 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6233 0 \
6234 -c "Read from server: 16384 bytes read"
6235
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006236run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6237 "$P_SRV response_size=16384" \
6238 "$P_CLI force_version=tls1_1 etm=0 \
6239 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006240 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006241 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006242 -c "Read from server: 16384 bytes read"
6243
6244requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6245run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6246 "$P_SRV response_size=16384" \
6247 "$P_CLI force_version=tls1_1 \
6248 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6249 trunc_hmac=1" \
6250 0 \
6251 -c "Read from server: 16384 bytes read"
6252
6253requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006254run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6255 "$P_SRV response_size=16384 trunc_hmac=1" \
6256 "$P_CLI force_version=tls1_1 \
6257 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6258 0 \
6259 -s "16384 bytes written in 1 fragments" \
6260 -c "Read from server: 16384 bytes read"
6261
6262run_test "Large server packet TLS 1.1 StreamCipher" \
6263 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6264 "$P_CLI force_version=tls1_1 \
6265 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6266 0 \
6267 -c "Read from server: 16384 bytes read"
6268
6269run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6270 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6271 "$P_CLI force_version=tls1_1 \
6272 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6273 0 \
6274 -s "16384 bytes written in 1 fragments" \
6275 -c "Read from server: 16384 bytes read"
6276
6277requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006278run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6279 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6280 "$P_CLI force_version=tls1_1 \
6281 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6282 trunc_hmac=1" \
6283 0 \
6284 -c "Read from server: 16384 bytes read"
6285
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006286run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6287 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6288 "$P_CLI force_version=tls1_1 \
6289 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6290 0 \
6291 -s "16384 bytes written in 1 fragments" \
6292 -c "Read from server: 16384 bytes read"
6293
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006294run_test "Large server packet TLS 1.2 BlockCipher" \
6295 "$P_SRV response_size=16384" \
6296 "$P_CLI force_version=tls1_2 \
6297 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6298 0 \
6299 -c "Read from server: 16384 bytes read"
6300
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006301run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6302 "$P_SRV response_size=16384" \
6303 "$P_CLI force_version=tls1_2 etm=0 \
6304 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6305 0 \
6306 -s "16384 bytes written in 1 fragments" \
6307 -c "Read from server: 16384 bytes read"
6308
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006309run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6310 "$P_SRV response_size=16384" \
6311 "$P_CLI force_version=tls1_2 \
6312 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6313 0 \
6314 -c "Read from server: 16384 bytes read"
6315
6316requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6317run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6318 "$P_SRV response_size=16384" \
6319 "$P_CLI force_version=tls1_2 \
6320 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6321 trunc_hmac=1" \
6322 0 \
6323 -c "Read from server: 16384 bytes read"
6324
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006325run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6326 "$P_SRV response_size=16384 trunc_hmac=1" \
6327 "$P_CLI force_version=tls1_2 \
6328 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6329 0 \
6330 -s "16384 bytes written in 1 fragments" \
6331 -c "Read from server: 16384 bytes read"
6332
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006333run_test "Large server packet TLS 1.2 StreamCipher" \
6334 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6335 "$P_CLI force_version=tls1_2 \
6336 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6337 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006338 -s "16384 bytes written in 1 fragments" \
6339 -c "Read from server: 16384 bytes read"
6340
6341run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6342 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6343 "$P_CLI force_version=tls1_2 \
6344 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6345 0 \
6346 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006347 -c "Read from server: 16384 bytes read"
6348
6349requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6350run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6351 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6352 "$P_CLI force_version=tls1_2 \
6353 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6354 trunc_hmac=1" \
6355 0 \
6356 -c "Read from server: 16384 bytes read"
6357
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006358requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6359run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6360 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6361 "$P_CLI force_version=tls1_2 \
6362 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6363 0 \
6364 -s "16384 bytes written in 1 fragments" \
6365 -c "Read from server: 16384 bytes read"
6366
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006367run_test "Large server packet TLS 1.2 AEAD" \
6368 "$P_SRV response_size=16384" \
6369 "$P_CLI force_version=tls1_2 \
6370 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6371 0 \
6372 -c "Read from server: 16384 bytes read"
6373
6374run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6375 "$P_SRV response_size=16384" \
6376 "$P_CLI force_version=tls1_2 \
6377 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6378 0 \
6379 -c "Read from server: 16384 bytes read"
6380
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006381# Tests for restartable ECC
6382
6383requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6384run_test "EC restart: TLS, default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006385 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006386 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006387 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006388 debug_level=1" \
6389 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006390 -C "x509_verify_cert.*4b00" \
6391 -C "mbedtls_pk_verify.*4b00" \
6392 -C "mbedtls_ecdh_make_public.*4b00" \
6393 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006394
6395requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6396run_test "EC restart: TLS, max_ops=0" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006397 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006398 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006399 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006400 debug_level=1 ec_max_ops=0" \
6401 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006402 -C "x509_verify_cert.*4b00" \
6403 -C "mbedtls_pk_verify.*4b00" \
6404 -C "mbedtls_ecdh_make_public.*4b00" \
6405 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006406
6407requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6408run_test "EC restart: TLS, max_ops=65535" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006409 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006410 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006411 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006412 debug_level=1 ec_max_ops=65535" \
6413 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006414 -C "x509_verify_cert.*4b00" \
6415 -C "mbedtls_pk_verify.*4b00" \
6416 -C "mbedtls_ecdh_make_public.*4b00" \
6417 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006418
6419requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6420run_test "EC restart: TLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006421 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006422 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006423 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006424 debug_level=1 ec_max_ops=1000" \
6425 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006426 -c "x509_verify_cert.*4b00" \
6427 -c "mbedtls_pk_verify.*4b00" \
6428 -c "mbedtls_ecdh_make_public.*4b00" \
6429 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006430
6431requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Hanno Becker4a156fc2019-06-14 17:07:06 +01006432requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006433requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006434run_test "EC restart: TLS, max_ops=1000, badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006435 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006436 crt_file=data_files/server5-badsign.crt \
6437 key_file=data_files/server5.key" \
6438 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006439 key_file=data_files/server5.key crt_file=data_files/server5.crt ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006440 debug_level=1 ec_max_ops=1000" \
6441 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006442 -c "x509_verify_cert.*4b00" \
6443 -C "mbedtls_pk_verify.*4b00" \
6444 -C "mbedtls_ecdh_make_public.*4b00" \
6445 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006446 -c "! The certificate is not correctly signed by the trusted CA" \
6447 -c "! mbedtls_ssl_handshake returned" \
6448 -c "X509 - Certificate verification failed"
6449
Hanno Becker4a156fc2019-06-14 17:07:06 +01006450requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006451requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6452run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006453 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006454 crt_file=data_files/server5-badsign.crt \
6455 key_file=data_files/server5.key" \
6456 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6457 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006458 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006459 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6460 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006461 -c "x509_verify_cert.*4b00" \
6462 -c "mbedtls_pk_verify.*4b00" \
6463 -c "mbedtls_ecdh_make_public.*4b00" \
6464 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006465 -c "! The certificate is not correctly signed by the trusted CA" \
6466 -C "! mbedtls_ssl_handshake returned" \
6467 -C "X509 - Certificate verification failed"
6468
Hanno Becker4a156fc2019-06-14 17:07:06 +01006469requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006470requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006471requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6472run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006473 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006474 crt_file=data_files/server5-badsign.crt \
6475 key_file=data_files/server5.key" \
6476 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006477 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006478 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6479 debug_level=1 ec_max_ops=1000 auth_mode=none" \
6480 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006481 -C "x509_verify_cert.*4b00" \
6482 -c "mbedtls_pk_verify.*4b00" \
6483 -c "mbedtls_ecdh_make_public.*4b00" \
6484 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006485 -C "! The certificate is not correctly signed by the trusted CA" \
6486 -C "! mbedtls_ssl_handshake returned" \
6487 -C "X509 - Certificate verification failed"
6488
6489requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006490run_test "EC restart: DTLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006491 "$P_SRV auth_mode=required dtls=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006492 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006493 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006494 dtls=1 debug_level=1 ec_max_ops=1000" \
6495 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006496 -c "x509_verify_cert.*4b00" \
6497 -c "mbedtls_pk_verify.*4b00" \
6498 -c "mbedtls_ecdh_make_public.*4b00" \
6499 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006500
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006501requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6502run_test "EC restart: TLS, max_ops=1000 no client auth" \
6503 "$P_SRV" \
6504 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6505 debug_level=1 ec_max_ops=1000" \
6506 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006507 -c "x509_verify_cert.*4b00" \
6508 -c "mbedtls_pk_verify.*4b00" \
6509 -c "mbedtls_ecdh_make_public.*4b00" \
6510 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006511
6512requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6513run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6514 "$P_SRV psk=abc123" \
6515 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6516 psk=abc123 debug_level=1 ec_max_ops=1000" \
6517 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006518 -C "x509_verify_cert.*4b00" \
6519 -C "mbedtls_pk_verify.*4b00" \
6520 -C "mbedtls_ecdh_make_public.*4b00" \
6521 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006522
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006523# Tests of asynchronous private key support in SSL
6524
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006525requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006526run_test "SSL async private: sign, delay=0" \
6527 "$P_SRV \
6528 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006529 "$P_CLI" \
6530 0 \
6531 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006532 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006533
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006534requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006535run_test "SSL async private: sign, delay=1" \
6536 "$P_SRV \
6537 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006538 "$P_CLI" \
6539 0 \
6540 -s "Async sign callback: using key slot " \
6541 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006542 -s "Async resume (slot [0-9]): sign done, status=0"
6543
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006544requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6545run_test "SSL async private: sign, delay=2" \
6546 "$P_SRV \
6547 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6548 "$P_CLI" \
6549 0 \
6550 -s "Async sign callback: using key slot " \
6551 -U "Async sign callback: using key slot " \
6552 -s "Async resume (slot [0-9]): call 1 more times." \
6553 -s "Async resume (slot [0-9]): call 0 more times." \
6554 -s "Async resume (slot [0-9]): sign done, status=0"
6555
Gilles Peskined3268832018-04-26 06:23:59 +02006556# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
6557# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
6558requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6559requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6560run_test "SSL async private: sign, RSA, TLS 1.1" \
6561 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
6562 async_operations=s async_private_delay1=0 async_private_delay2=0" \
6563 "$P_CLI force_version=tls1_1" \
6564 0 \
6565 -s "Async sign callback: using key slot " \
6566 -s "Async resume (slot [0-9]): sign done, status=0"
6567
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006568requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerb2c63832019-06-17 08:35:16 +01006569requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03006570requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006571requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskine807d74a2018-04-30 10:30:49 +02006572run_test "SSL async private: sign, SNI" \
6573 "$P_SRV debug_level=3 \
6574 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6575 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6576 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6577 "$P_CLI server_name=polarssl.example" \
6578 0 \
6579 -s "Async sign callback: using key slot " \
6580 -s "Async resume (slot [0-9]): sign done, status=0" \
6581 -s "parse ServerName extension" \
6582 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6583 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6584
6585requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006586run_test "SSL async private: decrypt, delay=0" \
6587 "$P_SRV \
6588 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6589 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6590 0 \
6591 -s "Async decrypt callback: using key slot " \
6592 -s "Async resume (slot [0-9]): decrypt done, status=0"
6593
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006594requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006595run_test "SSL async private: decrypt, delay=1" \
6596 "$P_SRV \
6597 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6598 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6599 0 \
6600 -s "Async decrypt callback: using key slot " \
6601 -s "Async resume (slot [0-9]): call 0 more times." \
6602 -s "Async resume (slot [0-9]): decrypt done, status=0"
6603
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006604requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006605run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6606 "$P_SRV psk=abc123 \
6607 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6608 "$P_CLI psk=abc123 \
6609 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6610 0 \
6611 -s "Async decrypt callback: using key slot " \
6612 -s "Async resume (slot [0-9]): decrypt done, status=0"
6613
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006614requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006615run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6616 "$P_SRV psk=abc123 \
6617 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6618 "$P_CLI psk=abc123 \
6619 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6620 0 \
6621 -s "Async decrypt callback: using key slot " \
6622 -s "Async resume (slot [0-9]): call 0 more times." \
6623 -s "Async resume (slot [0-9]): decrypt done, status=0"
6624
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006625requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006626run_test "SSL async private: sign callback not present" \
6627 "$P_SRV \
6628 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6629 "$P_CLI; [ \$? -eq 1 ] &&
6630 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6631 0 \
6632 -S "Async sign callback" \
6633 -s "! mbedtls_ssl_handshake returned" \
6634 -s "The own private key or pre-shared key is not set, but needed" \
6635 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6636 -s "Successful connection"
6637
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006638requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006639run_test "SSL async private: decrypt callback not present" \
6640 "$P_SRV debug_level=1 \
6641 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6642 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6643 [ \$? -eq 1 ] && $P_CLI" \
6644 0 \
6645 -S "Async decrypt callback" \
6646 -s "! mbedtls_ssl_handshake returned" \
6647 -s "got no RSA private key" \
6648 -s "Async resume (slot [0-9]): sign done, status=0" \
6649 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006650
6651# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006652requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006653run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006654 "$P_SRV \
6655 async_operations=s async_private_delay1=1 \
6656 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6657 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006658 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 ca_file=data_files/test-ca2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006659 0 \
6660 -s "Async sign callback: using key slot 0," \
6661 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006662 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006663
6664# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006665requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006666run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006667 "$P_SRV \
6668 async_operations=s async_private_delay2=1 \
6669 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6670 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006671 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6672 0 \
6673 -s "Async sign callback: using key slot 0," \
6674 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006675 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006676
6677# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006678requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006679run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006680 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006681 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006682 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6683 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006684 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6685 0 \
6686 -s "Async sign callback: using key slot 1," \
6687 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006688 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006689
6690# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006691requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006692run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006693 "$P_SRV \
6694 async_operations=s async_private_delay1=1 \
6695 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6696 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006697 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6698 0 \
6699 -s "Async sign callback: no key matches this certificate."
6700
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006701requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006702run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006703 "$P_SRV \
6704 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6705 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006706 "$P_CLI" \
6707 1 \
6708 -s "Async sign callback: injected error" \
6709 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006710 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006711 -s "! mbedtls_ssl_handshake returned"
6712
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006713requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006714run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006715 "$P_SRV \
6716 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6717 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006718 "$P_CLI" \
6719 1 \
6720 -s "Async sign callback: using key slot " \
6721 -S "Async resume" \
6722 -s "Async cancel"
6723
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006724requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006725run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006726 "$P_SRV \
6727 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6728 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006729 "$P_CLI" \
6730 1 \
6731 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006732 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006733 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006734 -s "! mbedtls_ssl_handshake returned"
6735
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006736requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006737run_test "SSL async private: decrypt, error in start" \
6738 "$P_SRV \
6739 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6740 async_private_error=1" \
6741 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6742 1 \
6743 -s "Async decrypt callback: injected error" \
6744 -S "Async resume" \
6745 -S "Async cancel" \
6746 -s "! mbedtls_ssl_handshake returned"
6747
6748requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6749run_test "SSL async private: decrypt, cancel after start" \
6750 "$P_SRV \
6751 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6752 async_private_error=2" \
6753 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6754 1 \
6755 -s "Async decrypt callback: using key slot " \
6756 -S "Async resume" \
6757 -s "Async cancel"
6758
6759requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6760run_test "SSL async private: decrypt, error in resume" \
6761 "$P_SRV \
6762 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6763 async_private_error=3" \
6764 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6765 1 \
6766 -s "Async decrypt callback: using key slot " \
6767 -s "Async resume callback: decrypt done but injected error" \
6768 -S "Async cancel" \
6769 -s "! mbedtls_ssl_handshake returned"
6770
6771requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006772run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006773 "$P_SRV \
6774 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6775 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006776 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6777 0 \
6778 -s "Async cancel" \
6779 -s "! mbedtls_ssl_handshake returned" \
6780 -s "Async resume" \
6781 -s "Successful connection"
6782
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006783requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006784run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006785 "$P_SRV \
6786 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6787 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006788 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6789 0 \
6790 -s "! mbedtls_ssl_handshake returned" \
6791 -s "Async resume" \
6792 -s "Successful connection"
6793
6794# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006795requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006796run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006797 "$P_SRV \
6798 async_operations=s async_private_delay1=1 async_private_error=-2 \
6799 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6800 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006801 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6802 [ \$? -eq 1 ] &&
6803 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6804 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006805 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006806 -S "Async resume" \
6807 -s "Async cancel" \
6808 -s "! mbedtls_ssl_handshake returned" \
6809 -s "Async sign callback: no key matches this certificate." \
6810 -s "Successful connection"
6811
6812# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006813requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006814run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006815 "$P_SRV \
6816 async_operations=s async_private_delay1=1 async_private_error=-3 \
6817 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6818 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006819 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6820 [ \$? -eq 1 ] &&
6821 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6822 0 \
6823 -s "Async resume" \
6824 -s "! mbedtls_ssl_handshake returned" \
6825 -s "Async sign callback: no key matches this certificate." \
6826 -s "Successful connection"
6827
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006828requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006829requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006830run_test "SSL async private: renegotiation: client-initiated; sign" \
6831 "$P_SRV \
6832 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006833 exchanges=2 renegotiation=1" \
6834 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6835 0 \
6836 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006837 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006838
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006839requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006840requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006841run_test "SSL async private: renegotiation: server-initiated; sign" \
6842 "$P_SRV \
6843 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006844 exchanges=2 renegotiation=1 renegotiate=1" \
6845 "$P_CLI exchanges=2 renegotiation=1" \
6846 0 \
6847 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006848 -s "Async resume (slot [0-9]): sign done, status=0"
6849
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006850requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006851requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6852run_test "SSL async private: renegotiation: client-initiated; decrypt" \
6853 "$P_SRV \
6854 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6855 exchanges=2 renegotiation=1" \
6856 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6857 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6858 0 \
6859 -s "Async decrypt callback: using key slot " \
6860 -s "Async resume (slot [0-9]): decrypt done, status=0"
6861
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006862requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006863requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6864run_test "SSL async private: renegotiation: server-initiated; decrypt" \
6865 "$P_SRV \
6866 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6867 exchanges=2 renegotiation=1 renegotiate=1" \
6868 "$P_CLI exchanges=2 renegotiation=1 \
6869 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6870 0 \
6871 -s "Async decrypt callback: using key slot " \
6872 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006873
Ron Eldor58093c82018-06-28 13:22:05 +03006874# Tests for ECC extensions (rfc 4492)
6875
Ron Eldor643df7c2018-06-28 16:17:00 +03006876requires_config_enabled MBEDTLS_AES_C
6877requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6878requires_config_enabled MBEDTLS_SHA256_C
6879requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006880run_test "Force a non ECC ciphersuite in the client side" \
6881 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006882 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006883 0 \
6884 -C "client hello, adding supported_elliptic_curves extension" \
6885 -C "client hello, adding supported_point_formats extension" \
6886 -S "found supported elliptic curves extension" \
6887 -S "found supported point formats extension"
6888
Ron Eldor643df7c2018-06-28 16:17:00 +03006889requires_config_enabled MBEDTLS_AES_C
6890requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6891requires_config_enabled MBEDTLS_SHA256_C
6892requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006893run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006894 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006895 "$P_CLI debug_level=3" \
6896 0 \
6897 -C "found supported_point_formats extension" \
6898 -S "server hello, supported_point_formats extension"
6899
Ron Eldor643df7c2018-06-28 16:17:00 +03006900requires_config_enabled MBEDTLS_AES_C
6901requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6902requires_config_enabled MBEDTLS_SHA256_C
6903requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006904run_test "Force an ECC ciphersuite in the client side" \
6905 "$P_SRV debug_level=3" \
6906 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6907 0 \
6908 -c "client hello, adding supported_elliptic_curves extension" \
6909 -c "client hello, adding supported_point_formats extension" \
6910 -s "found supported elliptic curves extension" \
6911 -s "found supported point formats extension"
6912
Ron Eldor643df7c2018-06-28 16:17:00 +03006913requires_config_enabled MBEDTLS_AES_C
6914requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6915requires_config_enabled MBEDTLS_SHA256_C
6916requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006917run_test "Force an ECC ciphersuite in the server side" \
6918 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6919 "$P_CLI debug_level=3" \
6920 0 \
6921 -c "found supported_point_formats extension" \
6922 -s "server hello, supported_point_formats extension"
6923
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006924# Tests for DTLS HelloVerifyRequest
6925
6926run_test "DTLS cookie: enabled" \
6927 "$P_SRV dtls=1 debug_level=2" \
6928 "$P_CLI dtls=1 debug_level=2" \
6929 0 \
6930 -s "cookie verification failed" \
6931 -s "cookie verification passed" \
6932 -S "cookie verification skipped" \
6933 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006934 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006935 -S "SSL - The requested feature is not available"
6936
6937run_test "DTLS cookie: disabled" \
6938 "$P_SRV dtls=1 debug_level=2 cookies=0" \
6939 "$P_CLI dtls=1 debug_level=2" \
6940 0 \
6941 -S "cookie verification failed" \
6942 -S "cookie verification passed" \
6943 -s "cookie verification skipped" \
6944 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006945 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006946 -S "SSL - The requested feature is not available"
6947
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006948run_test "DTLS cookie: default (failing)" \
6949 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
6950 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
6951 1 \
6952 -s "cookie verification failed" \
6953 -S "cookie verification passed" \
6954 -S "cookie verification skipped" \
6955 -C "received hello verify request" \
6956 -S "hello verification requested" \
6957 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006958
6959requires_ipv6
6960run_test "DTLS cookie: enabled, IPv6" \
6961 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
6962 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
6963 0 \
6964 -s "cookie verification failed" \
6965 -s "cookie verification passed" \
6966 -S "cookie verification skipped" \
6967 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006968 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006969 -S "SSL - The requested feature is not available"
6970
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006971run_test "DTLS cookie: enabled, nbio" \
6972 "$P_SRV dtls=1 nbio=2 debug_level=2" \
6973 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6974 0 \
6975 -s "cookie verification failed" \
6976 -s "cookie verification passed" \
6977 -S "cookie verification skipped" \
6978 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006979 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006980 -S "SSL - The requested feature is not available"
6981
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006982# Tests for client reconnecting from the same port with DTLS
6983
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006984not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006985run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006986 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
6987 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006988 0 \
6989 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006990 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006991 -S "Client initiated reconnection from same port"
6992
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006993not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006994run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006995 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
6996 "$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 +02006997 0 \
6998 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006999 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007000 -s "Client initiated reconnection from same port"
7001
Paul Bakker362689d2016-05-13 10:33:25 +01007002not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
7003run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007004 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7005 "$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 +02007006 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007007 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007008 -s "Client initiated reconnection from same port"
7009
Paul Bakker362689d2016-05-13 10:33:25 +01007010only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
7011run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7012 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7013 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7014 0 \
7015 -S "The operation timed out" \
7016 -s "Client initiated reconnection from same port"
7017
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007018run_test "DTLS client reconnect from same port: no cookies" \
7019 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007020 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7021 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007022 -s "The operation timed out" \
7023 -S "Client initiated reconnection from same port"
7024
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007025# Tests for various cases of client authentication with DTLS
7026# (focused on handshake flows and message parsing)
7027
7028run_test "DTLS client auth: required" \
7029 "$P_SRV dtls=1 auth_mode=required" \
7030 "$P_CLI dtls=1" \
7031 0 \
7032 -s "Verifying peer X.509 certificate... ok"
7033
Hanno Becker4a156fc2019-06-14 17:07:06 +01007034requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007035requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007036run_test "DTLS client auth: optional, client has no cert" \
7037 "$P_SRV dtls=1 auth_mode=optional" \
7038 "$P_CLI dtls=1 crt_file=none key_file=none" \
7039 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007040 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007041
Hanno Becker4a156fc2019-06-14 17:07:06 +01007042requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007043requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007044run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007045 "$P_SRV dtls=1 auth_mode=none" \
7046 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7047 0 \
7048 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007049 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007050
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007051run_test "DTLS wrong PSK: badmac alert" \
7052 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7053 "$P_CLI dtls=1 psk=abc124" \
7054 1 \
7055 -s "SSL - Verification of the message MAC failed" \
7056 -c "SSL - A fatal alert message was received from our peer"
7057
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007058# Tests for receiving fragmented handshake messages with DTLS
7059
7060requires_gnutls
7061run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7062 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007063 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007064 0 \
7065 -C "found fragmented DTLS handshake message" \
7066 -C "error"
7067
7068requires_gnutls
7069run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7070 "$G_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007071 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007072 0 \
7073 -c "found fragmented DTLS handshake message" \
7074 -C "error"
7075
7076requires_gnutls
7077run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7078 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007079 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007080 0 \
7081 -c "found fragmented DTLS handshake message" \
7082 -C "error"
7083
7084requires_gnutls
7085run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7086 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007087 "$P_CLI dtls=1 nbio=2 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007088 0 \
7089 -c "found fragmented DTLS handshake message" \
7090 -C "error"
7091
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007092requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007093requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007094run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7095 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007096 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007097 0 \
7098 -c "found fragmented DTLS handshake message" \
7099 -c "client hello, adding renegotiation extension" \
7100 -c "found renegotiation extension" \
7101 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007102 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007103 -C "error" \
7104 -s "Extra-header:"
7105
7106requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007107requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007108run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7109 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007110 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007111 0 \
7112 -c "found fragmented DTLS handshake message" \
7113 -c "client hello, adding renegotiation extension" \
7114 -c "found renegotiation extension" \
7115 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007116 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007117 -C "error" \
7118 -s "Extra-header:"
7119
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007120run_test "DTLS reassembly: no fragmentation (openssl server)" \
7121 "$O_SRV -dtls1 -mtu 2048" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007122 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007123 0 \
7124 -C "found fragmented DTLS handshake message" \
7125 -C "error"
7126
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007127run_test "DTLS reassembly: some fragmentation (openssl server)" \
7128 "$O_SRV -dtls1 -mtu 768" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007129 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007130 0 \
7131 -c "found fragmented DTLS handshake message" \
7132 -C "error"
7133
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007134run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007135 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007136 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007137 0 \
7138 -c "found fragmented DTLS handshake message" \
7139 -C "error"
7140
7141run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7142 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007143 "$P_CLI dtls=1 nbio=2 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007144 0 \
7145 -c "found fragmented DTLS handshake message" \
7146 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007147
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007148# Tests for sending fragmented handshake messages with DTLS
7149#
7150# Use client auth when we need the client to send large messages,
7151# and use large cert chains on both sides too (the long chains we have all use
7152# both RSA and ECDSA, but ideally we should have long chains with either).
7153# Sizes reached (UDP payload):
7154# - 2037B for server certificate
7155# - 1542B for client certificate
7156# - 1013B for newsessionticket
7157# - all others below 512B
7158# All those tests assume MAX_CONTENT_LEN is at least 2048
7159
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007160requires_config_enabled MBEDTLS_RSA_C
7161requires_config_enabled MBEDTLS_ECDSA_C
7162requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7163run_test "DTLS fragmenting: none (for reference)" \
7164 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7165 crt_file=data_files/server7_int-ca.crt \
7166 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007167 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007168 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007169 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007170 "$P_CLI dtls=1 debug_level=2 \
7171 crt_file=data_files/server8_int-ca2.crt \
7172 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007173 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007174 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007175 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007176 0 \
7177 -S "found fragmented DTLS handshake message" \
7178 -C "found fragmented DTLS handshake message" \
7179 -C "error"
7180
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007181requires_config_enabled MBEDTLS_RSA_C
7182requires_config_enabled MBEDTLS_ECDSA_C
7183requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007184run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007185 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7186 crt_file=data_files/server7_int-ca.crt \
7187 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007188 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007189 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007190 max_frag_len=1024" \
7191 "$P_CLI dtls=1 debug_level=2 \
7192 crt_file=data_files/server8_int-ca2.crt \
7193 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007194 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007195 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007196 max_frag_len=2048" \
7197 0 \
7198 -S "found fragmented DTLS handshake message" \
7199 -c "found fragmented DTLS handshake message" \
7200 -C "error"
7201
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007202# With the MFL extension, the server has no way of forcing
7203# the client to not exceed a certain MTU; hence, the following
7204# test can't be replicated with an MTU proxy such as the one
7205# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007206requires_config_enabled MBEDTLS_RSA_C
7207requires_config_enabled MBEDTLS_ECDSA_C
7208requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007209run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007210 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7211 crt_file=data_files/server7_int-ca.crt \
7212 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007213 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007214 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007215 max_frag_len=512" \
7216 "$P_CLI dtls=1 debug_level=2 \
7217 crt_file=data_files/server8_int-ca2.crt \
7218 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007219 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007220 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007221 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007222 0 \
7223 -S "found fragmented DTLS handshake message" \
7224 -c "found fragmented DTLS handshake message" \
7225 -C "error"
7226
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007227requires_config_enabled MBEDTLS_RSA_C
7228requires_config_enabled MBEDTLS_ECDSA_C
7229requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007230run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007231 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7232 crt_file=data_files/server7_int-ca.crt \
7233 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007234 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007235 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007236 max_frag_len=2048" \
7237 "$P_CLI dtls=1 debug_level=2 \
7238 crt_file=data_files/server8_int-ca2.crt \
7239 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007240 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007241 hs_timeout=2500-60000 \
7242 max_frag_len=1024" \
7243 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007244 -S "found fragmented DTLS handshake message" \
7245 -c "found fragmented DTLS handshake message" \
7246 -C "error"
7247
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007248# While not required by the standard defining the MFL extension
7249# (according to which it only applies to records, not to datagrams),
7250# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7251# as otherwise there wouldn't be any means to communicate MTU restrictions
7252# to the peer.
7253# The next test checks that no datagrams significantly larger than the
7254# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007255requires_config_enabled MBEDTLS_RSA_C
7256requires_config_enabled MBEDTLS_ECDSA_C
7257requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7258run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007259 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007260 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7261 crt_file=data_files/server7_int-ca.crt \
7262 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007263 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007264 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007265 max_frag_len=2048" \
7266 "$P_CLI dtls=1 debug_level=2 \
7267 crt_file=data_files/server8_int-ca2.crt \
7268 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007269 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007270 hs_timeout=2500-60000 \
7271 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007272 0 \
7273 -S "found fragmented DTLS handshake message" \
7274 -c "found fragmented DTLS handshake message" \
7275 -C "error"
7276
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007277requires_config_enabled MBEDTLS_RSA_C
7278requires_config_enabled MBEDTLS_ECDSA_C
7279requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007280run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007281 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7282 crt_file=data_files/server7_int-ca.crt \
7283 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007284 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007285 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007286 max_frag_len=2048" \
7287 "$P_CLI dtls=1 debug_level=2 \
7288 crt_file=data_files/server8_int-ca2.crt \
7289 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007290 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007291 hs_timeout=2500-60000 \
7292 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007293 0 \
7294 -s "found fragmented DTLS handshake message" \
7295 -c "found fragmented DTLS handshake message" \
7296 -C "error"
7297
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007298# While not required by the standard defining the MFL extension
7299# (according to which it only applies to records, not to datagrams),
7300# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7301# as otherwise there wouldn't be any means to communicate MTU restrictions
7302# to the peer.
7303# The next test checks that no datagrams significantly larger than the
7304# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007305requires_config_enabled MBEDTLS_RSA_C
7306requires_config_enabled MBEDTLS_ECDSA_C
7307requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7308run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007309 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007310 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7311 crt_file=data_files/server7_int-ca.crt \
7312 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007313 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007314 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007315 max_frag_len=2048" \
7316 "$P_CLI dtls=1 debug_level=2 \
7317 crt_file=data_files/server8_int-ca2.crt \
7318 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007319 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007320 hs_timeout=2500-60000 \
7321 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007322 0 \
7323 -s "found fragmented DTLS handshake message" \
7324 -c "found fragmented DTLS handshake message" \
7325 -C "error"
7326
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007327requires_config_enabled MBEDTLS_RSA_C
7328requires_config_enabled MBEDTLS_ECDSA_C
7329run_test "DTLS fragmenting: none (for reference) (MTU)" \
7330 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7331 crt_file=data_files/server7_int-ca.crt \
7332 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007333 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007334 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007335 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007336 "$P_CLI dtls=1 debug_level=2 \
7337 crt_file=data_files/server8_int-ca2.crt \
7338 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007339 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007340 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007341 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007342 0 \
7343 -S "found fragmented DTLS handshake message" \
7344 -C "found fragmented DTLS handshake message" \
7345 -C "error"
7346
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007347requires_config_enabled MBEDTLS_RSA_C
7348requires_config_enabled MBEDTLS_ECDSA_C
7349run_test "DTLS fragmenting: client (MTU)" \
7350 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7351 crt_file=data_files/server7_int-ca.crt \
7352 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007353 ca_file=data_files/test-ca.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007354 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007355 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007356 "$P_CLI dtls=1 debug_level=2 \
7357 crt_file=data_files/server8_int-ca2.crt \
7358 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007359 ca_file=data_files/test-ca2.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007360 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007361 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007362 0 \
7363 -s "found fragmented DTLS handshake message" \
7364 -C "found fragmented DTLS handshake message" \
7365 -C "error"
7366
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007367requires_config_enabled MBEDTLS_RSA_C
7368requires_config_enabled MBEDTLS_ECDSA_C
7369run_test "DTLS fragmenting: server (MTU)" \
7370 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7371 crt_file=data_files/server7_int-ca.crt \
7372 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007373 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007374 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007375 mtu=512" \
7376 "$P_CLI dtls=1 debug_level=2 \
7377 crt_file=data_files/server8_int-ca2.crt \
7378 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007379 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007380 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007381 mtu=2048" \
7382 0 \
7383 -S "found fragmented DTLS handshake message" \
7384 -c "found fragmented DTLS handshake message" \
7385 -C "error"
7386
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007387requires_config_enabled MBEDTLS_RSA_C
7388requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007389run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007390 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007391 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7392 crt_file=data_files/server7_int-ca.crt \
7393 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007394 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007395 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007396 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007397 "$P_CLI dtls=1 debug_level=2 \
7398 crt_file=data_files/server8_int-ca2.crt \
7399 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007400 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007401 hs_timeout=2500-60000 \
7402 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007403 0 \
7404 -s "found fragmented DTLS handshake message" \
7405 -c "found fragmented DTLS handshake message" \
7406 -C "error"
7407
Andrzej Kurek77826052018-10-11 07:34:08 -04007408# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007409requires_config_enabled MBEDTLS_RSA_C
7410requires_config_enabled MBEDTLS_ECDSA_C
7411requires_config_enabled MBEDTLS_SHA256_C
7412requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7413requires_config_enabled MBEDTLS_AES_C
7414requires_config_enabled MBEDTLS_GCM_C
7415run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007416 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007417 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7418 crt_file=data_files/server7_int-ca.crt \
7419 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007420 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007421 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007422 mtu=512" \
7423 "$P_CLI dtls=1 debug_level=2 \
7424 crt_file=data_files/server8_int-ca2.crt \
7425 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007426 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007427 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7428 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007429 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007430 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007431 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007432 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007433 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007434
Andrzej Kurek7311c782018-10-11 06:49:41 -04007435# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007436# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007437# The ratio of max/min timeout should ideally equal 4 to accept two
7438# retransmissions, but in some cases (like both the server and client using
7439# fragmentation and auto-reduction) an extra retransmission might occur,
7440# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007441not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007442requires_config_enabled MBEDTLS_RSA_C
7443requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007444requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7445requires_config_enabled MBEDTLS_AES_C
7446requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007447run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7448 -p "$P_PXY mtu=508" \
7449 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7450 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007451 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007452 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007453 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007454 "$P_CLI dtls=1 debug_level=2 \
7455 crt_file=data_files/server8_int-ca2.crt \
7456 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007457 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007458 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7459 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007460 0 \
7461 -s "found fragmented DTLS handshake message" \
7462 -c "found fragmented DTLS handshake message" \
7463 -C "error"
7464
Andrzej Kurek77826052018-10-11 07:34:08 -04007465# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007466only_with_valgrind
Hanno Becker108992e2018-08-29 17:04:18 +01007467requires_config_enabled MBEDTLS_RSA_C
7468requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007469requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7470requires_config_enabled MBEDTLS_AES_C
7471requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01007472run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7473 -p "$P_PXY mtu=508" \
7474 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7475 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007476 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007477 ca_file=data_files/test-ca.crt \
Hanno Becker108992e2018-08-29 17:04:18 +01007478 hs_timeout=250-10000" \
7479 "$P_CLI dtls=1 debug_level=2 \
7480 crt_file=data_files/server8_int-ca2.crt \
7481 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007482 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007483 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007484 hs_timeout=250-10000" \
7485 0 \
7486 -s "found fragmented DTLS handshake message" \
7487 -c "found fragmented DTLS handshake message" \
7488 -C "error"
7489
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007490# 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 +02007491# OTOH the client might resend if the server is to slow to reset after sending
7492# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007493not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007494requires_config_enabled MBEDTLS_RSA_C
7495requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007496run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007497 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007498 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7499 crt_file=data_files/server7_int-ca.crt \
7500 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007501 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007502 hs_timeout=10000-60000 \
7503 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007504 "$P_CLI dtls=1 debug_level=2 \
7505 crt_file=data_files/server8_int-ca2.crt \
7506 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007507 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007508 hs_timeout=10000-60000 \
7509 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007510 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007511 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007512 -s "found fragmented DTLS handshake message" \
7513 -c "found fragmented DTLS handshake message" \
7514 -C "error"
7515
Andrzej Kurek77826052018-10-11 07:34:08 -04007516# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007517# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7518# OTOH the client might resend if the server is to slow to reset after sending
7519# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007520not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007521requires_config_enabled MBEDTLS_RSA_C
7522requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007523requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7524requires_config_enabled MBEDTLS_AES_C
7525requires_config_enabled MBEDTLS_GCM_C
7526run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007527 -p "$P_PXY mtu=512" \
7528 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7529 crt_file=data_files/server7_int-ca.crt \
7530 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007531 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007532 hs_timeout=10000-60000 \
7533 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007534 "$P_CLI dtls=1 debug_level=2 \
7535 crt_file=data_files/server8_int-ca2.crt \
7536 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007537 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007538 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7539 hs_timeout=10000-60000 \
7540 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007541 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007542 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007543 -s "found fragmented DTLS handshake message" \
7544 -c "found fragmented DTLS handshake message" \
7545 -C "error"
7546
Andrzej Kurek7311c782018-10-11 06:49:41 -04007547not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007548requires_config_enabled MBEDTLS_RSA_C
7549requires_config_enabled MBEDTLS_ECDSA_C
7550run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007551 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007552 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7553 crt_file=data_files/server7_int-ca.crt \
7554 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007555 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007556 hs_timeout=10000-60000 \
7557 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007558 "$P_CLI dtls=1 debug_level=2 \
7559 crt_file=data_files/server8_int-ca2.crt \
7560 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007561 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007562 hs_timeout=10000-60000 \
7563 mtu=1024 nbio=2" \
7564 0 \
7565 -S "autoreduction" \
7566 -s "found fragmented DTLS handshake message" \
7567 -c "found fragmented DTLS handshake message" \
7568 -C "error"
7569
Andrzej Kurek77826052018-10-11 07:34:08 -04007570# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007571not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007572requires_config_enabled MBEDTLS_RSA_C
7573requires_config_enabled MBEDTLS_ECDSA_C
7574requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7575requires_config_enabled MBEDTLS_AES_C
7576requires_config_enabled MBEDTLS_GCM_C
7577run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7578 -p "$P_PXY mtu=512" \
7579 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7580 crt_file=data_files/server7_int-ca.crt \
7581 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007582 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007583 hs_timeout=10000-60000 \
7584 mtu=512 nbio=2" \
7585 "$P_CLI dtls=1 debug_level=2 \
7586 crt_file=data_files/server8_int-ca2.crt \
7587 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007588 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007589 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7590 hs_timeout=10000-60000 \
7591 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007592 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007593 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007594 -s "found fragmented DTLS handshake message" \
7595 -c "found fragmented DTLS handshake message" \
7596 -C "error"
7597
Andrzej Kurek77826052018-10-11 07:34:08 -04007598# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007599# This ensures things still work after session_reset().
7600# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007601# Since we don't support reading fragmented ClientHello yet,
7602# up the MTU to 1450 (larger than ClientHello with session ticket,
7603# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007604# An autoreduction on the client-side might happen if the server is
7605# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007606# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007607# resumed listening, which would result in a spurious autoreduction.
7608not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007609requires_config_enabled MBEDTLS_RSA_C
7610requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007611requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7612requires_config_enabled MBEDTLS_AES_C
7613requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007614run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7615 -p "$P_PXY mtu=1450" \
7616 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7617 crt_file=data_files/server7_int-ca.crt \
7618 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007619 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007620 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007621 mtu=1450" \
7622 "$P_CLI dtls=1 debug_level=2 \
7623 crt_file=data_files/server8_int-ca2.crt \
7624 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007625 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007626 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007627 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007628 mtu=1450 reconnect=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007629 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007630 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007631 -s "found fragmented DTLS handshake message" \
7632 -c "found fragmented DTLS handshake message" \
7633 -C "error"
7634
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007635# An autoreduction on the client-side might happen if the server is
7636# slow to reset, therefore omitting '-C "autoreduction"' below.
7637not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007638requires_config_enabled MBEDTLS_RSA_C
7639requires_config_enabled MBEDTLS_ECDSA_C
7640requires_config_enabled MBEDTLS_SHA256_C
7641requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7642requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7643requires_config_enabled MBEDTLS_CHACHAPOLY_C
7644run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7645 -p "$P_PXY mtu=512" \
7646 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7647 crt_file=data_files/server7_int-ca.crt \
7648 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007649 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007650 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007651 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007652 mtu=512" \
7653 "$P_CLI dtls=1 debug_level=2 \
7654 crt_file=data_files/server8_int-ca2.crt \
7655 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007656 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007657 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007658 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007659 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007660 mtu=512" \
7661 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007662 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007663 -s "found fragmented DTLS handshake message" \
7664 -c "found fragmented DTLS handshake message" \
7665 -C "error"
7666
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007667# An autoreduction on the client-side might happen if the server is
7668# slow to reset, therefore omitting '-C "autoreduction"' below.
7669not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007670requires_config_enabled MBEDTLS_RSA_C
7671requires_config_enabled MBEDTLS_ECDSA_C
7672requires_config_enabled MBEDTLS_SHA256_C
7673requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7674requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7675requires_config_enabled MBEDTLS_AES_C
7676requires_config_enabled MBEDTLS_GCM_C
7677run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7678 -p "$P_PXY mtu=512" \
7679 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7680 crt_file=data_files/server7_int-ca.crt \
7681 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007682 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007683 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007684 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007685 mtu=512" \
7686 "$P_CLI dtls=1 debug_level=2 \
7687 crt_file=data_files/server8_int-ca2.crt \
7688 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007689 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007690 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007691 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007692 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007693 mtu=512" \
7694 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007695 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007696 -s "found fragmented DTLS handshake message" \
7697 -c "found fragmented DTLS handshake message" \
7698 -C "error"
7699
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007700# An autoreduction on the client-side might happen if the server is
7701# slow to reset, therefore omitting '-C "autoreduction"' below.
7702not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007703requires_config_enabled MBEDTLS_RSA_C
7704requires_config_enabled MBEDTLS_ECDSA_C
7705requires_config_enabled MBEDTLS_SHA256_C
7706requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7707requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7708requires_config_enabled MBEDTLS_AES_C
7709requires_config_enabled MBEDTLS_CCM_C
7710run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007711 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007712 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7713 crt_file=data_files/server7_int-ca.crt \
7714 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007715 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007716 exchanges=2 renegotiation=1 \
7717 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007718 hs_timeout=10000-60000 \
7719 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007720 "$P_CLI dtls=1 debug_level=2 \
7721 crt_file=data_files/server8_int-ca2.crt \
7722 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007723 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007724 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007725 hs_timeout=10000-60000 \
7726 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007727 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007728 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007729 -s "found fragmented DTLS handshake message" \
7730 -c "found fragmented DTLS handshake message" \
7731 -C "error"
7732
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007733# An autoreduction on the client-side might happen if the server is
7734# slow to reset, therefore omitting '-C "autoreduction"' below.
7735not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007736requires_config_enabled MBEDTLS_RSA_C
7737requires_config_enabled MBEDTLS_ECDSA_C
7738requires_config_enabled MBEDTLS_SHA256_C
7739requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7740requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7741requires_config_enabled MBEDTLS_AES_C
7742requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7743requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7744run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007745 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007746 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7747 crt_file=data_files/server7_int-ca.crt \
7748 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007749 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007750 exchanges=2 renegotiation=1 \
7751 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007752 hs_timeout=10000-60000 \
7753 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007754 "$P_CLI dtls=1 debug_level=2 \
7755 crt_file=data_files/server8_int-ca2.crt \
7756 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007757 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007758 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007759 hs_timeout=10000-60000 \
7760 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007761 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007762 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007763 -s "found fragmented DTLS handshake message" \
7764 -c "found fragmented DTLS handshake message" \
7765 -C "error"
7766
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007767# An autoreduction on the client-side might happen if the server is
7768# slow to reset, therefore omitting '-C "autoreduction"' below.
7769not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007770requires_config_enabled MBEDTLS_RSA_C
7771requires_config_enabled MBEDTLS_ECDSA_C
7772requires_config_enabled MBEDTLS_SHA256_C
7773requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7774requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7775requires_config_enabled MBEDTLS_AES_C
7776requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7777run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007778 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007779 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7780 crt_file=data_files/server7_int-ca.crt \
7781 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007782 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007783 exchanges=2 renegotiation=1 \
7784 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007785 hs_timeout=10000-60000 \
7786 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007787 "$P_CLI dtls=1 debug_level=2 \
7788 crt_file=data_files/server8_int-ca2.crt \
7789 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007790 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007791 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007792 hs_timeout=10000-60000 \
7793 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007794 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007795 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007796 -s "found fragmented DTLS handshake message" \
7797 -c "found fragmented DTLS handshake message" \
7798 -C "error"
7799
Andrzej Kurek77826052018-10-11 07:34:08 -04007800# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007801requires_config_enabled MBEDTLS_RSA_C
7802requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007803requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7804requires_config_enabled MBEDTLS_AES_C
7805requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007806client_needs_more_time 2
7807run_test "DTLS fragmenting: proxy MTU + 3d" \
7808 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007809 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007810 crt_file=data_files/server7_int-ca.crt \
7811 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007812 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007813 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007814 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007815 crt_file=data_files/server8_int-ca2.crt \
7816 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007817 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007818 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007819 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007820 0 \
7821 -s "found fragmented DTLS handshake message" \
7822 -c "found fragmented DTLS handshake message" \
7823 -C "error"
7824
Andrzej Kurek77826052018-10-11 07:34:08 -04007825# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007826requires_config_enabled MBEDTLS_RSA_C
7827requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007828requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7829requires_config_enabled MBEDTLS_AES_C
7830requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007831client_needs_more_time 2
7832run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7833 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7834 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7835 crt_file=data_files/server7_int-ca.crt \
7836 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007837 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007838 hs_timeout=250-10000 mtu=512 nbio=2" \
7839 "$P_CLI dtls=1 debug_level=2 \
7840 crt_file=data_files/server8_int-ca2.crt \
7841 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007842 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007843 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007844 hs_timeout=250-10000 mtu=512 nbio=2" \
7845 0 \
7846 -s "found fragmented DTLS handshake message" \
7847 -c "found fragmented DTLS handshake message" \
7848 -C "error"
7849
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007850# interop tests for DTLS fragmentating with reliable connection
7851#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007852# here and below we just want to test that the we fragment in a way that
7853# pleases other implementations, so we don't need the peer to fragment
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007854requires_config_enabled MBEDTLS_RSA_C
7855requires_config_enabled MBEDTLS_ECDSA_C
7856requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007857requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007858run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7859 "$G_SRV -u" \
7860 "$P_CLI dtls=1 debug_level=2 \
7861 crt_file=data_files/server8_int-ca2.crt \
7862 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007863 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007864 mtu=512 force_version=dtls1_2" \
7865 0 \
7866 -c "fragmenting handshake message" \
7867 -C "error"
7868
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007869requires_config_enabled MBEDTLS_RSA_C
7870requires_config_enabled MBEDTLS_ECDSA_C
7871requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007872requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007873run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
7874 "$G_SRV -u" \
7875 "$P_CLI dtls=1 debug_level=2 \
7876 crt_file=data_files/server8_int-ca2.crt \
7877 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007878 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007879 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007880 0 \
7881 -c "fragmenting handshake message" \
7882 -C "error"
7883
Hanno Beckerb9a00862018-08-28 10:20:22 +01007884# We use --insecure for the GnuTLS client because it expects
7885# the hostname / IP it connects to to be the name used in the
7886# certificate obtained from the server. Here, however, it
7887# connects to 127.0.0.1 while our test certificates use 'localhost'
7888# as the server name in the certificate. This will make the
7889# certifiate validation fail, but passing --insecure makes
7890# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007891requires_config_enabled MBEDTLS_RSA_C
7892requires_config_enabled MBEDTLS_ECDSA_C
7893requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007894requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007895requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007896run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007897 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007898 crt_file=data_files/server7_int-ca.crt \
7899 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007900 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007901 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007902 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007903 0 \
7904 -s "fragmenting handshake message"
7905
Hanno Beckerb9a00862018-08-28 10:20:22 +01007906# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007907requires_config_enabled MBEDTLS_RSA_C
7908requires_config_enabled MBEDTLS_ECDSA_C
7909requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007910requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007911requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007912run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007913 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007914 crt_file=data_files/server7_int-ca.crt \
7915 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007916 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007917 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007918 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007919 0 \
7920 -s "fragmenting handshake message"
7921
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007922requires_config_enabled MBEDTLS_RSA_C
7923requires_config_enabled MBEDTLS_ECDSA_C
7924requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7925run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
7926 "$O_SRV -dtls1_2 -verify 10" \
7927 "$P_CLI dtls=1 debug_level=2 \
7928 crt_file=data_files/server8_int-ca2.crt \
7929 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007930 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007931 mtu=512 force_version=dtls1_2" \
7932 0 \
7933 -c "fragmenting handshake message" \
7934 -C "error"
7935
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007936requires_config_enabled MBEDTLS_RSA_C
7937requires_config_enabled MBEDTLS_ECDSA_C
7938requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7939run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
7940 "$O_SRV -dtls1 -verify 10" \
7941 "$P_CLI dtls=1 debug_level=2 \
7942 crt_file=data_files/server8_int-ca2.crt \
7943 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007944 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007945 mtu=512 force_version=dtls1" \
7946 0 \
7947 -c "fragmenting handshake message" \
7948 -C "error"
7949
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007950requires_config_enabled MBEDTLS_RSA_C
7951requires_config_enabled MBEDTLS_ECDSA_C
7952requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7953run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
7954 "$P_SRV dtls=1 debug_level=2 \
7955 crt_file=data_files/server7_int-ca.crt \
7956 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007957 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007958 mtu=512 force_version=dtls1_2" \
7959 "$O_CLI -dtls1_2" \
7960 0 \
7961 -s "fragmenting handshake message"
7962
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007963requires_config_enabled MBEDTLS_RSA_C
7964requires_config_enabled MBEDTLS_ECDSA_C
7965requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7966run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
7967 "$P_SRV dtls=1 debug_level=2 \
7968 crt_file=data_files/server7_int-ca.crt \
7969 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007970 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007971 mtu=512 force_version=dtls1" \
7972 "$O_CLI -dtls1" \
7973 0 \
7974 -s "fragmenting handshake message"
7975
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007976# interop tests for DTLS fragmentating with unreliable connection
7977#
7978# again we just want to test that the we fragment in a way that
7979# pleases other implementations, so we don't need the peer to fragment
7980requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007981requires_config_enabled MBEDTLS_RSA_C
7982requires_config_enabled MBEDTLS_ECDSA_C
7983requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007984client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007985run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
7986 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7987 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007988 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007989 crt_file=data_files/server8_int-ca2.crt \
7990 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007991 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007992 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007993 0 \
7994 -c "fragmenting handshake message" \
7995 -C "error"
7996
7997requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007998requires_config_enabled MBEDTLS_RSA_C
7999requires_config_enabled MBEDTLS_ECDSA_C
8000requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008001client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008002run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8003 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8004 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008005 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008006 crt_file=data_files/server8_int-ca2.crt \
8007 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008008 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008009 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008010 0 \
8011 -c "fragmenting handshake message" \
8012 -C "error"
8013
k-stachowiakabb843e2019-02-18 16:14:03 +01008014requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008015requires_config_enabled MBEDTLS_RSA_C
8016requires_config_enabled MBEDTLS_ECDSA_C
8017requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8018client_needs_more_time 4
8019run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8020 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8021 "$P_SRV dtls=1 debug_level=2 \
8022 crt_file=data_files/server7_int-ca.crt \
8023 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008024 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008025 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008026 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008027 0 \
8028 -s "fragmenting handshake message"
8029
k-stachowiakabb843e2019-02-18 16:14:03 +01008030requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008031requires_config_enabled MBEDTLS_RSA_C
8032requires_config_enabled MBEDTLS_ECDSA_C
8033requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8034client_needs_more_time 4
8035run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8036 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8037 "$P_SRV dtls=1 debug_level=2 \
8038 crt_file=data_files/server7_int-ca.crt \
8039 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008040 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008041 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008042 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008043 0 \
8044 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008045
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008046## Interop test with OpenSSL might trigger a bug in recent versions (including
8047## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008048## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008049## They should be re-enabled once a fixed version of OpenSSL is available
8050## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008051skip_next_test
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008052requires_config_enabled MBEDTLS_RSA_C
8053requires_config_enabled MBEDTLS_ECDSA_C
8054requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8055client_needs_more_time 4
8056run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8057 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8058 "$O_SRV -dtls1_2 -verify 10" \
8059 "$P_CLI dtls=1 debug_level=2 \
8060 crt_file=data_files/server8_int-ca2.crt \
8061 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008062 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008063 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8064 0 \
8065 -c "fragmenting handshake message" \
8066 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008067
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008068skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008069requires_config_enabled MBEDTLS_RSA_C
8070requires_config_enabled MBEDTLS_ECDSA_C
8071requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008072client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008073run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8074 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008075 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008076 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008077 crt_file=data_files/server8_int-ca2.crt \
8078 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008079 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008080 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008081 0 \
8082 -c "fragmenting handshake message" \
8083 -C "error"
8084
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008085skip_next_test
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008086requires_config_enabled MBEDTLS_RSA_C
8087requires_config_enabled MBEDTLS_ECDSA_C
8088requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8089client_needs_more_time 4
8090run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8091 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8092 "$P_SRV dtls=1 debug_level=2 \
8093 crt_file=data_files/server7_int-ca.crt \
8094 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008095 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008096 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8097 "$O_CLI -dtls1_2" \
8098 0 \
8099 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008100
8101# -nbio is added to prevent s_client from blocking in case of duplicated
8102# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008103skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008104requires_config_enabled MBEDTLS_RSA_C
8105requires_config_enabled MBEDTLS_ECDSA_C
8106requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008107client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008108run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8109 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008110 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008111 crt_file=data_files/server7_int-ca.crt \
8112 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008113 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008114 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008115 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008116 0 \
8117 -s "fragmenting handshake message"
8118
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008119# Tests for specific things with "unreliable" UDP connection
8120
8121not_with_valgrind # spurious resend due to timeout
8122run_test "DTLS proxy: reference" \
8123 -p "$P_PXY" \
8124 "$P_SRV dtls=1 debug_level=2" \
8125 "$P_CLI dtls=1 debug_level=2" \
8126 0 \
8127 -C "replayed record" \
8128 -S "replayed record" \
Hanno Beckere03eb7b2019-07-19 15:43:09 +01008129 -C "Buffer record from epoch" \
8130 -S "Buffer record from epoch" \
8131 -C "ssl_buffer_message" \
8132 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008133 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008134 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008135 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008136 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008137 -c "HTTP/1.0 200 OK"
8138
8139not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008140run_test "DTLS proxy: duplicate every packet" \
8141 -p "$P_PXY duplicate=1" \
Hanno Becker7f376f42019-06-12 16:20:48 +01008142 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008143 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008144 0 \
8145 -c "replayed record" \
8146 -s "replayed record" \
8147 -c "record from another epoch" \
8148 -s "record from another epoch" \
8149 -S "resend" \
8150 -s "Extra-header:" \
8151 -c "HTTP/1.0 200 OK"
8152
8153run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8154 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008155 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8156 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008157 0 \
8158 -c "replayed record" \
8159 -S "replayed record" \
8160 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008161 -s "record from another epoch" \
8162 -c "resend" \
8163 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008164 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008165 -c "HTTP/1.0 200 OK"
8166
8167run_test "DTLS proxy: multiple records in same datagram" \
8168 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008169 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8170 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008171 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008172 -c "next record in same datagram" \
8173 -s "next record in same datagram"
8174
8175run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8176 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008177 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8178 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008179 0 \
8180 -c "next record in same datagram" \
8181 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008182
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008183run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8184 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008185 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8186 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008187 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008188 -c "discarding invalid record (mac)" \
8189 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008190 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008191 -c "HTTP/1.0 200 OK" \
8192 -S "too many records with bad MAC" \
8193 -S "Verification of the message MAC failed"
8194
8195run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8196 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008197 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8198 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008199 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008200 -C "discarding invalid record (mac)" \
8201 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008202 -S "Extra-header:" \
8203 -C "HTTP/1.0 200 OK" \
8204 -s "too many records with bad MAC" \
8205 -s "Verification of the message MAC failed"
8206
8207run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8208 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008209 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8210 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008211 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008212 -c "discarding invalid record (mac)" \
8213 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008214 -s "Extra-header:" \
8215 -c "HTTP/1.0 200 OK" \
8216 -S "too many records with bad MAC" \
8217 -S "Verification of the message MAC failed"
8218
8219run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8220 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008221 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8222 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008223 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008224 -c "discarding invalid record (mac)" \
8225 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008226 -s "Extra-header:" \
8227 -c "HTTP/1.0 200 OK" \
8228 -s "too many records with bad MAC" \
8229 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008230
8231run_test "DTLS proxy: delay ChangeCipherSpec" \
8232 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008233 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8234 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008235 0 \
8236 -c "record from another epoch" \
8237 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008238 -s "Extra-header:" \
8239 -c "HTTP/1.0 200 OK"
8240
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008241# Tests for reordering support with DTLS
8242
Hanno Becker56cdfd12018-08-17 13:42:15 +01008243run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8244 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008245 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8246 hs_timeout=2500-60000" \
8247 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8248 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008249 0 \
8250 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008251 -c "Next handshake message has been buffered - load"\
8252 -S "Buffering HS message" \
8253 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008254 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008255 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008256 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008257 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008258
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008259run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8260 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008261 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8262 hs_timeout=2500-60000" \
8263 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8264 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008265 0 \
8266 -c "Buffering HS message" \
8267 -c "found fragmented DTLS handshake message"\
8268 -c "Next handshake message 1 not or only partially bufffered" \
8269 -c "Next handshake message has been buffered - load"\
8270 -S "Buffering HS message" \
8271 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008272 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008273 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008274 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008275 -S "Remember CCS message"
8276
Hanno Beckera1adcca2018-08-24 14:41:07 +01008277# The client buffers the ServerKeyExchange before receiving the fragmented
8278# Certificate message; at the time of writing, together these are aroudn 1200b
8279# in size, so that the bound below ensures that the certificate can be reassembled
8280# while keeping the ServerKeyExchange.
8281requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8282run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008283 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008284 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8285 hs_timeout=2500-60000" \
8286 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8287 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008288 0 \
8289 -c "Buffering HS message" \
8290 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008291 -C "attempt to make space by freeing buffered messages" \
8292 -S "Buffering HS message" \
8293 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008294 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008295 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008296 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008297 -S "Remember CCS message"
8298
8299# The size constraints ensure that the delayed certificate message can't
8300# be reassembled while keeping the ServerKeyExchange message, but it can
8301# when dropping it first.
8302requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8303requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8304run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8305 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008306 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8307 hs_timeout=2500-60000" \
8308 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8309 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008310 0 \
8311 -c "Buffering HS message" \
8312 -c "attempt to make space by freeing buffered future messages" \
8313 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008314 -S "Buffering HS message" \
8315 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008316 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008317 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008318 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008319 -S "Remember CCS message"
8320
Hanno Becker56cdfd12018-08-17 13:42:15 +01008321run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8322 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008323 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8324 hs_timeout=2500-60000" \
8325 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8326 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008327 0 \
8328 -C "Buffering HS message" \
8329 -C "Next handshake message has been buffered - load"\
8330 -s "Buffering HS message" \
8331 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008332 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008333 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008334 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008335 -S "Remember CCS message"
8336
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02008337# This needs session tickets; otherwise CCS is the first message in its flight
8338requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008339run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8340 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008341 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8342 hs_timeout=2500-60000" \
8343 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8344 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008345 0 \
8346 -C "Buffering HS message" \
8347 -C "Next handshake message has been buffered - load"\
8348 -S "Buffering HS message" \
8349 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008350 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008351 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008352 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008353 -S "Remember CCS message"
8354
8355run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8356 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008357 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8358 hs_timeout=2500-60000" \
8359 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8360 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008361 0 \
8362 -C "Buffering HS message" \
8363 -C "Next handshake message has been buffered - load"\
8364 -S "Buffering HS message" \
8365 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008366 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008367 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008368 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008369 -s "Remember CCS message"
8370
Hanno Beckera1adcca2018-08-24 14:41:07 +01008371run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008372 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008373 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8374 hs_timeout=2500-60000" \
8375 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8376 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008377 0 \
8378 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008379 -s "Found buffered record from current epoch - load" \
8380 -c "Buffer record from epoch 1" \
8381 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008382
Hanno Beckera1adcca2018-08-24 14:41:07 +01008383# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8384# from the server are delayed, so that the encrypted Finished message
8385# is received and buffered. When the fragmented NewSessionTicket comes
8386# in afterwards, the encrypted Finished message must be freed in order
8387# to make space for the NewSessionTicket to be reassembled.
8388# This works only in very particular circumstances:
8389# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8390# of the NewSessionTicket, but small enough to also allow buffering of
8391# the encrypted Finished message.
8392# - The MTU setting on the server must be so small that the NewSessionTicket
8393# needs to be fragmented.
8394# - All messages sent by the server must be small enough to be either sent
8395# without fragmentation or be reassembled within the bounds of
8396# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8397# handshake, omitting CRTs.
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008398requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8399requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008400run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8401 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008402 "$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 +01008403 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8404 0 \
8405 -s "Buffer record from epoch 1" \
8406 -s "Found buffered record from current epoch - load" \
8407 -c "Buffer record from epoch 1" \
8408 -C "Found buffered record from current epoch - load" \
8409 -c "Enough space available after freeing future epoch record"
8410
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008411# Tests for "randomly unreliable connection": try a variety of flows and peers
8412
8413client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008414run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8415 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008416 "$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 +02008417 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008418 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008419 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8420 0 \
8421 -s "Extra-header:" \
8422 -c "HTTP/1.0 200 OK"
8423
Janos Follath74537a62016-09-02 13:45:28 +01008424client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008425run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8426 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008427 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8428 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008429 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8430 0 \
8431 -s "Extra-header:" \
8432 -c "HTTP/1.0 200 OK"
8433
Janos Follath74537a62016-09-02 13:45:28 +01008434client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008435run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8436 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008437 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8438 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008439 0 \
8440 -s "Extra-header:" \
8441 -c "HTTP/1.0 200 OK"
8442
Janos Follath74537a62016-09-02 13:45:28 +01008443client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008444run_test "DTLS proxy: 3d, FS, client auth" \
8445 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008446 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8447 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008448 0 \
8449 -s "Extra-header:" \
8450 -c "HTTP/1.0 200 OK"
8451
Janos Follath74537a62016-09-02 13:45:28 +01008452client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008453run_test "DTLS proxy: 3d, FS, ticket" \
8454 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008455 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8456 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008457 0 \
8458 -s "Extra-header:" \
8459 -c "HTTP/1.0 200 OK"
8460
Janos Follath74537a62016-09-02 13:45:28 +01008461client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008462run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8463 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008464 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8465 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008466 0 \
8467 -s "Extra-header:" \
8468 -c "HTTP/1.0 200 OK"
8469
Janos Follath74537a62016-09-02 13:45:28 +01008470client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008471run_test "DTLS proxy: 3d, max handshake, nbio" \
8472 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008473 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008474 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008475 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008476 0 \
8477 -s "Extra-header:" \
8478 -c "HTTP/1.0 200 OK"
8479
Janos Follath74537a62016-09-02 13:45:28 +01008480client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008481requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008482requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008483requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008484run_test "DTLS proxy: 3d, min handshake, resumption" \
8485 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008486 "$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 +02008487 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008488 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008489 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8490 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8491 0 \
8492 -s "a session has been resumed" \
8493 -c "a session has been resumed" \
8494 -s "Extra-header:" \
8495 -c "HTTP/1.0 200 OK"
8496
Janos Follath74537a62016-09-02 13:45:28 +01008497client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008498requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008499requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008500requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008501run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8502 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008503 "$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 +02008504 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008505 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008506 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8507 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8508 0 \
8509 -s "a session has been resumed" \
8510 -c "a session has been resumed" \
8511 -s "Extra-header:" \
8512 -c "HTTP/1.0 200 OK"
8513
Janos Follath74537a62016-09-02 13:45:28 +01008514client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008515requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008516run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008517 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008518 "$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 +02008519 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008520 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008521 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008522 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8523 0 \
8524 -c "=> renegotiate" \
8525 -s "=> renegotiate" \
8526 -s "Extra-header:" \
8527 -c "HTTP/1.0 200 OK"
8528
Janos Follath74537a62016-09-02 13:45:28 +01008529client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008530requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008531run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8532 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008533 "$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 +02008534 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008535 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008536 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008537 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8538 0 \
8539 -c "=> renegotiate" \
8540 -s "=> renegotiate" \
8541 -s "Extra-header:" \
8542 -c "HTTP/1.0 200 OK"
8543
Janos Follath74537a62016-09-02 13:45:28 +01008544client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008545requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008546run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008547 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008548 "$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 +02008549 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008550 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008551 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008552 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008553 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8554 0 \
8555 -c "=> renegotiate" \
8556 -s "=> renegotiate" \
8557 -s "Extra-header:" \
8558 -c "HTTP/1.0 200 OK"
8559
Janos Follath74537a62016-09-02 13:45:28 +01008560client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008561requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008562run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008563 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008564 "$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 +02008565 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008566 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008567 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008568 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008569 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8570 0 \
8571 -c "=> renegotiate" \
8572 -s "=> renegotiate" \
8573 -s "Extra-header:" \
8574 -c "HTTP/1.0 200 OK"
8575
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008576## Interop tests with OpenSSL might trigger a bug in recent versions (including
8577## all versions installed on the CI machines), reported here:
8578## Bug report: https://github.com/openssl/openssl/issues/6902
8579## They should be re-enabled once a fixed version of OpenSSL is available
8580## (this should happen in some 1.1.1_ release according to the ticket).
8581skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008582client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008583not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008584run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008585 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8586 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008587 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008588 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008589 -c "HTTP/1.0 200 OK"
8590
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008591skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008592client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008593not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008594run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8595 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8596 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008597 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008598 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008599 -c "HTTP/1.0 200 OK"
8600
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008601skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008602client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008603not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008604run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8605 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8606 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008607 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008608 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008609 -c "HTTP/1.0 200 OK"
8610
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008611requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008612client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008613not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008614run_test "DTLS proxy: 3d, gnutls server" \
8615 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8616 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008617 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008618 0 \
8619 -s "Extra-header:" \
8620 -c "Extra-header:"
8621
k-stachowiakabb843e2019-02-18 16:14:03 +01008622requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008623client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008624not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008625run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8626 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008627 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008628 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008629 0 \
8630 -s "Extra-header:" \
8631 -c "Extra-header:"
8632
k-stachowiakabb843e2019-02-18 16:14:03 +01008633requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008634client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008635not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008636run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8637 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008638 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008639 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008640 0 \
8641 -s "Extra-header:" \
8642 -c "Extra-header:"
8643
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008644# Final report
8645
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008646echo "------------------------------------------------------------------------"
8647
8648if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008649 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008650else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008651 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008652fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008653PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008654echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008655
8656exit $FAILS