blob: 745f9b742af98fa8f178bc2123bb9b37884c19d8 [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é-Gonnardc73339f2014-02-26 16:35:27 +010074MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010075FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020076EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010077
Paul Bakkere20310a2016-05-10 11:18:17 +010078SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010079RUN_TEST_NUMBER=''
80
Paul Bakkeracaac852016-05-10 11:47:13 +010081PRESERVE_LOGS=0
82
Gilles Peskinef93c7d32017-04-14 17:55:28 +020083# Pick a "unique" server port in the range 10000-19999, and a proxy
84# port which is this plus 10000. Each port number may be independently
85# overridden by a command line option.
86SRV_PORT=$(($$ % 10000 + 10000))
87PXY_PORT=$((SRV_PORT + 10000))
88
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010089print_usage() {
90 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010091 printf " -h|--help\tPrint this help.\n"
92 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020093 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
94 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010095 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010096 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010097 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020098 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
99 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100100 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100101}
102
103get_options() {
104 while [ $# -gt 0 ]; do
105 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100106 -f|--filter)
107 shift; FILTER=$1
108 ;;
109 -e|--exclude)
110 shift; EXCLUDE=$1
111 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100112 -m|--memcheck)
113 MEMCHECK=1
114 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100115 -n|--number)
116 shift; RUN_TEST_NUMBER=$1
117 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100118 -s|--show-numbers)
119 SHOW_TEST_NUMBER=1
120 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100121 -p|--preserve-logs)
122 PRESERVE_LOGS=1
123 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200124 --port)
125 shift; SRV_PORT=$1
126 ;;
127 --proxy-port)
128 shift; PXY_PORT=$1
129 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100130 --seed)
131 shift; SEED="$1"
132 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100133 -h|--help)
134 print_usage
135 exit 0
136 ;;
137 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200138 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100139 print_usage
140 exit 1
141 ;;
142 esac
143 shift
144 done
145}
146
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100147# Skip next test; use this macro to skip tests which are legitimate
148# in theory and expected to be re-introduced at some point, but
149# aren't expected to succeed at the moment due to problems outside
150# our control (such as bugs in other TLS implementations).
151skip_next_test() {
152 SKIP_NEXT="YES"
153}
154
Hanno Becker91900362019-07-03 13:22:59 +0100155requires_ciphersuite_enabled() {
156 if [ -z "$($P_CLI --help | grep "$1")" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Hanno Becker7c48dd12018-08-28 16:09:22 +0100161get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100162 # This function uses the query_config command line option to query the
163 # required Mbed TLS compile time configuration from the ssl_server2
164 # program. The command will always return a success value if the
165 # configuration is defined and the value will be printed to stdout.
166 #
167 # Note that if the configuration is not defined or is defined to nothing,
168 # the output of this function will be an empty string.
169 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100170}
171
Hanno Beckerab9a29b2019-09-24 16:14:39 +0100172# skip next test if the flag is enabled in config.h
173requires_config_disabled() {
174 if get_config_value_or_default $1; then
175 SKIP_NEXT="YES"
176 fi
177}
178
179requires_config_enabled() {
180 if ! get_config_value_or_default $1; then
181 SKIP_NEXT="YES"
182 fi
183}
184
Hanno Becker7c48dd12018-08-28 16:09:22 +0100185requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100186 VAL="$( get_config_value_or_default "$1" )"
187 if [ -z "$VAL" ]; then
188 # Should never happen
189 echo "Mbed TLS configuration $1 is not defined"
190 exit 1
191 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100192 SKIP_NEXT="YES"
193 fi
194}
195
196requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100197 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100198 if [ -z "$VAL" ]; then
199 # Should never happen
200 echo "Mbed TLS configuration $1 is not defined"
201 exit 1
202 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100203 SKIP_NEXT="YES"
204 fi
205}
206
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200207# skip next test if OpenSSL doesn't support FALLBACK_SCSV
208requires_openssl_with_fallback_scsv() {
209 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
210 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
211 then
212 OPENSSL_HAS_FBSCSV="YES"
213 else
214 OPENSSL_HAS_FBSCSV="NO"
215 fi
216 fi
217 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
218 SKIP_NEXT="YES"
219 fi
220}
221
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200222# skip next test if GnuTLS isn't available
223requires_gnutls() {
224 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200225 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200226 GNUTLS_AVAILABLE="YES"
227 else
228 GNUTLS_AVAILABLE="NO"
229 fi
230 fi
231 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
232 SKIP_NEXT="YES"
233 fi
234}
235
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200236# skip next test if GnuTLS-next isn't available
237requires_gnutls_next() {
238 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
239 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
240 GNUTLS_NEXT_AVAILABLE="YES"
241 else
242 GNUTLS_NEXT_AVAILABLE="NO"
243 fi
244 fi
245 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
246 SKIP_NEXT="YES"
247 fi
248}
249
250# skip next test if OpenSSL-legacy isn't available
251requires_openssl_legacy() {
252 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
253 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
254 OPENSSL_LEGACY_AVAILABLE="YES"
255 else
256 OPENSSL_LEGACY_AVAILABLE="NO"
257 fi
258 fi
259 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
260 SKIP_NEXT="YES"
261 fi
262}
263
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200264# skip next test if IPv6 isn't available on this host
265requires_ipv6() {
266 if [ -z "${HAS_IPV6:-}" ]; then
267 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
268 SRV_PID=$!
269 sleep 1
270 kill $SRV_PID >/dev/null 2>&1
271 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
272 HAS_IPV6="NO"
273 else
274 HAS_IPV6="YES"
275 fi
276 rm -r $SRV_OUT
277 fi
278
279 if [ "$HAS_IPV6" = "NO" ]; then
280 SKIP_NEXT="YES"
281 fi
282}
283
Andrzej Kurekb4593462018-10-11 08:43:30 -0400284# skip next test if it's i686 or uname is not available
285requires_not_i686() {
286 if [ -z "${IS_I686:-}" ]; then
287 IS_I686="YES"
288 if which "uname" >/dev/null 2>&1; then
289 if [ -z "$(uname -a | grep i686)" ]; then
290 IS_I686="NO"
291 fi
292 fi
293 fi
294 if [ "$IS_I686" = "YES" ]; then
295 SKIP_NEXT="YES"
296 fi
297}
298
Angus Grattonc4dd0732018-04-11 16:28:39 +1000299# Calculate the input & output maximum content lengths set in the config
Arto Kinnunen78213522019-09-26 11:06:39 +0300300MAX_CONTENT_LEN="$( get_config_value_or_default MBEDTLS_SSL_MAX_CONTENT_LEN )"
301if [ -z "$MAX_CONTENT_LEN" ]; then
302 MAX_CONTENT_LEN=16384
303fi
304
305MAX_IN_LEN="$( get_config_value_or_default MBEDTLS_SSL_IN_CONTENT_LEN )"
306if [ -z "$MAX_IN_LEN" ]; then
307 MAX_IN_LEN=$MAX_CONTENT_LEN
308fi
309
310MAX_OUT_LEN="$( get_config_value_or_default MBEDTLS_SSL_OUT_CONTENT_LEN )"
311if [ -z "$MAX_OUT_LEN" ]; then
312 MAX_OUT_LEN=$MAX_CONTENT_LEN
313fi
Angus Grattonc4dd0732018-04-11 16:28:39 +1000314
315if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
316 MAX_CONTENT_LEN="$MAX_IN_LEN"
317fi
318if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
319 MAX_CONTENT_LEN="$MAX_OUT_LEN"
320fi
321
322# skip the next test if the SSL output buffer is less than 16KB
323requires_full_size_output_buffer() {
324 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
325 SKIP_NEXT="YES"
326 fi
327}
328
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200329# skip the next test if valgrind is in use
330not_with_valgrind() {
331 if [ "$MEMCHECK" -gt 0 ]; then
332 SKIP_NEXT="YES"
333 fi
334}
335
Paul Bakker362689d2016-05-13 10:33:25 +0100336# skip the next test if valgrind is NOT in use
337only_with_valgrind() {
338 if [ "$MEMCHECK" -eq 0 ]; then
339 SKIP_NEXT="YES"
340 fi
341}
342
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200343# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100344client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200345 CLI_DELAY_FACTOR=$1
346}
347
Janos Follath74537a62016-09-02 13:45:28 +0100348# wait for the given seconds after the client finished in the next test
349server_needs_more_time() {
350 SRV_DELAY_SECONDS=$1
351}
352
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100353# print_name <name>
354print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100355 TESTS=$(( $TESTS + 1 ))
356 LINE=""
357
358 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
359 LINE="$TESTS "
360 fi
361
362 LINE="$LINE$1"
363 printf "$LINE "
364 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100365 for i in `seq 1 $LEN`; do printf '.'; done
366 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100367
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100368}
369
370# fail <message>
371fail() {
372 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100373 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100374
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200375 mv $SRV_OUT o-srv-${TESTS}.log
376 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200377 if [ -n "$PXY_CMD" ]; then
378 mv $PXY_OUT o-pxy-${TESTS}.log
379 fi
380 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100381
Azim Khan19d13732018-03-29 11:04:20 +0100382 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 +0200383 echo " ! server output:"
384 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200385 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200386 echo " ! client output:"
387 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200388 if [ -n "$PXY_CMD" ]; then
389 echo " ! ========================================================"
390 echo " ! proxy output:"
391 cat o-pxy-${TESTS}.log
392 fi
393 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200394 fi
395
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200396 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100397}
398
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100399# is_polar <cmd_line>
400is_polar() {
401 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
402}
403
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200404# openssl s_server doesn't have -www with DTLS
405check_osrv_dtls() {
406 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
407 NEEDS_INPUT=1
408 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
409 else
410 NEEDS_INPUT=0
411 fi
412}
413
414# provide input to commands that need it
415provide_input() {
416 if [ $NEEDS_INPUT -eq 0 ]; then
417 return
418 fi
419
420 while true; do
421 echo "HTTP/1.0 200 OK"
422 sleep 1
423 done
424}
425
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100426# has_mem_err <log_file_name>
427has_mem_err() {
428 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
429 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
430 then
431 return 1 # false: does not have errors
432 else
433 return 0 # true: has errors
434 fi
435}
436
Unknown43dc0d62019-09-02 10:42:57 -0400437# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100438if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400439 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100440 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200441 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100442 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200443 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100444 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200445 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100446 # Make a tight loop, server normally takes less than 1s to start.
447 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
448 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400449 echo "$3 START TIMEOUT"
450 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100451 break
452 fi
453 # Linux and *BSD support decimal arguments to sleep. On other
454 # OSes this may be a tight loop.
455 sleep 0.1 2>/dev/null || true
456 done
457 }
458else
Unknown43dc0d62019-09-02 10:42:57 -0400459 echo "Warning: lsof not available, wait_app_start = sleep"
460 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200461 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100462 }
463fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200464
Unknown43dc0d62019-09-02 10:42:57 -0400465# Wait for server process $2 to be listening on port $1.
466wait_server_start() {
467 wait_app_start $1 $2 "SERVER" $SRV_OUT
468}
469
470# Wait for proxy process $2 to be listening on port $1.
471wait_proxy_start() {
472 wait_app_start $1 $2 "PROXY" $PXY_OUT
473}
474
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100475# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100476# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100477# acceptable bounds
478check_server_hello_time() {
479 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100480 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100481 # Get the Unix timestamp for now
482 CUR_TIME=$(date +'%s')
483 THRESHOLD_IN_SECS=300
484
485 # Check if the ServerHello time was printed
486 if [ -z "$SERVER_HELLO_TIME" ]; then
487 return 1
488 fi
489
490 # Check the time in ServerHello is within acceptable bounds
491 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
492 # The time in ServerHello is at least 5 minutes before now
493 return 1
494 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100495 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100496 return 1
497 else
498 return 0
499 fi
500}
501
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200502# wait for client to terminate and set CLI_EXIT
503# must be called right after starting the client
504wait_client_done() {
505 CLI_PID=$!
506
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200507 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
508 CLI_DELAY_FACTOR=1
509
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200510 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200511 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200512
513 wait $CLI_PID
514 CLI_EXIT=$?
515
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200516 kill $DOG_PID >/dev/null 2>&1
517 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200518
519 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100520
521 sleep $SRV_DELAY_SECONDS
522 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200523}
524
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200525# check if the given command uses dtls and sets global variable DTLS
526detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200527 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200528 DTLS=1
529 else
530 DTLS=0
531 fi
532}
533
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100534# Strip off a particular parameter from the command line
535# and return its value.
536# Parameter 1: Command line parameter to strip off
537# ENV I/O: CMD command line to search and modify
538extract_cmdline_argument() {
539 __ARG=$(echo "$CMD" | sed -n "s/^.* $1=\([^ ]*\).*$/\1/p")
540 CMD=$(echo "$CMD" | sed "s/$1=\([^ ]*\)//")
541}
542
543# Check compatibility of the ssl_client2/ssl_server2 command-line
544# with a particular compile-time configurable option.
545# Parameter 1: Command-line argument (e.g. extended_ms)
546# Parameter 2: Corresponding compile-time configuration
547# (e.g. MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET)
548# ENV I/O: CMD command line to search and modify
549# SKIP_NEXT set to "YES" on a mismatch
550check_cmdline_param_compat() {
551 __VAL="$( get_config_value_or_default "$2" )"
552 if [ ! -z "$__VAL" ]; then
553 extract_cmdline_argument "$1"
554 if [ ! -z "$__ARG" ] && [ "$__ARG" != "$__VAL" ]; then
555 SKIP_NEXT="YES"
556 fi
557 fi
558}
559
Hanno Beckera43f85c2019-09-05 14:51:20 +0100560check_cmdline_check_tls_dtls() {
Hanno Becker73b72d12019-07-26 12:00:38 +0100561 detect_dtls "$CMD"
562 if [ "$DTLS" = "0" ]; then
563 requires_config_disabled MBEDTLS_SSL_PROTO_NO_TLS
Hanno Beckera43f85c2019-09-05 14:51:20 +0100564 elif [ "$DTLS" = "1" ]; then
565 requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Hanno Becker73b72d12019-07-26 12:00:38 +0100566 fi
567}
568
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100569check_cmdline_authmode_compat() {
570 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_AUTHMODE" )"
571 if [ ! -z "$__VAL" ]; then
572 extract_cmdline_argument "auth_mode"
573 if [ "$__ARG" = "none" ] && [ "$__VAL" != "0" ]; then
574 SKIP_NEXT="YES";
575 elif [ "$__ARG" = "optional" ] && [ "$__VAL" != "1" ]; then
576 SKIP_NEXT="YES"
577 elif [ "$__ARG" = "required" ] && [ "$__VAL" != "2" ]; then
578 SKIP_NEXT="YES"
579 fi
580 fi
581}
582
Hanno Beckerb0b2b672019-06-12 16:58:10 +0100583check_cmdline_legacy_renego_compat() {
584 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_ALLOW_LEGACY_RENEGOTIATION" )"
585 if [ ! -z "$__VAL" ]; then
586 extract_cmdline_argument "allow_legacy"
587 if [ "$__ARG" = "-1" ] && [ "$__VAL" != "2" ]; then
588 SKIP_NEXT="YES";
589 elif [ "$__ARG" = "0" ] && [ "$__VAL" != "0" ]; then
590 SKIP_NEXT="YES"
591 elif [ "$__ARG" = "1" ] && [ "$__VAL" != "1" ]; then
592 SKIP_NEXT="YES"
593 fi
594 fi
595}
596
Hanno Beckerd82a0302019-07-05 11:40:52 +0100597check_cmdline_min_minor_version_compat() {
598 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MIN_MINOR_VER" )"
599 if [ ! -z "$__VAL" ]; then
600 extract_cmdline_argument "min_version"
601 if [ "$__ARG" = "ssl3" ] && [ "$__VAL" != "0" ]; then
602 SKIP_NEXT="YES";
603 elif [ "$__ARG" = "tls1" ] && [ "$__VAL" != "1" ]; then
604 SKIP_NEXT="YES"
605 elif [ "$__ARG" = "tls1_1" ] && [ "$__VAL" != "2" ]; then
606 SKIP_NEXT="YES"
607 elif [ "$__ARG" = "tls1_2" ] && [ "$__VAL" != "3" ]; then
608 SKIP_NEXT="YES"
609 fi
610 fi
611}
612
613check_cmdline_max_minor_version_compat() {
614 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MAX_MINOR_VER" )"
615 if [ ! -z "$__VAL" ]; then
616 extract_cmdline_argument "max_version"
617 if [ "$__ARG" = "ssl3" ] && [ "$__VAL" != "0" ]; then
618 SKIP_NEXT="YES";
619 elif [ "$__ARG" = "tls1" ] && [ "$__VAL" != "1" ]; then
620 SKIP_NEXT="YES"
621 elif [ "$__ARG" = "tls1_1" ] && [ "$__VAL" != "2" ]; then
622 SKIP_NEXT="YES"
623 elif [ "$__ARG" = "tls1_2" ] && [ "$__VAL" != "3" ]; then
624 SKIP_NEXT="YES"
625 fi
626 fi
627}
628
629check_cmdline_force_version_compat() {
630 __VAL_MAX="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MAX_MINOR_VER" )"
631 __VAL_MIN="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MIN_MINOR_VER" )"
632 if [ ! -z "$__VAL_MIN" ]; then
633
634 # SSL cli/srv cmd line
635
636 extract_cmdline_argument "force_version"
637 if [ "$__ARG" = "ssl3" ] && \
638 ( [ "$__VAL_MIN" != "0" ] || [ "$__VAL_MAX" != "0" ] ); then
639 SKIP_NEXT="YES";
640 elif [ "$__ARG" = "tls1" ] && \
641 ( [ "$__VAL_MIN" != "1" ] || [ "$__VAL_MAX" != "1" ] ); then
642 SKIP_NEXT="YES"
643 elif ( [ "$__ARG" = "tls1_1" ] || [ "$__ARG" = "dtls1" ] ) && \
644 ( [ "$__VAL_MIN" != "2" ] || [ "$__VAL_MAX" != "2" ] ); then
645 SKIP_NEXT="YES"
646 elif ( [ "$__ARG" = "tls1_2" ] || [ "$__ARG" = "dtls1_2" ] ) && \
647 ( [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ] ); then
648 echo "FORCE SKIP"
649 SKIP_NEXT="YES"
650 fi
651
652 # OpenSSL cmd line
653
654 if echo "$CMD" | grep -e "-tls1\($\|[^_]\)" > /dev/null; then
655 if [ "$__VAL_MIN" != "1" ] || [ "$__VAL_MAX" != "1" ]; then
656 SKIP_NEXT="YES"
657 fi
658 fi
659
660 if echo "$CMD" | grep -e "-\(dtls1\($\|[^_]\)\|tls1_1\)" > /dev/null; then
661 if [ "$__VAL_MIN" != "2" ] || [ "$__VAL_MAX" != "2" ]; then
662 SKIP_NEXT="YES"
663 fi
664 fi
665
666 if echo "$CMD" | grep -e "-\(dtls1_2\($\|[^_]\)\|tls1_2\)" > /dev/null; then
667 if [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ]; then
668 SKIP_NEXT="YES"
669 fi
670 fi
671
672 fi
673}
674
Hanno Becker69c6cde2019-09-02 14:34:23 +0100675check_cmdline_crt_key_files_compat() {
676
677 # test-ca2.crt
678 if echo "$CMD" | grep -e "test-ca2" > /dev/null; then
679 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
680 fi
681
682 # Variants of server5.key and server5.crt
683 if echo "$CMD" | grep -e "server5" > /dev/null; then
684 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
685 fi
686
687 # Variants of server6.key and server6.crt
688 if echo "$CMD" | grep -e "server6" > /dev/null; then
689 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
690 fi
691
692}
693
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100694# Go through all options that can be hardcoded at compile-time and
695# detect whether the command line configures them in a conflicting
696# way. If so, skip the test. Otherwise, remove the corresponding
697# entry.
698# Parameter 1: Command line to inspect
699# Output: Modified command line
700# ENV I/O: SKIP_TEST set to 1 on mismatch.
701check_cmdline_compat() {
702 CMD="$1"
703
Hanno Becker69c6cde2019-09-02 14:34:23 +0100704 # Check that if we're specifying particular certificate and/or
705 # ECC key files, the corresponding curve is enabled.
706 check_cmdline_crt_key_files_compat
707
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100708 # ExtendedMasterSecret configuration
709 check_cmdline_param_compat "extended_ms" \
710 "MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET"
711 check_cmdline_param_compat "enforce_extended_master_secret" \
712 "MBEDTLS_SSL_CONF_ENFORCE_EXTENDED_MASTER_SECRET"
Hanno Becker7f376f42019-06-12 16:20:48 +0100713
714 # DTLS anti replay protection configuration
715 check_cmdline_param_compat "anti_replay" \
716 "MBEDTLS_SSL_CONF_ANTI_REPLAY"
717
Hanno Beckerde671542019-06-12 16:30:46 +0100718 # DTLS bad MAC limit
719 check_cmdline_param_compat "badmac_limit" \
720 "MBEDTLS_SSL_CONF_BADMAC_LIMIT"
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100721
Hanno Beckera43f85c2019-09-05 14:51:20 +0100722 # Skip tests relying on TLS/DTLS in configs that disable it.
723 check_cmdline_check_tls_dtls
Hanno Becker73b72d12019-07-26 12:00:38 +0100724
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100725 # Authentication mode
726 check_cmdline_authmode_compat
Hanno Beckerb0b2b672019-06-12 16:58:10 +0100727
728 # Legacy renegotiation
729 check_cmdline_legacy_renego_compat
Hanno Beckerd82a0302019-07-05 11:40:52 +0100730
731 # Version configuration
732 check_cmdline_min_minor_version_compat
733 check_cmdline_max_minor_version_compat
734 check_cmdline_force_version_compat
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100735}
736
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200737# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100738# Options: -s pattern pattern that must be present in server output
739# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100740# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100741# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100742# -S pattern pattern that must be absent in server output
743# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100744# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100745# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100746run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100747 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200748 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100749
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100750 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
751 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200752 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100753 return
754 fi
755
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100756 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100757
Paul Bakkerb7584a52016-05-10 10:50:43 +0100758 # Do we only run numbered tests?
759 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
760 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
761 else
762 SKIP_NEXT="YES"
763 fi
764
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200765 # does this test use a proxy?
766 if [ "X$1" = "X-p" ]; then
767 PXY_CMD="$2"
768 shift 2
769 else
770 PXY_CMD=""
771 fi
772
773 # get commands and client output
774 SRV_CMD="$1"
775 CLI_CMD="$2"
776 CLI_EXPECT="$3"
777 shift 3
778
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100779 check_cmdline_compat "$SRV_CMD"
780 SRV_CMD="$CMD"
781
782 check_cmdline_compat "$CLI_CMD"
783 CLI_CMD="$CMD"
784
Hanno Becker7a11e722019-05-10 14:38:42 +0100785 # Check if test uses files
786 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
787 if [ ! -z "$TEST_USES_FILES" ]; then
788 requires_config_enabled MBEDTLS_FS_IO
789 fi
790
791 # should we skip?
792 if [ "X$SKIP_NEXT" = "XYES" ]; then
793 SKIP_NEXT="NO"
794 echo "SKIP"
795 SKIPS=$(( $SKIPS + 1 ))
796 return
797 fi
798
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200799 # fix client port
800 if [ -n "$PXY_CMD" ]; then
801 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
802 else
803 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
804 fi
805
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200806 # update DTLS variable
807 detect_dtls "$SRV_CMD"
808
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100809 # prepend valgrind to our commands if active
810 if [ "$MEMCHECK" -gt 0 ]; then
811 if is_polar "$SRV_CMD"; then
812 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
813 fi
814 if is_polar "$CLI_CMD"; then
815 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
816 fi
817 fi
818
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200819 TIMES_LEFT=2
820 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200821 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200822
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200823 # run the commands
824 if [ -n "$PXY_CMD" ]; then
825 echo "$PXY_CMD" > $PXY_OUT
826 $PXY_CMD >> $PXY_OUT 2>&1 &
827 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400828 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200829 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200830
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200831 check_osrv_dtls
832 echo "$SRV_CMD" > $SRV_OUT
833 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
834 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100835 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200836
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200837 echo "$CLI_CMD" > $CLI_OUT
838 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
839 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100840
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100841 sleep 0.05
842
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200843 # terminate the server (and the proxy)
844 kill $SRV_PID
845 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100846
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200847 if [ -n "$PXY_CMD" ]; then
848 kill $PXY_PID >/dev/null 2>&1
849 wait $PXY_PID
850 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100851
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200852 # retry only on timeouts
853 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
854 printf "RETRY "
855 else
856 TIMES_LEFT=0
857 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200858 done
859
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100860 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200861 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100862 # expected client exit to incorrectly succeed in case of catastrophic
863 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100864 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200865 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100866 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100867 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100868 return
869 fi
870 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100871 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200872 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100873 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100874 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100875 return
876 fi
877 fi
878
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100879 # check server exit code
880 if [ $? != 0 ]; then
881 fail "server fail"
882 return
883 fi
884
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100885 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100886 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
887 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100888 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200889 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100890 return
891 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100892
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100893 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200894 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100895 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100896 while [ $# -gt 0 ]
897 do
898 case $1 in
899 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100900 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 +0100901 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100902 return
903 fi
904 ;;
905
906 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100907 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 +0100908 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100909 return
910 fi
911 ;;
912
913 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100914 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 +0100915 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100916 return
917 fi
918 ;;
919
920 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100921 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 +0100922 fail "pattern '$2' MUST NOT be present in the Client output"
923 return
924 fi
925 ;;
926
927 # The filtering in the following two options (-u and -U) do the following
928 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100929 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100930 # - keep one of each non-unique line
931 # - count how many lines remain
932 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
933 # if there were no duplicates.
934 "-U")
935 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
936 fail "lines following pattern '$2' must be unique in Server output"
937 return
938 fi
939 ;;
940
941 "-u")
942 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
943 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100944 return
945 fi
946 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100947 "-F")
948 if ! $2 "$SRV_OUT"; then
949 fail "function call to '$2' failed on Server output"
950 return
951 fi
952 ;;
953 "-f")
954 if ! $2 "$CLI_OUT"; then
955 fail "function call to '$2' failed on Client output"
956 return
957 fi
958 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100959
960 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200961 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100962 exit 1
963 esac
964 shift 2
965 done
966
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100967 # check valgrind's results
968 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200969 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100970 fail "Server has memory errors"
971 return
972 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200973 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100974 fail "Client has memory errors"
975 return
976 fi
977 fi
978
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100979 # if we're here, everything is ok
980 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100981 if [ "$PRESERVE_LOGS" -gt 0 ]; then
982 mv $SRV_OUT o-srv-${TESTS}.log
983 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100984 if [ -n "$PXY_CMD" ]; then
985 mv $PXY_OUT o-pxy-${TESTS}.log
986 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100987 fi
988
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200989 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100990}
991
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100992cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200993 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200994 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
995 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
996 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
997 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100998 exit 1
999}
1000
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +01001001#
1002# MAIN
1003#
1004
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +01001005get_options "$@"
1006
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001007# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +01001008P_SRV_BIN="${P_SRV%%[ ]*}"
1009P_CLI_BIN="${P_CLI%%[ ]*}"
1010P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +01001011if [ ! -x "$P_SRV_BIN" ]; then
1012 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001013 exit 1
1014fi
Hanno Becker17c04932017-10-10 14:44:53 +01001015if [ ! -x "$P_CLI_BIN" ]; then
1016 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001017 exit 1
1018fi
Hanno Becker17c04932017-10-10 14:44:53 +01001019if [ ! -x "$P_PXY_BIN" ]; then
1020 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001021 exit 1
1022fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +01001023if [ "$MEMCHECK" -gt 0 ]; then
1024 if which valgrind >/dev/null 2>&1; then :; else
1025 echo "Memcheck not possible. Valgrind not found"
1026 exit 1
1027 fi
1028fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001029if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1030 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001031 exit 1
1032fi
1033
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001034# used by watchdog
1035MAIN_PID="$$"
1036
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001037# We use somewhat arbitrary delays for tests:
1038# - how long do we wait for the server to start (when lsof not available)?
1039# - how long do we allow for the client to finish?
1040# (not to check performance, just to avoid waiting indefinitely)
1041# Things are slower with valgrind, so give extra time here.
1042#
1043# Note: without lsof, there is a trade-off between the running time of this
1044# script and the risk of spurious errors because we didn't wait long enough.
1045# The watchdog delay on the other hand doesn't affect normal running time of
1046# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001047if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001048 START_DELAY=6
1049 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001050else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001051 START_DELAY=2
1052 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001053fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001054
1055# some particular tests need more time:
1056# - for the client, we multiply the usual watchdog limit by a factor
1057# - for the server, we sleep for a number of seconds after the client exits
1058# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001059CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001060SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001061
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001062# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001063# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001064P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1065P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001066P_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 +02001067O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001068O_CLI="$O_CLI -connect localhost:+SRV_PORT"
1069G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001070G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001071
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001072if [ -n "${OPENSSL_LEGACY:-}" ]; then
1073 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1074 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1075fi
1076
Hanno Becker58e9dc32018-08-17 15:53:21 +01001077if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001078 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1079fi
1080
Hanno Becker58e9dc32018-08-17 15:53:21 +01001081if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001082 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001083fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001084
Gilles Peskine62469d92017-05-10 10:13:59 +02001085# Allow SHA-1, because many of our test certificates use it
1086P_SRV="$P_SRV allow_sha1=1"
1087P_CLI="$P_CLI allow_sha1=1"
1088
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001089# Also pick a unique name for intermediate files
1090SRV_OUT="srv_out.$$"
1091CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001092PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001093SESSION="session.$$"
1094
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001095SKIP_NEXT="NO"
1096
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001097trap cleanup INT TERM HUP
1098
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001099# Basic test
1100
Hanno Becker91900362019-07-03 13:22:59 +01001101run_test "Default" \
1102 "$P_SRV debug_level=3" \
1103 "$P_CLI" \
1104 0
1105
1106run_test "Default, DTLS" \
1107 "$P_SRV dtls=1" \
1108 "$P_CLI dtls=1" \
1109 0
1110
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001111# Checks that:
1112# - things work with all ciphersuites active (used with config-full in all.sh)
1113# - the expected (highest security) parameters are selected
1114# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Hanno Becker91900362019-07-03 13:22:59 +01001115requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1116requires_config_enabled MBEDTLS_SHA512_C
1117requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1118requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1119run_test "Default, choose highest security suite and hash" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001120 "$P_SRV debug_level=3" \
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03001121 "$P_CLI" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001122 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001123 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001124 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001125 -s "client hello v3, signature_algorithm ext: 6" \
1126 -s "ECDHE curve: secp521r1" \
1127 -S "error" \
1128 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001129
Hanno Becker91900362019-07-03 13:22:59 +01001130requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1131requires_config_enabled MBEDTLS_SHA512_C
1132requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1133requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1134run_test "Default, choose highest security suite and hash, DTLS" \
1135 "$P_SRV debug_level=3 dtls=1" \
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001136 "$P_CLI dtls=1" \
1137 0 \
1138 -s "Protocol is DTLSv1.2" \
Hanno Becker91900362019-07-03 13:22:59 +01001139 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
1140 -s "client hello v3, signature_algorithm ext: 6" \
1141 -s "ECDHE curve: secp521r1"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001142
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001143# Test current time in ServerHello
1144requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001145run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001146 "$P_SRV debug_level=3" \
1147 "$P_CLI debug_level=3" \
1148 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001149 -f "check_server_hello_time" \
1150 -F "check_server_hello_time"
1151
Simon Butcher8e004102016-10-14 00:48:33 +01001152# Test for uniqueness of IVs in AEAD ciphersuites
1153run_test "Unique IV in GCM" \
1154 "$P_SRV exchanges=20 debug_level=4" \
1155 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1156 0 \
1157 -u "IV used" \
1158 -U "IV used"
1159
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001160# Tests for rc4 option
1161
Simon Butchera410af52016-05-19 22:12:18 +01001162requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001163run_test "RC4: server disabled, client enabled" \
1164 "$P_SRV" \
1165 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1166 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001167 -s "SSL - The server has no ciphersuites in common"
1168
Simon Butchera410af52016-05-19 22:12:18 +01001169requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001170run_test "RC4: server half, client enabled" \
1171 "$P_SRV arc4=1" \
1172 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1173 1 \
1174 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001175
1176run_test "RC4: server enabled, client disabled" \
1177 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1178 "$P_CLI" \
1179 1 \
1180 -s "SSL - The server has no ciphersuites in common"
1181
1182run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001183 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001184 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1185 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001186 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001187 -S "SSL - The server has no ciphersuites in common"
1188
Hanno Beckerd26bb202018-08-17 09:54:10 +01001189# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1190
1191requires_gnutls
1192requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1193run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1194 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001195 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001196 0
1197
1198requires_gnutls
1199requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1200run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1201 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001202 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001203 0
1204
Gilles Peskinebc70a182017-05-09 15:59:24 +02001205# Tests for SHA-1 support
1206
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001207requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001208requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001209requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001210run_test "SHA-1 forbidden by default in server certificate" \
1211 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1212 "$P_CLI debug_level=2 allow_sha1=0" \
1213 1 \
1214 -c "The certificate is signed with an unacceptable hash"
1215
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001216requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1217run_test "SHA-1 forbidden by default in server certificate" \
1218 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1219 "$P_CLI debug_level=2 allow_sha1=0" \
1220 0
1221
Gilles Peskinebc70a182017-05-09 15:59:24 +02001222run_test "SHA-1 explicitly allowed in server certificate" \
1223 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1224 "$P_CLI allow_sha1=1" \
1225 0
1226
1227run_test "SHA-256 allowed by default in server certificate" \
1228 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1229 "$P_CLI allow_sha1=0" \
1230 0
1231
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001232requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001233requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001234requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001235run_test "SHA-1 forbidden by default in client certificate" \
1236 "$P_SRV auth_mode=required allow_sha1=0" \
1237 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1238 1 \
1239 -s "The certificate is signed with an unacceptable hash"
1240
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001241requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1242run_test "SHA-1 forbidden by default in client certificate" \
1243 "$P_SRV auth_mode=required allow_sha1=0" \
1244 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1245 0
1246
Gilles Peskinebc70a182017-05-09 15:59:24 +02001247run_test "SHA-1 explicitly allowed in client certificate" \
1248 "$P_SRV auth_mode=required allow_sha1=1" \
1249 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1250 0
1251
1252run_test "SHA-256 allowed by default in client certificate" \
1253 "$P_SRV auth_mode=required allow_sha1=0" \
1254 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1255 0
1256
Hanno Becker7ae8a762018-08-14 15:43:35 +01001257# Tests for datagram packing
1258run_test "DTLS: multiple records in same datagram, client and server" \
1259 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1260 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1261 0 \
1262 -c "next record in same datagram" \
1263 -s "next record in same datagram"
1264
1265run_test "DTLS: multiple records in same datagram, client only" \
1266 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1267 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1268 0 \
1269 -s "next record in same datagram" \
1270 -C "next record in same datagram"
1271
1272run_test "DTLS: multiple records in same datagram, server only" \
1273 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1274 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1275 0 \
1276 -S "next record in same datagram" \
1277 -c "next record in same datagram"
1278
1279run_test "DTLS: multiple records in same datagram, neither client nor server" \
1280 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1281 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1282 0 \
1283 -S "next record in same datagram" \
1284 -C "next record in same datagram"
1285
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001286# Tests for Truncated HMAC extension
1287
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001288run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001289 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001290 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001291 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001292 -s "dumping 'expected mac' (20 bytes)" \
1293 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001294
Hanno Becker32c55012017-11-10 08:42:54 +00001295requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001296run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001297 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001298 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001299 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001300 -s "dumping 'expected mac' (20 bytes)" \
1301 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001302
Hanno Becker32c55012017-11-10 08:42:54 +00001303requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001304run_test "Truncated HMAC: client enabled, server default" \
1305 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001306 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001307 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001308 -s "dumping 'expected mac' (20 bytes)" \
1309 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001310
Hanno Becker32c55012017-11-10 08:42:54 +00001311requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001312run_test "Truncated HMAC: client enabled, server disabled" \
1313 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001314 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001315 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001316 -s "dumping 'expected mac' (20 bytes)" \
1317 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001318
Hanno Becker32c55012017-11-10 08:42:54 +00001319requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001320run_test "Truncated HMAC: client disabled, server enabled" \
1321 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001322 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001323 0 \
1324 -s "dumping 'expected mac' (20 bytes)" \
1325 -S "dumping 'expected mac' (10 bytes)"
1326
1327requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001328run_test "Truncated HMAC: client enabled, server enabled" \
1329 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001330 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001331 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001332 -S "dumping 'expected mac' (20 bytes)" \
1333 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001334
Hanno Becker4c4f4102017-11-10 09:16:05 +00001335run_test "Truncated HMAC, DTLS: client default, server default" \
1336 "$P_SRV dtls=1 debug_level=4" \
1337 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1338 0 \
1339 -s "dumping 'expected mac' (20 bytes)" \
1340 -S "dumping 'expected mac' (10 bytes)"
1341
1342requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1343run_test "Truncated HMAC, DTLS: client disabled, server default" \
1344 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001345 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001346 0 \
1347 -s "dumping 'expected mac' (20 bytes)" \
1348 -S "dumping 'expected mac' (10 bytes)"
1349
1350requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1351run_test "Truncated HMAC, DTLS: client enabled, server default" \
1352 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001353 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001354 0 \
1355 -s "dumping 'expected mac' (20 bytes)" \
1356 -S "dumping 'expected mac' (10 bytes)"
1357
1358requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1359run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1360 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001361 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001362 0 \
1363 -s "dumping 'expected mac' (20 bytes)" \
1364 -S "dumping 'expected mac' (10 bytes)"
1365
1366requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1367run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1368 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001369 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001370 0 \
1371 -s "dumping 'expected mac' (20 bytes)" \
1372 -S "dumping 'expected mac' (10 bytes)"
1373
1374requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1375run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1376 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001377 "$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 +01001378 0 \
1379 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001380 -s "dumping 'expected mac' (10 bytes)"
1381
Jarno Lamsafa45e602019-06-04 11:33:23 +03001382# Tests for Context serialization
1383
1384requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001385run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001386 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001387 "$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 +03001388 0 \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001389 -c "Deserializing connection..." \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001390 -S "Deserializing connection..."
1391
1392requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001393run_test "Context serialization, client serializes, ChaChaPoly" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001394 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001395 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001396 0 \
1397 -c "Deserializing connection..." \
1398 -S "Deserializing connection..."
1399
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001400requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001401run_test "Context serialization, client serializes, GCM" \
1402 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1403 "$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 +03001404 0 \
1405 -c "Deserializing connection..." \
1406 -S "Deserializing connection..."
Jarno Lamsacc281b82019-06-04 15:21:13 +03001407
Jarno Lamsafa45e602019-06-04 11:33:23 +03001408requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001409requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1410run_test "Context serialization, client serializes, with CID" \
1411 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1412 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1413 0 \
1414 -c "Deserializing connection..." \
1415 -S "Deserializing connection..."
1416
1417requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001418run_test "Context serialization, server serializes, CCM" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001419 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001420 "$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 +03001421 0 \
1422 -C "Deserializing connection..." \
1423 -s "Deserializing connection..."
1424
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001425requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001426run_test "Context serialization, server serializes, ChaChaPoly" \
1427 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1428 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1429 0 \
1430 -C "Deserializing connection..." \
1431 -s "Deserializing connection..."
1432
1433requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1434run_test "Context serialization, server serializes, GCM" \
1435 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1436 "$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 +03001437 0 \
1438 -C "Deserializing connection..." \
Jarno Lamsacc281b82019-06-04 15:21:13 +03001439 -s "Deserializing connection..."
Jarno Lamsafa45e602019-06-04 11:33:23 +03001440
1441requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001442requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1443run_test "Context serialization, server serializes, with CID" \
1444 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1445 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1446 0 \
1447 -C "Deserializing connection..." \
1448 -s "Deserializing connection..."
1449
1450requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001451run_test "Context serialization, both serialize, CCM" \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001452 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001453 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1454 0 \
1455 -c "Deserializing connection..." \
1456 -s "Deserializing connection..."
1457
1458requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1459run_test "Context serialization, both serialize, ChaChaPoly" \
1460 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1461 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1462 0 \
1463 -c "Deserializing connection..." \
1464 -s "Deserializing connection..."
1465
1466requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1467run_test "Context serialization, both serialize, GCM" \
1468 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1469 "$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 +03001470 0 \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001471 -c "Deserializing connection..." \
1472 -s "Deserializing connection..."
1473
1474requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001475requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1476run_test "Context serialization, both serialize, with CID" \
1477 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1478 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1479 0 \
1480 -c "Deserializing connection..." \
1481 -s "Deserializing connection..."
1482
1483requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001484run_test "Context serialization, re-init, client serializes, CCM" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001485 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001486 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1487 0 \
1488 -c "Deserializing connection..." \
1489 -S "Deserializing connection..."
1490
1491requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1492run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1493 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1494 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1495 0 \
1496 -c "Deserializing connection..." \
1497 -S "Deserializing connection..."
1498
1499requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1500run_test "Context serialization, re-init, client serializes, GCM" \
1501 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1502 "$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 +03001503 0 \
1504 -c "Deserializing connection..." \
1505 -S "Deserializing connection..."
1506
1507requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001508requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1509run_test "Context serialization, re-init, client serializes, with CID" \
1510 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1511 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1512 0 \
1513 -c "Deserializing connection..." \
1514 -S "Deserializing connection..."
1515
1516requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001517run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001518 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001519 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1520 0 \
1521 -C "Deserializing connection..." \
1522 -s "Deserializing connection..."
1523
1524requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1525run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1526 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1527 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1528 0 \
1529 -C "Deserializing connection..." \
1530 -s "Deserializing connection..."
1531
1532requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1533run_test "Context serialization, re-init, server serializes, GCM" \
1534 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1535 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001536 0 \
1537 -C "Deserializing connection..." \
1538 -s "Deserializing connection..."
1539
1540requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001541requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1542run_test "Context serialization, re-init, server serializes, with CID" \
1543 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1544 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1545 0 \
1546 -C "Deserializing connection..." \
1547 -s "Deserializing connection..."
1548
1549requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001550run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001551 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001552 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1553 0 \
1554 -c "Deserializing connection..." \
1555 -s "Deserializing connection..."
1556
1557requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1558run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1559 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1560 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1561 0 \
1562 -c "Deserializing connection..." \
1563 -s "Deserializing connection..."
1564
1565requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1566run_test "Context serialization, re-init, both serialize, GCM" \
1567 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1568 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001569 0 \
1570 -c "Deserializing connection..." \
1571 -s "Deserializing connection..."
1572
Hanno Beckere80c1b02019-08-30 11:18:59 +01001573requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1574requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1575run_test "Context serialization, re-init, both serialize, with CID" \
1576 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1577 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001578 0 \
1579 -c "Deserializing connection..." \
Hanno Becker73455992019-04-25 17:01:43 +01001580 -s "Deserializing connection..."
Hanno Beckerc008cb52019-04-26 14:17:56 +01001581
Hanno Becker4eb05872019-04-26 16:00:29 +01001582# Tests for DTLS Connection ID extension
Hanno Beckercf2a5652019-04-26 16:13:31 +01001583
Hanno Becker5e2cd142019-04-26 16:23:52 +01001584# So far, the CID API isn't implemented, so we can't
1585# grep for output witnessing its use. This needs to be
Hanno Becker6a3ff282019-04-26 17:19:46 +01001586# changed once the CID extension is implemented.
Hanno Beckerad8e2c92019-05-08 13:19:53 +01001587
Hanno Becker2dcdc922019-04-09 18:08:47 +01001588requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckera5a2b082019-05-15 14:03:01 +01001589run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001590 "$P_SRV debug_level=3 dtls=1 cid=0" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001591 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1592 0 \
1593 -s "Disable use of CID extension." \
1594 -s "found CID extension" \
Hanno Becker73455992019-04-25 17:01:43 +01001595 -s "Client sent CID extension, but CID disabled" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001596 -c "Enable use of CID extension." \
1597 -c "client hello, adding CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001598 -S "server hello, adding CID extension" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001599 -C "found CID extension" \
1600 -S "Copy CIDs into SSL transform" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001601 -C "Copy CIDs into SSL transform" \
1602 -c "Use of Connection ID was rejected by the server"
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001603
1604requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1605run_test "Connection ID: Cli disabled, Srv enabled" \
1606 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1607 "$P_CLI debug_level=3 dtls=1 cid=0" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001608 0 \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001609 -c "Disable use of CID extension." \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001610 -C "client hello, adding CID extension" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001611 -S "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001612 -s "Enable use of CID extension." \
1613 -S "server hello, adding CID extension" \
1614 -C "found CID extension" \
1615 -S "Copy CIDs into SSL transform" \
1616 -C "Copy CIDs into SSL transform" \
1617 -s "Use of Connection ID was not offered by client"
1618
1619requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1620run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
1621 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1622 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1623 0 \
1624 -c "Enable use of CID extension." \
1625 -s "Enable use of CID extension." \
1626 -c "client hello, adding CID extension" \
1627 -s "found CID extension" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001628 -s "Use of CID extension negotiated" \
1629 -s "server hello, adding CID extension" \
1630 -c "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001631 -c "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001632 -s "Copy CIDs into SSL transform" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001633 -c "Copy CIDs into SSL transform" \
1634 -c "Peer CID (length 2 Bytes): de ad" \
1635 -s "Peer CID (length 2 Bytes): be ef" \
1636 -s "Use of Connection ID has been negotiated" \
1637 -c "Use of Connection ID has been negotiated"
1638
1639requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1640run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
1641 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
1642 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1643 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1644 0 \
1645 -c "Enable use of CID extension." \
1646 -s "Enable use of CID extension." \
1647 -c "client hello, adding CID extension" \
1648 -s "found CID extension" \
1649 -s "Use of CID extension negotiated" \
1650 -s "server hello, adding CID extension" \
1651 -c "found CID extension" \
1652 -c "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001653 -s "Copy CIDs into SSL transform" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001654 -c "Copy CIDs into SSL transform" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001655 -c "Peer CID (length 2 Bytes): de ad" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001656 -s "Peer CID (length 2 Bytes): be ef" \
1657 -s "Use of Connection ID has been negotiated" \
1658 -c "Use of Connection ID has been negotiated" \
1659 -c "ignoring unexpected CID" \
1660 -s "ignoring unexpected CID"
1661
1662requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1663run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1664 -p "$P_PXY mtu=800" \
1665 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1666 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1667 0 \
1668 -c "Enable use of CID extension." \
1669 -s "Enable use of CID extension." \
1670 -c "client hello, adding CID extension" \
1671 -s "found CID extension" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001672 -s "Use of CID extension negotiated" \
1673 -s "server hello, adding CID extension" \
1674 -c "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001675 -c "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001676 -s "Copy CIDs into SSL transform" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001677 -c "Copy CIDs into SSL transform" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001678 -c "Peer CID (length 2 Bytes): de ad" \
1679 -s "Peer CID (length 2 Bytes): be ef" \
1680 -s "Use of Connection ID has been negotiated" \
1681 -c "Use of Connection ID has been negotiated"
Hanno Becker73455992019-04-25 17:01:43 +01001682
Hanno Beckerc008cb52019-04-26 14:17:56 +01001683requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1684run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001685 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001686 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1687 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001688 0 \
1689 -c "Enable use of CID extension." \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001690 -s "Enable use of CID extension." \
1691 -c "client hello, adding CID extension" \
1692 -s "found CID extension" \
1693 -s "Use of CID extension negotiated" \
1694 -s "server hello, adding CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001695 -c "found CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001696 -c "Use of CID extension negotiated" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001697 -s "Copy CIDs into SSL transform" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001698 -c "Copy CIDs into SSL transform" \
1699 -c "Peer CID (length 2 Bytes): de ad" \
1700 -s "Peer CID (length 2 Bytes): be ef" \
1701 -s "Use of Connection ID has been negotiated" \
Hanno Becker73455992019-04-25 17:01:43 +01001702 -c "Use of Connection ID has been negotiated" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001703 -c "ignoring unexpected CID" \
1704 -s "ignoring unexpected CID"
Hanno Becker4eb05872019-04-26 16:00:29 +01001705
Hanno Beckercf2a5652019-04-26 16:13:31 +01001706requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1707run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001708 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1709 "$P_CLI debug_level=3 dtls=1 cid=1" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001710 0 \
1711 -c "Enable use of CID extension." \
1712 -s "Enable use of CID extension." \
1713 -c "client hello, adding CID extension" \
1714 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001715 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001716 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001717 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001718 -c "Use of CID extension negotiated" \
1719 -s "Copy CIDs into SSL transform" \
1720 -c "Copy CIDs into SSL transform" \
1721 -c "Peer CID (length 4 Bytes): de ad be ef" \
Hanno Becker73455992019-04-25 17:01:43 +01001722 -s "Peer CID (length 0 Bytes):" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001723 -s "Use of Connection ID has been negotiated" \
1724 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001725
Hanno Beckercf2a5652019-04-26 16:13:31 +01001726requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1727run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001728 "$P_SRV debug_level=3 dtls=1 cid=1" \
1729 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001730 0 \
1731 -c "Enable use of CID extension." \
1732 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001733 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001734 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001735 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001736 -s "server hello, adding CID extension" \
1737 -c "found CID extension" \
1738 -c "Use of CID extension negotiated" \
1739 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001740 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001741 -s "Peer CID (length 4 Bytes): de ad be ef" \
1742 -c "Peer CID (length 0 Bytes):" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001743 -s "Use of Connection ID has been negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001744 -c "Use of Connection ID has been negotiated"
1745
Hanno Becker5e2cd142019-04-26 16:23:52 +01001746requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1747run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001748 "$P_SRV debug_level=3 dtls=1 cid=1" \
1749 "$P_CLI debug_level=3 dtls=1 cid=1" \
1750 0 \
1751 -c "Enable use of CID extension." \
1752 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001753 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001754 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001755 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001756 -s "server hello, adding CID extension" \
1757 -c "found CID extension" \
1758 -c "Use of CID extension negotiated" \
1759 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001760 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001761 -S "Use of Connection ID has been negotiated" \
1762 -C "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001763
Hanno Beckercf2a5652019-04-26 16:13:31 +01001764requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1765run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001766 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1767 "$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 +01001768 0 \
1769 -c "Enable use of CID extension." \
1770 -s "Enable use of CID extension." \
1771 -c "client hello, adding CID extension" \
1772 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001773 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001774 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001775 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001776 -c "Use of CID extension negotiated" \
1777 -s "Copy CIDs into SSL transform" \
1778 -c "Copy CIDs into SSL transform" \
1779 -c "Peer CID (length 2 Bytes): de ad" \
Hanno Becker73455992019-04-25 17:01:43 +01001780 -s "Peer CID (length 2 Bytes): be ef" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001781 -s "Use of Connection ID has been negotiated" \
1782 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001783
Hanno Beckercf2a5652019-04-26 16:13:31 +01001784requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1785run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001786 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1787 "$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 +01001788 0 \
1789 -c "Enable use of CID extension." \
1790 -s "Enable use of CID extension." \
1791 -c "client hello, adding CID extension" \
1792 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001793 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001794 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001795 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001796 -c "Use of CID extension negotiated" \
1797 -s "Copy CIDs into SSL transform" \
1798 -c "Copy CIDs into SSL transform" \
1799 -c "Peer CID (length 4 Bytes): de ad be ef" \
Hanno Becker73455992019-04-25 17:01:43 +01001800 -s "Peer CID (length 0 Bytes):" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001801 -s "Use of Connection ID has been negotiated" \
1802 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001803
Hanno Beckercf2a5652019-04-26 16:13:31 +01001804requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1805run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001806 "$P_SRV debug_level=3 dtls=1 cid=1" \
1807 "$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 +01001808 0 \
1809 -c "Enable use of CID extension." \
1810 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001811 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001812 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001813 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001814 -s "server hello, adding CID extension" \
1815 -c "found CID extension" \
1816 -c "Use of CID extension negotiated" \
1817 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001818 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001819 -s "Peer CID (length 4 Bytes): de ad be ef" \
1820 -c "Peer CID (length 0 Bytes):" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001821 -s "Use of Connection ID has been negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001822 -c "Use of Connection ID has been negotiated"
1823
Hanno Becker5e2cd142019-04-26 16:23:52 +01001824requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1825run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001826 "$P_SRV debug_level=3 dtls=1 cid=1" \
1827 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1828 0 \
1829 -c "Enable use of CID extension." \
1830 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001831 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001832 -s "found CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001833 -s "Use of CID extension negotiated" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001834 -s "server hello, adding CID extension" \
1835 -c "found CID extension" \
1836 -c "Use of CID extension negotiated" \
1837 -s "Copy CIDs into SSL transform" \
Hanno Becker73455992019-04-25 17:01:43 +01001838 -c "Copy CIDs into SSL transform" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001839 -S "Use of Connection ID has been negotiated" \
1840 -C "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001841
Hanno Beckercf2a5652019-04-26 16:13:31 +01001842requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1843run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001844 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1845 "$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 +01001846 0 \
1847 -c "Enable use of CID extension." \
1848 -s "Enable use of CID extension." \
1849 -c "client hello, adding CID extension" \
1850 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001851 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001852 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001853 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001854 -c "Use of CID extension negotiated" \
1855 -s "Copy CIDs into SSL transform" \
1856 -c "Copy CIDs into SSL transform" \
1857 -c "Peer CID (length 2 Bytes): de ad" \
Hanno Becker73455992019-04-25 17:01:43 +01001858 -s "Peer CID (length 2 Bytes): be ef" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001859 -s "Use of Connection ID has been negotiated" \
1860 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001861
Hanno Beckercf2a5652019-04-26 16:13:31 +01001862requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1863run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001864 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1865 "$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 +01001866 0 \
1867 -c "Enable use of CID extension." \
1868 -s "Enable use of CID extension." \
1869 -c "client hello, adding CID extension" \
1870 -s "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001871 -s "Use of CID extension negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001872 -s "server hello, adding CID extension" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001873 -c "found CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001874 -c "Use of CID extension negotiated" \
1875 -s "Copy CIDs into SSL transform" \
1876 -c "Copy CIDs into SSL transform" \
1877 -c "Peer CID (length 4 Bytes): de ad be ef" \
Hanno Becker73455992019-04-25 17:01:43 +01001878 -s "Peer CID (length 0 Bytes):" \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001879 -s "Use of Connection ID has been negotiated" \
1880 -c "Use of Connection ID has been negotiated"
Hanno Becker4eb05872019-04-26 16:00:29 +01001881
Hanno Beckercf2a5652019-04-26 16:13:31 +01001882requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1883run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001884 "$P_SRV debug_level=3 dtls=1 cid=1" \
1885 "$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 +01001886 0 \
1887 -c "Enable use of CID extension." \
1888 -s "Enable use of CID extension." \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001889 -c "client hello, adding CID extension" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001890 -s "found CID extension" \
Hanno Becker963cb352019-04-23 11:52:44 +01001891 -s "Use of CID extension negotiated" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001892 -s "server hello, adding CID extension" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001893 -c "found CID extension" \
1894 -c "Use of CID extension negotiated" \
1895 -s "Copy CIDs into SSL transform" \
Hanno Becker96870292019-05-03 17:30:59 +01001896 -c "Copy CIDs into SSL transform" \
1897 -s "Peer CID (length 4 Bytes): de ad be ef" \
1898 -c "Peer CID (length 0 Bytes):" \
1899 -s "Use of Connection ID has been negotiated" \
1900 -c "Use of Connection ID has been negotiated"
1901
1902requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1903run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
1904 "$P_SRV debug_level=3 dtls=1 cid=1" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001905 "$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 +01001906 0 \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001907 -c "Enable use of CID extension." \
Hanno Becker96870292019-05-03 17:30:59 +01001908 -s "Enable use of CID extension." \
1909 -c "client hello, adding CID extension" \
1910 -s "found CID extension" \
1911 -s "Use of CID extension negotiated" \
1912 -s "server hello, adding CID extension" \
1913 -c "found CID extension" \
1914 -c "Use of CID extension negotiated" \
1915 -s "Copy CIDs into SSL transform" \
1916 -c "Copy CIDs into SSL transform" \
1917 -S "Use of Connection ID has been negotiated" \
1918 -C "Use of Connection ID has been negotiated"
1919
Hanno Beckera5a2b082019-05-15 14:03:01 +01001920requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001921requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01001922run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
1923 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1924 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1925 0 \
1926 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1927 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1928 -s "(initial handshake) Use of Connection ID has been negotiated" \
1929 -c "(initial handshake) Use of Connection ID has been negotiated" \
1930 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1931 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1932 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1933 -c "(after renegotiation) Use of Connection ID has been negotiated"
1934
Hanno Beckera5a2b082019-05-15 14:03:01 +01001935requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01001936requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001937run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001938 "$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 +01001939 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1940 0 \
1941 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1942 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1943 -s "(initial handshake) Use of Connection ID has been negotiated" \
1944 -c "(initial handshake) Use of Connection ID has been negotiated" \
1945 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1946 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1947 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1948 -c "(after renegotiation) Use of Connection ID has been negotiated"
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001949
1950requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1951requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001952run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001953 "$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 +01001954 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1955 0 \
Hanno Becker96870292019-05-03 17:30:59 +01001956 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1957 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1958 -s "(initial handshake) Use of Connection ID has been negotiated" \
1959 -c "(initial handshake) Use of Connection ID has been negotiated" \
1960 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1961 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1962 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1963 -c "(after renegotiation) Use of Connection ID has been negotiated"
1964
1965requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1966requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
1967run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01001968 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker96870292019-05-03 17:30:59 +01001969 "$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 +01001970 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1971 0 \
1972 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1973 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1974 -s "(initial handshake) Use of Connection ID has been negotiated" \
1975 -c "(initial handshake) Use of Connection ID has been negotiated" \
1976 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1977 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1978 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1979 -c "(after renegotiation) Use of Connection ID has been negotiated" \
1980 -c "ignoring unexpected CID" \
1981 -s "ignoring unexpected CID"
1982
Hanno Beckera5a2b082019-05-15 14:03:01 +01001983requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01001984requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001985run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001986 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001987 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
1988 0 \
1989 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1990 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1991 -s "(initial handshake) Use of Connection ID has been negotiated" \
1992 -c "(initial handshake) Use of Connection ID has been negotiated" \
1993 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1994 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1995 -C "(after renegotiation) Use of Connection ID has been negotiated" \
1996 -S "(after renegotiation) Use of Connection ID has been negotiated"
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001997
1998requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1999requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002000run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01002001 "$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 +01002002 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2003 0 \
Hanno Becker96870292019-05-03 17:30:59 +01002004 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2005 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2006 -s "(initial handshake) Use of Connection ID has been negotiated" \
2007 -c "(initial handshake) Use of Connection ID has been negotiated" \
2008 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2009 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2010 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2011 -S "(after renegotiation) Use of Connection ID has been negotiated"
2012
2013requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckera5a2b082019-05-15 14:03:01 +01002014requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker96870292019-05-03 17:30:59 +01002015run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Becker84bbc512019-05-08 16:20:46 +01002016 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
2017 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2018 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2019 0 \
2020 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2021 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2022 -s "(initial handshake) Use of Connection ID has been negotiated" \
2023 -c "(initial handshake) Use of Connection ID has been negotiated" \
2024 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2025 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2026 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01002027 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Becker84bbc512019-05-08 16:20:46 +01002028 -c "ignoring unexpected CID" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002029 -s "ignoring unexpected CID"
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002030
Hanno Becker04ca04c2019-05-08 13:31:15 +01002031requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2032requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2033run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
2034 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2035 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2036 0 \
2037 -S "(initial handshake) Use of Connection ID has been negotiated" \
2038 -C "(initial handshake) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002039 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2040 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2041 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002042 -s "(after renegotiation) Use of Connection ID has been negotiated"
Hanno Beckera5a2b082019-05-15 14:03:01 +01002043
Hanno Becker04ca04c2019-05-08 13:31:15 +01002044requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2045requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker96870292019-05-03 17:30:59 +01002046run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2047 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2048 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2049 0 \
2050 -S "(initial handshake) Use of Connection ID has been negotiated" \
2051 -C "(initial handshake) Use of Connection ID has been negotiated" \
2052 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2053 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2054 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2055 -s "(after renegotiation) Use of Connection ID has been negotiated"
2056
2057requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2058requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckera5a2b082019-05-15 14:03:01 +01002059run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002060 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002061 "$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 +01002062 "$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 +01002063 0 \
2064 -S "(initial handshake) Use of Connection ID has been negotiated" \
2065 -C "(initial handshake) Use of Connection ID has been negotiated" \
2066 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2067 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2068 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2069 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2070 -c "ignoring unexpected CID" \
2071 -s "ignoring unexpected CID"
2072
2073requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002074requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2075run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
2076 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002077 "$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 +01002078 0 \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002079 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2080 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2081 -s "(initial handshake) Use of Connection ID has been negotiated" \
2082 -c "(initial handshake) Use of Connection ID has been negotiated" \
2083 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2084 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2085 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2086 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2087 -s "(after renegotiation) Use of Connection ID was not offered by client"
2088
2089requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2090requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2091run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
2092 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
2093 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
Hanno Beckera5a2b082019-05-15 14:03:01 +01002094 "$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 +01002095 0 \
2096 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002097 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
Hanno Becker96870292019-05-03 17:30:59 +01002098 -s "(initial handshake) Use of Connection ID has been negotiated" \
2099 -c "(initial handshake) Use of Connection ID has been negotiated" \
2100 -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 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2105 -c "ignoring unexpected CID" \
2106 -s "ignoring unexpected CID"
2107
2108requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002109requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2110run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2111 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01002112 "$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 +01002113 0 \
2114 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2115 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002116 -s "(initial handshake) Use of Connection ID has been negotiated" \
2117 -c "(initial handshake) Use of Connection ID has been negotiated" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002118 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2119 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2120 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2121 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2122 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2123
2124requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2125requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2126run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
2127 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002128 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2129 "$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 +01002130 0 \
2131 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2132 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2133 -s "(initial handshake) Use of Connection ID has been negotiated" \
2134 -c "(initial handshake) Use of Connection ID has been negotiated" \
2135 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2136 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2137 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2138 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002139 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2140 -c "ignoring unexpected CID" \
2141 -s "ignoring unexpected CID"
2142
2143# Tests for Encrypt-then-MAC extension
2144
2145run_test "Encrypt then MAC: default" \
2146 "$P_SRV debug_level=3 \
2147 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2148 "$P_CLI debug_level=3" \
2149 0 \
2150 -c "client hello, adding encrypt_then_mac extension" \
2151 -s "found encrypt then mac extension" \
2152 -s "server hello, adding encrypt then mac extension" \
2153 -c "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002154 -c "using encrypt then mac" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002155 -s "using encrypt then mac"
2156
2157run_test "Encrypt then MAC: client enabled, server disabled" \
2158 "$P_SRV debug_level=3 etm=0 \
2159 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2160 "$P_CLI debug_level=3 etm=1" \
2161 0 \
2162 -c "client hello, adding encrypt_then_mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002163 -s "found encrypt then mac extension" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002164 -S "server hello, adding encrypt then mac extension" \
2165 -C "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002166 -C "using encrypt then mac" \
2167 -S "using encrypt then mac"
2168
2169run_test "Encrypt then MAC: client enabled, aead cipher" \
2170 "$P_SRV debug_level=3 etm=1 \
2171 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2172 "$P_CLI debug_level=3 etm=1" \
2173 0 \
2174 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathe2681a42016-03-07 15:57:05 +00002175 -s "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002176 -S "server hello, adding encrypt then mac extension" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002177 -C "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002178 -C "using encrypt then mac" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002179 -S "using encrypt then mac"
2180
2181run_test "Encrypt then MAC: client enabled, stream cipher" \
2182 "$P_SRV debug_level=3 etm=1 \
2183 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2184 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2185 0 \
2186 -c "client hello, adding encrypt_then_mac extension" \
2187 -s "found encrypt then mac extension" \
Janos Follathe2681a42016-03-07 15:57:05 +00002188 -S "server hello, adding encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002189 -C "found encrypt_then_mac extension" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002190 -C "using encrypt then mac" \
2191 -S "using encrypt then mac"
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002192
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002193run_test "Encrypt then MAC: client disabled, server enabled" \
2194 "$P_SRV debug_level=3 etm=1 \
Janos Follath00efff72016-05-06 13:48:23 +01002195 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002196 "$P_CLI debug_level=3 etm=0" \
2197 0 \
2198 -C "client hello, adding encrypt_then_mac extension" \
2199 -S "found encrypt then mac extension" \
2200 -S "server hello, adding encrypt then mac extension" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002201 -C "found encrypt_then_mac extension" \
2202 -C "using encrypt then mac" \
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002203 -S "using encrypt then mac"
2204
2205requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2206run_test "Encrypt then MAC: client SSLv3, server enabled" \
2207 "$P_SRV debug_level=3 min_version=ssl3 \
2208 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2209 "$P_CLI debug_level=3 force_version=ssl3" \
2210 0 \
2211 -C "client hello, adding encrypt_then_mac extension" \
2212 -S "found encrypt then mac extension" \
2213 -S "server hello, adding encrypt then mac extension" \
2214 -C "found encrypt_then_mac extension" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002215 -C "using encrypt then mac" \
2216 -S "using encrypt then mac"
2217
2218requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2219run_test "Encrypt then MAC: client enabled, server SSLv3" \
2220 "$P_SRV debug_level=3 force_version=ssl3 \
2221 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2222 "$P_CLI debug_level=3 min_version=ssl3" \
2223 0 \
2224 -c "client hello, adding encrypt_then_mac extension" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002225 -S "found encrypt then mac extension" \
2226 -S "server hello, adding encrypt then mac extension" \
2227 -C "found encrypt_then_mac extension" \
2228 -C "using encrypt then mac" \
2229 -S "using encrypt then mac"
2230
2231# Tests for Extended Master Secret extension
2232
2233run_test "Extended Master Secret: default (not enforcing)" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002234 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0 " \
2235 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01002236 0 \
2237 -c "client hello, adding extended_master_secret extension" \
2238 -s "found extended master secret extension" \
2239 -s "server hello, adding extended master secret extension" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002240 -c "found extended_master_secret extension" \
2241 -c "session hash for extended master secret" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002242 -s "session hash for extended master secret"
2243
Jarno Lamsa41b35912019-06-10 15:51:11 +03002244run_test "Extended Master Secret: both enabled, both enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002245 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2246 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002247 0 \
2248 -c "client hello, adding extended_master_secret extension" \
2249 -s "found extended master secret extension" \
2250 -s "server hello, adding extended master secret extension" \
2251 -c "found extended_master_secret extension" \
2252 -c "session hash for extended master secret" \
2253 -s "session hash for extended master secret"
2254
Jarno Lamsa20095af2019-06-11 17:16:58 +03002255run_test "Extended Master Secret: both enabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002256 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2257 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002258 0 \
2259 -c "client hello, adding extended_master_secret extension" \
2260 -s "found extended master secret extension" \
2261 -s "server hello, adding extended master secret extension" \
2262 -c "found extended_master_secret extension" \
2263 -c "session hash for extended master secret" \
2264 -s "session hash for extended master secret"
2265
2266run_test "Extended Master Secret: both enabled, server enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002267 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2268 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002269 0 \
2270 -c "client hello, adding extended_master_secret extension" \
2271 -s "found extended master secret extension" \
2272 -s "server hello, adding extended master secret extension" \
2273 -c "found extended_master_secret extension" \
2274 -c "session hash for extended master secret" \
2275 -s "session hash for extended master secret"
2276
2277run_test "Extended Master Secret: client enabled, server disabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002278 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002279 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2280 1 \
2281 -c "client hello, adding extended_master_secret extension" \
2282 -s "found extended master secret extension" \
2283 -S "server hello, adding extended master secret extension" \
2284 -C "found extended_master_secret extension" \
2285 -c "Peer not offering extended master secret, while it is enforced"
2286
Jarno Lamsa20095af2019-06-11 17:16:58 +03002287run_test "Extended Master Secret enforced: client disabled, server enabled, server enforcing" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002288 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002289 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002290 1 \
2291 -C "client hello, adding extended_master_secret extension" \
2292 -S "found extended master secret extension" \
2293 -S "server hello, adding extended master secret extension" \
2294 -C "found extended_master_secret extension" \
2295 -s "Peer not offering extended master secret, while it is enforced"
2296
Jarno Lamsa20095af2019-06-11 17:16:58 +03002297run_test "Extended Master Secret: client enabled, server disabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002298 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2299 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002300 0 \
2301 -c "client hello, adding extended_master_secret extension" \
2302 -s "found extended master secret extension" \
2303 -S "server hello, adding extended master secret extension" \
2304 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002305 -C "session hash for extended master secret" \
2306 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002307
Jarno Lamsa20095af2019-06-11 17:16:58 +03002308run_test "Extended Master Secret: client disabled, server enabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002309 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2310 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002311 0 \
2312 -C "client hello, adding extended_master_secret extension" \
2313 -S "found extended master secret extension" \
2314 -S "server hello, adding extended master secret extension" \
2315 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002316 -C "session hash for extended master secret" \
2317 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002318
Jarno Lamsa20095af2019-06-11 17:16:58 +03002319run_test "Extended Master Secret: client disabled, server disabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002320 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2321 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002322 0 \
2323 -C "client hello, adding extended_master_secret extension" \
2324 -S "found extended master secret extension" \
2325 -S "server hello, adding extended master secret extension" \
2326 -C "found extended_master_secret extension" \
2327 -C "session hash for extended master secret" \
2328 -S "session hash for extended master secret"
2329
Janos Follathe2681a42016-03-07 15:57:05 +00002330requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002331run_test "Extended Master Secret: client SSLv3, server enabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002332 "$P_SRV debug_level=3 min_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2333 "$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 +02002334 0 \
2335 -C "client hello, adding extended_master_secret extension" \
2336 -S "found extended master secret extension" \
2337 -S "server hello, adding extended master secret extension" \
2338 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002339 -C "session hash for extended master secret" \
2340 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002341
Janos Follathe2681a42016-03-07 15:57:05 +00002342requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002343run_test "Extended Master Secret: client enabled, server SSLv3" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002344 "$P_SRV debug_level=3 force_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2345 "$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 +02002346 0 \
2347 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002348 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002349 -S "server hello, adding extended master secret extension" \
2350 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002351 -C "session hash for extended master secret" \
2352 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002353
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002354# Tests for FALLBACK_SCSV
2355
2356run_test "Fallback SCSV: default" \
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" \
2359 0 \
2360 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002361 -S "received FALLBACK_SCSV" \
2362 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002363 -C "is a fatal alert message (msg 86)"
2364
2365run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002366 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002367 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2368 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
2374run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002375 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002376 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002377 1 \
2378 -c "adding FALLBACK_SCSV" \
2379 -s "received FALLBACK_SCSV" \
2380 -s "inapropriate fallback" \
2381 -c "is a fatal alert message (msg 86)"
2382
2383run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002384 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002385 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002386 0 \
2387 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002388 -s "received FALLBACK_SCSV" \
2389 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002390 -C "is a fatal alert message (msg 86)"
2391
2392requires_openssl_with_fallback_scsv
2393run_test "Fallback SCSV: default, openssl server" \
2394 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002395 "$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 +02002396 0 \
2397 -C "adding FALLBACK_SCSV" \
2398 -C "is a fatal alert message (msg 86)"
2399
2400requires_openssl_with_fallback_scsv
2401run_test "Fallback SCSV: enabled, openssl server" \
2402 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002403 "$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 +02002404 1 \
2405 -c "adding FALLBACK_SCSV" \
2406 -c "is a fatal alert message (msg 86)"
2407
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002408requires_openssl_with_fallback_scsv
2409run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002410 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002411 "$O_CLI -tls1_1" \
2412 0 \
2413 -S "received FALLBACK_SCSV" \
2414 -S "inapropriate fallback"
2415
2416requires_openssl_with_fallback_scsv
2417run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002418 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002419 "$O_CLI -tls1_1 -fallback_scsv" \
2420 1 \
2421 -s "received FALLBACK_SCSV" \
2422 -s "inapropriate fallback"
2423
2424requires_openssl_with_fallback_scsv
2425run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002426 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002427 "$O_CLI -fallback_scsv" \
2428 0 \
2429 -s "received FALLBACK_SCSV" \
2430 -S "inapropriate fallback"
2431
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002432# Test sending and receiving empty application data records
2433
2434run_test "Encrypt then MAC: empty application data record" \
2435 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2436 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2437 0 \
2438 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2439 -s "dumping 'input payload after decrypt' (0 bytes)" \
2440 -c "0 bytes written in 1 fragments"
2441
2442run_test "Default, no Encrypt then MAC: empty application data record" \
2443 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2444 "$P_CLI auth_mode=none etm=0 request_size=0" \
2445 0 \
2446 -s "dumping 'input payload after decrypt' (0 bytes)" \
2447 -c "0 bytes written in 1 fragments"
2448
2449run_test "Encrypt then MAC, DTLS: empty application data record" \
2450 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2451 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2452 0 \
2453 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2454 -s "dumping 'input payload after decrypt' (0 bytes)" \
2455 -c "0 bytes written in 1 fragments"
2456
2457run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
2458 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2459 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2460 0 \
2461 -s "dumping 'input payload after decrypt' (0 bytes)" \
2462 -c "0 bytes written in 1 fragments"
2463
Gilles Peskined50177f2017-05-16 17:53:03 +02002464## ClientHello generated with
2465## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2466## then manually twiddling the ciphersuite list.
2467## The ClientHello content is spelled out below as a hex string as
2468## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2469## The expected response is an inappropriate_fallback alert.
2470requires_openssl_with_fallback_scsv
2471run_test "Fallback SCSV: beginning of list" \
2472 "$P_SRV debug_level=2" \
2473 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2474 0 \
2475 -s "received FALLBACK_SCSV" \
2476 -s "inapropriate fallback"
2477
2478requires_openssl_with_fallback_scsv
2479run_test "Fallback SCSV: end of list" \
2480 "$P_SRV debug_level=2" \
2481 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2482 0 \
2483 -s "received FALLBACK_SCSV" \
2484 -s "inapropriate fallback"
2485
2486## Here the expected response is a valid ServerHello prefix, up to the random.
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02002487## Due to the way the clienthello was generated, this currently needs the
2488## server to have support for session tickets.
2489requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Gilles Peskined50177f2017-05-16 17:53:03 +02002490requires_openssl_with_fallback_scsv
2491run_test "Fallback SCSV: not in list" \
2492 "$P_SRV debug_level=2" \
2493 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2494 0 \
2495 -S "received FALLBACK_SCSV" \
2496 -S "inapropriate fallback"
2497
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002498# Tests for CBC 1/n-1 record splitting
2499
2500run_test "CBC Record splitting: TLS 1.2, no splitting" \
2501 "$P_SRV" \
2502 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2503 request_size=123 force_version=tls1_2" \
2504 0 \
2505 -s "Read from client: 123 bytes read" \
2506 -S "Read from client: 1 bytes read" \
2507 -S "122 bytes read"
2508
2509run_test "CBC Record splitting: TLS 1.1, no splitting" \
2510 "$P_SRV" \
2511 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2512 request_size=123 force_version=tls1_1" \
2513 0 \
2514 -s "Read from client: 123 bytes read" \
2515 -S "Read from client: 1 bytes read" \
2516 -S "122 bytes read"
2517
2518run_test "CBC Record splitting: TLS 1.0, splitting" \
2519 "$P_SRV" \
2520 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2521 request_size=123 force_version=tls1" \
2522 0 \
2523 -S "Read from client: 123 bytes read" \
2524 -s "Read from client: 1 bytes read" \
2525 -s "122 bytes read"
2526
Janos Follathe2681a42016-03-07 15:57:05 +00002527requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002528run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002529 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002530 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2531 request_size=123 force_version=ssl3" \
2532 0 \
2533 -S "Read from client: 123 bytes read" \
2534 -s "Read from client: 1 bytes read" \
2535 -s "122 bytes read"
2536
2537run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002538 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002539 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2540 request_size=123 force_version=tls1" \
2541 0 \
2542 -s "Read from client: 123 bytes read" \
2543 -S "Read from client: 1 bytes read" \
2544 -S "122 bytes read"
2545
2546run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2547 "$P_SRV" \
2548 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2549 request_size=123 force_version=tls1 recsplit=0" \
2550 0 \
2551 -s "Read from client: 123 bytes read" \
2552 -S "Read from client: 1 bytes read" \
2553 -S "122 bytes read"
2554
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002555run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2556 "$P_SRV nbio=2" \
2557 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2558 request_size=123 force_version=tls1" \
2559 0 \
2560 -S "Read from client: 123 bytes read" \
2561 -s "Read from client: 1 bytes read" \
2562 -s "122 bytes read"
2563
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002564# Tests for Session Tickets
2565
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002566requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002567requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002568run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002569 "$P_SRV debug_level=3 tickets=1" \
2570 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002571 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002572 -c "client hello, adding session ticket extension" \
2573 -s "found session ticket extension" \
2574 -s "server hello, adding session ticket extension" \
2575 -c "found session_ticket extension" \
2576 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002577 -S "session successfully restored from cache" \
2578 -s "session successfully restored from ticket" \
2579 -s "a session has been resumed" \
2580 -c "a session has been resumed"
2581
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002582requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002583requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002584run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002585 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2586 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002587 0 \
2588 -c "client hello, adding session ticket extension" \
2589 -s "found session ticket extension" \
2590 -s "server hello, adding session ticket extension" \
2591 -c "found session_ticket extension" \
2592 -c "parse new session ticket" \
2593 -S "session successfully restored from cache" \
2594 -s "session successfully restored from ticket" \
2595 -s "a session has been resumed" \
2596 -c "a session has been resumed"
2597
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002598requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002599requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002600run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002601 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2602 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002603 0 \
2604 -c "client hello, adding session ticket extension" \
2605 -s "found session ticket extension" \
2606 -s "server hello, adding session ticket extension" \
2607 -c "found session_ticket extension" \
2608 -c "parse new session ticket" \
2609 -S "session successfully restored from cache" \
2610 -S "session successfully restored from ticket" \
2611 -S "a session has been resumed" \
2612 -C "a session has been resumed"
2613
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002614requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002615requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002616run_test "Session resume using tickets: session copy" \
2617 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2618 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2619 0 \
2620 -c "client hello, adding session ticket extension" \
2621 -s "found session ticket extension" \
2622 -s "server hello, adding session ticket extension" \
2623 -c "found session_ticket extension" \
2624 -c "parse new session ticket" \
2625 -S "session successfully restored from cache" \
2626 -s "session successfully restored from ticket" \
2627 -s "a session has been resumed" \
2628 -c "a session has been resumed"
2629
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002630requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002631requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002632run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002633 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002634 "$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 +01002635 0 \
2636 -c "client hello, adding session ticket extension" \
2637 -c "found session_ticket extension" \
2638 -c "parse new session ticket" \
2639 -c "a session has been resumed"
2640
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002641requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002642requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002643run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002644 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002645 "( $O_CLI -sess_out $SESSION; \
2646 $O_CLI -sess_in $SESSION; \
2647 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002648 0 \
2649 -s "found session ticket extension" \
2650 -s "server hello, adding session ticket extension" \
2651 -S "session successfully restored from cache" \
2652 -s "session successfully restored from ticket" \
2653 -s "a session has been resumed"
2654
Hanno Becker1d739932018-08-21 13:55:22 +01002655# Tests for Session Tickets with DTLS
2656
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002657requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002658requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002659run_test "Session resume using tickets, DTLS: basic" \
2660 "$P_SRV debug_level=3 dtls=1 tickets=1" \
2661 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2662 0 \
2663 -c "client hello, adding session ticket extension" \
2664 -s "found session ticket extension" \
2665 -s "server hello, adding session ticket extension" \
2666 -c "found session_ticket extension" \
2667 -c "parse new session ticket" \
2668 -S "session successfully restored from cache" \
2669 -s "session successfully restored from ticket" \
2670 -s "a session has been resumed" \
2671 -c "a session has been resumed"
2672
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002673requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002674requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002675run_test "Session resume using tickets, DTLS: cache disabled" \
2676 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2677 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2678 0 \
2679 -c "client hello, adding session ticket extension" \
2680 -s "found session ticket extension" \
2681 -s "server hello, adding session ticket extension" \
2682 -c "found session_ticket extension" \
2683 -c "parse new session ticket" \
2684 -S "session successfully restored from cache" \
2685 -s "session successfully restored from ticket" \
2686 -s "a session has been resumed" \
2687 -c "a session has been resumed"
2688
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002689requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002690requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002691run_test "Session resume using tickets, DTLS: timeout" \
2692 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
2693 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \
2694 0 \
2695 -c "client hello, adding session ticket extension" \
2696 -s "found session ticket extension" \
2697 -s "server hello, adding session ticket extension" \
2698 -c "found session_ticket extension" \
2699 -c "parse new session ticket" \
2700 -S "session successfully restored from cache" \
2701 -S "session successfully restored from ticket" \
2702 -S "a session has been resumed" \
2703 -C "a session has been resumed"
2704
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002705requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002706requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002707run_test "Session resume using tickets, DTLS: session copy" \
2708 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2709 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_mode=0" \
2710 0 \
2711 -c "client hello, adding session ticket extension" \
2712 -s "found session ticket extension" \
2713 -s "server hello, adding session ticket extension" \
2714 -c "found session_ticket extension" \
2715 -c "parse new session ticket" \
2716 -S "session successfully restored from cache" \
2717 -s "session successfully restored from ticket" \
2718 -s "a session has been resumed" \
2719 -c "a session has been resumed"
2720
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002721requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002722requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002723run_test "Session resume using tickets, DTLS: openssl server" \
2724 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002725 "$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 +01002726 0 \
2727 -c "client hello, adding session ticket extension" \
2728 -c "found session_ticket extension" \
2729 -c "parse new session ticket" \
2730 -c "a session has been resumed"
2731
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002732requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002733requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002734run_test "Session resume using tickets, DTLS: openssl client" \
2735 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2736 "( $O_CLI -dtls1 -sess_out $SESSION; \
2737 $O_CLI -dtls1 -sess_in $SESSION; \
2738 rm -f $SESSION )" \
2739 0 \
2740 -s "found session ticket extension" \
2741 -s "server hello, adding session ticket extension" \
2742 -S "session successfully restored from cache" \
2743 -s "session successfully restored from ticket" \
2744 -s "a session has been resumed"
2745
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002746# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002747
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002748requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002749requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002750requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002751run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002752 "$P_SRV debug_level=3 tickets=0" \
2753 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002754 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002755 -c "client hello, adding session ticket extension" \
2756 -s "found session ticket extension" \
2757 -S "server hello, adding session ticket extension" \
2758 -C "found session_ticket extension" \
2759 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002760 -s "session successfully restored from cache" \
2761 -S "session successfully restored from ticket" \
2762 -s "a session has been resumed" \
2763 -c "a session has been resumed"
2764
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002765requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002766requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002767requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002768run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002769 "$P_SRV debug_level=3 tickets=1" \
2770 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002771 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002772 -C "client hello, adding session ticket extension" \
2773 -S "found session ticket extension" \
2774 -S "server hello, adding session ticket extension" \
2775 -C "found session_ticket extension" \
2776 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002777 -s "session successfully restored from cache" \
2778 -S "session successfully restored from ticket" \
2779 -s "a session has been resumed" \
2780 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002781
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002782requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2783requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002784run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002785 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2786 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002787 0 \
2788 -S "session successfully restored from cache" \
2789 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002790 -S "a session has been resumed" \
2791 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002792
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002793requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2794requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002795run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002796 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2797 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002798 0 \
2799 -s "session successfully restored from cache" \
2800 -S "session successfully restored from ticket" \
2801 -s "a session has been resumed" \
2802 -c "a session has been resumed"
2803
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002804requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2805requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002806run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002807 "$P_SRV debug_level=3 tickets=0" \
2808 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002809 0 \
2810 -s "session successfully restored from cache" \
2811 -S "session successfully restored from ticket" \
2812 -s "a session has been resumed" \
2813 -c "a session has been resumed"
2814
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002815requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2816requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002817run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002818 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2819 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002820 0 \
2821 -S "session successfully restored from cache" \
2822 -S "session successfully restored from ticket" \
2823 -S "a session has been resumed" \
2824 -C "a session has been resumed"
2825
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002826requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2827requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002828run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002829 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2830 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002831 0 \
2832 -s "session successfully restored from cache" \
2833 -S "session successfully restored from ticket" \
2834 -s "a session has been resumed" \
2835 -c "a session has been resumed"
2836
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002837requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2838requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002839run_test "Session resume using cache: session copy" \
2840 "$P_SRV debug_level=3 tickets=0" \
2841 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2842 0 \
2843 -s "session successfully restored from cache" \
2844 -S "session successfully restored from ticket" \
2845 -s "a session has been resumed" \
2846 -c "a session has been resumed"
2847
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002848requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2849requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002850run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002851 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002852 "( $O_CLI -sess_out $SESSION; \
2853 $O_CLI -sess_in $SESSION; \
2854 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002855 0 \
2856 -s "found session ticket extension" \
2857 -S "server hello, adding session ticket extension" \
2858 -s "session successfully restored from cache" \
2859 -S "session successfully restored from ticket" \
2860 -s "a session has been resumed"
2861
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002862requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2863requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002864run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002865 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002866 "$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 +01002867 0 \
2868 -C "found session_ticket extension" \
2869 -C "parse new session ticket" \
2870 -c "a session has been resumed"
2871
Hanno Becker1d739932018-08-21 13:55:22 +01002872# Tests for Session Resume based on session-ID and cache, DTLS
2873
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002874requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002875requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002876requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002877run_test "Session resume using cache, DTLS: tickets enabled on client" \
2878 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2879 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2880 0 \
2881 -c "client hello, adding session ticket extension" \
2882 -s "found session ticket extension" \
2883 -S "server hello, adding session ticket extension" \
2884 -C "found session_ticket extension" \
2885 -C "parse new session ticket" \
2886 -s "session successfully restored from cache" \
2887 -S "session successfully restored from ticket" \
2888 -s "a session has been resumed" \
2889 -c "a session has been resumed"
2890
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002891requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002892requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002893requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002894run_test "Session resume using cache, DTLS: tickets enabled on server" \
2895 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2896 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2897 0 \
2898 -C "client hello, adding session ticket extension" \
2899 -S "found session ticket extension" \
2900 -S "server hello, adding session ticket extension" \
2901 -C "found session_ticket extension" \
2902 -C "parse new session ticket" \
2903 -s "session successfully restored from cache" \
2904 -S "session successfully restored from ticket" \
2905 -s "a session has been resumed" \
2906 -c "a session has been resumed"
2907
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002908requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2909requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002910run_test "Session resume using cache, DTLS: cache_max=0" \
2911 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
2912 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2913 0 \
2914 -S "session successfully restored from cache" \
2915 -S "session successfully restored from ticket" \
2916 -S "a session has been resumed" \
2917 -C "a session has been resumed"
2918
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002919requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2920requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002921run_test "Session resume using cache, DTLS: cache_max=1" \
2922 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
2923 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2924 0 \
2925 -s "session successfully restored from cache" \
2926 -S "session successfully restored from ticket" \
2927 -s "a session has been resumed" \
2928 -c "a session has been resumed"
2929
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002930requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2931requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002932run_test "Session resume using cache, DTLS: timeout > delay" \
2933 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2934 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
2935 0 \
2936 -s "session successfully restored from cache" \
2937 -S "session successfully restored from ticket" \
2938 -s "a session has been resumed" \
2939 -c "a session has been resumed"
2940
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002941requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2942requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002943run_test "Session resume using cache, DTLS: timeout < delay" \
2944 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
2945 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2946 0 \
2947 -S "session successfully restored from cache" \
2948 -S "session successfully restored from ticket" \
2949 -S "a session has been resumed" \
2950 -C "a session has been resumed"
2951
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002952requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2953requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002954run_test "Session resume using cache, DTLS: no timeout" \
2955 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
2956 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2957 0 \
2958 -s "session successfully restored from cache" \
2959 -S "session successfully restored from ticket" \
2960 -s "a session has been resumed" \
2961 -c "a session has been resumed"
2962
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002963requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2964requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002965run_test "Session resume using cache, DTLS: session copy" \
2966 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2967 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2968 0 \
2969 -s "session successfully restored from cache" \
2970 -S "session successfully restored from ticket" \
2971 -s "a session has been resumed" \
2972 -c "a session has been resumed"
2973
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002974requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2975requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002976run_test "Session resume using cache, DTLS: openssl client" \
2977 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2978 "( $O_CLI -dtls1 -sess_out $SESSION; \
2979 $O_CLI -dtls1 -sess_in $SESSION; \
2980 rm -f $SESSION )" \
2981 0 \
2982 -s "found session ticket extension" \
2983 -S "server hello, adding session ticket extension" \
2984 -s "session successfully restored from cache" \
2985 -S "session successfully restored from ticket" \
2986 -s "a session has been resumed"
2987
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002988requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2989requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002990run_test "Session resume using cache, DTLS: openssl server" \
2991 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002992 "$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 +01002993 0 \
2994 -C "found session_ticket extension" \
2995 -C "parse new session ticket" \
2996 -c "a session has been resumed"
2997
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002998# Tests for Max Fragment Length extension
2999
Angus Grattonc4dd0732018-04-11 16:28:39 +10003000if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
Hanno Beckerab9a29b2019-09-24 16:14:39 +01003001 printf "The configuration defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n"
Hanno Becker6428f8d2017-09-22 16:58:50 +01003002 exit 1
3003fi
3004
Angus Grattonc4dd0732018-04-11 16:28:39 +10003005if [ $MAX_CONTENT_LEN -ne 16384 ]; then
3006 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
3007fi
3008
Hanno Becker4aed27e2017-09-18 15:00:34 +01003009requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003010run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003011 "$P_SRV debug_level=3" \
3012 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003013 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003014 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3015 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003016 -C "client hello, adding max_fragment_length extension" \
3017 -S "found max fragment length extension" \
3018 -S "server hello, max_fragment_length extension" \
3019 -C "found max_fragment_length extension"
3020
Hanno Becker4aed27e2017-09-18 15:00:34 +01003021requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003022run_test "Max fragment length: enabled, default, larger message" \
3023 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003024 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003025 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003026 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3027 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003028 -C "client hello, adding max_fragment_length extension" \
3029 -S "found max fragment length extension" \
3030 -S "server hello, max_fragment_length extension" \
3031 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003032 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3033 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003034 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003035
3036requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3037run_test "Max fragment length, DTLS: enabled, default, larger message" \
3038 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003039 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003040 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003041 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3042 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003043 -C "client hello, adding max_fragment_length extension" \
3044 -S "found max fragment length extension" \
3045 -S "server hello, max_fragment_length extension" \
3046 -C "found max_fragment_length extension" \
3047 -c "fragment larger than.*maximum "
3048
Angus Grattonc4dd0732018-04-11 16:28:39 +10003049# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3050# (session fragment length will be 16384 regardless of mbedtls
3051# content length configuration.)
3052
Hanno Beckerc5266962017-09-18 15:01:50 +01003053requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3054run_test "Max fragment length: disabled, larger message" \
3055 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003056 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003057 0 \
3058 -C "Maximum fragment length is 16384" \
3059 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003060 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3061 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003062 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003063
3064requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3065run_test "Max fragment length DTLS: disabled, larger message" \
3066 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003067 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003068 1 \
3069 -C "Maximum fragment length is 16384" \
3070 -S "Maximum fragment length is 16384" \
3071 -c "fragment larger than.*maximum "
3072
3073requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003074run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003075 "$P_SRV debug_level=3" \
3076 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003077 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003078 -c "Maximum fragment length is 4096" \
3079 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003080 -c "client hello, adding max_fragment_length extension" \
3081 -s "found max fragment length extension" \
3082 -s "server hello, max_fragment_length extension" \
3083 -c "found max_fragment_length extension"
3084
Hanno Becker4aed27e2017-09-18 15:00:34 +01003085requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003086run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003087 "$P_SRV debug_level=3 max_frag_len=4096" \
3088 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003089 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003090 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003091 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003092 -C "client hello, adding max_fragment_length extension" \
3093 -S "found max fragment length extension" \
3094 -S "server hello, max_fragment_length extension" \
3095 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003096
Hanno Becker4aed27e2017-09-18 15:00:34 +01003097requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003098requires_gnutls
3099run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003100 "$G_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003101 "$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 +02003102 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003103 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003104 -c "client hello, adding max_fragment_length extension" \
3105 -c "found max_fragment_length extension"
3106
Hanno Becker4aed27e2017-09-18 15:00:34 +01003107requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003108run_test "Max fragment length: client, message just fits" \
3109 "$P_SRV debug_level=3" \
3110 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3111 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003112 -c "Maximum fragment length is 2048" \
3113 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003114 -c "client hello, adding max_fragment_length extension" \
3115 -s "found max fragment length extension" \
3116 -s "server hello, max_fragment_length extension" \
3117 -c "found max_fragment_length extension" \
3118 -c "2048 bytes written in 1 fragments" \
3119 -s "2048 bytes read"
3120
Hanno Becker4aed27e2017-09-18 15:00:34 +01003121requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003122run_test "Max fragment length: client, larger message" \
3123 "$P_SRV debug_level=3" \
3124 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3125 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003126 -c "Maximum fragment length is 2048" \
3127 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003128 -c "client hello, adding max_fragment_length extension" \
3129 -s "found max fragment length extension" \
3130 -s "server hello, max_fragment_length extension" \
3131 -c "found max_fragment_length extension" \
3132 -c "2345 bytes written in 2 fragments" \
3133 -s "2048 bytes read" \
3134 -s "297 bytes read"
3135
Hanno Becker4aed27e2017-09-18 15:00:34 +01003136requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003137run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003138 "$P_SRV debug_level=3 dtls=1" \
3139 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3140 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003141 -c "Maximum fragment length is 2048" \
3142 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003143 -c "client hello, adding max_fragment_length extension" \
3144 -s "found max fragment length extension" \
3145 -s "server hello, max_fragment_length extension" \
3146 -c "found max_fragment_length extension" \
3147 -c "fragment larger than.*maximum"
3148
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003149# Tests for renegotiation
3150
Hanno Becker6a243642017-10-12 15:18:45 +01003151# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003152run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003153 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003154 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003155 0 \
3156 -C "client hello, adding renegotiation extension" \
3157 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3158 -S "found renegotiation extension" \
3159 -s "server hello, secure renegotiation extension" \
3160 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003161 -C "=> renegotiate" \
3162 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003163 -S "write hello request"
3164
Hanno Becker6a243642017-10-12 15:18:45 +01003165requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003166run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003167 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003168 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003169 0 \
3170 -c "client hello, adding renegotiation extension" \
3171 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3172 -s "found renegotiation extension" \
3173 -s "server hello, secure renegotiation extension" \
3174 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003175 -c "=> renegotiate" \
3176 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003177 -S "write hello request"
3178
Hanno Becker6a243642017-10-12 15:18:45 +01003179requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003180run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003181 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003182 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003183 0 \
3184 -c "client hello, adding renegotiation extension" \
3185 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3186 -s "found renegotiation extension" \
3187 -s "server hello, secure renegotiation extension" \
3188 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003189 -c "=> renegotiate" \
3190 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003191 -s "write hello request"
3192
Janos Follathb0f148c2017-10-05 12:29:42 +01003193# 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, client-initiated" \
3198 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3199 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=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
3211# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3212# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3213# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003214requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003215run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3216 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3217 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3218 0 \
3219 -c "client hello, adding renegotiation extension" \
3220 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3221 -s "found renegotiation extension" \
3222 -s "server hello, secure renegotiation extension" \
3223 -c "found renegotiation extension" \
3224 -c "=> renegotiate" \
3225 -s "=> renegotiate" \
3226 -s "write hello request" \
3227 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3228
Hanno Becker6a243642017-10-12 15:18:45 +01003229requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003230run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003231 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003232 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003233 0 \
3234 -c "client hello, adding renegotiation extension" \
3235 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3236 -s "found renegotiation extension" \
3237 -s "server hello, secure renegotiation extension" \
3238 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003239 -c "=> renegotiate" \
3240 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003241 -s "write hello request"
3242
Hanno Becker6a243642017-10-12 15:18:45 +01003243requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003244run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003245 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003246 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003247 1 \
3248 -c "client hello, adding renegotiation extension" \
3249 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3250 -S "found renegotiation extension" \
3251 -s "server hello, secure renegotiation extension" \
3252 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003253 -c "=> renegotiate" \
3254 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003255 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003256 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003257 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003258
Hanno Becker6a243642017-10-12 15:18:45 +01003259requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003260run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003261 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003262 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003263 0 \
3264 -C "client hello, adding renegotiation extension" \
3265 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3266 -S "found renegotiation extension" \
3267 -s "server hello, secure renegotiation extension" \
3268 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003269 -C "=> renegotiate" \
3270 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003271 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003272 -S "SSL - An unexpected message was received from our peer" \
3273 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003274
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, not enforced" \
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=-1 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
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003292# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003293requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003294run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003295 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003296 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003297 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003298 0 \
3299 -C "client hello, adding renegotiation extension" \
3300 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3301 -S "found renegotiation extension" \
3302 -s "server hello, secure renegotiation extension" \
3303 -c "found renegotiation extension" \
3304 -C "=> renegotiate" \
3305 -S "=> renegotiate" \
3306 -s "write hello request" \
3307 -S "SSL - An unexpected message was received from our peer" \
3308 -S "failed"
3309
Hanno Becker6a243642017-10-12 15:18:45 +01003310requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003311run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003312 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003313 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003314 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003315 0 \
3316 -C "client hello, adding renegotiation extension" \
3317 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3318 -S "found renegotiation extension" \
3319 -s "server hello, secure renegotiation extension" \
3320 -c "found renegotiation extension" \
3321 -C "=> renegotiate" \
3322 -S "=> renegotiate" \
3323 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003324 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003325
Hanno Becker6a243642017-10-12 15:18:45 +01003326requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003327run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003328 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003329 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003330 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003331 0 \
3332 -c "client hello, adding renegotiation extension" \
3333 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3334 -s "found renegotiation extension" \
3335 -s "server hello, secure renegotiation extension" \
3336 -c "found renegotiation extension" \
3337 -c "=> renegotiate" \
3338 -s "=> renegotiate" \
3339 -s "write hello request" \
3340 -S "SSL - An unexpected message was received from our peer" \
3341 -S "failed"
3342
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 below 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é-Gonnard590f4162014-11-05 14:23:03 +01003346 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3347 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
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003360# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003361requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003362run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003363 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003364 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003365 0 \
3366 -c "client hello, adding renegotiation extension" \
3367 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3368 -s "found renegotiation extension" \
3369 -s "server hello, secure renegotiation extension" \
3370 -c "found renegotiation extension" \
3371 -s "record counter limit reached: renegotiate" \
3372 -c "=> renegotiate" \
3373 -s "=> renegotiate" \
3374 -s "write hello request" \
3375 -S "SSL - An unexpected message was received from our peer" \
3376 -S "failed"
3377
Hanno Becker6a243642017-10-12 15:18:45 +01003378requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003379run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003380 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003381 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003382 0 \
3383 -c "client hello, adding renegotiation extension" \
3384 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3385 -s "found renegotiation extension" \
3386 -s "server hello, secure renegotiation extension" \
3387 -c "found renegotiation extension" \
3388 -s "record counter limit reached: renegotiate" \
3389 -c "=> renegotiate" \
3390 -s "=> renegotiate" \
3391 -s "write hello request" \
3392 -S "SSL - An unexpected message was received from our peer" \
3393 -S "failed"
3394
Hanno Becker6a243642017-10-12 15:18:45 +01003395requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003396run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003397 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003398 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3399 0 \
3400 -C "client hello, adding renegotiation extension" \
3401 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3402 -S "found renegotiation extension" \
3403 -s "server hello, secure renegotiation extension" \
3404 -c "found renegotiation extension" \
3405 -S "record counter limit reached: renegotiate" \
3406 -C "=> renegotiate" \
3407 -S "=> renegotiate" \
3408 -S "write hello request" \
3409 -S "SSL - An unexpected message was received from our peer" \
3410 -S "failed"
3411
Hanno Becker6a243642017-10-12 15:18:45 +01003412requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003413run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003414 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003415 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003416 0 \
3417 -c "client hello, adding renegotiation extension" \
3418 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3419 -s "found renegotiation extension" \
3420 -s "server hello, secure renegotiation extension" \
3421 -c "found renegotiation extension" \
3422 -c "=> renegotiate" \
3423 -s "=> renegotiate" \
3424 -S "write hello request"
3425
Hanno Becker6a243642017-10-12 15:18:45 +01003426requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003427run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003428 "$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 +02003429 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003430 0 \
3431 -c "client hello, adding renegotiation extension" \
3432 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3433 -s "found renegotiation extension" \
3434 -s "server hello, secure renegotiation extension" \
3435 -c "found renegotiation extension" \
3436 -c "=> renegotiate" \
3437 -s "=> renegotiate" \
3438 -s "write hello request"
3439
Hanno Becker6a243642017-10-12 15:18:45 +01003440requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003441run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003442 "$O_SRV -www" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003443 "$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 +02003444 0 \
3445 -c "client hello, adding renegotiation extension" \
3446 -c "found renegotiation extension" \
3447 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003448 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003449 -C "error" \
3450 -c "HTTP/1.0 200 [Oo][Kk]"
3451
Paul Bakker539d9722015-02-08 16:18:35 +01003452requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003453requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003454run_test "Renegotiation: gnutls server strict, client-initiated" \
3455 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003456 "$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 +02003457 0 \
3458 -c "client hello, adding renegotiation extension" \
3459 -c "found renegotiation extension" \
3460 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003461 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003462 -C "error" \
3463 -c "HTTP/1.0 200 [Oo][Kk]"
3464
Paul Bakker539d9722015-02-08 16:18:35 +01003465requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003466requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003467run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3468 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003469 "$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 +01003470 1 \
3471 -c "client hello, adding renegotiation extension" \
3472 -C "found renegotiation extension" \
3473 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003474 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003475 -c "error" \
3476 -C "HTTP/1.0 200 [Oo][Kk]"
3477
Paul Bakker539d9722015-02-08 16:18:35 +01003478requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003479requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003480run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3481 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003482 "$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 +01003483 allow_legacy=0" \
3484 1 \
3485 -c "client hello, adding renegotiation extension" \
3486 -C "found renegotiation extension" \
3487 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003488 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003489 -c "error" \
3490 -C "HTTP/1.0 200 [Oo][Kk]"
3491
Paul Bakker539d9722015-02-08 16:18:35 +01003492requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003493requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003494run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3495 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003496 "$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 +01003497 allow_legacy=1" \
3498 0 \
3499 -c "client hello, adding renegotiation extension" \
3500 -C "found renegotiation extension" \
3501 -c "=> renegotiate" \
3502 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003503 -C "error" \
3504 -c "HTTP/1.0 200 [Oo][Kk]"
3505
Hanno Becker6a243642017-10-12 15:18:45 +01003506requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003507run_test "Renegotiation: DTLS, client-initiated" \
3508 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3509 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3510 0 \
3511 -c "client hello, adding renegotiation extension" \
3512 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3513 -s "found renegotiation extension" \
3514 -s "server hello, secure renegotiation extension" \
3515 -c "found renegotiation extension" \
3516 -c "=> renegotiate" \
3517 -s "=> renegotiate" \
3518 -S "write hello request"
3519
Hanno Becker6a243642017-10-12 15:18:45 +01003520requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003521run_test "Renegotiation: DTLS, server-initiated" \
3522 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003523 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3524 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003525 0 \
3526 -c "client hello, adding renegotiation extension" \
3527 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3528 -s "found renegotiation extension" \
3529 -s "server hello, secure renegotiation extension" \
3530 -c "found renegotiation extension" \
3531 -c "=> renegotiate" \
3532 -s "=> renegotiate" \
3533 -s "write hello request"
3534
Hanno Becker6a243642017-10-12 15:18:45 +01003535requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003536run_test "Renegotiation: DTLS, renego_period overflow" \
3537 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3538 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3539 0 \
3540 -c "client hello, adding renegotiation extension" \
3541 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3542 -s "found renegotiation extension" \
3543 -s "server hello, secure renegotiation extension" \
3544 -s "record counter limit reached: renegotiate" \
3545 -c "=> renegotiate" \
3546 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003547 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003548
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003549requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003550requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003551run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3552 "$G_SRV -u --mtu 4096" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003553 "$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 +02003554 0 \
3555 -c "client hello, adding renegotiation extension" \
3556 -c "found renegotiation extension" \
3557 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003558 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003559 -C "error" \
3560 -s "Extra-header:"
3561
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003562# Test for the "secure renegotation" extension only (no actual renegotiation)
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 strict, client default" \
3566 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003567 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003568 0 \
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 server unsafe, client default" \
3575 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003576 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003577 0 \
3578 -C "found renegotiation extension" \
3579 -C "error" \
3580 -c "HTTP/1.0 200 [Oo][Kk]"
3581
Paul Bakker539d9722015-02-08 16:18:35 +01003582requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003583run_test "Renego ext: gnutls server unsafe, client break legacy" \
3584 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3585 "$P_CLI debug_level=3 allow_legacy=-1" \
3586 1 \
3587 -C "found renegotiation extension" \
3588 -c "error" \
3589 -C "HTTP/1.0 200 [Oo][Kk]"
3590
Paul Bakker539d9722015-02-08 16:18:35 +01003591requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003592run_test "Renego ext: gnutls client strict, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003593 "$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 +02003594 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003595 0 \
3596 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3597 -s "server hello, secure renegotiation extension"
3598
Paul Bakker539d9722015-02-08 16:18:35 +01003599requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003600run_test "Renego ext: gnutls client unsafe, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003601 "$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 +02003602 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003603 0 \
3604 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3605 -S "server hello, secure renegotiation extension"
3606
Paul Bakker539d9722015-02-08 16:18:35 +01003607requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003608run_test "Renego ext: gnutls client unsafe, server break legacy" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003609 "$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 +02003610 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003611 1 \
3612 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3613 -S "server hello, secure renegotiation extension"
3614
Janos Follath0b242342016-02-17 10:11:21 +00003615# Tests for silently dropping trailing extra bytes in .der certificates
3616
3617requires_gnutls
3618run_test "DER format: no trailing bytes" \
3619 "$P_SRV crt_file=data_files/server5-der0.crt \
3620 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003621 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003622 0 \
3623 -c "Handshake was completed" \
3624
3625requires_gnutls
3626run_test "DER format: with a trailing zero byte" \
3627 "$P_SRV crt_file=data_files/server5-der1a.crt \
3628 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003629 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003630 0 \
3631 -c "Handshake was completed" \
3632
3633requires_gnutls
3634run_test "DER format: with a trailing random byte" \
3635 "$P_SRV crt_file=data_files/server5-der1b.crt \
3636 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003637 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003638 0 \
3639 -c "Handshake was completed" \
3640
3641requires_gnutls
3642run_test "DER format: with 2 trailing random bytes" \
3643 "$P_SRV crt_file=data_files/server5-der2.crt \
3644 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003645 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003646 0 \
3647 -c "Handshake was completed" \
3648
3649requires_gnutls
3650run_test "DER format: with 4 trailing random bytes" \
3651 "$P_SRV crt_file=data_files/server5-der4.crt \
3652 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003653 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003654 0 \
3655 -c "Handshake was completed" \
3656
3657requires_gnutls
3658run_test "DER format: with 8 trailing random bytes" \
3659 "$P_SRV crt_file=data_files/server5-der8.crt \
3660 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003661 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003662 0 \
3663 -c "Handshake was completed" \
3664
3665requires_gnutls
3666run_test "DER format: with 9 trailing random bytes" \
3667 "$P_SRV crt_file=data_files/server5-der9.crt \
3668 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003669 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003670 0 \
3671 -c "Handshake was completed" \
3672
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003673# Tests for auth_mode
3674
Hanno Becker4a156fc2019-06-14 17:07:06 +01003675requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003676requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003677run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003678 "$P_SRV crt_file=data_files/server5-badsign.crt \
3679 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003680 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003681 1 \
3682 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003683 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003684 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003685 -c "X509 - Certificate verification failed"
3686
Hanno Becker4a156fc2019-06-14 17:07:06 +01003687requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003688requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003689run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003690 "$P_SRV crt_file=data_files/server5-badsign.crt \
3691 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003692 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003693 0 \
3694 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003695 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003696 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003697 -C "X509 - Certificate verification failed"
3698
Hanno Becker4a156fc2019-06-14 17:07:06 +01003699requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003700requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003701run_test "Authentication: server goodcert, client optional, no trusted CA" \
3702 "$P_SRV" \
3703 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3704 0 \
3705 -c "x509_verify_cert() returned" \
3706 -c "! The certificate is not correctly signed by the trusted CA" \
3707 -c "! Certificate verification flags"\
3708 -C "! mbedtls_ssl_handshake returned" \
3709 -C "X509 - Certificate verification failed" \
3710 -C "SSL - No CA Chain is set, but required to operate"
3711
Hanno Becker4a156fc2019-06-14 17:07:06 +01003712requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003713requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003714run_test "Authentication: server goodcert, client required, no trusted CA" \
3715 "$P_SRV" \
3716 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3717 1 \
3718 -c "x509_verify_cert() returned" \
3719 -c "! The certificate is not correctly signed by the trusted CA" \
3720 -c "! Certificate verification flags"\
3721 -c "! mbedtls_ssl_handshake returned" \
3722 -c "SSL - No CA Chain is set, but required to operate"
3723
3724# The purpose of the next two tests is to test the client's behaviour when receiving a server
3725# certificate with an unsupported elliptic curve. This should usually not happen because
3726# the client informs the server about the supported curves - it does, though, in the
3727# corner case of a static ECDH suite, because the server doesn't check the curve on that
3728# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3729# different means to have the server ignoring the client's supported curve list.
3730
3731requires_config_enabled MBEDTLS_ECP_C
3732run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3733 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3734 crt_file=data_files/server5.ku-ka.crt" \
3735 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3736 1 \
3737 -c "bad certificate (EC key curve)"\
3738 -c "! Certificate verification flags"\
3739 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3740
3741requires_config_enabled MBEDTLS_ECP_C
3742run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3743 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3744 crt_file=data_files/server5.ku-ka.crt" \
3745 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3746 1 \
3747 -c "bad certificate (EC key curve)"\
3748 -c "! Certificate verification flags"\
3749 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003751run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003752 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003753 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003754 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003755 0 \
3756 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003757 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003758 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003759 -C "X509 - Certificate verification failed"
3760
Simon Butcher99000142016-10-13 17:21:01 +01003761run_test "Authentication: client SHA256, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003762 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003763 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3764 key_file=data_files/server6.key \
3765 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3766 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003767 -c "Supported Signature Algorithm found: 5,"
3768
3769run_test "Authentication: client SHA384, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003770 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003771 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3772 key_file=data_files/server6.key \
3773 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3774 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003775 -c "Supported Signature Algorithm found: 5,"
3776
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003777requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3778run_test "Authentication: client has no cert, server required (SSLv3)" \
3779 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3780 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3781 key_file=data_files/server5.key" \
3782 1 \
3783 -S "skip write certificate request" \
3784 -C "skip parse certificate request" \
3785 -c "got a certificate request" \
3786 -c "got no certificate to send" \
3787 -S "x509_verify_cert() returned" \
3788 -s "client has no certificate" \
3789 -s "! mbedtls_ssl_handshake returned" \
3790 -c "! mbedtls_ssl_handshake returned" \
3791 -s "No client certification received from the client, but required by the authentication mode"
3792
3793run_test "Authentication: client has no cert, server required (TLS)" \
3794 "$P_SRV debug_level=3 auth_mode=required" \
3795 "$P_CLI debug_level=3 crt_file=none \
3796 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 "= write certificate$" \
3802 -C "skip write certificate$" \
3803 -S "x509_verify_cert() returned" \
3804 -s "client has no certificate" \
3805 -s "! mbedtls_ssl_handshake returned" \
3806 -c "! mbedtls_ssl_handshake returned" \
3807 -s "No client certification received from the client, but required by the authentication mode"
3808
Hanno Becker4a156fc2019-06-14 17:07:06 +01003809requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003810requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003811run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003812 "$P_SRV debug_level=3 auth_mode=required" \
3813 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003814 key_file=data_files/server5.key" \
3815 1 \
3816 -S "skip write certificate request" \
3817 -C "skip parse certificate request" \
3818 -c "got a certificate request" \
3819 -C "skip write certificate" \
3820 -C "skip write certificate verify" \
3821 -S "skip parse certificate verify" \
3822 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003823 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003824 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003825 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003826 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003827 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003828# We don't check that the client receives the alert because it might
3829# detect that its write end of the connection is closed and abort
3830# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003831
Hanno Becker4a156fc2019-06-14 17:07:06 +01003832requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003833requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01003834run_test "Authentication: client cert not trusted, server required" \
3835 "$P_SRV debug_level=3 auth_mode=required" \
3836 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3837 key_file=data_files/server5.key" \
3838 1 \
3839 -S "skip write certificate request" \
3840 -C "skip parse certificate request" \
3841 -c "got a certificate request" \
3842 -C "skip write certificate" \
3843 -C "skip write certificate verify" \
3844 -S "skip parse certificate verify" \
3845 -s "x509_verify_cert() returned" \
3846 -s "! The certificate is not correctly signed by the trusted CA" \
3847 -s "! mbedtls_ssl_handshake returned" \
3848 -c "! mbedtls_ssl_handshake returned" \
3849 -s "X509 - Certificate verification failed"
3850
Hanno Becker4a156fc2019-06-14 17:07:06 +01003851requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003852requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003853run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003854 "$P_SRV debug_level=3 auth_mode=optional" \
3855 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003856 key_file=data_files/server5.key" \
3857 0 \
3858 -S "skip write certificate request" \
3859 -C "skip parse certificate request" \
3860 -c "got a certificate request" \
3861 -C "skip write certificate" \
3862 -C "skip write certificate verify" \
3863 -S "skip parse certificate verify" \
3864 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003865 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003866 -S "! mbedtls_ssl_handshake returned" \
3867 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003868 -S "X509 - Certificate verification failed"
3869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003870run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003871 "$P_SRV debug_level=3 auth_mode=none" \
3872 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003873 key_file=data_files/server5.key" \
3874 0 \
3875 -s "skip write certificate request" \
3876 -C "skip parse certificate request" \
3877 -c "got no certificate request" \
3878 -c "skip write certificate" \
3879 -c "skip write certificate verify" \
3880 -s "skip parse certificate verify" \
3881 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003882 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003883 -S "! mbedtls_ssl_handshake returned" \
3884 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003885 -S "X509 - Certificate verification failed"
3886
Hanno Becker4a156fc2019-06-14 17:07:06 +01003887requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003888requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003889run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003890 "$P_SRV debug_level=3 auth_mode=optional" \
3891 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003892 0 \
3893 -S "skip write certificate request" \
3894 -C "skip parse certificate request" \
3895 -c "got a certificate request" \
3896 -C "skip write certificate$" \
3897 -C "got no certificate to send" \
3898 -S "SSLv3 client has no certificate" \
3899 -c "skip write certificate verify" \
3900 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003901 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003902 -S "! mbedtls_ssl_handshake returned" \
3903 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003904 -S "X509 - Certificate verification failed"
3905
Hanno Becker4a156fc2019-06-14 17:07:06 +01003906requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003907requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003908run_test "Authentication: openssl client no cert, server optional" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003909 "$P_SRV debug_level=3 auth_mode=optional ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003910 "$O_CLI" \
3911 0 \
3912 -S "skip write certificate request" \
3913 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003914 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003915 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003916 -S "X509 - Certificate verification failed"
3917
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003918run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003919 "$O_SRV -verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003920 "$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 +01003921 0 \
3922 -C "skip parse certificate request" \
3923 -c "got a certificate request" \
3924 -C "skip write certificate$" \
3925 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003926 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003927
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003928run_test "Authentication: client no cert, openssl server required" \
3929 "$O_SRV -Verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003930 "$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 +02003931 1 \
3932 -C "skip parse certificate request" \
3933 -c "got a certificate request" \
3934 -C "skip write certificate$" \
3935 -c "skip write certificate verify" \
3936 -c "! mbedtls_ssl_handshake returned"
3937
Janos Follathe2681a42016-03-07 15:57:05 +00003938requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Hanno Beckerb2c63832019-06-17 08:35:16 +01003939requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003940requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003941run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003942 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003943 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003944 0 \
3945 -S "skip write certificate request" \
3946 -C "skip parse certificate request" \
3947 -c "got a certificate request" \
3948 -C "skip write certificate$" \
3949 -c "skip write certificate verify" \
3950 -c "got no certificate to send" \
3951 -s "SSLv3 client has no certificate" \
3952 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003953 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003954 -S "! mbedtls_ssl_handshake returned" \
3955 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003956 -S "X509 - Certificate verification failed"
3957
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02003958# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
3959# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003960
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003961MAX_IM_CA='8'
Arto Kinnunen78213522019-09-26 11:06:39 +03003962MAX_IM_CA_CONFIG="$( get_config_value_or_default MBEDTLS_X509_MAX_INTERMEDIATE_CA )"
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003963
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003964if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Hanno Beckerab9a29b2019-09-24 16:14:39 +01003965 printf "The configuration file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003966 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003967 printf "test value of ${MAX_IM_CA}. \n"
3968 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003969 printf "The tests assume this value and if it changes, the tests in this\n"
3970 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003971 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01003972
3973 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003974fi
3975
Angus Grattonc4dd0732018-04-11 16:28:39 +10003976requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003977run_test "Authentication: server max_int chain, client default" \
3978 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
3979 key_file=data_files/dir-maxpath/09.key" \
3980 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
3981 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003982 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003983
Angus Grattonc4dd0732018-04-11 16:28:39 +10003984requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003985run_test "Authentication: server max_int+1 chain, client default" \
3986 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3987 key_file=data_files/dir-maxpath/10.key" \
3988 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
3989 1 \
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: server max_int+1 chain, client optional" \
3994 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3995 key_file=data_files/dir-maxpath/10.key" \
3996 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
3997 auth_mode=optional" \
3998 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003999 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004000
Angus Grattonc4dd0732018-04-11 16:28:39 +10004001requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004002run_test "Authentication: server max_int+1 chain, client none" \
4003 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4004 key_file=data_files/dir-maxpath/10.key" \
4005 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4006 auth_mode=none" \
4007 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004008 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004009
Angus Grattonc4dd0732018-04-11 16:28:39 +10004010requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004011run_test "Authentication: client max_int+1 chain, server default" \
4012 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4013 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4014 key_file=data_files/dir-maxpath/10.key" \
4015 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004016 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004017
Angus Grattonc4dd0732018-04-11 16:28:39 +10004018requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004019run_test "Authentication: client max_int+1 chain, server optional" \
4020 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4021 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4022 key_file=data_files/dir-maxpath/10.key" \
4023 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004024 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004025
Angus Grattonc4dd0732018-04-11 16:28:39 +10004026requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004027run_test "Authentication: client max_int+1 chain, server required" \
4028 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4029 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4030 key_file=data_files/dir-maxpath/10.key" \
4031 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004032 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004033
Angus Grattonc4dd0732018-04-11 16:28:39 +10004034requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004035run_test "Authentication: client max_int chain, server required" \
4036 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4037 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4038 key_file=data_files/dir-maxpath/09.key" \
4039 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004040 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004041
Janos Follath89baba22017-04-10 14:34:35 +01004042# Tests for CA list in CertificateRequest messages
4043
4044run_test "Authentication: send CA list in CertificateRequest (default)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004045 "$P_SRV debug_level=3 auth_mode=required ca_file=data_files/test-ca2.crt" \
Janos Follath89baba22017-04-10 14:34:35 +01004046 "$P_CLI crt_file=data_files/server6.crt \
4047 key_file=data_files/server6.key" \
4048 0 \
4049 -s "requested DN"
4050
4051run_test "Authentication: do not send CA list in CertificateRequest" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004052 "$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 +01004053 "$P_CLI crt_file=data_files/server6.crt \
4054 key_file=data_files/server6.key" \
4055 0 \
4056 -S "requested DN"
4057
Hanno Becker4a156fc2019-06-14 17:07:06 +01004058requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004059requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01004060run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4061 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4062 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4063 key_file=data_files/server5.key" \
4064 1 \
4065 -S "requested DN" \
4066 -s "x509_verify_cert() returned" \
4067 -s "! The certificate is not correctly signed by the trusted CA" \
4068 -s "! mbedtls_ssl_handshake returned" \
4069 -c "! mbedtls_ssl_handshake returned" \
4070 -s "X509 - Certificate verification failed"
4071
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004072# Tests for certificate selection based on SHA verson
4073
Hanno Becker4a156fc2019-06-14 17:07:06 +01004074requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004075requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004076run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4077 "$P_SRV crt_file=data_files/server5.crt \
4078 key_file=data_files/server5.key \
4079 crt_file2=data_files/server5-sha1.crt \
4080 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004081 "$P_CLI force_version=tls1_2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004082 0 \
4083 -c "signed using.*ECDSA with SHA256" \
4084 -C "signed using.*ECDSA with SHA1"
4085
Hanno Becker4a156fc2019-06-14 17:07:06 +01004086requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004087requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004088run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4089 "$P_SRV crt_file=data_files/server5.crt \
4090 key_file=data_files/server5.key \
4091 crt_file2=data_files/server5-sha1.crt \
4092 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004093 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004094 0 \
4095 -C "signed using.*ECDSA with SHA256" \
4096 -c "signed using.*ECDSA with SHA1"
4097
Hanno Becker4a156fc2019-06-14 17:07:06 +01004098requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004099requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004100run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4101 "$P_SRV crt_file=data_files/server5.crt \
4102 key_file=data_files/server5.key \
4103 crt_file2=data_files/server5-sha1.crt \
4104 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004105 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004106 0 \
4107 -C "signed using.*ECDSA with SHA256" \
4108 -c "signed using.*ECDSA with SHA1"
4109
Hanno Becker4a156fc2019-06-14 17:07:06 +01004110requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004111requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004112run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4113 "$P_SRV crt_file=data_files/server5.crt \
4114 key_file=data_files/server5.key \
4115 crt_file2=data_files/server6.crt \
4116 key_file2=data_files/server6.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004117 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004118 0 \
4119 -c "serial number.*09" \
4120 -c "signed using.*ECDSA with SHA256" \
4121 -C "signed using.*ECDSA with SHA1"
4122
Hanno Becker4a156fc2019-06-14 17:07:06 +01004123requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004124requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004125run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4126 "$P_SRV crt_file=data_files/server6.crt \
4127 key_file=data_files/server6.key \
4128 crt_file2=data_files/server5.crt \
4129 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004130 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004131 0 \
4132 -c "serial number.*0A" \
4133 -c "signed using.*ECDSA with SHA256" \
4134 -C "signed using.*ECDSA with SHA1"
4135
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004136# tests for SNI
4137
Hanno Becker4a156fc2019-06-14 17:07:06 +01004138requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004139requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004140run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004141 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004142 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004143 "$P_CLI server_name=localhost ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004144 0 \
4145 -S "parse ServerName extension" \
4146 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4147 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004148
Hanno Becker4a156fc2019-06-14 17:07:06 +01004149requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004150requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004151requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004152run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004153 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004154 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004155 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 +01004156 "$P_CLI server_name=localhost ca_file=data_files/test-ca.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004157 0 \
4158 -s "parse ServerName extension" \
4159 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4160 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004161
Hanno Becker4a156fc2019-06-14 17:07:06 +01004162requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004163requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004164requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004165run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004166 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004167 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004168 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 +02004169 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004170 0 \
4171 -s "parse ServerName extension" \
4172 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4173 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004174
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004175requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004176run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004177 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004178 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004179 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 +02004180 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004181 1 \
4182 -s "parse ServerName extension" \
4183 -s "ssl_sni_wrapper() returned" \
4184 -s "mbedtls_ssl_handshake returned" \
4185 -c "mbedtls_ssl_handshake returned" \
4186 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004187
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004188run_test "SNI: client auth no override: optional" \
4189 "$P_SRV debug_level=3 auth_mode=optional \
4190 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4191 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4192 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004193 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004194 -S "skip write certificate request" \
4195 -C "skip parse certificate request" \
4196 -c "got a certificate request" \
4197 -C "skip write certificate" \
4198 -C "skip write certificate verify" \
4199 -S "skip parse certificate verify"
4200
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004201requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004202run_test "SNI: client auth override: none -> optional" \
4203 "$P_SRV debug_level=3 auth_mode=none \
4204 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4205 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4206 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004207 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004208 -S "skip write certificate request" \
4209 -C "skip parse certificate request" \
4210 -c "got a certificate request" \
4211 -C "skip write certificate" \
4212 -C "skip write certificate verify" \
4213 -S "skip parse certificate verify"
4214
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004215requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004216run_test "SNI: client auth override: optional -> none" \
4217 "$P_SRV debug_level=3 auth_mode=optional \
4218 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4219 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4220 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004221 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004222 -s "skip write certificate request" \
4223 -C "skip parse certificate request" \
4224 -c "got no certificate request" \
4225 -c "skip write certificate" \
4226 -c "skip write certificate verify" \
4227 -s "skip parse certificate verify"
4228
Hanno Becker4a156fc2019-06-14 17:07:06 +01004229requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004230requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004231requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004232run_test "SNI: CA no override" \
4233 "$P_SRV debug_level=3 auth_mode=optional \
4234 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4235 ca_file=data_files/test-ca.crt \
4236 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4237 "$P_CLI debug_level=3 server_name=localhost \
4238 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4239 1 \
4240 -S "skip write certificate request" \
4241 -C "skip parse certificate request" \
4242 -c "got a certificate request" \
4243 -C "skip write certificate" \
4244 -C "skip write certificate verify" \
4245 -S "skip parse certificate verify" \
4246 -s "x509_verify_cert() returned" \
4247 -s "! The certificate is not correctly signed by the trusted CA" \
4248 -S "The certificate has been revoked (is on a CRL)"
4249
Hanno Becker4a156fc2019-06-14 17:07:06 +01004250requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004251requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004252requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004253run_test "SNI: CA override" \
4254 "$P_SRV debug_level=3 auth_mode=optional \
4255 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4256 ca_file=data_files/test-ca.crt \
4257 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4258 "$P_CLI debug_level=3 server_name=localhost \
4259 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4260 0 \
4261 -S "skip write certificate request" \
4262 -C "skip parse certificate request" \
4263 -c "got a certificate request" \
4264 -C "skip write certificate" \
4265 -C "skip write certificate verify" \
4266 -S "skip parse certificate verify" \
4267 -S "x509_verify_cert() returned" \
4268 -S "! The certificate is not correctly signed by the trusted CA" \
4269 -S "The certificate has been revoked (is on a CRL)"
4270
Hanno Becker4a156fc2019-06-14 17:07:06 +01004271requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004272requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004273requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004274run_test "SNI: CA override with CRL" \
4275 "$P_SRV debug_level=3 auth_mode=optional \
4276 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4277 ca_file=data_files/test-ca.crt \
4278 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4279 "$P_CLI debug_level=3 server_name=localhost \
4280 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4281 1 \
4282 -S "skip write certificate request" \
4283 -C "skip parse certificate request" \
4284 -c "got a certificate request" \
4285 -C "skip write certificate" \
4286 -C "skip write certificate verify" \
4287 -S "skip parse certificate verify" \
4288 -s "x509_verify_cert() returned" \
4289 -S "! The certificate is not correctly signed by the trusted CA" \
4290 -s "The certificate has been revoked (is on a CRL)"
4291
Andres AG1a834452016-12-07 10:01:30 +00004292# Tests for SNI and DTLS
4293
Hanno Becker4a156fc2019-06-14 17:07:06 +01004294requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004295requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004296run_test "SNI: DTLS, no SNI callback" \
4297 "$P_SRV debug_level=3 dtls=1 \
4298 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004299 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca2.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004300 0 \
4301 -S "parse ServerName extension" \
4302 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4303 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4304
Hanno Becker4a156fc2019-06-14 17:07:06 +01004305requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004306requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004307requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004308run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004309 "$P_SRV debug_level=3 dtls=1 \
4310 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4311 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 +01004312 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca.crt" \
Andres AG1a834452016-12-07 10:01:30 +00004313 0 \
4314 -s "parse ServerName extension" \
4315 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4316 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4317
Hanno Becker4a156fc2019-06-14 17:07:06 +01004318requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004319requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004320requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004321run_test "SNI: DTLS, matching cert 2" \
4322 "$P_SRV debug_level=3 dtls=1 \
4323 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4324 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 +01004325 "$P_CLI server_name=polarssl.example dtls=1 ca_file=data_files/test-ca.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004326 0 \
4327 -s "parse ServerName extension" \
4328 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4329 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4330
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004331requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004332run_test "SNI: DTLS, no matching cert" \
4333 "$P_SRV debug_level=3 dtls=1 \
4334 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4335 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4336 "$P_CLI server_name=nonesuch.example dtls=1" \
4337 1 \
4338 -s "parse ServerName extension" \
4339 -s "ssl_sni_wrapper() returned" \
4340 -s "mbedtls_ssl_handshake returned" \
4341 -c "mbedtls_ssl_handshake returned" \
4342 -c "SSL - A fatal alert message was received from our peer"
4343
4344run_test "SNI: DTLS, client auth no override: optional" \
4345 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4346 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4347 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4348 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4349 0 \
4350 -S "skip write certificate request" \
4351 -C "skip parse certificate request" \
4352 -c "got a certificate request" \
4353 -C "skip write certificate" \
4354 -C "skip write certificate verify" \
4355 -S "skip parse certificate verify"
4356
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004357requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004358run_test "SNI: DTLS, client auth override: none -> optional" \
4359 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4360 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4361 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4362 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4363 0 \
4364 -S "skip write certificate request" \
4365 -C "skip parse certificate request" \
4366 -c "got a certificate request" \
4367 -C "skip write certificate" \
4368 -C "skip write certificate verify" \
4369 -S "skip parse certificate verify"
4370
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004371requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004372run_test "SNI: DTLS, client auth override: optional -> none" \
4373 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4374 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4375 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4376 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4377 0 \
4378 -s "skip write certificate request" \
4379 -C "skip parse certificate request" \
4380 -c "got no certificate request" \
4381 -c "skip write certificate" \
4382 -c "skip write certificate verify" \
4383 -s "skip parse certificate verify"
4384
Hanno Becker4a156fc2019-06-14 17:07:06 +01004385requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004386requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004387requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004388run_test "SNI: DTLS, CA no override" \
4389 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4390 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4391 ca_file=data_files/test-ca.crt \
4392 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4393 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4394 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4395 1 \
4396 -S "skip write certificate request" \
4397 -C "skip parse certificate request" \
4398 -c "got a certificate request" \
4399 -C "skip write certificate" \
4400 -C "skip write certificate verify" \
4401 -S "skip parse certificate verify" \
4402 -s "x509_verify_cert() returned" \
4403 -s "! The certificate is not correctly signed by the trusted CA" \
4404 -S "The certificate has been revoked (is on a CRL)"
4405
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004406requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004407run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004408 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4409 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4410 ca_file=data_files/test-ca.crt \
4411 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4412 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4413 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4414 0 \
4415 -S "skip write certificate request" \
4416 -C "skip parse certificate request" \
4417 -c "got a certificate request" \
4418 -C "skip write certificate" \
4419 -C "skip write certificate verify" \
4420 -S "skip parse certificate verify" \
4421 -S "x509_verify_cert() returned" \
4422 -S "! The certificate is not correctly signed by the trusted CA" \
4423 -S "The certificate has been revoked (is on a CRL)"
4424
Hanno Becker4a156fc2019-06-14 17:07:06 +01004425requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004426requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004427requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004428run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004429 "$P_SRV debug_level=3 auth_mode=optional \
4430 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4431 ca_file=data_files/test-ca.crt \
4432 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4433 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4434 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4435 1 \
4436 -S "skip write certificate request" \
4437 -C "skip parse certificate request" \
4438 -c "got a certificate request" \
4439 -C "skip write certificate" \
4440 -C "skip write certificate verify" \
4441 -S "skip parse certificate verify" \
4442 -s "x509_verify_cert() returned" \
4443 -S "! The certificate is not correctly signed by the trusted CA" \
4444 -s "The certificate has been revoked (is on a CRL)"
4445
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004446# Tests for non-blocking I/O: exercise a variety of handshake flows
4447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004448run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004449 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4450 "$P_CLI nbio=2 tickets=0" \
4451 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004452 -S "mbedtls_ssl_handshake returned" \
4453 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004454 -c "Read from server: .* bytes read"
4455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004456run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004457 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4458 "$P_CLI nbio=2 tickets=0" \
4459 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004460 -S "mbedtls_ssl_handshake returned" \
4461 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004462 -c "Read from server: .* bytes read"
4463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004464run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004465 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4466 "$P_CLI nbio=2 tickets=1" \
4467 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004468 -S "mbedtls_ssl_handshake returned" \
4469 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004470 -c "Read from server: .* bytes read"
4471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004472run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004473 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4474 "$P_CLI nbio=2 tickets=1" \
4475 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004476 -S "mbedtls_ssl_handshake returned" \
4477 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004478 -c "Read from server: .* bytes read"
4479
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004480run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004481 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4482 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4483 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004484 -S "mbedtls_ssl_handshake returned" \
4485 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004486 -c "Read from server: .* bytes read"
4487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004488run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004489 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4490 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4491 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004492 -S "mbedtls_ssl_handshake returned" \
4493 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004494 -c "Read from server: .* bytes read"
4495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004496run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004497 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4498 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4499 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004500 -S "mbedtls_ssl_handshake returned" \
4501 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004502 -c "Read from server: .* bytes read"
4503
Hanno Becker00076712017-11-15 16:39:08 +00004504# Tests for event-driven I/O: exercise a variety of handshake flows
4505
4506run_test "Event-driven I/O: basic handshake" \
4507 "$P_SRV event=1 tickets=0 auth_mode=none" \
4508 "$P_CLI event=1 tickets=0" \
4509 0 \
4510 -S "mbedtls_ssl_handshake returned" \
4511 -C "mbedtls_ssl_handshake returned" \
4512 -c "Read from server: .* bytes read"
4513
4514run_test "Event-driven I/O: client auth" \
4515 "$P_SRV event=1 tickets=0 auth_mode=required" \
4516 "$P_CLI event=1 tickets=0" \
4517 0 \
4518 -S "mbedtls_ssl_handshake returned" \
4519 -C "mbedtls_ssl_handshake returned" \
4520 -c "Read from server: .* bytes read"
4521
4522run_test "Event-driven I/O: ticket" \
4523 "$P_SRV event=1 tickets=1 auth_mode=none" \
4524 "$P_CLI event=1 tickets=1" \
4525 0 \
4526 -S "mbedtls_ssl_handshake returned" \
4527 -C "mbedtls_ssl_handshake returned" \
4528 -c "Read from server: .* bytes read"
4529
4530run_test "Event-driven I/O: ticket + client auth" \
4531 "$P_SRV event=1 tickets=1 auth_mode=required" \
4532 "$P_CLI event=1 tickets=1" \
4533 0 \
4534 -S "mbedtls_ssl_handshake returned" \
4535 -C "mbedtls_ssl_handshake returned" \
4536 -c "Read from server: .* bytes read"
4537
4538run_test "Event-driven I/O: ticket + client auth + resume" \
4539 "$P_SRV event=1 tickets=1 auth_mode=required" \
4540 "$P_CLI event=1 tickets=1 reconnect=1" \
4541 0 \
4542 -S "mbedtls_ssl_handshake returned" \
4543 -C "mbedtls_ssl_handshake returned" \
4544 -c "Read from server: .* bytes read"
4545
4546run_test "Event-driven I/O: ticket + resume" \
4547 "$P_SRV event=1 tickets=1 auth_mode=none" \
4548 "$P_CLI event=1 tickets=1 reconnect=1" \
4549 0 \
4550 -S "mbedtls_ssl_handshake returned" \
4551 -C "mbedtls_ssl_handshake returned" \
4552 -c "Read from server: .* bytes read"
4553
4554run_test "Event-driven I/O: session-id resume" \
4555 "$P_SRV event=1 tickets=0 auth_mode=none" \
4556 "$P_CLI event=1 tickets=0 reconnect=1" \
4557 0 \
4558 -S "mbedtls_ssl_handshake returned" \
4559 -C "mbedtls_ssl_handshake returned" \
4560 -c "Read from server: .* bytes read"
4561
Hanno Becker6a33f592018-03-13 11:38:46 +00004562run_test "Event-driven I/O, DTLS: basic handshake" \
4563 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4564 "$P_CLI dtls=1 event=1 tickets=0" \
4565 0 \
4566 -c "Read from server: .* bytes read"
4567
4568run_test "Event-driven I/O, DTLS: client auth" \
4569 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4570 "$P_CLI dtls=1 event=1 tickets=0" \
4571 0 \
4572 -c "Read from server: .* bytes read"
4573
4574run_test "Event-driven I/O, DTLS: ticket" \
4575 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4576 "$P_CLI dtls=1 event=1 tickets=1" \
4577 0 \
4578 -c "Read from server: .* bytes read"
4579
4580run_test "Event-driven I/O, DTLS: ticket + client auth" \
4581 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4582 "$P_CLI dtls=1 event=1 tickets=1" \
4583 0 \
4584 -c "Read from server: .* bytes read"
4585
4586run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4587 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4588 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4589 0 \
4590 -c "Read from server: .* bytes read"
4591
4592run_test "Event-driven I/O, DTLS: ticket + resume" \
4593 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4594 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4595 0 \
4596 -c "Read from server: .* bytes read"
4597
4598run_test "Event-driven I/O, DTLS: session-id resume" \
4599 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4600 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4601 0 \
4602 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004603
4604# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4605# During session resumption, the client will send its ApplicationData record
4606# within the same datagram as the Finished messages. In this situation, the
4607# server MUST NOT idle on the underlying transport after handshake completion,
4608# because the ApplicationData request has already been queued internally.
4609run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004610 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004611 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4612 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4613 0 \
4614 -c "Read from server: .* bytes read"
4615
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004616# Tests for version negotiation
4617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004618run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004619 "$P_SRV" \
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.2" \
4625 -c "Protocol is TLSv1.2"
4626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004627run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004628 "$P_SRV" \
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: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004637 "$P_SRV max_version=tls1_1" \
4638 "$P_CLI" \
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+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 max_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 max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004655 "$P_SRV min_version=tls1_1" \
4656 "$P_CLI max_version=tls1_1" \
4657 0 \
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 -s "Protocol is TLSv1.1" \
4661 -c "Protocol is TLSv1.1"
4662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004663run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004664 "$P_SRV max_version=tls1_1" \
4665 "$P_CLI min_version=tls1_1" \
4666 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004667 -S "mbedtls_ssl_handshake returned" \
4668 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004669 -s "Protocol is TLSv1.1" \
4670 -c "Protocol is TLSv1.1"
4671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004672run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004673 "$P_SRV max_version=tls1_1" \
4674 "$P_CLI min_version=tls1_2" \
4675 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004676 -s "mbedtls_ssl_handshake returned" \
4677 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004678 -c "SSL - Handshake protocol not within min/max boundaries"
4679
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004680run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004681 "$P_SRV min_version=tls1_2" \
4682 "$P_CLI max_version=tls1_1" \
4683 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004684 -s "mbedtls_ssl_handshake returned" \
4685 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004686 -s "SSL - Handshake protocol not within min/max boundaries"
4687
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004688# Tests for ALPN extension
4689
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004690run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004691 "$P_SRV debug_level=3" \
4692 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004693 0 \
4694 -C "client hello, adding alpn extension" \
4695 -S "found alpn extension" \
4696 -C "got an alert message, type: \\[2:120]" \
4697 -S "server hello, adding alpn extension" \
4698 -C "found alpn extension " \
4699 -C "Application Layer Protocol is" \
4700 -S "Application Layer Protocol is"
4701
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004702run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004703 "$P_SRV debug_level=3" \
4704 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004705 0 \
4706 -c "client hello, adding alpn extension" \
4707 -s "found alpn extension" \
4708 -C "got an alert message, type: \\[2:120]" \
4709 -S "server hello, adding alpn extension" \
4710 -C "found alpn extension " \
4711 -c "Application Layer Protocol is (none)" \
4712 -S "Application Layer Protocol is"
4713
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004714run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004715 "$P_SRV debug_level=3 alpn=abc,1234" \
4716 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004717 0 \
4718 -C "client hello, adding alpn extension" \
4719 -S "found alpn extension" \
4720 -C "got an alert message, type: \\[2:120]" \
4721 -S "server hello, adding alpn extension" \
4722 -C "found alpn extension " \
4723 -C "Application Layer Protocol is" \
4724 -s "Application Layer Protocol is (none)"
4725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004726run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004727 "$P_SRV debug_level=3 alpn=abc,1234" \
4728 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004729 0 \
4730 -c "client hello, adding alpn extension" \
4731 -s "found alpn extension" \
4732 -C "got an alert message, type: \\[2:120]" \
4733 -s "server hello, adding alpn extension" \
4734 -c "found alpn extension" \
4735 -c "Application Layer Protocol is abc" \
4736 -s "Application Layer Protocol is abc"
4737
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004738run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004739 "$P_SRV debug_level=3 alpn=abc,1234" \
4740 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004741 0 \
4742 -c "client hello, adding alpn extension" \
4743 -s "found alpn extension" \
4744 -C "got an alert message, type: \\[2:120]" \
4745 -s "server hello, adding alpn extension" \
4746 -c "found alpn extension" \
4747 -c "Application Layer Protocol is abc" \
4748 -s "Application Layer Protocol is abc"
4749
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004750run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004751 "$P_SRV debug_level=3 alpn=abc,1234" \
4752 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004753 0 \
4754 -c "client hello, adding alpn extension" \
4755 -s "found alpn extension" \
4756 -C "got an alert message, type: \\[2:120]" \
4757 -s "server hello, adding alpn extension" \
4758 -c "found alpn extension" \
4759 -c "Application Layer Protocol is 1234" \
4760 -s "Application Layer Protocol is 1234"
4761
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004762run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004763 "$P_SRV debug_level=3 alpn=abc,123" \
4764 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004765 1 \
4766 -c "client hello, adding alpn extension" \
4767 -s "found alpn extension" \
4768 -c "got an alert message, type: \\[2:120]" \
4769 -S "server hello, adding alpn extension" \
4770 -C "found alpn extension" \
4771 -C "Application Layer Protocol is 1234" \
4772 -S "Application Layer Protocol is 1234"
4773
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02004774
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004775# Tests for keyUsage in leaf certificates, part 1:
4776# server-side certificate/suite selection
4777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004778run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004779 "$P_SRV key_file=data_files/server2.key \
4780 crt_file=data_files/server2.ku-ds.crt" \
4781 "$P_CLI" \
4782 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02004783 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004784
4785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004786run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004787 "$P_SRV key_file=data_files/server2.key \
4788 crt_file=data_files/server2.ku-ke.crt" \
4789 "$P_CLI" \
4790 0 \
4791 -c "Ciphersuite is TLS-RSA-WITH-"
4792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004793run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004794 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004795 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004796 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004797 1 \
4798 -C "Ciphersuite is "
4799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004800run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004801 "$P_SRV key_file=data_files/server5.key \
4802 crt_file=data_files/server5.ku-ds.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004803 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004804 0 \
4805 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
4806
4807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004808run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004809 "$P_SRV key_file=data_files/server5.key \
4810 crt_file=data_files/server5.ku-ka.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004811 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004812 0 \
4813 -c "Ciphersuite is TLS-ECDH-"
4814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004815run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004816 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004817 crt_file=data_files/server5.ku-ke.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004818 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004819 1 \
4820 -C "Ciphersuite is "
4821
4822# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004823# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004825run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004826 "$O_SRV -key data_files/server2.key \
4827 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004828 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004829 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4830 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004831 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004832 -C "Processing of the Certificate handshake message failed" \
4833 -c "Ciphersuite is TLS-"
4834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004835run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004836 "$O_SRV -key data_files/server2.key \
4837 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004838 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004839 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4840 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004841 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004842 -C "Processing of the Certificate handshake message failed" \
4843 -c "Ciphersuite is TLS-"
4844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004845run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004846 "$O_SRV -key data_files/server2.key \
4847 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004848 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004849 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4850 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004851 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004852 -C "Processing of the Certificate handshake message failed" \
4853 -c "Ciphersuite is TLS-"
4854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004855run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004856 "$O_SRV -key data_files/server2.key \
4857 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004858 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004859 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4860 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004861 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004862 -c "Processing of the Certificate handshake message failed" \
4863 -C "Ciphersuite is TLS-"
4864
Hanno Becker4a156fc2019-06-14 17:07:06 +01004865requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004866requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004867run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
4868 "$O_SRV -key data_files/server2.key \
4869 -cert data_files/server2.ku-ke.crt" \
4870 "$P_CLI debug_level=1 auth_mode=optional \
4871 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4872 0 \
4873 -c "bad certificate (usage extensions)" \
4874 -C "Processing of the Certificate handshake message failed" \
4875 -c "Ciphersuite is TLS-" \
4876 -c "! Usage does not match the keyUsage extension"
4877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004878run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004879 "$O_SRV -key data_files/server2.key \
4880 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004881 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004882 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4883 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004884 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004885 -C "Processing of the Certificate handshake message failed" \
4886 -c "Ciphersuite is TLS-"
4887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004888run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004889 "$O_SRV -key data_files/server2.key \
4890 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004891 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004892 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4893 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004894 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004895 -c "Processing of the Certificate handshake message failed" \
4896 -C "Ciphersuite is TLS-"
4897
Hanno Becker4a156fc2019-06-14 17:07:06 +01004898requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004899requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004900run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
4901 "$O_SRV -key data_files/server2.key \
4902 -cert data_files/server2.ku-ds.crt" \
4903 "$P_CLI debug_level=1 auth_mode=optional \
4904 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4905 0 \
4906 -c "bad certificate (usage extensions)" \
4907 -C "Processing of the Certificate handshake message failed" \
4908 -c "Ciphersuite is TLS-" \
4909 -c "! Usage does not match the keyUsage extension"
4910
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004911# Tests for keyUsage in leaf certificates, part 3:
4912# server-side checking of client cert
4913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004914run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004915 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004916 "$O_CLI -key data_files/server2.key \
4917 -cert data_files/server2.ku-ds.crt" \
4918 0 \
4919 -S "bad certificate (usage extensions)" \
4920 -S "Processing of the Certificate handshake message failed"
4921
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004922run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004923 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004924 "$O_CLI -key data_files/server2.key \
4925 -cert data_files/server2.ku-ke.crt" \
4926 0 \
4927 -s "bad certificate (usage extensions)" \
4928 -S "Processing of the Certificate handshake message failed"
4929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004930run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004931 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004932 "$O_CLI -key data_files/server2.key \
4933 -cert data_files/server2.ku-ke.crt" \
4934 1 \
4935 -s "bad certificate (usage extensions)" \
4936 -s "Processing of the Certificate handshake message failed"
4937
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004938run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004939 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004940 "$O_CLI -key data_files/server5.key \
4941 -cert data_files/server5.ku-ds.crt" \
4942 0 \
4943 -S "bad certificate (usage extensions)" \
4944 -S "Processing of the Certificate handshake message failed"
4945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004946run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004947 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004948 "$O_CLI -key data_files/server5.key \
4949 -cert data_files/server5.ku-ka.crt" \
4950 0 \
4951 -s "bad certificate (usage extensions)" \
4952 -S "Processing of the Certificate handshake message failed"
4953
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004954# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
4955
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004956run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004957 "$P_SRV key_file=data_files/server5.key \
4958 crt_file=data_files/server5.eku-srv.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 0
4961
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004962run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004963 "$P_SRV key_file=data_files/server5.key \
4964 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004965 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004966 0
4967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004968run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004969 "$P_SRV key_file=data_files/server5.key \
4970 crt_file=data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004971 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004972 0
4973
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004974run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02004975 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004976 crt_file=data_files/server5.eku-cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004977 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004978 1
4979
4980# Tests for extendedKeyUsage, part 2: client-side checking of server cert
4981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004982run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004983 "$O_SRV -key data_files/server5.key \
4984 -cert data_files/server5.eku-srv.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: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004992 "$O_SRV -key data_files/server5.key \
4993 -cert data_files/server5.eku-srv_cli.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 0 \
4996 -C "bad certificate (usage extensions)" \
4997 -C "Processing of the Certificate handshake message failed" \
4998 -c "Ciphersuite is TLS-"
4999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005000run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005001 "$O_SRV -key data_files/server5.key \
5002 -cert data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005003 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005004 0 \
5005 -C "bad certificate (usage extensions)" \
5006 -C "Processing of the Certificate handshake message failed" \
5007 -c "Ciphersuite is TLS-"
5008
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005009run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005010 "$O_SRV -key data_files/server5.key \
5011 -cert data_files/server5.eku-cs.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005012 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005013 1 \
5014 -c "bad certificate (usage extensions)" \
5015 -c "Processing of the Certificate handshake message failed" \
5016 -C "Ciphersuite is TLS-"
5017
5018# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005020run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005021 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005022 "$O_CLI -key data_files/server5.key \
5023 -cert data_files/server5.eku-cli.crt" \
5024 0 \
5025 -S "bad certificate (usage extensions)" \
5026 -S "Processing of the Certificate handshake message failed"
5027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005028run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005029 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005030 "$O_CLI -key data_files/server5.key \
5031 -cert data_files/server5.eku-srv_cli.crt" \
5032 0 \
5033 -S "bad certificate (usage extensions)" \
5034 -S "Processing of the Certificate handshake message failed"
5035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005036run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005037 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005038 "$O_CLI -key data_files/server5.key \
5039 -cert data_files/server5.eku-cs_any.crt" \
5040 0 \
5041 -S "bad certificate (usage extensions)" \
5042 -S "Processing of the Certificate handshake message failed"
5043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005044run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005045 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005046 "$O_CLI -key data_files/server5.key \
5047 -cert data_files/server5.eku-cs.crt" \
5048 0 \
5049 -s "bad certificate (usage extensions)" \
5050 -S "Processing of the Certificate handshake message failed"
5051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005052run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005053 "$P_SRV debug_level=1 auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005054 "$O_CLI -key data_files/server5.key \
5055 -cert data_files/server5.eku-cs.crt" \
5056 1 \
5057 -s "bad certificate (usage extensions)" \
5058 -s "Processing of the Certificate handshake message failed"
5059
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005060# Tests for DHM parameters loading
5061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005062run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005063 "$P_SRV" \
5064 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5065 debug_level=3" \
5066 0 \
5067 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005068 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005070run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005071 "$P_SRV dhm_file=data_files/dhparams.pem" \
5072 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5073 debug_level=3" \
5074 0 \
5075 -c "value of 'DHM: P ' (1024 bits)" \
5076 -c "value of 'DHM: G ' (2 bits)"
5077
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005078# Tests for DHM client-side size checking
5079
5080run_test "DHM size: server default, client default, OK" \
5081 "$P_SRV" \
5082 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5083 debug_level=1" \
5084 0 \
5085 -C "DHM prime too short:"
5086
5087run_test "DHM size: server default, client 2048, OK" \
5088 "$P_SRV" \
5089 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5090 debug_level=1 dhmlen=2048" \
5091 0 \
5092 -C "DHM prime too short:"
5093
5094run_test "DHM size: server 1024, client default, OK" \
5095 "$P_SRV dhm_file=data_files/dhparams.pem" \
5096 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5097 debug_level=1" \
5098 0 \
5099 -C "DHM prime too short:"
5100
5101run_test "DHM size: server 1000, client default, rejected" \
5102 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5103 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5104 debug_level=1" \
5105 1 \
5106 -c "DHM prime too short:"
5107
5108run_test "DHM size: server default, client 2049, rejected" \
5109 "$P_SRV" \
5110 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5111 debug_level=1 dhmlen=2049" \
5112 1 \
5113 -c "DHM prime too short:"
5114
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005115# Tests for PSK callback
5116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005117run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005118 "$P_SRV psk=abc123 psk_identity=foo" \
5119 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5120 psk_identity=foo psk=abc123" \
5121 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005122 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +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: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005127 "$P_SRV" \
5128 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5129 psk_identity=foo psk=abc123" \
5130 1 \
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: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005136 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5137 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5138 psk_identity=foo psk=abc123" \
5139 1 \
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: first id matches" \
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=abc psk=dead" \
5148 0 \
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: second id matches" \
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=def psk=beef" \
5157 0 \
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"
5161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005162run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005163 "$P_SRV psk_list=abc,dead,def,beef" \
5164 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5165 psk_identity=ghi psk=beef" \
5166 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005167 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005168 -s "SSL - Unknown identity received" \
5169 -S "SSL - Verification of the message MAC failed"
5170
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005171run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005172 "$P_SRV psk_list=abc,dead,def,beef" \
5173 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5174 psk_identity=abc psk=beef" \
5175 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005176 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005177 -S "SSL - Unknown identity received" \
5178 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005179
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005180# Tests for EC J-PAKE
5181
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005182requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005183run_test "ECJPAKE: client not configured" \
5184 "$P_SRV debug_level=3" \
5185 "$P_CLI debug_level=3" \
5186 0 \
5187 -C "add ciphersuite: c0ff" \
5188 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005189 -S "found ecjpake kkpp extension" \
5190 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005191 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005192 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005193 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005194 -S "None of the common ciphersuites is usable"
5195
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005196requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005197run_test "ECJPAKE: server not configured" \
5198 "$P_SRV debug_level=3" \
5199 "$P_CLI debug_level=3 ecjpake_pw=bla \
5200 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5201 1 \
5202 -c "add ciphersuite: c0ff" \
5203 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005204 -s "found ecjpake kkpp extension" \
5205 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005206 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005207 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005208 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005209 -s "None of the common ciphersuites is usable"
5210
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005211requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005212run_test "ECJPAKE: working, TLS" \
5213 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5214 "$P_CLI debug_level=3 ecjpake_pw=bla \
5215 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005216 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005217 -c "add ciphersuite: c0ff" \
5218 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005219 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005220 -s "found ecjpake kkpp extension" \
5221 -S "skip ecjpake kkpp extension" \
5222 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005223 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005224 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005225 -S "None of the common ciphersuites is usable" \
5226 -S "SSL - Verification of the message MAC failed"
5227
Janos Follath74537a62016-09-02 13:45:28 +01005228server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005229requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005230run_test "ECJPAKE: password mismatch, TLS" \
5231 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5232 "$P_CLI debug_level=3 ecjpake_pw=bad \
5233 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5234 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005235 -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
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005238requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005239run_test "ECJPAKE: working, DTLS" \
5240 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5241 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5242 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5243 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005244 -c "re-using cached ecjpake parameters" \
5245 -S "SSL - Verification of the message MAC failed"
5246
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005247requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005248run_test "ECJPAKE: working, DTLS, no cookie" \
5249 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5250 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5251 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5252 0 \
5253 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005254 -S "SSL - Verification of the message MAC failed"
5255
Janos Follath74537a62016-09-02 13:45:28 +01005256server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005257requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005258run_test "ECJPAKE: password mismatch, DTLS" \
5259 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5260 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5261 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5262 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005263 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005264 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005265
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005266# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005267requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005268run_test "ECJPAKE: working, DTLS, nolog" \
5269 "$P_SRV dtls=1 ecjpake_pw=bla" \
5270 "$P_CLI dtls=1 ecjpake_pw=bla \
5271 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5272 0
5273
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005274# Tests for ciphersuites per version
5275
Janos Follathe2681a42016-03-07 15:57:05 +00005276requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005277requires_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: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005280 "$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 +02005281 "$P_CLI force_version=ssl3" \
5282 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005283 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005284
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005285requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
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.0" \
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é-Gonnardbd47a582015-01-12 13:43:29 +01005290 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005291 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005292 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005293
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005294requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5295requires_config_enabled MBEDTLS_CAMELLIA_C
5296requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005297run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005298 "$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 +02005299 "$P_CLI force_version=tls1_1" \
5300 0 \
5301 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5302
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005303requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5304requires_config_enabled MBEDTLS_CAMELLIA_C
5305requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005306run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005307 "$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 +02005308 "$P_CLI force_version=tls1_2" \
5309 0 \
5310 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5311
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005312# Test for ClientHello without extensions
5313
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005314requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005315run_test "ClientHello without extensions, SHA-1 allowed" \
Ron Eldorb76e7652019-01-16 23:14:41 +02005316 "$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 +02005317 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005318 0 \
5319 -s "dumping 'client hello extensions' (0 bytes)"
5320
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005321requires_gnutls
5322run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
5323 "$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 +02005324 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005325 0 \
5326 -s "dumping 'client hello extensions' (0 bytes)"
5327
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005328# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005329
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005330run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005331 "$P_SRV" \
5332 "$P_CLI request_size=100" \
5333 0 \
5334 -s "Read from client: 100 bytes read$"
5335
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005336run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005337 "$P_SRV" \
5338 "$P_CLI request_size=500" \
5339 0 \
5340 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005341
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005342# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005343
Janos Follathe2681a42016-03-07 15:57:05 +00005344requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005345run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005346 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005347 "$P_CLI request_size=1 force_version=ssl3 \
5348 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5349 0 \
5350 -s "Read from client: 1 bytes read"
5351
Janos Follathe2681a42016-03-07 15:57:05 +00005352requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005353run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005354 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005355 "$P_CLI request_size=1 force_version=ssl3 \
5356 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5357 0 \
5358 -s "Read from client: 1 bytes read"
5359
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005360run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005361 "$P_SRV" \
5362 "$P_CLI request_size=1 force_version=tls1 \
5363 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5364 0 \
5365 -s "Read from client: 1 bytes read"
5366
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005367run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005368 "$P_SRV" \
5369 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5370 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5371 0 \
5372 -s "Read from client: 1 bytes read"
5373
Hanno Becker32c55012017-11-10 08:42:54 +00005374requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005375run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005376 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005377 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005378 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005379 0 \
5380 -s "Read from client: 1 bytes read"
5381
Hanno Becker32c55012017-11-10 08:42:54 +00005382requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005383run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005384 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005385 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005386 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005387 0 \
5388 -s "Read from client: 1 bytes read"
5389
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005390run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005391 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005392 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005393 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5394 0 \
5395 -s "Read from client: 1 bytes read"
5396
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005397run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005398 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5399 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005400 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005401 0 \
5402 -s "Read from client: 1 bytes read"
5403
5404requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005405run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005406 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005407 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005408 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005409 0 \
5410 -s "Read from client: 1 bytes read"
5411
Hanno Becker8501f982017-11-10 08:59:04 +00005412requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005413run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005414 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5415 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5416 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005417 0 \
5418 -s "Read from client: 1 bytes read"
5419
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005420run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005421 "$P_SRV" \
5422 "$P_CLI request_size=1 force_version=tls1_1 \
5423 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5424 0 \
5425 -s "Read from client: 1 bytes read"
5426
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005427run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005428 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005429 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005430 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005431 0 \
5432 -s "Read from client: 1 bytes read"
5433
5434requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005435run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005436 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005437 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005438 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005439 0 \
5440 -s "Read from client: 1 bytes read"
5441
5442requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005443run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005444 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005445 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005446 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005447 0 \
5448 -s "Read from client: 1 bytes read"
5449
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005450run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005451 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005452 "$P_CLI request_size=1 force_version=tls1_1 \
5453 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5454 0 \
5455 -s "Read from client: 1 bytes read"
5456
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005457run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005458 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005459 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005460 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005461 0 \
5462 -s "Read from client: 1 bytes read"
5463
Hanno Becker8501f982017-11-10 08:59:04 +00005464requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005465run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005466 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005467 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005468 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005469 0 \
5470 -s "Read from client: 1 bytes read"
5471
Hanno Becker32c55012017-11-10 08:42:54 +00005472requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005473run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005474 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005475 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005476 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005477 0 \
5478 -s "Read from client: 1 bytes read"
5479
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005480run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005481 "$P_SRV" \
5482 "$P_CLI request_size=1 force_version=tls1_2 \
5483 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5484 0 \
5485 -s "Read from client: 1 bytes read"
5486
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005487run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005488 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005489 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005490 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005491 0 \
5492 -s "Read from client: 1 bytes read"
5493
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005494run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005495 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005496 "$P_CLI request_size=1 force_version=tls1_2 \
5497 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005498 0 \
5499 -s "Read from client: 1 bytes read"
5500
Hanno Becker32c55012017-11-10 08:42:54 +00005501requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005502run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005503 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005504 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005505 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005506 0 \
5507 -s "Read from client: 1 bytes read"
5508
Hanno Becker8501f982017-11-10 08:59:04 +00005509requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005510run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005511 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005512 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005513 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005514 0 \
5515 -s "Read from client: 1 bytes read"
5516
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005517run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005518 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005519 "$P_CLI request_size=1 force_version=tls1_2 \
5520 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5521 0 \
5522 -s "Read from client: 1 bytes read"
5523
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005524run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005525 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005526 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005527 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005528 0 \
5529 -s "Read from client: 1 bytes read"
5530
Hanno Becker32c55012017-11-10 08:42:54 +00005531requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005532run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005533 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005534 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005535 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005536 0 \
5537 -s "Read from client: 1 bytes read"
5538
Hanno Becker8501f982017-11-10 08:59:04 +00005539requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005540run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005541 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005542 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005543 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005544 0 \
5545 -s "Read from client: 1 bytes read"
5546
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005547run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005548 "$P_SRV" \
5549 "$P_CLI request_size=1 force_version=tls1_2 \
5550 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5551 0 \
5552 -s "Read from client: 1 bytes read"
5553
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005554run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005555 "$P_SRV" \
5556 "$P_CLI request_size=1 force_version=tls1_2 \
5557 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5558 0 \
5559 -s "Read from client: 1 bytes read"
5560
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005561# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005562
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005563run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005564 "$P_SRV dtls=1 force_version=dtls1" \
5565 "$P_CLI dtls=1 request_size=1 \
5566 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5567 0 \
5568 -s "Read from client: 1 bytes read"
5569
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005570run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00005571 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
5572 "$P_CLI dtls=1 request_size=1 \
5573 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5574 0 \
5575 -s "Read from client: 1 bytes read"
5576
Hanno Beckere2148042017-11-10 08:59:18 +00005577requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005578run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005579 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
5580 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00005581 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5582 0 \
5583 -s "Read from client: 1 bytes read"
5584
Hanno Beckere2148042017-11-10 08:59:18 +00005585requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005586run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005587 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005588 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005589 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005590 0 \
5591 -s "Read from client: 1 bytes read"
5592
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005593run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00005594 "$P_SRV dtls=1 force_version=dtls1_2" \
5595 "$P_CLI dtls=1 request_size=1 \
5596 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5597 0 \
5598 -s "Read from client: 1 bytes read"
5599
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005600run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005601 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005602 "$P_CLI dtls=1 request_size=1 \
5603 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5604 0 \
5605 -s "Read from client: 1 bytes read"
5606
Hanno Beckere2148042017-11-10 08:59:18 +00005607requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005608run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005609 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005610 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005611 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005612 0 \
5613 -s "Read from client: 1 bytes read"
5614
Hanno Beckere2148042017-11-10 08:59:18 +00005615requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005616run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005617 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005618 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005619 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005620 0 \
5621 -s "Read from client: 1 bytes read"
5622
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005623# Tests for small server packets
5624
5625requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5626run_test "Small server packet SSLv3 BlockCipher" \
5627 "$P_SRV response_size=1 min_version=ssl3" \
5628 "$P_CLI force_version=ssl3 \
5629 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5630 0 \
5631 -c "Read from server: 1 bytes read"
5632
5633requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5634run_test "Small server packet SSLv3 StreamCipher" \
5635 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5636 "$P_CLI force_version=ssl3 \
5637 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5638 0 \
5639 -c "Read from server: 1 bytes read"
5640
5641run_test "Small server packet TLS 1.0 BlockCipher" \
5642 "$P_SRV response_size=1" \
5643 "$P_CLI force_version=tls1 \
5644 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5645 0 \
5646 -c "Read from server: 1 bytes read"
5647
5648run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
5649 "$P_SRV response_size=1" \
5650 "$P_CLI force_version=tls1 etm=0 \
5651 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5652 0 \
5653 -c "Read from server: 1 bytes read"
5654
5655requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5656run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
5657 "$P_SRV response_size=1 trunc_hmac=1" \
5658 "$P_CLI force_version=tls1 \
5659 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5660 0 \
5661 -c "Read from server: 1 bytes read"
5662
5663requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5664run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
5665 "$P_SRV response_size=1 trunc_hmac=1" \
5666 "$P_CLI force_version=tls1 \
5667 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5668 0 \
5669 -c "Read from server: 1 bytes read"
5670
5671run_test "Small server packet TLS 1.0 StreamCipher" \
5672 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5673 "$P_CLI force_version=tls1 \
5674 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5675 0 \
5676 -c "Read from server: 1 bytes read"
5677
5678run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
5679 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5680 "$P_CLI force_version=tls1 \
5681 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5682 0 \
5683 -c "Read from server: 1 bytes read"
5684
5685requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5686run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
5687 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5688 "$P_CLI force_version=tls1 \
5689 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5690 0 \
5691 -c "Read from server: 1 bytes read"
5692
5693requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5694run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5695 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5696 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5697 trunc_hmac=1 etm=0" \
5698 0 \
5699 -c "Read from server: 1 bytes read"
5700
5701run_test "Small server packet TLS 1.1 BlockCipher" \
5702 "$P_SRV response_size=1" \
5703 "$P_CLI force_version=tls1_1 \
5704 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5705 0 \
5706 -c "Read from server: 1 bytes read"
5707
5708run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
5709 "$P_SRV response_size=1" \
5710 "$P_CLI force_version=tls1_1 \
5711 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5712 0 \
5713 -c "Read from server: 1 bytes read"
5714
5715requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5716run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
5717 "$P_SRV response_size=1 trunc_hmac=1" \
5718 "$P_CLI force_version=tls1_1 \
5719 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5720 0 \
5721 -c "Read from server: 1 bytes read"
5722
5723requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5724run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5725 "$P_SRV response_size=1 trunc_hmac=1" \
5726 "$P_CLI force_version=tls1_1 \
5727 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5728 0 \
5729 -c "Read from server: 1 bytes read"
5730
5731run_test "Small server packet TLS 1.1 StreamCipher" \
5732 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5733 "$P_CLI force_version=tls1_1 \
5734 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5735 0 \
5736 -c "Read from server: 1 bytes read"
5737
5738run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
5739 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5740 "$P_CLI force_version=tls1_1 \
5741 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5742 0 \
5743 -c "Read from server: 1 bytes read"
5744
5745requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5746run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
5747 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5748 "$P_CLI force_version=tls1_1 \
5749 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5750 0 \
5751 -c "Read from server: 1 bytes read"
5752
5753requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5754run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5755 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5756 "$P_CLI force_version=tls1_1 \
5757 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5758 0 \
5759 -c "Read from server: 1 bytes read"
5760
5761run_test "Small server packet TLS 1.2 BlockCipher" \
5762 "$P_SRV response_size=1" \
5763 "$P_CLI force_version=tls1_2 \
5764 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5765 0 \
5766 -c "Read from server: 1 bytes read"
5767
5768run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5769 "$P_SRV response_size=1" \
5770 "$P_CLI force_version=tls1_2 \
5771 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5772 0 \
5773 -c "Read from server: 1 bytes read"
5774
5775run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5776 "$P_SRV response_size=1" \
5777 "$P_CLI force_version=tls1_2 \
5778 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5779 0 \
5780 -c "Read from server: 1 bytes read"
5781
5782requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5783run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5784 "$P_SRV response_size=1 trunc_hmac=1" \
5785 "$P_CLI force_version=tls1_2 \
5786 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5787 0 \
5788 -c "Read from server: 1 bytes read"
5789
5790requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5791run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5792 "$P_SRV response_size=1 trunc_hmac=1" \
5793 "$P_CLI force_version=tls1_2 \
5794 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5795 0 \
5796 -c "Read from server: 1 bytes read"
5797
5798run_test "Small server packet TLS 1.2 StreamCipher" \
5799 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5800 "$P_CLI force_version=tls1_2 \
5801 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5802 0 \
5803 -c "Read from server: 1 bytes read"
5804
5805run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
5806 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5807 "$P_CLI force_version=tls1_2 \
5808 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5809 0 \
5810 -c "Read from server: 1 bytes read"
5811
5812requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5813run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
5814 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5815 "$P_CLI force_version=tls1_2 \
5816 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5817 0 \
5818 -c "Read from server: 1 bytes read"
5819
5820requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5821run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5822 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5823 "$P_CLI force_version=tls1_2 \
5824 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5825 0 \
5826 -c "Read from server: 1 bytes read"
5827
5828run_test "Small server packet TLS 1.2 AEAD" \
5829 "$P_SRV response_size=1" \
5830 "$P_CLI force_version=tls1_2 \
5831 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5832 0 \
5833 -c "Read from server: 1 bytes read"
5834
5835run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5836 "$P_SRV response_size=1" \
5837 "$P_CLI force_version=tls1_2 \
5838 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5839 0 \
5840 -c "Read from server: 1 bytes read"
5841
5842# Tests for small server packets in DTLS
5843
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005844run_test "Small server packet DTLS 1.0" \
5845 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
5846 "$P_CLI dtls=1 \
5847 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5848 0 \
5849 -c "Read from server: 1 bytes read"
5850
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005851run_test "Small server packet DTLS 1.0, without EtM" \
5852 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
5853 "$P_CLI dtls=1 \
5854 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5855 0 \
5856 -c "Read from server: 1 bytes read"
5857
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005858requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5859run_test "Small server packet DTLS 1.0, truncated hmac" \
5860 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
5861 "$P_CLI dtls=1 trunc_hmac=1 \
5862 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5863 0 \
5864 -c "Read from server: 1 bytes read"
5865
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005866requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5867run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
5868 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
5869 "$P_CLI dtls=1 \
5870 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5871 0 \
5872 -c "Read from server: 1 bytes read"
5873
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005874run_test "Small server packet DTLS 1.2" \
5875 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
5876 "$P_CLI dtls=1 \
5877 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5878 0 \
5879 -c "Read from server: 1 bytes read"
5880
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005881run_test "Small server packet DTLS 1.2, without EtM" \
5882 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5883 "$P_CLI dtls=1 \
5884 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5885 0 \
5886 -c "Read from server: 1 bytes read"
5887
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005888requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5889run_test "Small server packet DTLS 1.2, truncated hmac" \
5890 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5891 "$P_CLI dtls=1 \
5892 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5893 0 \
5894 -c "Read from server: 1 bytes read"
5895
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005896requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5897run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5898 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5899 "$P_CLI dtls=1 \
5900 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5901 0 \
5902 -c "Read from server: 1 bytes read"
5903
Janos Follath00efff72016-05-06 13:48:23 +01005904# A test for extensions in SSLv3
5905
5906requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5907run_test "SSLv3 with extensions, server side" \
5908 "$P_SRV min_version=ssl3 debug_level=3" \
5909 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
5910 0 \
5911 -S "dumping 'client hello extensions'" \
5912 -S "server hello, total extension length:"
5913
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005914# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005915
Angus Grattonc4dd0732018-04-11 16:28:39 +10005916# How many fragments do we expect to write $1 bytes?
5917fragments_for_write() {
5918 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
5919}
5920
Janos Follathe2681a42016-03-07 15:57:05 +00005921requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005922run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005923 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005924 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005925 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5926 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005927 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5928 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005929
Janos Follathe2681a42016-03-07 15:57:05 +00005930requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005931run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005932 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005933 "$P_CLI request_size=16384 force_version=ssl3 \
5934 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5935 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005936 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5937 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005938
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005939run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005940 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005941 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005942 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5943 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005944 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5945 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005946
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005947run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005948 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005949 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
5950 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5951 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005952 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005953
Hanno Becker32c55012017-11-10 08:42:54 +00005954requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005955run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005956 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005957 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005958 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005959 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005960 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5961 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005962
Hanno Becker32c55012017-11-10 08:42:54 +00005963requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005964run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005965 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005966 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005967 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005968 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005969 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005970
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005971run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005972 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005973 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005974 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5975 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005976 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005977
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005978run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005979 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5980 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005981 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005982 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005983 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005984
5985requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005986run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005987 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005988 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005989 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005990 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005991 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005992
Hanno Becker278fc7a2017-11-10 09:16:28 +00005993requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005994run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005995 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005996 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005997 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005998 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005999 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6000 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006001
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006002run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006003 "$P_SRV" \
6004 "$P_CLI request_size=16384 force_version=tls1_1 \
6005 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6006 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006007 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6008 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006009
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006010run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006011 "$P_SRV" \
6012 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6013 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006014 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006015 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006016
Hanno Becker32c55012017-11-10 08:42:54 +00006017requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006018run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006019 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006020 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006021 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006022 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006023 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006024
Hanno Becker32c55012017-11-10 08:42:54 +00006025requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006026run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006027 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006028 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006029 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006030 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006031 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006032
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006033run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006034 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6035 "$P_CLI request_size=16384 force_version=tls1_1 \
6036 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6037 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006038 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6039 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006040
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006041run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006042 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006043 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006044 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006045 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006046 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6047 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006048
Hanno Becker278fc7a2017-11-10 09:16:28 +00006049requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006050run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006051 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006052 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006053 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006054 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006055 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006056
Hanno Becker278fc7a2017-11-10 09:16:28 +00006057requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006058run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006059 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006060 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006061 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006062 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006063 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6064 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006065
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006066run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006067 "$P_SRV" \
6068 "$P_CLI request_size=16384 force_version=tls1_2 \
6069 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6070 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006071 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6072 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006073
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006074run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006075 "$P_SRV" \
6076 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6077 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6078 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006079 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006080
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006081run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006082 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006083 "$P_CLI request_size=16384 force_version=tls1_2 \
6084 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006085 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006086 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6087 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006088
Hanno Becker32c55012017-11-10 08:42:54 +00006089requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006090run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006091 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006092 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006093 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006094 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006095 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006096
Hanno Becker278fc7a2017-11-10 09:16:28 +00006097requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006098run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006099 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006100 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006101 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006102 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006103 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6104 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006105
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006106run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006107 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006108 "$P_CLI request_size=16384 force_version=tls1_2 \
6109 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6110 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006111 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6112 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006113
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006114run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006115 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006116 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006117 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6118 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006119 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006120
Hanno Becker32c55012017-11-10 08:42:54 +00006121requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006122run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006123 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006124 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006125 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006126 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006127 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006128
Hanno Becker278fc7a2017-11-10 09:16:28 +00006129requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006130run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006131 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006132 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006133 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006134 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006135 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6136 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006137
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006138run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006139 "$P_SRV" \
6140 "$P_CLI request_size=16384 force_version=tls1_2 \
6141 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6142 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006143 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6144 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006145
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006146run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006147 "$P_SRV" \
6148 "$P_CLI request_size=16384 force_version=tls1_2 \
6149 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6150 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006151 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6152 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006153
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006154# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006155requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6156run_test "Large server packet SSLv3 StreamCipher" \
6157 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6158 "$P_CLI force_version=ssl3 \
6159 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6160 0 \
6161 -c "Read from server: 16384 bytes read"
6162
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006163# Checking next 4 tests logs for 1n-1 split against BEAST too
6164requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6165run_test "Large server packet SSLv3 BlockCipher" \
6166 "$P_SRV response_size=16384 min_version=ssl3" \
6167 "$P_CLI force_version=ssl3 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 +02006174run_test "Large server packet TLS 1.0 BlockCipher" \
6175 "$P_SRV response_size=16384" \
6176 "$P_CLI force_version=tls1 recsplit=0 \
6177 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6178 0 \
6179 -c "Read from server: 1 bytes read"\
6180 -c "16383 bytes read"\
6181 -C "Read from server: 16384 bytes read"
6182
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006183run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6184 "$P_SRV response_size=16384" \
6185 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6186 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6187 0 \
6188 -c "Read from server: 1 bytes read"\
6189 -c "16383 bytes read"\
6190 -C "Read from server: 16384 bytes read"
6191
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006192requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6193run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6194 "$P_SRV response_size=16384" \
6195 "$P_CLI force_version=tls1 recsplit=0 \
6196 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6197 trunc_hmac=1" \
6198 0 \
6199 -c "Read from server: 1 bytes read"\
6200 -c "16383 bytes read"\
6201 -C "Read from server: 16384 bytes read"
6202
6203requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6204run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6205 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6206 "$P_CLI force_version=tls1 \
6207 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6208 trunc_hmac=1" \
6209 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006210 -s "16384 bytes written in 1 fragments" \
6211 -c "Read from server: 16384 bytes read"
6212
6213run_test "Large server packet TLS 1.0 StreamCipher" \
6214 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6215 "$P_CLI force_version=tls1 \
6216 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6217 0 \
6218 -s "16384 bytes written in 1 fragments" \
6219 -c "Read from server: 16384 bytes read"
6220
6221run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6222 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6223 "$P_CLI force_version=tls1 \
6224 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6225 0 \
6226 -s "16384 bytes written in 1 fragments" \
6227 -c "Read from server: 16384 bytes read"
6228
6229requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6230run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6231 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6232 "$P_CLI force_version=tls1 \
6233 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6234 0 \
6235 -s "16384 bytes written in 1 fragments" \
6236 -c "Read from server: 16384 bytes read"
6237
6238requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6239run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6240 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6241 "$P_CLI force_version=tls1 \
6242 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6243 0 \
6244 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006245 -c "Read from server: 16384 bytes read"
6246
6247run_test "Large server packet TLS 1.1 BlockCipher" \
6248 "$P_SRV response_size=16384" \
6249 "$P_CLI force_version=tls1_1 \
6250 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6251 0 \
6252 -c "Read from server: 16384 bytes read"
6253
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006254run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6255 "$P_SRV response_size=16384" \
6256 "$P_CLI force_version=tls1_1 etm=0 \
6257 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006258 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006259 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006260 -c "Read from server: 16384 bytes read"
6261
6262requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6263run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6264 "$P_SRV response_size=16384" \
6265 "$P_CLI force_version=tls1_1 \
6266 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6267 trunc_hmac=1" \
6268 0 \
6269 -c "Read from server: 16384 bytes read"
6270
6271requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006272run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6273 "$P_SRV response_size=16384 trunc_hmac=1" \
6274 "$P_CLI force_version=tls1_1 \
6275 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6276 0 \
6277 -s "16384 bytes written in 1 fragments" \
6278 -c "Read from server: 16384 bytes read"
6279
6280run_test "Large server packet TLS 1.1 StreamCipher" \
6281 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6282 "$P_CLI force_version=tls1_1 \
6283 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6284 0 \
6285 -c "Read from server: 16384 bytes read"
6286
6287run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6288 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6289 "$P_CLI force_version=tls1_1 \
6290 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6291 0 \
6292 -s "16384 bytes written in 1 fragments" \
6293 -c "Read from server: 16384 bytes read"
6294
6295requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006296run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6297 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6298 "$P_CLI force_version=tls1_1 \
6299 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6300 trunc_hmac=1" \
6301 0 \
6302 -c "Read from server: 16384 bytes read"
6303
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006304run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6305 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6306 "$P_CLI force_version=tls1_1 \
6307 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6308 0 \
6309 -s "16384 bytes written in 1 fragments" \
6310 -c "Read from server: 16384 bytes read"
6311
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006312run_test "Large server packet TLS 1.2 BlockCipher" \
6313 "$P_SRV response_size=16384" \
6314 "$P_CLI force_version=tls1_2 \
6315 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6316 0 \
6317 -c "Read from server: 16384 bytes read"
6318
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006319run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6320 "$P_SRV response_size=16384" \
6321 "$P_CLI force_version=tls1_2 etm=0 \
6322 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6323 0 \
6324 -s "16384 bytes written in 1 fragments" \
6325 -c "Read from server: 16384 bytes read"
6326
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006327run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6328 "$P_SRV response_size=16384" \
6329 "$P_CLI force_version=tls1_2 \
6330 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6331 0 \
6332 -c "Read from server: 16384 bytes read"
6333
6334requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6335run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6336 "$P_SRV response_size=16384" \
6337 "$P_CLI force_version=tls1_2 \
6338 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6339 trunc_hmac=1" \
6340 0 \
6341 -c "Read from server: 16384 bytes read"
6342
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006343run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6344 "$P_SRV response_size=16384 trunc_hmac=1" \
6345 "$P_CLI force_version=tls1_2 \
6346 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6347 0 \
6348 -s "16384 bytes written in 1 fragments" \
6349 -c "Read from server: 16384 bytes read"
6350
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006351run_test "Large server packet TLS 1.2 StreamCipher" \
6352 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6353 "$P_CLI force_version=tls1_2 \
6354 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6355 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006356 -s "16384 bytes written in 1 fragments" \
6357 -c "Read from server: 16384 bytes read"
6358
6359run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6360 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6361 "$P_CLI force_version=tls1_2 \
6362 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6363 0 \
6364 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006365 -c "Read from server: 16384 bytes read"
6366
6367requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6368run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6369 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6370 "$P_CLI force_version=tls1_2 \
6371 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6372 trunc_hmac=1" \
6373 0 \
6374 -c "Read from server: 16384 bytes read"
6375
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006376requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6377run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6378 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6379 "$P_CLI force_version=tls1_2 \
6380 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6381 0 \
6382 -s "16384 bytes written in 1 fragments" \
6383 -c "Read from server: 16384 bytes read"
6384
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006385run_test "Large server packet TLS 1.2 AEAD" \
6386 "$P_SRV response_size=16384" \
6387 "$P_CLI force_version=tls1_2 \
6388 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6389 0 \
6390 -c "Read from server: 16384 bytes read"
6391
6392run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6393 "$P_SRV response_size=16384" \
6394 "$P_CLI force_version=tls1_2 \
6395 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6396 0 \
6397 -c "Read from server: 16384 bytes read"
6398
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006399# Tests for restartable ECC
6400
6401requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6402run_test "EC restart: TLS, default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006403 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006404 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006405 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006406 debug_level=1" \
6407 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006408 -C "x509_verify_cert.*4b00" \
6409 -C "mbedtls_pk_verify.*4b00" \
6410 -C "mbedtls_ecdh_make_public.*4b00" \
6411 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006412
6413requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6414run_test "EC restart: TLS, max_ops=0" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006415 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006416 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006417 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006418 debug_level=1 ec_max_ops=0" \
6419 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006420 -C "x509_verify_cert.*4b00" \
6421 -C "mbedtls_pk_verify.*4b00" \
6422 -C "mbedtls_ecdh_make_public.*4b00" \
6423 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006424
6425requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6426run_test "EC restart: TLS, max_ops=65535" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006427 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006428 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006429 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006430 debug_level=1 ec_max_ops=65535" \
6431 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006432 -C "x509_verify_cert.*4b00" \
6433 -C "mbedtls_pk_verify.*4b00" \
6434 -C "mbedtls_ecdh_make_public.*4b00" \
6435 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006436
6437requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6438run_test "EC restart: TLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006439 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006440 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006441 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006442 debug_level=1 ec_max_ops=1000" \
6443 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006444 -c "x509_verify_cert.*4b00" \
6445 -c "mbedtls_pk_verify.*4b00" \
6446 -c "mbedtls_ecdh_make_public.*4b00" \
6447 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006448
6449requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Hanno Becker4a156fc2019-06-14 17:07:06 +01006450requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006451run_test "EC restart: TLS, max_ops=1000, badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006452 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006453 crt_file=data_files/server5-badsign.crt \
6454 key_file=data_files/server5.key" \
6455 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker03d77462019-08-27 16:24:56 +01006456 key_file=data_files/server5.key crt_file=data_files/server5.crt ca_file=data_files/test-ca2.crt \
6457 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6458 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006459 -c "x509_verify_cert.*4b00" \
Hanno Becker03d77462019-08-27 16:24:56 +01006460 -c "mbedtls_pk_verify.*4b00" \
6461 -c "mbedtls_ecdh_make_public.*4b00" \
6462 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006463 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006464
Hanno Becker4a156fc2019-06-14 17:07:06 +01006465requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006466requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6467run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006468 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006469 crt_file=data_files/server5-badsign.crt \
6470 key_file=data_files/server5.key" \
6471 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6472 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006473 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006474 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6475 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006476 -c "x509_verify_cert.*4b00" \
6477 -c "mbedtls_pk_verify.*4b00" \
6478 -c "mbedtls_ecdh_make_public.*4b00" \
6479 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006480 -c "! The certificate is not correctly signed by the trusted CA" \
6481 -C "! mbedtls_ssl_handshake returned" \
6482 -C "X509 - Certificate verification failed"
6483
Hanno Becker4a156fc2019-06-14 17:07:06 +01006484requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006485requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006486requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6487run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006488 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006489 crt_file=data_files/server5-badsign.crt \
6490 key_file=data_files/server5.key" \
6491 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006492 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006493 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6494 debug_level=1 ec_max_ops=1000 auth_mode=none" \
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é-Gonnard3bf49c42017-08-15 13:47:06 +02006500 -C "! The certificate is not correctly signed by the trusted CA" \
6501 -C "! mbedtls_ssl_handshake returned" \
6502 -C "X509 - Certificate verification failed"
6503
6504requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006505run_test "EC restart: DTLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006506 "$P_SRV auth_mode=required dtls=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006507 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006508 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006509 dtls=1 debug_level=1 ec_max_ops=1000" \
6510 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006511 -c "x509_verify_cert.*4b00" \
6512 -c "mbedtls_pk_verify.*4b00" \
6513 -c "mbedtls_ecdh_make_public.*4b00" \
6514 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006515
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006516requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6517run_test "EC restart: TLS, max_ops=1000 no client auth" \
6518 "$P_SRV" \
6519 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6520 debug_level=1 ec_max_ops=1000" \
6521 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006522 -c "x509_verify_cert.*4b00" \
6523 -c "mbedtls_pk_verify.*4b00" \
6524 -c "mbedtls_ecdh_make_public.*4b00" \
6525 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006526
6527requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6528run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6529 "$P_SRV psk=abc123" \
6530 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6531 psk=abc123 debug_level=1 ec_max_ops=1000" \
6532 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006533 -C "x509_verify_cert.*4b00" \
6534 -C "mbedtls_pk_verify.*4b00" \
6535 -C "mbedtls_ecdh_make_public.*4b00" \
6536 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006537
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006538# Tests of asynchronous private key support in SSL
6539
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006540requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006541run_test "SSL async private: sign, delay=0" \
6542 "$P_SRV \
6543 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006544 "$P_CLI" \
6545 0 \
6546 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006547 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006548
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006549requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006550run_test "SSL async private: sign, delay=1" \
6551 "$P_SRV \
6552 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006553 "$P_CLI" \
6554 0 \
6555 -s "Async sign callback: using key slot " \
6556 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006557 -s "Async resume (slot [0-9]): sign done, status=0"
6558
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006559requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6560run_test "SSL async private: sign, delay=2" \
6561 "$P_SRV \
6562 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6563 "$P_CLI" \
6564 0 \
6565 -s "Async sign callback: using key slot " \
6566 -U "Async sign callback: using key slot " \
6567 -s "Async resume (slot [0-9]): call 1 more times." \
6568 -s "Async resume (slot [0-9]): call 0 more times." \
6569 -s "Async resume (slot [0-9]): sign done, status=0"
6570
Gilles Peskined3268832018-04-26 06:23:59 +02006571# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
6572# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
6573requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6574requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6575run_test "SSL async private: sign, RSA, TLS 1.1" \
6576 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
6577 async_operations=s async_private_delay1=0 async_private_delay2=0" \
6578 "$P_CLI force_version=tls1_1" \
6579 0 \
6580 -s "Async sign callback: using key slot " \
6581 -s "Async resume (slot [0-9]): sign done, status=0"
6582
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006583requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerb2c63832019-06-17 08:35:16 +01006584requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03006585requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006586requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskine807d74a2018-04-30 10:30:49 +02006587run_test "SSL async private: sign, SNI" \
6588 "$P_SRV debug_level=3 \
6589 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6590 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6591 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6592 "$P_CLI server_name=polarssl.example" \
6593 0 \
6594 -s "Async sign callback: using key slot " \
6595 -s "Async resume (slot [0-9]): sign done, status=0" \
6596 -s "parse ServerName extension" \
6597 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6598 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6599
6600requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006601run_test "SSL async private: decrypt, delay=0" \
6602 "$P_SRV \
6603 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6604 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6605 0 \
6606 -s "Async decrypt callback: using key slot " \
6607 -s "Async resume (slot [0-9]): decrypt done, status=0"
6608
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006609requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006610run_test "SSL async private: decrypt, delay=1" \
6611 "$P_SRV \
6612 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6613 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6614 0 \
6615 -s "Async decrypt callback: using key slot " \
6616 -s "Async resume (slot [0-9]): call 0 more times." \
6617 -s "Async resume (slot [0-9]): decrypt done, status=0"
6618
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006619requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006620run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6621 "$P_SRV psk=abc123 \
6622 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6623 "$P_CLI psk=abc123 \
6624 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6625 0 \
6626 -s "Async decrypt callback: using key slot " \
6627 -s "Async resume (slot [0-9]): decrypt done, status=0"
6628
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006629requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006630run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6631 "$P_SRV psk=abc123 \
6632 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6633 "$P_CLI psk=abc123 \
6634 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6635 0 \
6636 -s "Async decrypt callback: using key slot " \
6637 -s "Async resume (slot [0-9]): call 0 more times." \
6638 -s "Async resume (slot [0-9]): decrypt done, status=0"
6639
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006640requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006641run_test "SSL async private: sign callback not present" \
6642 "$P_SRV \
6643 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6644 "$P_CLI; [ \$? -eq 1 ] &&
6645 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6646 0 \
6647 -S "Async sign callback" \
6648 -s "! mbedtls_ssl_handshake returned" \
6649 -s "The own private key or pre-shared key is not set, but needed" \
6650 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6651 -s "Successful connection"
6652
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006653requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006654run_test "SSL async private: decrypt callback not present" \
6655 "$P_SRV debug_level=1 \
6656 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6657 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6658 [ \$? -eq 1 ] && $P_CLI" \
6659 0 \
6660 -S "Async decrypt callback" \
6661 -s "! mbedtls_ssl_handshake returned" \
6662 -s "got no RSA private key" \
6663 -s "Async resume (slot [0-9]): sign done, status=0" \
6664 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006665
6666# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006667requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006668run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006669 "$P_SRV \
6670 async_operations=s async_private_delay1=1 \
6671 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6672 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006673 "$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 +01006674 0 \
6675 -s "Async sign callback: using key slot 0," \
6676 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006677 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006678
6679# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006680requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006681run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006682 "$P_SRV \
6683 async_operations=s async_private_delay2=1 \
6684 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6685 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006686 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6687 0 \
6688 -s "Async sign callback: using key slot 0," \
6689 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006690 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006691
6692# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006693requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006694run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006695 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006696 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006697 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6698 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006699 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6700 0 \
6701 -s "Async sign callback: using key slot 1," \
6702 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006703 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006704
6705# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006706requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006707run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006708 "$P_SRV \
6709 async_operations=s async_private_delay1=1 \
6710 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6711 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006712 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6713 0 \
6714 -s "Async sign callback: no key matches this certificate."
6715
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006716requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006717run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006718 "$P_SRV \
6719 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6720 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006721 "$P_CLI" \
6722 1 \
6723 -s "Async sign callback: injected error" \
6724 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006725 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006726 -s "! mbedtls_ssl_handshake returned"
6727
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006728requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006729run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006730 "$P_SRV \
6731 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6732 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006733 "$P_CLI" \
6734 1 \
6735 -s "Async sign callback: using key slot " \
6736 -S "Async resume" \
6737 -s "Async cancel"
6738
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006739requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006740run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006741 "$P_SRV \
6742 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6743 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006744 "$P_CLI" \
6745 1 \
6746 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006747 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006748 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006749 -s "! mbedtls_ssl_handshake returned"
6750
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006751requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006752run_test "SSL async private: decrypt, error in start" \
6753 "$P_SRV \
6754 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6755 async_private_error=1" \
6756 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6757 1 \
6758 -s "Async decrypt callback: injected error" \
6759 -S "Async resume" \
6760 -S "Async cancel" \
6761 -s "! mbedtls_ssl_handshake returned"
6762
6763requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6764run_test "SSL async private: decrypt, cancel after start" \
6765 "$P_SRV \
6766 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6767 async_private_error=2" \
6768 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6769 1 \
6770 -s "Async decrypt callback: using key slot " \
6771 -S "Async resume" \
6772 -s "Async cancel"
6773
6774requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6775run_test "SSL async private: decrypt, error in resume" \
6776 "$P_SRV \
6777 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6778 async_private_error=3" \
6779 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6780 1 \
6781 -s "Async decrypt callback: using key slot " \
6782 -s "Async resume callback: decrypt done but injected error" \
6783 -S "Async cancel" \
6784 -s "! mbedtls_ssl_handshake returned"
6785
6786requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006787run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006788 "$P_SRV \
6789 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6790 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006791 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6792 0 \
6793 -s "Async cancel" \
6794 -s "! mbedtls_ssl_handshake returned" \
6795 -s "Async resume" \
6796 -s "Successful connection"
6797
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006798requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006799run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006800 "$P_SRV \
6801 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6802 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006803 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6804 0 \
6805 -s "! mbedtls_ssl_handshake returned" \
6806 -s "Async resume" \
6807 -s "Successful connection"
6808
6809# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006810requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006811run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006812 "$P_SRV \
6813 async_operations=s async_private_delay1=1 async_private_error=-2 \
6814 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6815 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006816 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6817 [ \$? -eq 1 ] &&
6818 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6819 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006820 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006821 -S "Async resume" \
6822 -s "Async cancel" \
6823 -s "! mbedtls_ssl_handshake returned" \
6824 -s "Async sign callback: no key matches this certificate." \
6825 -s "Successful connection"
6826
6827# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006828requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006829run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006830 "$P_SRV \
6831 async_operations=s async_private_delay1=1 async_private_error=-3 \
6832 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6833 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006834 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6835 [ \$? -eq 1 ] &&
6836 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6837 0 \
6838 -s "Async resume" \
6839 -s "! mbedtls_ssl_handshake returned" \
6840 -s "Async sign callback: no key matches this certificate." \
6841 -s "Successful connection"
6842
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006843requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006844requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006845run_test "SSL async private: renegotiation: client-initiated; sign" \
6846 "$P_SRV \
6847 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006848 exchanges=2 renegotiation=1" \
6849 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6850 0 \
6851 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006852 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006853
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006854requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006855requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006856run_test "SSL async private: renegotiation: server-initiated; sign" \
6857 "$P_SRV \
6858 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006859 exchanges=2 renegotiation=1 renegotiate=1" \
6860 "$P_CLI exchanges=2 renegotiation=1" \
6861 0 \
6862 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006863 -s "Async resume (slot [0-9]): sign done, status=0"
6864
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006865requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006866requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6867run_test "SSL async private: renegotiation: client-initiated; decrypt" \
6868 "$P_SRV \
6869 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6870 exchanges=2 renegotiation=1" \
6871 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6872 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6873 0 \
6874 -s "Async decrypt callback: using key slot " \
6875 -s "Async resume (slot [0-9]): decrypt done, status=0"
6876
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006877requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006878requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6879run_test "SSL async private: renegotiation: server-initiated; decrypt" \
6880 "$P_SRV \
6881 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6882 exchanges=2 renegotiation=1 renegotiate=1" \
6883 "$P_CLI exchanges=2 renegotiation=1 \
6884 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6885 0 \
6886 -s "Async decrypt callback: using key slot " \
6887 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006888
Ron Eldor58093c82018-06-28 13:22:05 +03006889# Tests for ECC extensions (rfc 4492)
6890
Ron Eldor643df7c2018-06-28 16:17:00 +03006891requires_config_enabled MBEDTLS_AES_C
6892requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6893requires_config_enabled MBEDTLS_SHA256_C
6894requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006895run_test "Force a non ECC ciphersuite in the client side" \
6896 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006897 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006898 0 \
6899 -C "client hello, adding supported_elliptic_curves extension" \
6900 -C "client hello, adding supported_point_formats extension" \
6901 -S "found supported elliptic curves extension" \
6902 -S "found supported point formats extension"
6903
Ron Eldor643df7c2018-06-28 16:17:00 +03006904requires_config_enabled MBEDTLS_AES_C
6905requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6906requires_config_enabled MBEDTLS_SHA256_C
6907requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006908run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006909 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006910 "$P_CLI debug_level=3" \
6911 0 \
6912 -C "found supported_point_formats extension" \
6913 -S "server hello, supported_point_formats extension"
6914
Ron Eldor643df7c2018-06-28 16:17:00 +03006915requires_config_enabled MBEDTLS_AES_C
6916requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6917requires_config_enabled MBEDTLS_SHA256_C
6918requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006919run_test "Force an ECC ciphersuite in the client side" \
6920 "$P_SRV debug_level=3" \
6921 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6922 0 \
6923 -c "client hello, adding supported_elliptic_curves extension" \
6924 -c "client hello, adding supported_point_formats extension" \
6925 -s "found supported elliptic curves extension" \
6926 -s "found supported point formats extension"
6927
Ron Eldor643df7c2018-06-28 16:17:00 +03006928requires_config_enabled MBEDTLS_AES_C
6929requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6930requires_config_enabled MBEDTLS_SHA256_C
6931requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006932run_test "Force an ECC ciphersuite in the server side" \
6933 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6934 "$P_CLI debug_level=3" \
6935 0 \
6936 -c "found supported_point_formats extension" \
6937 -s "server hello, supported_point_formats extension"
6938
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006939# Tests for DTLS HelloVerifyRequest
6940
6941run_test "DTLS cookie: enabled" \
6942 "$P_SRV dtls=1 debug_level=2" \
6943 "$P_CLI dtls=1 debug_level=2" \
6944 0 \
6945 -s "cookie verification failed" \
6946 -s "cookie verification passed" \
6947 -S "cookie verification skipped" \
6948 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006949 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006950 -S "SSL - The requested feature is not available"
6951
6952run_test "DTLS cookie: disabled" \
6953 "$P_SRV dtls=1 debug_level=2 cookies=0" \
6954 "$P_CLI dtls=1 debug_level=2" \
6955 0 \
6956 -S "cookie verification failed" \
6957 -S "cookie verification passed" \
6958 -s "cookie verification skipped" \
6959 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006960 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006961 -S "SSL - The requested feature is not available"
6962
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006963run_test "DTLS cookie: default (failing)" \
6964 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
6965 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
6966 1 \
6967 -s "cookie verification failed" \
6968 -S "cookie verification passed" \
6969 -S "cookie verification skipped" \
6970 -C "received hello verify request" \
6971 -S "hello verification requested" \
6972 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006973
6974requires_ipv6
6975run_test "DTLS cookie: enabled, IPv6" \
6976 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
6977 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
6978 0 \
6979 -s "cookie verification failed" \
6980 -s "cookie verification passed" \
6981 -S "cookie verification skipped" \
6982 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006983 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006984 -S "SSL - The requested feature is not available"
6985
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006986run_test "DTLS cookie: enabled, nbio" \
6987 "$P_SRV dtls=1 nbio=2 debug_level=2" \
6988 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6989 0 \
6990 -s "cookie verification failed" \
6991 -s "cookie verification passed" \
6992 -S "cookie verification skipped" \
6993 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006994 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006995 -S "SSL - The requested feature is not available"
6996
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006997# Tests for client reconnecting from the same port with DTLS
6998
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006999not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007000run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007001 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7002 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007003 0 \
7004 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007005 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007006 -S "Client initiated reconnection from same port"
7007
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007008not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007009run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007010 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7011 "$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 +02007012 0 \
7013 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007014 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007015 -s "Client initiated reconnection from same port"
7016
Paul Bakker362689d2016-05-13 10:33:25 +01007017not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
7018run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007019 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7020 "$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 +02007021 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007022 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007023 -s "Client initiated reconnection from same port"
7024
Paul Bakker362689d2016-05-13 10:33:25 +01007025only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
7026run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7027 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7028 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7029 0 \
7030 -S "The operation timed out" \
7031 -s "Client initiated reconnection from same port"
7032
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007033run_test "DTLS client reconnect from same port: no cookies" \
7034 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007035 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7036 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007037 -s "The operation timed out" \
7038 -S "Client initiated reconnection from same port"
7039
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007040# Tests for various cases of client authentication with DTLS
7041# (focused on handshake flows and message parsing)
7042
7043run_test "DTLS client auth: required" \
7044 "$P_SRV dtls=1 auth_mode=required" \
7045 "$P_CLI dtls=1" \
7046 0 \
7047 -s "Verifying peer X.509 certificate... ok"
7048
Hanno Becker4a156fc2019-06-14 17:07:06 +01007049requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007050requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007051run_test "DTLS client auth: optional, client has no cert" \
7052 "$P_SRV dtls=1 auth_mode=optional" \
7053 "$P_CLI dtls=1 crt_file=none key_file=none" \
7054 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007055 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007056
Hanno Becker4a156fc2019-06-14 17:07:06 +01007057requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007058requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007059run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007060 "$P_SRV dtls=1 auth_mode=none" \
7061 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7062 0 \
7063 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007064 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007065
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007066run_test "DTLS wrong PSK: badmac alert" \
7067 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7068 "$P_CLI dtls=1 psk=abc124" \
7069 1 \
7070 -s "SSL - Verification of the message MAC failed" \
7071 -c "SSL - A fatal alert message was received from our peer"
7072
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007073# Tests for receiving fragmented handshake messages with DTLS
7074
7075requires_gnutls
7076run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7077 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007078 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007079 0 \
7080 -C "found fragmented DTLS handshake message" \
7081 -C "error"
7082
7083requires_gnutls
7084run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7085 "$G_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007086 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007087 0 \
7088 -c "found fragmented DTLS handshake message" \
7089 -C "error"
7090
7091requires_gnutls
7092run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7093 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007094 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007095 0 \
7096 -c "found fragmented DTLS handshake message" \
7097 -C "error"
7098
7099requires_gnutls
7100run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7101 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007102 "$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 +02007103 0 \
7104 -c "found fragmented DTLS handshake message" \
7105 -C "error"
7106
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007107requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007108requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007109run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7110 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007111 "$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 +02007112 0 \
7113 -c "found fragmented DTLS handshake message" \
7114 -c "client hello, adding renegotiation extension" \
7115 -c "found renegotiation extension" \
7116 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007117 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007118 -C "error" \
7119 -s "Extra-header:"
7120
7121requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007122requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007123run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7124 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007125 "$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 +02007126 0 \
7127 -c "found fragmented DTLS handshake message" \
7128 -c "client hello, adding renegotiation extension" \
7129 -c "found renegotiation extension" \
7130 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007131 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007132 -C "error" \
7133 -s "Extra-header:"
7134
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007135run_test "DTLS reassembly: no fragmentation (openssl server)" \
7136 "$O_SRV -dtls1 -mtu 2048" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007137 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007138 0 \
7139 -C "found fragmented DTLS handshake message" \
7140 -C "error"
7141
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007142run_test "DTLS reassembly: some fragmentation (openssl server)" \
7143 "$O_SRV -dtls1 -mtu 768" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007144 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007145 0 \
7146 -c "found fragmented DTLS handshake message" \
7147 -C "error"
7148
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007149run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007150 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007151 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007152 0 \
7153 -c "found fragmented DTLS handshake message" \
7154 -C "error"
7155
7156run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7157 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007158 "$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 +02007159 0 \
7160 -c "found fragmented DTLS handshake message" \
7161 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007162
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007163# Tests for sending fragmented handshake messages with DTLS
7164#
7165# Use client auth when we need the client to send large messages,
7166# and use large cert chains on both sides too (the long chains we have all use
7167# both RSA and ECDSA, but ideally we should have long chains with either).
7168# Sizes reached (UDP payload):
7169# - 2037B for server certificate
7170# - 1542B for client certificate
7171# - 1013B for newsessionticket
7172# - all others below 512B
7173# All those tests assume MAX_CONTENT_LEN is at least 2048
7174
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007175requires_config_enabled MBEDTLS_RSA_C
7176requires_config_enabled MBEDTLS_ECDSA_C
7177requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7178run_test "DTLS fragmenting: none (for reference)" \
7179 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7180 crt_file=data_files/server7_int-ca.crt \
7181 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007182 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007183 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007184 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007185 "$P_CLI dtls=1 debug_level=2 \
7186 crt_file=data_files/server8_int-ca2.crt \
7187 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007188 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007189 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007190 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007191 0 \
7192 -S "found fragmented DTLS handshake message" \
7193 -C "found fragmented DTLS handshake message" \
7194 -C "error"
7195
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007196requires_config_enabled MBEDTLS_RSA_C
7197requires_config_enabled MBEDTLS_ECDSA_C
7198requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007199run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007200 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7201 crt_file=data_files/server7_int-ca.crt \
7202 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007203 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007204 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007205 max_frag_len=1024" \
7206 "$P_CLI dtls=1 debug_level=2 \
7207 crt_file=data_files/server8_int-ca2.crt \
7208 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007209 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007210 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007211 max_frag_len=2048" \
7212 0 \
7213 -S "found fragmented DTLS handshake message" \
7214 -c "found fragmented DTLS handshake message" \
7215 -C "error"
7216
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007217# With the MFL extension, the server has no way of forcing
7218# the client to not exceed a certain MTU; hence, the following
7219# test can't be replicated with an MTU proxy such as the one
7220# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007221requires_config_enabled MBEDTLS_RSA_C
7222requires_config_enabled MBEDTLS_ECDSA_C
7223requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007224run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007225 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7226 crt_file=data_files/server7_int-ca.crt \
7227 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007228 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007229 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007230 max_frag_len=512" \
7231 "$P_CLI dtls=1 debug_level=2 \
7232 crt_file=data_files/server8_int-ca2.crt \
7233 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007234 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007235 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007236 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007237 0 \
7238 -S "found fragmented DTLS handshake message" \
7239 -c "found fragmented DTLS handshake message" \
7240 -C "error"
7241
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007242requires_config_enabled MBEDTLS_RSA_C
7243requires_config_enabled MBEDTLS_ECDSA_C
7244requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007245run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007246 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7247 crt_file=data_files/server7_int-ca.crt \
7248 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007249 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007250 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007251 max_frag_len=2048" \
7252 "$P_CLI dtls=1 debug_level=2 \
7253 crt_file=data_files/server8_int-ca2.crt \
7254 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007255 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007256 hs_timeout=2500-60000 \
7257 max_frag_len=1024" \
7258 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007259 -S "found fragmented DTLS handshake message" \
7260 -c "found fragmented DTLS handshake message" \
7261 -C "error"
7262
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007263# While not required by the standard defining the MFL extension
7264# (according to which it only applies to records, not to datagrams),
7265# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7266# as otherwise there wouldn't be any means to communicate MTU restrictions
7267# to the peer.
7268# The next test checks that no datagrams significantly larger than the
7269# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007270requires_config_enabled MBEDTLS_RSA_C
7271requires_config_enabled MBEDTLS_ECDSA_C
7272requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7273run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007274 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007275 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7276 crt_file=data_files/server7_int-ca.crt \
7277 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007278 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007279 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007280 max_frag_len=2048" \
7281 "$P_CLI dtls=1 debug_level=2 \
7282 crt_file=data_files/server8_int-ca2.crt \
7283 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007284 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007285 hs_timeout=2500-60000 \
7286 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007287 0 \
7288 -S "found fragmented DTLS handshake message" \
7289 -c "found fragmented DTLS handshake message" \
7290 -C "error"
7291
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007292requires_config_enabled MBEDTLS_RSA_C
7293requires_config_enabled MBEDTLS_ECDSA_C
7294requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007295run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007296 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7297 crt_file=data_files/server7_int-ca.crt \
7298 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007299 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007300 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007301 max_frag_len=2048" \
7302 "$P_CLI dtls=1 debug_level=2 \
7303 crt_file=data_files/server8_int-ca2.crt \
7304 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007305 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007306 hs_timeout=2500-60000 \
7307 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007308 0 \
7309 -s "found fragmented DTLS handshake message" \
7310 -c "found fragmented DTLS handshake message" \
7311 -C "error"
7312
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007313# While not required by the standard defining the MFL extension
7314# (according to which it only applies to records, not to datagrams),
7315# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7316# as otherwise there wouldn't be any means to communicate MTU restrictions
7317# to the peer.
7318# The next test checks that no datagrams significantly larger than the
7319# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007320requires_config_enabled MBEDTLS_RSA_C
7321requires_config_enabled MBEDTLS_ECDSA_C
7322requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7323run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007324 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007325 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7326 crt_file=data_files/server7_int-ca.crt \
7327 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007328 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007329 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007330 max_frag_len=2048" \
7331 "$P_CLI dtls=1 debug_level=2 \
7332 crt_file=data_files/server8_int-ca2.crt \
7333 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007334 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007335 hs_timeout=2500-60000 \
7336 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007337 0 \
7338 -s "found fragmented DTLS handshake message" \
7339 -c "found fragmented DTLS handshake message" \
7340 -C "error"
7341
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007342requires_config_enabled MBEDTLS_RSA_C
7343requires_config_enabled MBEDTLS_ECDSA_C
7344run_test "DTLS fragmenting: none (for reference) (MTU)" \
7345 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7346 crt_file=data_files/server7_int-ca.crt \
7347 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007348 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007349 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007350 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007351 "$P_CLI dtls=1 debug_level=2 \
7352 crt_file=data_files/server8_int-ca2.crt \
7353 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007354 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007355 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007356 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007357 0 \
7358 -S "found fragmented DTLS handshake message" \
7359 -C "found fragmented DTLS handshake message" \
7360 -C "error"
7361
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007362requires_config_enabled MBEDTLS_RSA_C
7363requires_config_enabled MBEDTLS_ECDSA_C
7364run_test "DTLS fragmenting: client (MTU)" \
7365 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7366 crt_file=data_files/server7_int-ca.crt \
7367 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007368 ca_file=data_files/test-ca.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007369 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007370 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007371 "$P_CLI dtls=1 debug_level=2 \
7372 crt_file=data_files/server8_int-ca2.crt \
7373 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007374 ca_file=data_files/test-ca2.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007375 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007376 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007377 0 \
7378 -s "found fragmented DTLS handshake message" \
7379 -C "found fragmented DTLS handshake message" \
7380 -C "error"
7381
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007382requires_config_enabled MBEDTLS_RSA_C
7383requires_config_enabled MBEDTLS_ECDSA_C
7384run_test "DTLS fragmenting: server (MTU)" \
7385 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7386 crt_file=data_files/server7_int-ca.crt \
7387 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007388 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007389 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007390 mtu=512" \
7391 "$P_CLI dtls=1 debug_level=2 \
7392 crt_file=data_files/server8_int-ca2.crt \
7393 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007394 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007395 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007396 mtu=2048" \
7397 0 \
7398 -S "found fragmented DTLS handshake message" \
7399 -c "found fragmented DTLS handshake message" \
7400 -C "error"
7401
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007402requires_config_enabled MBEDTLS_RSA_C
7403requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007404run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007405 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007406 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7407 crt_file=data_files/server7_int-ca.crt \
7408 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007409 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007410 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007411 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007412 "$P_CLI dtls=1 debug_level=2 \
7413 crt_file=data_files/server8_int-ca2.crt \
7414 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007415 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007416 hs_timeout=2500-60000 \
7417 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007418 0 \
7419 -s "found fragmented DTLS handshake message" \
7420 -c "found fragmented DTLS handshake message" \
7421 -C "error"
7422
Andrzej Kurek77826052018-10-11 07:34:08 -04007423# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007424requires_config_enabled MBEDTLS_RSA_C
7425requires_config_enabled MBEDTLS_ECDSA_C
7426requires_config_enabled MBEDTLS_SHA256_C
7427requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7428requires_config_enabled MBEDTLS_AES_C
7429requires_config_enabled MBEDTLS_GCM_C
7430run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007431 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007432 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7433 crt_file=data_files/server7_int-ca.crt \
7434 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007435 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007436 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007437 mtu=512" \
7438 "$P_CLI dtls=1 debug_level=2 \
7439 crt_file=data_files/server8_int-ca2.crt \
7440 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007441 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007442 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7443 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007444 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007445 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007446 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007447 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007448 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007449
Andrzej Kurek7311c782018-10-11 06:49:41 -04007450# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007451# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007452# The ratio of max/min timeout should ideally equal 4 to accept two
7453# retransmissions, but in some cases (like both the server and client using
7454# fragmentation and auto-reduction) an extra retransmission might occur,
7455# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007456not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007457requires_config_enabled MBEDTLS_RSA_C
7458requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007459requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7460requires_config_enabled MBEDTLS_AES_C
7461requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007462run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7463 -p "$P_PXY mtu=508" \
7464 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7465 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007466 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007467 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007468 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007469 "$P_CLI dtls=1 debug_level=2 \
7470 crt_file=data_files/server8_int-ca2.crt \
7471 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007472 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007473 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7474 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007475 0 \
7476 -s "found fragmented DTLS handshake message" \
7477 -c "found fragmented DTLS handshake message" \
7478 -C "error"
7479
Andrzej Kurek77826052018-10-11 07:34:08 -04007480# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007481only_with_valgrind
Hanno Becker108992e2018-08-29 17:04:18 +01007482requires_config_enabled MBEDTLS_RSA_C
7483requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007484requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7485requires_config_enabled MBEDTLS_AES_C
7486requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01007487run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7488 -p "$P_PXY mtu=508" \
7489 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7490 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007491 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007492 ca_file=data_files/test-ca.crt \
Hanno Becker108992e2018-08-29 17:04:18 +01007493 hs_timeout=250-10000" \
7494 "$P_CLI dtls=1 debug_level=2 \
7495 crt_file=data_files/server8_int-ca2.crt \
7496 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007497 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007498 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007499 hs_timeout=250-10000" \
7500 0 \
7501 -s "found fragmented DTLS handshake message" \
7502 -c "found fragmented DTLS handshake message" \
7503 -C "error"
7504
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007505# 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 +02007506# OTOH the client might resend if the server is to slow to reset after sending
7507# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007508not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007509requires_config_enabled MBEDTLS_RSA_C
7510requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007511run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007512 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007513 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7514 crt_file=data_files/server7_int-ca.crt \
7515 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007516 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007517 hs_timeout=10000-60000 \
7518 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007519 "$P_CLI dtls=1 debug_level=2 \
7520 crt_file=data_files/server8_int-ca2.crt \
7521 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007522 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007523 hs_timeout=10000-60000 \
7524 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007525 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007526 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007527 -s "found fragmented DTLS handshake message" \
7528 -c "found fragmented DTLS handshake message" \
7529 -C "error"
7530
Andrzej Kurek77826052018-10-11 07:34:08 -04007531# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007532# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7533# OTOH the client might resend if the server is to slow to reset after sending
7534# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007535not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007536requires_config_enabled MBEDTLS_RSA_C
7537requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007538requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7539requires_config_enabled MBEDTLS_AES_C
7540requires_config_enabled MBEDTLS_GCM_C
7541run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007542 -p "$P_PXY mtu=512" \
7543 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7544 crt_file=data_files/server7_int-ca.crt \
7545 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007546 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007547 hs_timeout=10000-60000 \
7548 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007549 "$P_CLI dtls=1 debug_level=2 \
7550 crt_file=data_files/server8_int-ca2.crt \
7551 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007552 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007553 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7554 hs_timeout=10000-60000 \
7555 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007556 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007557 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007558 -s "found fragmented DTLS handshake message" \
7559 -c "found fragmented DTLS handshake message" \
7560 -C "error"
7561
Andrzej Kurek7311c782018-10-11 06:49:41 -04007562not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007563requires_config_enabled MBEDTLS_RSA_C
7564requires_config_enabled MBEDTLS_ECDSA_C
7565run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007566 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007567 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7568 crt_file=data_files/server7_int-ca.crt \
7569 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007570 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007571 hs_timeout=10000-60000 \
7572 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007573 "$P_CLI dtls=1 debug_level=2 \
7574 crt_file=data_files/server8_int-ca2.crt \
7575 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007576 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007577 hs_timeout=10000-60000 \
7578 mtu=1024 nbio=2" \
7579 0 \
7580 -S "autoreduction" \
7581 -s "found fragmented DTLS handshake message" \
7582 -c "found fragmented DTLS handshake message" \
7583 -C "error"
7584
Andrzej Kurek77826052018-10-11 07:34:08 -04007585# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007586not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007587requires_config_enabled MBEDTLS_RSA_C
7588requires_config_enabled MBEDTLS_ECDSA_C
7589requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7590requires_config_enabled MBEDTLS_AES_C
7591requires_config_enabled MBEDTLS_GCM_C
7592run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7593 -p "$P_PXY mtu=512" \
7594 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7595 crt_file=data_files/server7_int-ca.crt \
7596 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007597 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007598 hs_timeout=10000-60000 \
7599 mtu=512 nbio=2" \
7600 "$P_CLI dtls=1 debug_level=2 \
7601 crt_file=data_files/server8_int-ca2.crt \
7602 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007603 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007604 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7605 hs_timeout=10000-60000 \
7606 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007607 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007608 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007609 -s "found fragmented DTLS handshake message" \
7610 -c "found fragmented DTLS handshake message" \
7611 -C "error"
7612
Andrzej Kurek77826052018-10-11 07:34:08 -04007613# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007614# This ensures things still work after session_reset().
7615# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007616# Since we don't support reading fragmented ClientHello yet,
7617# up the MTU to 1450 (larger than ClientHello with session ticket,
7618# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007619# An autoreduction on the client-side might happen if the server is
7620# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007621# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007622# resumed listening, which would result in a spurious autoreduction.
7623not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007624requires_config_enabled MBEDTLS_RSA_C
7625requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007626requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7627requires_config_enabled MBEDTLS_AES_C
7628requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007629run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7630 -p "$P_PXY mtu=1450" \
7631 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7632 crt_file=data_files/server7_int-ca.crt \
7633 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007634 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007635 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007636 mtu=1450" \
7637 "$P_CLI dtls=1 debug_level=2 \
7638 crt_file=data_files/server8_int-ca2.crt \
7639 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007640 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007641 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007642 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007643 mtu=1450 reconnect=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007644 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007645 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007646 -s "found fragmented DTLS handshake message" \
7647 -c "found fragmented DTLS handshake message" \
7648 -C "error"
7649
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007650# An autoreduction on the client-side might happen if the server is
7651# slow to reset, therefore omitting '-C "autoreduction"' below.
7652not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007653requires_config_enabled MBEDTLS_RSA_C
7654requires_config_enabled MBEDTLS_ECDSA_C
7655requires_config_enabled MBEDTLS_SHA256_C
7656requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7657requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7658requires_config_enabled MBEDTLS_CHACHAPOLY_C
7659run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7660 -p "$P_PXY mtu=512" \
7661 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7662 crt_file=data_files/server7_int-ca.crt \
7663 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007664 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007665 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007666 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007667 mtu=512" \
7668 "$P_CLI dtls=1 debug_level=2 \
7669 crt_file=data_files/server8_int-ca2.crt \
7670 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007671 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007672 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007673 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007674 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007675 mtu=512" \
7676 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007677 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007678 -s "found fragmented DTLS handshake message" \
7679 -c "found fragmented DTLS handshake message" \
7680 -C "error"
7681
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007682# An autoreduction on the client-side might happen if the server is
7683# slow to reset, therefore omitting '-C "autoreduction"' below.
7684not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007685requires_config_enabled MBEDTLS_RSA_C
7686requires_config_enabled MBEDTLS_ECDSA_C
7687requires_config_enabled MBEDTLS_SHA256_C
7688requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7689requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7690requires_config_enabled MBEDTLS_AES_C
7691requires_config_enabled MBEDTLS_GCM_C
7692run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7693 -p "$P_PXY mtu=512" \
7694 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7695 crt_file=data_files/server7_int-ca.crt \
7696 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007697 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007698 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007699 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007700 mtu=512" \
7701 "$P_CLI dtls=1 debug_level=2 \
7702 crt_file=data_files/server8_int-ca2.crt \
7703 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007704 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007705 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007706 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007707 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007708 mtu=512" \
7709 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007710 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007711 -s "found fragmented DTLS handshake message" \
7712 -c "found fragmented DTLS handshake message" \
7713 -C "error"
7714
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007715# An autoreduction on the client-side might happen if the server is
7716# slow to reset, therefore omitting '-C "autoreduction"' below.
7717not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007718requires_config_enabled MBEDTLS_RSA_C
7719requires_config_enabled MBEDTLS_ECDSA_C
7720requires_config_enabled MBEDTLS_SHA256_C
7721requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7722requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7723requires_config_enabled MBEDTLS_AES_C
7724requires_config_enabled MBEDTLS_CCM_C
7725run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007726 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007727 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7728 crt_file=data_files/server7_int-ca.crt \
7729 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007730 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007731 exchanges=2 renegotiation=1 \
7732 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007733 hs_timeout=10000-60000 \
7734 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007735 "$P_CLI dtls=1 debug_level=2 \
7736 crt_file=data_files/server8_int-ca2.crt \
7737 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007738 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007739 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007740 hs_timeout=10000-60000 \
7741 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007742 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007743 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007744 -s "found fragmented DTLS handshake message" \
7745 -c "found fragmented DTLS handshake message" \
7746 -C "error"
7747
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007748# An autoreduction on the client-side might happen if the server is
7749# slow to reset, therefore omitting '-C "autoreduction"' below.
7750not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007751requires_config_enabled MBEDTLS_RSA_C
7752requires_config_enabled MBEDTLS_ECDSA_C
7753requires_config_enabled MBEDTLS_SHA256_C
7754requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7755requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7756requires_config_enabled MBEDTLS_AES_C
7757requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7758requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7759run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007760 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007761 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7762 crt_file=data_files/server7_int-ca.crt \
7763 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007764 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007765 exchanges=2 renegotiation=1 \
7766 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007767 hs_timeout=10000-60000 \
7768 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007769 "$P_CLI dtls=1 debug_level=2 \
7770 crt_file=data_files/server8_int-ca2.crt \
7771 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007772 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007773 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007774 hs_timeout=10000-60000 \
7775 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007776 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007777 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007778 -s "found fragmented DTLS handshake message" \
7779 -c "found fragmented DTLS handshake message" \
7780 -C "error"
7781
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007782# An autoreduction on the client-side might happen if the server is
7783# slow to reset, therefore omitting '-C "autoreduction"' below.
7784not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007785requires_config_enabled MBEDTLS_RSA_C
7786requires_config_enabled MBEDTLS_ECDSA_C
7787requires_config_enabled MBEDTLS_SHA256_C
7788requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7789requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7790requires_config_enabled MBEDTLS_AES_C
7791requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7792run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007793 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007794 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7795 crt_file=data_files/server7_int-ca.crt \
7796 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007797 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007798 exchanges=2 renegotiation=1 \
7799 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007800 hs_timeout=10000-60000 \
7801 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007802 "$P_CLI dtls=1 debug_level=2 \
7803 crt_file=data_files/server8_int-ca2.crt \
7804 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007805 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007806 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007807 hs_timeout=10000-60000 \
7808 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007809 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007810 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007811 -s "found fragmented DTLS handshake message" \
7812 -c "found fragmented DTLS handshake message" \
7813 -C "error"
7814
Andrzej Kurek77826052018-10-11 07:34:08 -04007815# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007816requires_config_enabled MBEDTLS_RSA_C
7817requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007818requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7819requires_config_enabled MBEDTLS_AES_C
7820requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007821client_needs_more_time 2
7822run_test "DTLS fragmenting: proxy MTU + 3d" \
7823 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007824 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007825 crt_file=data_files/server7_int-ca.crt \
7826 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007827 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007828 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007829 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007830 crt_file=data_files/server8_int-ca2.crt \
7831 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007832 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007833 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007834 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007835 0 \
7836 -s "found fragmented DTLS handshake message" \
7837 -c "found fragmented DTLS handshake message" \
7838 -C "error"
7839
Andrzej Kurek77826052018-10-11 07:34:08 -04007840# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007841requires_config_enabled MBEDTLS_RSA_C
7842requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007843requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7844requires_config_enabled MBEDTLS_AES_C
7845requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007846client_needs_more_time 2
7847run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7848 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7849 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7850 crt_file=data_files/server7_int-ca.crt \
7851 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007852 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007853 hs_timeout=250-10000 mtu=512 nbio=2" \
7854 "$P_CLI dtls=1 debug_level=2 \
7855 crt_file=data_files/server8_int-ca2.crt \
7856 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007857 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007858 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007859 hs_timeout=250-10000 mtu=512 nbio=2" \
7860 0 \
7861 -s "found fragmented DTLS handshake message" \
7862 -c "found fragmented DTLS handshake message" \
7863 -C "error"
7864
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007865# interop tests for DTLS fragmentating with reliable connection
7866#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007867# here and below we just want to test that the we fragment in a way that
7868# pleases other implementations, so we don't need the peer to fragment
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_2
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.2" \
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é-Gonnard1218bc02018-08-17 10:51:26 +02007879 mtu=512 force_version=dtls1_2" \
7880 0 \
7881 -c "fragmenting handshake message" \
7882 -C "error"
7883
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007884requires_config_enabled MBEDTLS_RSA_C
7885requires_config_enabled MBEDTLS_ECDSA_C
7886requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007887requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007888run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
7889 "$G_SRV -u" \
7890 "$P_CLI dtls=1 debug_level=2 \
7891 crt_file=data_files/server8_int-ca2.crt \
7892 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007893 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007894 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007895 0 \
7896 -c "fragmenting handshake message" \
7897 -C "error"
7898
Hanno Beckerb9a00862018-08-28 10:20:22 +01007899# We use --insecure for the GnuTLS client because it expects
7900# the hostname / IP it connects to to be the name used in the
7901# certificate obtained from the server. Here, however, it
7902# connects to 127.0.0.1 while our test certificates use 'localhost'
7903# as the server name in the certificate. This will make the
7904# certifiate validation fail, but passing --insecure makes
7905# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007906requires_config_enabled MBEDTLS_RSA_C
7907requires_config_enabled MBEDTLS_ECDSA_C
7908requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007909requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007910requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007911run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007912 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007913 crt_file=data_files/server7_int-ca.crt \
7914 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007915 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007916 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007917 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007918 0 \
7919 -s "fragmenting handshake message"
7920
Hanno Beckerb9a00862018-08-28 10:20:22 +01007921# See previous test for the reason to use --insecure
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_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007925requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007926requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007927run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007928 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007929 crt_file=data_files/server7_int-ca.crt \
7930 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007931 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007932 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007933 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007934 0 \
7935 -s "fragmenting handshake message"
7936
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007937requires_config_enabled MBEDTLS_RSA_C
7938requires_config_enabled MBEDTLS_ECDSA_C
7939requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7940run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
7941 "$O_SRV -dtls1_2 -verify 10" \
7942 "$P_CLI dtls=1 debug_level=2 \
7943 crt_file=data_files/server8_int-ca2.crt \
7944 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007945 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007946 mtu=512 force_version=dtls1_2" \
7947 0 \
7948 -c "fragmenting handshake message" \
7949 -C "error"
7950
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007951requires_config_enabled MBEDTLS_RSA_C
7952requires_config_enabled MBEDTLS_ECDSA_C
7953requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7954run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
7955 "$O_SRV -dtls1 -verify 10" \
7956 "$P_CLI dtls=1 debug_level=2 \
7957 crt_file=data_files/server8_int-ca2.crt \
7958 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007959 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007960 mtu=512 force_version=dtls1" \
7961 0 \
7962 -c "fragmenting handshake message" \
7963 -C "error"
7964
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007965requires_config_enabled MBEDTLS_RSA_C
7966requires_config_enabled MBEDTLS_ECDSA_C
7967requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7968run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
7969 "$P_SRV dtls=1 debug_level=2 \
7970 crt_file=data_files/server7_int-ca.crt \
7971 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007972 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007973 mtu=512 force_version=dtls1_2" \
7974 "$O_CLI -dtls1_2" \
7975 0 \
7976 -s "fragmenting handshake message"
7977
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007978requires_config_enabled MBEDTLS_RSA_C
7979requires_config_enabled MBEDTLS_ECDSA_C
7980requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7981run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
7982 "$P_SRV dtls=1 debug_level=2 \
7983 crt_file=data_files/server7_int-ca.crt \
7984 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007985 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007986 mtu=512 force_version=dtls1" \
7987 "$O_CLI -dtls1" \
7988 0 \
7989 -s "fragmenting handshake message"
7990
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007991# interop tests for DTLS fragmentating with unreliable connection
7992#
7993# again we just want to test that the we fragment in a way that
7994# pleases other implementations, so we don't need the peer to fragment
7995requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007996requires_config_enabled MBEDTLS_RSA_C
7997requires_config_enabled MBEDTLS_ECDSA_C
7998requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007999client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008000run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8001 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8002 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008003 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008004 crt_file=data_files/server8_int-ca2.crt \
8005 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008006 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008007 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008008 0 \
8009 -c "fragmenting handshake message" \
8010 -C "error"
8011
8012requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008013requires_config_enabled MBEDTLS_RSA_C
8014requires_config_enabled MBEDTLS_ECDSA_C
8015requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008016client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008017run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8018 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8019 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008020 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008021 crt_file=data_files/server8_int-ca2.crt \
8022 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008023 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008024 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008025 0 \
8026 -c "fragmenting handshake message" \
8027 -C "error"
8028
k-stachowiakabb843e2019-02-18 16:14:03 +01008029requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008030requires_config_enabled MBEDTLS_RSA_C
8031requires_config_enabled MBEDTLS_ECDSA_C
8032requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8033client_needs_more_time 4
8034run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8035 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8036 "$P_SRV dtls=1 debug_level=2 \
8037 crt_file=data_files/server7_int-ca.crt \
8038 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008039 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008040 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008041 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008042 0 \
8043 -s "fragmenting handshake message"
8044
k-stachowiakabb843e2019-02-18 16:14:03 +01008045requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008046requires_config_enabled MBEDTLS_RSA_C
8047requires_config_enabled MBEDTLS_ECDSA_C
8048requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8049client_needs_more_time 4
8050run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8051 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8052 "$P_SRV dtls=1 debug_level=2 \
8053 crt_file=data_files/server7_int-ca.crt \
8054 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008055 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008056 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008057 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008058 0 \
8059 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008060
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008061## Interop test with OpenSSL might trigger a bug in recent versions (including
8062## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008063## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008064## They should be re-enabled once a fixed version of OpenSSL is available
8065## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008066skip_next_test
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008067requires_config_enabled MBEDTLS_RSA_C
8068requires_config_enabled MBEDTLS_ECDSA_C
8069requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8070client_needs_more_time 4
8071run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8072 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8073 "$O_SRV -dtls1_2 -verify 10" \
8074 "$P_CLI dtls=1 debug_level=2 \
8075 crt_file=data_files/server8_int-ca2.crt \
8076 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008077 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008078 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8079 0 \
8080 -c "fragmenting handshake message" \
8081 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008082
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008083skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008084requires_config_enabled MBEDTLS_RSA_C
8085requires_config_enabled MBEDTLS_ECDSA_C
8086requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008087client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008088run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8089 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008090 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008091 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008092 crt_file=data_files/server8_int-ca2.crt \
8093 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008094 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008095 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008096 0 \
8097 -c "fragmenting handshake message" \
8098 -C "error"
8099
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008100skip_next_test
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008101requires_config_enabled MBEDTLS_RSA_C
8102requires_config_enabled MBEDTLS_ECDSA_C
8103requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8104client_needs_more_time 4
8105run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8106 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8107 "$P_SRV dtls=1 debug_level=2 \
8108 crt_file=data_files/server7_int-ca.crt \
8109 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008110 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008111 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8112 "$O_CLI -dtls1_2" \
8113 0 \
8114 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008115
8116# -nbio is added to prevent s_client from blocking in case of duplicated
8117# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008118skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008119requires_config_enabled MBEDTLS_RSA_C
8120requires_config_enabled MBEDTLS_ECDSA_C
8121requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008122client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008123run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8124 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008125 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008126 crt_file=data_files/server7_int-ca.crt \
8127 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008128 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008129 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008130 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008131 0 \
8132 -s "fragmenting handshake message"
8133
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008134# Tests for specific things with "unreliable" UDP connection
8135
8136not_with_valgrind # spurious resend due to timeout
8137run_test "DTLS proxy: reference" \
8138 -p "$P_PXY" \
8139 "$P_SRV dtls=1 debug_level=2" \
8140 "$P_CLI dtls=1 debug_level=2" \
8141 0 \
8142 -C "replayed record" \
8143 -S "replayed record" \
Hanno Beckere03eb7b2019-07-19 15:43:09 +01008144 -C "Buffer record from epoch" \
8145 -S "Buffer record from epoch" \
8146 -C "ssl_buffer_message" \
8147 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008148 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008149 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008150 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008151 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008152 -c "HTTP/1.0 200 OK"
8153
8154not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008155run_test "DTLS proxy: duplicate every packet" \
8156 -p "$P_PXY duplicate=1" \
Hanno Becker7f376f42019-06-12 16:20:48 +01008157 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008158 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008159 0 \
8160 -c "replayed record" \
8161 -s "replayed record" \
8162 -c "record from another epoch" \
8163 -s "record from another epoch" \
8164 -S "resend" \
8165 -s "Extra-header:" \
8166 -c "HTTP/1.0 200 OK"
8167
8168run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8169 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008170 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8171 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008172 0 \
8173 -c "replayed record" \
8174 -S "replayed record" \
8175 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008176 -s "record from another epoch" \
8177 -c "resend" \
8178 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008179 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008180 -c "HTTP/1.0 200 OK"
8181
8182run_test "DTLS proxy: multiple records in same datagram" \
8183 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008184 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8185 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008186 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008187 -c "next record in same datagram" \
8188 -s "next record in same datagram"
8189
8190run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8191 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008192 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8193 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008194 0 \
8195 -c "next record in same datagram" \
8196 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008197
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008198run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8199 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008200 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8201 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008202 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008203 -c "discarding invalid record (mac)" \
8204 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008205 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008206 -c "HTTP/1.0 200 OK" \
8207 -S "too many records with bad MAC" \
8208 -S "Verification of the message MAC failed"
8209
8210run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8211 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008212 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8213 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008214 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008215 -C "discarding invalid record (mac)" \
8216 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008217 -S "Extra-header:" \
8218 -C "HTTP/1.0 200 OK" \
8219 -s "too many records with bad MAC" \
8220 -s "Verification of the message MAC failed"
8221
8222run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8223 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008224 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8225 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008226 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008227 -c "discarding invalid record (mac)" \
8228 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008229 -s "Extra-header:" \
8230 -c "HTTP/1.0 200 OK" \
8231 -S "too many records with bad MAC" \
8232 -S "Verification of the message MAC failed"
8233
8234run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8235 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008236 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8237 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008238 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008239 -c "discarding invalid record (mac)" \
8240 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008241 -s "Extra-header:" \
8242 -c "HTTP/1.0 200 OK" \
8243 -s "too many records with bad MAC" \
8244 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008245
8246run_test "DTLS proxy: delay ChangeCipherSpec" \
8247 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008248 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8249 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008250 0 \
8251 -c "record from another epoch" \
8252 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008253 -s "Extra-header:" \
8254 -c "HTTP/1.0 200 OK"
8255
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008256# Tests for reordering support with DTLS
8257
Hanno Becker56cdfd12018-08-17 13:42:15 +01008258run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8259 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008260 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8261 hs_timeout=2500-60000" \
8262 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8263 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008264 0 \
8265 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008266 -c "Next handshake message has been buffered - load"\
8267 -S "Buffering HS message" \
8268 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008269 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008270 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008271 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008272 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008273
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008274run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8275 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008276 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8277 hs_timeout=2500-60000" \
8278 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8279 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008280 0 \
8281 -c "Buffering HS message" \
8282 -c "found fragmented DTLS handshake message"\
8283 -c "Next handshake message 1 not or only partially bufffered" \
8284 -c "Next handshake message has been buffered - load"\
8285 -S "Buffering HS message" \
8286 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008287 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008288 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008289 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008290 -S "Remember CCS message"
8291
Hanno Beckera1adcca2018-08-24 14:41:07 +01008292# The client buffers the ServerKeyExchange before receiving the fragmented
8293# Certificate message; at the time of writing, together these are aroudn 1200b
8294# in size, so that the bound below ensures that the certificate can be reassembled
8295# while keeping the ServerKeyExchange.
8296requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8297run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008298 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008299 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8300 hs_timeout=2500-60000" \
8301 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8302 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008303 0 \
8304 -c "Buffering HS message" \
8305 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008306 -C "attempt to make space by freeing buffered messages" \
8307 -S "Buffering HS message" \
8308 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008309 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008310 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008311 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008312 -S "Remember CCS message"
8313
8314# The size constraints ensure that the delayed certificate message can't
8315# be reassembled while keeping the ServerKeyExchange message, but it can
8316# when dropping it first.
8317requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8318requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8319run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8320 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008321 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8322 hs_timeout=2500-60000" \
8323 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8324 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008325 0 \
8326 -c "Buffering HS message" \
8327 -c "attempt to make space by freeing buffered future messages" \
8328 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008329 -S "Buffering HS message" \
8330 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008331 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008332 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008333 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008334 -S "Remember CCS message"
8335
Hanno Becker56cdfd12018-08-17 13:42:15 +01008336run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8337 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008338 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8339 hs_timeout=2500-60000" \
8340 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8341 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008342 0 \
8343 -C "Buffering HS message" \
8344 -C "Next handshake message has been buffered - load"\
8345 -s "Buffering HS message" \
8346 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008347 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008348 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008349 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008350 -S "Remember CCS message"
8351
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02008352# This needs session tickets; otherwise CCS is the first message in its flight
8353requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008354run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8355 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008356 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8357 hs_timeout=2500-60000" \
8358 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8359 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008360 0 \
8361 -C "Buffering HS message" \
8362 -C "Next handshake message has been buffered - load"\
8363 -S "Buffering HS message" \
8364 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008365 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008366 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008367 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008368 -S "Remember CCS message"
8369
8370run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8371 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008372 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8373 hs_timeout=2500-60000" \
8374 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8375 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008376 0 \
8377 -C "Buffering HS message" \
8378 -C "Next handshake message has been buffered - load"\
8379 -S "Buffering HS message" \
8380 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008381 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008382 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008383 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008384 -s "Remember CCS message"
8385
Hanno Beckera1adcca2018-08-24 14:41:07 +01008386run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008387 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008388 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8389 hs_timeout=2500-60000" \
8390 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8391 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008392 0 \
8393 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008394 -s "Found buffered record from current epoch - load" \
8395 -c "Buffer record from epoch 1" \
8396 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008397
Hanno Beckera1adcca2018-08-24 14:41:07 +01008398# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8399# from the server are delayed, so that the encrypted Finished message
8400# is received and buffered. When the fragmented NewSessionTicket comes
8401# in afterwards, the encrypted Finished message must be freed in order
8402# to make space for the NewSessionTicket to be reassembled.
8403# This works only in very particular circumstances:
8404# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8405# of the NewSessionTicket, but small enough to also allow buffering of
8406# the encrypted Finished message.
8407# - The MTU setting on the server must be so small that the NewSessionTicket
8408# needs to be fragmented.
8409# - All messages sent by the server must be small enough to be either sent
8410# without fragmentation or be reassembled within the bounds of
8411# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8412# handshake, omitting CRTs.
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008413requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8414requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008415run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8416 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008417 "$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 +01008418 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8419 0 \
8420 -s "Buffer record from epoch 1" \
8421 -s "Found buffered record from current epoch - load" \
8422 -c "Buffer record from epoch 1" \
8423 -C "Found buffered record from current epoch - load" \
8424 -c "Enough space available after freeing future epoch record"
8425
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008426# Tests for "randomly unreliable connection": try a variety of flows and peers
8427
8428client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008429run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8430 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008431 "$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 +02008432 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008433 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008434 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8435 0 \
8436 -s "Extra-header:" \
8437 -c "HTTP/1.0 200 OK"
8438
Janos Follath74537a62016-09-02 13:45:28 +01008439client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008440run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8441 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008442 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8443 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008444 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8445 0 \
8446 -s "Extra-header:" \
8447 -c "HTTP/1.0 200 OK"
8448
Janos Follath74537a62016-09-02 13:45:28 +01008449client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008450run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8451 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008452 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8453 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008454 0 \
8455 -s "Extra-header:" \
8456 -c "HTTP/1.0 200 OK"
8457
Janos Follath74537a62016-09-02 13:45:28 +01008458client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008459run_test "DTLS proxy: 3d, FS, client auth" \
8460 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008461 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8462 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008463 0 \
8464 -s "Extra-header:" \
8465 -c "HTTP/1.0 200 OK"
8466
Janos Follath74537a62016-09-02 13:45:28 +01008467client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008468run_test "DTLS proxy: 3d, FS, ticket" \
8469 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008470 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8471 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008472 0 \
8473 -s "Extra-header:" \
8474 -c "HTTP/1.0 200 OK"
8475
Janos Follath74537a62016-09-02 13:45:28 +01008476client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008477run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8478 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008479 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8480 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008481 0 \
8482 -s "Extra-header:" \
8483 -c "HTTP/1.0 200 OK"
8484
Janos Follath74537a62016-09-02 13:45:28 +01008485client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008486run_test "DTLS proxy: 3d, max handshake, nbio" \
8487 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008488 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008489 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008490 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008491 0 \
8492 -s "Extra-header:" \
8493 -c "HTTP/1.0 200 OK"
8494
Janos Follath74537a62016-09-02 13:45:28 +01008495client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008496requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008497requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008498requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008499run_test "DTLS proxy: 3d, min handshake, resumption" \
8500 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008501 "$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 +02008502 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008503 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008504 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8505 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8506 0 \
8507 -s "a session has been resumed" \
8508 -c "a session has been resumed" \
8509 -s "Extra-header:" \
8510 -c "HTTP/1.0 200 OK"
8511
Janos Follath74537a62016-09-02 13:45:28 +01008512client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008513requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008514requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008515requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008516run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8517 -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é-Gonnard85beb302014-10-02 17:59:19 +02008519 psk=abc123 debug_level=3 nbio=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é-Gonnard85beb302014-10-02 17:59:19 +02008521 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8522 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8523 0 \
8524 -s "a session has been resumed" \
8525 -c "a session has been resumed" \
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" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008532 -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é-Gonnard1b753f12014-09-25 16:09:36 +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é-Gonnard6093d812014-09-29 17:52:57 +02008546run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8547 -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é-Gonnard37a4de22014-10-01 16:38:03 +02008549 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008550 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008551 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008552 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8553 0 \
8554 -c "=> renegotiate" \
8555 -s "=> renegotiate" \
8556 -s "Extra-header:" \
8557 -c "HTTP/1.0 200 OK"
8558
Janos Follath74537a62016-09-02 13:45:28 +01008559client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008560requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008561run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008562 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008563 "$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 +02008564 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008565 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008566 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008567 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008568 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8569 0 \
8570 -c "=> renegotiate" \
8571 -s "=> renegotiate" \
8572 -s "Extra-header:" \
8573 -c "HTTP/1.0 200 OK"
8574
Janos Follath74537a62016-09-02 13:45:28 +01008575client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008576requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008577run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008578 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008579 "$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 +02008580 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008581 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008582 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008583 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008584 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8585 0 \
8586 -c "=> renegotiate" \
8587 -s "=> renegotiate" \
8588 -s "Extra-header:" \
8589 -c "HTTP/1.0 200 OK"
8590
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008591## Interop tests with OpenSSL might trigger a bug in recent versions (including
8592## all versions installed on the CI machines), reported here:
8593## Bug report: https://github.com/openssl/openssl/issues/6902
8594## They should be re-enabled once a fixed version of OpenSSL is available
8595## (this should happen in some 1.1.1_ release according to the ticket).
8596skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008597client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008598not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008599run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008600 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8601 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008602 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008603 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008604 -c "HTTP/1.0 200 OK"
8605
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008606skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008607client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008608not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008609run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8610 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8611 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008612 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008613 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008614 -c "HTTP/1.0 200 OK"
8615
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008616skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008617client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008618not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008619run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8620 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8621 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008622 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008623 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008624 -c "HTTP/1.0 200 OK"
8625
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008626requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008627client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008628not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008629run_test "DTLS proxy: 3d, gnutls server" \
8630 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8631 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008632 "$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 +02008633 0 \
8634 -s "Extra-header:" \
8635 -c "Extra-header:"
8636
k-stachowiakabb843e2019-02-18 16:14:03 +01008637requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008638client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008639not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008640run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8641 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008642 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008643 "$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 +02008644 0 \
8645 -s "Extra-header:" \
8646 -c "Extra-header:"
8647
k-stachowiakabb843e2019-02-18 16:14:03 +01008648requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008649client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008650not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008651run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8652 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008653 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008654 "$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 +02008655 0 \
8656 -s "Extra-header:" \
8657 -c "Extra-header:"
8658
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008659# Final report
8660
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008661echo "------------------------------------------------------------------------"
8662
8663if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008664 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008665else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008666 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008667fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008668PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008669echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008670
8671exit $FAILS