blob: d0fcfeb04f4a8c586a316b179250c5232527e6e6 [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
Arto Kinnunenc457ab12019-09-27 12:00:51 +0300207requires_config_value_exactly() {
208 VAL=$( get_config_value_or_default "$1" )
209 if [ -z "$VAL" ]; then
210 # Should never happen
211 echo "Mbed TLS configuration $1 is not defined"
212 exit 1
Arto Kinnunen13db25f2019-09-27 13:06:25 +0300213 elif [ "$VAL" -ne "$2" ]; then
Arto Kinnunenc457ab12019-09-27 12:00:51 +0300214 SKIP_NEXT="YES"
215 fi
216}
217
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200218# skip next test if OpenSSL doesn't support FALLBACK_SCSV
219requires_openssl_with_fallback_scsv() {
220 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
221 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
222 then
223 OPENSSL_HAS_FBSCSV="YES"
224 else
225 OPENSSL_HAS_FBSCSV="NO"
226 fi
227 fi
228 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
229 SKIP_NEXT="YES"
230 fi
231}
232
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200233# skip next test if GnuTLS isn't available
234requires_gnutls() {
235 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200236 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200237 GNUTLS_AVAILABLE="YES"
238 else
239 GNUTLS_AVAILABLE="NO"
240 fi
241 fi
242 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
243 SKIP_NEXT="YES"
244 fi
245}
246
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200247# skip next test if GnuTLS-next isn't available
248requires_gnutls_next() {
249 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
250 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
251 GNUTLS_NEXT_AVAILABLE="YES"
252 else
253 GNUTLS_NEXT_AVAILABLE="NO"
254 fi
255 fi
256 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
257 SKIP_NEXT="YES"
258 fi
259}
260
261# skip next test if OpenSSL-legacy isn't available
262requires_openssl_legacy() {
263 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
264 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
265 OPENSSL_LEGACY_AVAILABLE="YES"
266 else
267 OPENSSL_LEGACY_AVAILABLE="NO"
268 fi
269 fi
270 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
271 SKIP_NEXT="YES"
272 fi
273}
274
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200275# skip next test if IPv6 isn't available on this host
276requires_ipv6() {
277 if [ -z "${HAS_IPV6:-}" ]; then
278 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
279 SRV_PID=$!
280 sleep 1
281 kill $SRV_PID >/dev/null 2>&1
282 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
283 HAS_IPV6="NO"
284 else
285 HAS_IPV6="YES"
286 fi
287 rm -r $SRV_OUT
288 fi
289
290 if [ "$HAS_IPV6" = "NO" ]; then
291 SKIP_NEXT="YES"
292 fi
293}
294
Andrzej Kurekb4593462018-10-11 08:43:30 -0400295# skip next test if it's i686 or uname is not available
296requires_not_i686() {
297 if [ -z "${IS_I686:-}" ]; then
298 IS_I686="YES"
299 if which "uname" >/dev/null 2>&1; then
300 if [ -z "$(uname -a | grep i686)" ]; then
301 IS_I686="NO"
302 fi
303 fi
304 fi
305 if [ "$IS_I686" = "YES" ]; then
306 SKIP_NEXT="YES"
307 fi
308}
309
Angus Grattonc4dd0732018-04-11 16:28:39 +1000310# Calculate the input & output maximum content lengths set in the config
Arto Kinnunen78213522019-09-26 11:06:39 +0300311MAX_CONTENT_LEN="$( get_config_value_or_default MBEDTLS_SSL_MAX_CONTENT_LEN )"
312if [ -z "$MAX_CONTENT_LEN" ]; then
313 MAX_CONTENT_LEN=16384
314fi
315
316MAX_IN_LEN="$( get_config_value_or_default MBEDTLS_SSL_IN_CONTENT_LEN )"
317if [ -z "$MAX_IN_LEN" ]; then
318 MAX_IN_LEN=$MAX_CONTENT_LEN
319fi
320
321MAX_OUT_LEN="$( get_config_value_or_default MBEDTLS_SSL_OUT_CONTENT_LEN )"
322if [ -z "$MAX_OUT_LEN" ]; then
323 MAX_OUT_LEN=$MAX_CONTENT_LEN
324fi
Angus Grattonc4dd0732018-04-11 16:28:39 +1000325
326if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
327 MAX_CONTENT_LEN="$MAX_IN_LEN"
328fi
329if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
330 MAX_CONTENT_LEN="$MAX_OUT_LEN"
331fi
332
333# skip the next test if the SSL output buffer is less than 16KB
334requires_full_size_output_buffer() {
335 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
336 SKIP_NEXT="YES"
337 fi
338}
339
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200340# skip the next test if valgrind is in use
341not_with_valgrind() {
342 if [ "$MEMCHECK" -gt 0 ]; then
343 SKIP_NEXT="YES"
344 fi
345}
346
Paul Bakker362689d2016-05-13 10:33:25 +0100347# skip the next test if valgrind is NOT in use
348only_with_valgrind() {
349 if [ "$MEMCHECK" -eq 0 ]; then
350 SKIP_NEXT="YES"
351 fi
352}
353
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200354# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100355client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200356 CLI_DELAY_FACTOR=$1
357}
358
Janos Follath74537a62016-09-02 13:45:28 +0100359# wait for the given seconds after the client finished in the next test
360server_needs_more_time() {
361 SRV_DELAY_SECONDS=$1
362}
363
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100364# print_name <name>
365print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100366 TESTS=$(( $TESTS + 1 ))
367 LINE=""
368
369 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
370 LINE="$TESTS "
371 fi
372
373 LINE="$LINE$1"
374 printf "$LINE "
375 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100376 for i in `seq 1 $LEN`; do printf '.'; done
377 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100378
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100379}
380
381# fail <message>
382fail() {
383 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100384 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100385
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200386 mv $SRV_OUT o-srv-${TESTS}.log
387 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200388 if [ -n "$PXY_CMD" ]; then
389 mv $PXY_OUT o-pxy-${TESTS}.log
390 fi
391 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100392
Azim Khan19d13732018-03-29 11:04:20 +0100393 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 +0200394 echo " ! server output:"
395 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200396 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200397 echo " ! client output:"
398 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200399 if [ -n "$PXY_CMD" ]; then
400 echo " ! ========================================================"
401 echo " ! proxy output:"
402 cat o-pxy-${TESTS}.log
403 fi
404 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200405 fi
406
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200407 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100408}
409
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100410# is_polar <cmd_line>
411is_polar() {
412 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
413}
414
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200415# openssl s_server doesn't have -www with DTLS
416check_osrv_dtls() {
417 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
418 NEEDS_INPUT=1
419 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
420 else
421 NEEDS_INPUT=0
422 fi
423}
424
425# provide input to commands that need it
426provide_input() {
427 if [ $NEEDS_INPUT -eq 0 ]; then
428 return
429 fi
430
431 while true; do
432 echo "HTTP/1.0 200 OK"
433 sleep 1
434 done
435}
436
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100437# has_mem_err <log_file_name>
438has_mem_err() {
439 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
440 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
441 then
442 return 1 # false: does not have errors
443 else
444 return 0 # true: has errors
445 fi
446}
447
Unknown43dc0d62019-09-02 10:42:57 -0400448# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100449if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400450 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100451 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200452 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100453 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200454 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100455 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200456 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100457 # Make a tight loop, server normally takes less than 1s to start.
458 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
459 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400460 echo "$3 START TIMEOUT"
461 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100462 break
463 fi
464 # Linux and *BSD support decimal arguments to sleep. On other
465 # OSes this may be a tight loop.
466 sleep 0.1 2>/dev/null || true
467 done
468 }
469else
Unknown43dc0d62019-09-02 10:42:57 -0400470 echo "Warning: lsof not available, wait_app_start = sleep"
471 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200472 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100473 }
474fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200475
Unknown43dc0d62019-09-02 10:42:57 -0400476# Wait for server process $2 to be listening on port $1.
477wait_server_start() {
478 wait_app_start $1 $2 "SERVER" $SRV_OUT
479}
480
481# Wait for proxy process $2 to be listening on port $1.
482wait_proxy_start() {
483 wait_app_start $1 $2 "PROXY" $PXY_OUT
484}
485
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100486# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100487# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100488# acceptable bounds
489check_server_hello_time() {
490 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100491 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100492 # Get the Unix timestamp for now
493 CUR_TIME=$(date +'%s')
494 THRESHOLD_IN_SECS=300
495
496 # Check if the ServerHello time was printed
497 if [ -z "$SERVER_HELLO_TIME" ]; then
498 return 1
499 fi
500
501 # Check the time in ServerHello is within acceptable bounds
502 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
503 # The time in ServerHello is at least 5 minutes before now
504 return 1
505 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100506 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100507 return 1
508 else
509 return 0
510 fi
511}
512
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200513# wait for client to terminate and set CLI_EXIT
514# must be called right after starting the client
515wait_client_done() {
516 CLI_PID=$!
517
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200518 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
519 CLI_DELAY_FACTOR=1
520
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200521 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200522 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200523
524 wait $CLI_PID
525 CLI_EXIT=$?
526
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200527 kill $DOG_PID >/dev/null 2>&1
528 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200529
530 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100531
532 sleep $SRV_DELAY_SECONDS
533 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200534}
535
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200536# check if the given command uses dtls and sets global variable DTLS
537detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200538 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200539 DTLS=1
540 else
541 DTLS=0
542 fi
543}
544
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100545# Strip off a particular parameter from the command line
546# and return its value.
547# Parameter 1: Command line parameter to strip off
548# ENV I/O: CMD command line to search and modify
549extract_cmdline_argument() {
550 __ARG=$(echo "$CMD" | sed -n "s/^.* $1=\([^ ]*\).*$/\1/p")
551 CMD=$(echo "$CMD" | sed "s/$1=\([^ ]*\)//")
552}
553
554# Check compatibility of the ssl_client2/ssl_server2 command-line
555# with a particular compile-time configurable option.
556# Parameter 1: Command-line argument (e.g. extended_ms)
557# Parameter 2: Corresponding compile-time configuration
558# (e.g. MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET)
559# ENV I/O: CMD command line to search and modify
560# SKIP_NEXT set to "YES" on a mismatch
561check_cmdline_param_compat() {
562 __VAL="$( get_config_value_or_default "$2" )"
563 if [ ! -z "$__VAL" ]; then
564 extract_cmdline_argument "$1"
565 if [ ! -z "$__ARG" ] && [ "$__ARG" != "$__VAL" ]; then
566 SKIP_NEXT="YES"
567 fi
568 fi
569}
570
Hanno Beckera43f85c2019-09-05 14:51:20 +0100571check_cmdline_check_tls_dtls() {
Hanno Becker73b72d12019-07-26 12:00:38 +0100572 detect_dtls "$CMD"
573 if [ "$DTLS" = "0" ]; then
574 requires_config_disabled MBEDTLS_SSL_PROTO_NO_TLS
Hanno Beckera43f85c2019-09-05 14:51:20 +0100575 elif [ "$DTLS" = "1" ]; then
576 requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Hanno Becker73b72d12019-07-26 12:00:38 +0100577 fi
578}
579
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100580check_cmdline_authmode_compat() {
581 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_AUTHMODE" )"
582 if [ ! -z "$__VAL" ]; then
583 extract_cmdline_argument "auth_mode"
584 if [ "$__ARG" = "none" ] && [ "$__VAL" != "0" ]; then
585 SKIP_NEXT="YES";
586 elif [ "$__ARG" = "optional" ] && [ "$__VAL" != "1" ]; then
587 SKIP_NEXT="YES"
588 elif [ "$__ARG" = "required" ] && [ "$__VAL" != "2" ]; then
589 SKIP_NEXT="YES"
590 fi
591 fi
592}
593
Hanno Beckerb0b2b672019-06-12 16:58:10 +0100594check_cmdline_legacy_renego_compat() {
595 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_ALLOW_LEGACY_RENEGOTIATION" )"
596 if [ ! -z "$__VAL" ]; then
597 extract_cmdline_argument "allow_legacy"
598 if [ "$__ARG" = "-1" ] && [ "$__VAL" != "2" ]; then
599 SKIP_NEXT="YES";
600 elif [ "$__ARG" = "0" ] && [ "$__VAL" != "0" ]; then
601 SKIP_NEXT="YES"
602 elif [ "$__ARG" = "1" ] && [ "$__VAL" != "1" ]; then
603 SKIP_NEXT="YES"
604 fi
605 fi
606}
607
Hanno Beckerd82a0302019-07-05 11:40:52 +0100608check_cmdline_min_minor_version_compat() {
609 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MIN_MINOR_VER" )"
610 if [ ! -z "$__VAL" ]; then
611 extract_cmdline_argument "min_version"
612 if [ "$__ARG" = "ssl3" ] && [ "$__VAL" != "0" ]; then
613 SKIP_NEXT="YES";
614 elif [ "$__ARG" = "tls1" ] && [ "$__VAL" != "1" ]; then
615 SKIP_NEXT="YES"
616 elif [ "$__ARG" = "tls1_1" ] && [ "$__VAL" != "2" ]; then
617 SKIP_NEXT="YES"
618 elif [ "$__ARG" = "tls1_2" ] && [ "$__VAL" != "3" ]; then
619 SKIP_NEXT="YES"
620 fi
621 fi
622}
623
624check_cmdline_max_minor_version_compat() {
625 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MAX_MINOR_VER" )"
626 if [ ! -z "$__VAL" ]; then
627 extract_cmdline_argument "max_version"
628 if [ "$__ARG" = "ssl3" ] && [ "$__VAL" != "0" ]; then
629 SKIP_NEXT="YES";
630 elif [ "$__ARG" = "tls1" ] && [ "$__VAL" != "1" ]; then
631 SKIP_NEXT="YES"
632 elif [ "$__ARG" = "tls1_1" ] && [ "$__VAL" != "2" ]; then
633 SKIP_NEXT="YES"
634 elif [ "$__ARG" = "tls1_2" ] && [ "$__VAL" != "3" ]; then
635 SKIP_NEXT="YES"
636 fi
637 fi
638}
639
640check_cmdline_force_version_compat() {
641 __VAL_MAX="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MAX_MINOR_VER" )"
642 __VAL_MIN="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MIN_MINOR_VER" )"
643 if [ ! -z "$__VAL_MIN" ]; then
644
645 # SSL cli/srv cmd line
646
647 extract_cmdline_argument "force_version"
648 if [ "$__ARG" = "ssl3" ] && \
649 ( [ "$__VAL_MIN" != "0" ] || [ "$__VAL_MAX" != "0" ] ); then
650 SKIP_NEXT="YES";
651 elif [ "$__ARG" = "tls1" ] && \
652 ( [ "$__VAL_MIN" != "1" ] || [ "$__VAL_MAX" != "1" ] ); then
653 SKIP_NEXT="YES"
654 elif ( [ "$__ARG" = "tls1_1" ] || [ "$__ARG" = "dtls1" ] ) && \
655 ( [ "$__VAL_MIN" != "2" ] || [ "$__VAL_MAX" != "2" ] ); then
656 SKIP_NEXT="YES"
657 elif ( [ "$__ARG" = "tls1_2" ] || [ "$__ARG" = "dtls1_2" ] ) && \
658 ( [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ] ); then
Hanno Beckerd82a0302019-07-05 11:40:52 +0100659 SKIP_NEXT="YES"
660 fi
661
662 # OpenSSL cmd line
663
664 if echo "$CMD" | grep -e "-tls1\($\|[^_]\)" > /dev/null; then
665 if [ "$__VAL_MIN" != "1" ] || [ "$__VAL_MAX" != "1" ]; then
666 SKIP_NEXT="YES"
667 fi
668 fi
669
670 if echo "$CMD" | grep -e "-\(dtls1\($\|[^_]\)\|tls1_1\)" > /dev/null; then
671 if [ "$__VAL_MIN" != "2" ] || [ "$__VAL_MAX" != "2" ]; then
672 SKIP_NEXT="YES"
673 fi
674 fi
675
676 if echo "$CMD" | grep -e "-\(dtls1_2\($\|[^_]\)\|tls1_2\)" > /dev/null; then
677 if [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ]; then
678 SKIP_NEXT="YES"
679 fi
680 fi
681
682 fi
683}
684
Hanno Becker69c6cde2019-09-02 14:34:23 +0100685check_cmdline_crt_key_files_compat() {
686
687 # test-ca2.crt
688 if echo "$CMD" | grep -e "test-ca2" > /dev/null; then
689 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
690 fi
691
692 # Variants of server5.key and server5.crt
693 if echo "$CMD" | grep -e "server5" > /dev/null; then
694 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
695 fi
696
697 # Variants of server6.key and server6.crt
698 if echo "$CMD" | grep -e "server6" > /dev/null; then
699 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
700 fi
701
702}
703
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100704# Go through all options that can be hardcoded at compile-time and
705# detect whether the command line configures them in a conflicting
706# way. If so, skip the test. Otherwise, remove the corresponding
707# entry.
708# Parameter 1: Command line to inspect
709# Output: Modified command line
710# ENV I/O: SKIP_TEST set to 1 on mismatch.
711check_cmdline_compat() {
712 CMD="$1"
713
Hanno Becker69c6cde2019-09-02 14:34:23 +0100714 # Check that if we're specifying particular certificate and/or
715 # ECC key files, the corresponding curve is enabled.
716 check_cmdline_crt_key_files_compat
717
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100718 # ExtendedMasterSecret configuration
719 check_cmdline_param_compat "extended_ms" \
720 "MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET"
721 check_cmdline_param_compat "enforce_extended_master_secret" \
722 "MBEDTLS_SSL_CONF_ENFORCE_EXTENDED_MASTER_SECRET"
Hanno Becker7f376f42019-06-12 16:20:48 +0100723
724 # DTLS anti replay protection configuration
725 check_cmdline_param_compat "anti_replay" \
726 "MBEDTLS_SSL_CONF_ANTI_REPLAY"
727
Hanno Beckerde671542019-06-12 16:30:46 +0100728 # DTLS bad MAC limit
729 check_cmdline_param_compat "badmac_limit" \
730 "MBEDTLS_SSL_CONF_BADMAC_LIMIT"
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100731
Hanno Beckera43f85c2019-09-05 14:51:20 +0100732 # Skip tests relying on TLS/DTLS in configs that disable it.
733 check_cmdline_check_tls_dtls
Hanno Becker73b72d12019-07-26 12:00:38 +0100734
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100735 # Authentication mode
736 check_cmdline_authmode_compat
Hanno Beckerb0b2b672019-06-12 16:58:10 +0100737
738 # Legacy renegotiation
739 check_cmdline_legacy_renego_compat
Hanno Beckerd82a0302019-07-05 11:40:52 +0100740
741 # Version configuration
742 check_cmdline_min_minor_version_compat
743 check_cmdline_max_minor_version_compat
744 check_cmdline_force_version_compat
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100745}
746
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200747# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100748# Options: -s pattern pattern that must be present in server output
749# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100750# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100751# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100752# -S pattern pattern that must be absent in server output
753# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100754# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100755# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100756run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100757 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200758 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100759
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100760 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
761 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200762 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100763 return
764 fi
765
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100766 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100767
Paul Bakkerb7584a52016-05-10 10:50:43 +0100768 # Do we only run numbered tests?
769 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
770 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
771 else
772 SKIP_NEXT="YES"
773 fi
774
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200775 # does this test use a proxy?
776 if [ "X$1" = "X-p" ]; then
777 PXY_CMD="$2"
778 shift 2
779 else
780 PXY_CMD=""
781 fi
782
783 # get commands and client output
784 SRV_CMD="$1"
785 CLI_CMD="$2"
786 CLI_EXPECT="$3"
787 shift 3
788
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100789 check_cmdline_compat "$SRV_CMD"
790 SRV_CMD="$CMD"
791
792 check_cmdline_compat "$CLI_CMD"
793 CLI_CMD="$CMD"
794
Hanno Becker7a11e722019-05-10 14:38:42 +0100795 # Check if test uses files
796 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
797 if [ ! -z "$TEST_USES_FILES" ]; then
798 requires_config_enabled MBEDTLS_FS_IO
799 fi
800
801 # should we skip?
802 if [ "X$SKIP_NEXT" = "XYES" ]; then
803 SKIP_NEXT="NO"
804 echo "SKIP"
805 SKIPS=$(( $SKIPS + 1 ))
806 return
807 fi
808
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200809 # fix client port
810 if [ -n "$PXY_CMD" ]; then
811 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
812 else
813 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
814 fi
815
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200816 # update DTLS variable
817 detect_dtls "$SRV_CMD"
818
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100819 # prepend valgrind to our commands if active
820 if [ "$MEMCHECK" -gt 0 ]; then
821 if is_polar "$SRV_CMD"; then
822 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
823 fi
824 if is_polar "$CLI_CMD"; then
825 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
826 fi
827 fi
828
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200829 TIMES_LEFT=2
830 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200831 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200832
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200833 # run the commands
834 if [ -n "$PXY_CMD" ]; then
835 echo "$PXY_CMD" > $PXY_OUT
836 $PXY_CMD >> $PXY_OUT 2>&1 &
837 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400838 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200839 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200840
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200841 check_osrv_dtls
842 echo "$SRV_CMD" > $SRV_OUT
843 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
844 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100845 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200846
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200847 echo "$CLI_CMD" > $CLI_OUT
848 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
849 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100850
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100851 sleep 0.05
852
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200853 # terminate the server (and the proxy)
854 kill $SRV_PID
855 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100856
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200857 if [ -n "$PXY_CMD" ]; then
858 kill $PXY_PID >/dev/null 2>&1
859 wait $PXY_PID
860 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100861
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200862 # retry only on timeouts
863 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
864 printf "RETRY "
865 else
866 TIMES_LEFT=0
867 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200868 done
869
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100870 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200871 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100872 # expected client exit to incorrectly succeed in case of catastrophic
873 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100874 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200875 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100876 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100877 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100878 return
879 fi
880 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100881 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200882 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100883 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100884 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100885 return
886 fi
887 fi
888
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100889 # check server exit code
890 if [ $? != 0 ]; then
891 fail "server fail"
892 return
893 fi
894
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100895 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100896 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
897 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100898 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200899 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100900 return
901 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100902
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100903 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200904 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100905 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100906 while [ $# -gt 0 ]
907 do
908 case $1 in
909 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100910 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 +0100911 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100912 return
913 fi
914 ;;
915
916 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100917 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 +0100918 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100919 return
920 fi
921 ;;
922
923 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100924 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 +0100925 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100926 return
927 fi
928 ;;
929
930 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100931 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 +0100932 fail "pattern '$2' MUST NOT be present in the Client output"
933 return
934 fi
935 ;;
936
937 # The filtering in the following two options (-u and -U) do the following
938 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100939 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100940 # - keep one of each non-unique line
941 # - count how many lines remain
942 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
943 # if there were no duplicates.
944 "-U")
945 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
946 fail "lines following pattern '$2' must be unique in Server output"
947 return
948 fi
949 ;;
950
951 "-u")
952 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
953 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100954 return
955 fi
956 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100957 "-F")
958 if ! $2 "$SRV_OUT"; then
959 fail "function call to '$2' failed on Server output"
960 return
961 fi
962 ;;
963 "-f")
964 if ! $2 "$CLI_OUT"; then
965 fail "function call to '$2' failed on Client output"
966 return
967 fi
968 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100969
970 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200971 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100972 exit 1
973 esac
974 shift 2
975 done
976
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100977 # check valgrind's results
978 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200979 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100980 fail "Server has memory errors"
981 return
982 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200983 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100984 fail "Client has memory errors"
985 return
986 fi
987 fi
988
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100989 # if we're here, everything is ok
990 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100991 if [ "$PRESERVE_LOGS" -gt 0 ]; then
992 mv $SRV_OUT o-srv-${TESTS}.log
993 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100994 if [ -n "$PXY_CMD" ]; then
995 mv $PXY_OUT o-pxy-${TESTS}.log
996 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100997 fi
998
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200999 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001000}
1001
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001002cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001003 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +02001004 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
1005 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
1006 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
1007 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001008 exit 1
1009}
1010
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +01001011#
1012# MAIN
1013#
1014
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +01001015get_options "$@"
1016
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001017# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +01001018P_SRV_BIN="${P_SRV%%[ ]*}"
1019P_CLI_BIN="${P_CLI%%[ ]*}"
1020P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +01001021if [ ! -x "$P_SRV_BIN" ]; then
1022 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001023 exit 1
1024fi
Hanno Becker17c04932017-10-10 14:44:53 +01001025if [ ! -x "$P_CLI_BIN" ]; then
1026 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001027 exit 1
1028fi
Hanno Becker17c04932017-10-10 14:44:53 +01001029if [ ! -x "$P_PXY_BIN" ]; then
1030 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001031 exit 1
1032fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +01001033if [ "$MEMCHECK" -gt 0 ]; then
1034 if which valgrind >/dev/null 2>&1; then :; else
1035 echo "Memcheck not possible. Valgrind not found"
1036 exit 1
1037 fi
1038fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001039if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1040 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001041 exit 1
1042fi
1043
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001044# used by watchdog
1045MAIN_PID="$$"
1046
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001047# We use somewhat arbitrary delays for tests:
1048# - how long do we wait for the server to start (when lsof not available)?
1049# - how long do we allow for the client to finish?
1050# (not to check performance, just to avoid waiting indefinitely)
1051# Things are slower with valgrind, so give extra time here.
1052#
1053# Note: without lsof, there is a trade-off between the running time of this
1054# script and the risk of spurious errors because we didn't wait long enough.
1055# The watchdog delay on the other hand doesn't affect normal running time of
1056# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001057if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001058 START_DELAY=6
1059 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001060else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001061 START_DELAY=2
1062 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001063fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001064
1065# some particular tests need more time:
1066# - for the client, we multiply the usual watchdog limit by a factor
1067# - for the server, we sleep for a number of seconds after the client exits
1068# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001069CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001070SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001071
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001072# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001073# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001074P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1075P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001076P_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 +02001077O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001078O_CLI="$O_CLI -connect localhost:+SRV_PORT"
1079G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001080G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001081
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001082if [ -n "${OPENSSL_LEGACY:-}" ]; then
1083 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1084 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1085fi
1086
Hanno Becker58e9dc32018-08-17 15:53:21 +01001087if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001088 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1089fi
1090
Hanno Becker58e9dc32018-08-17 15:53:21 +01001091if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001092 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001093fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001094
Gilles Peskine62469d92017-05-10 10:13:59 +02001095# Allow SHA-1, because many of our test certificates use it
1096P_SRV="$P_SRV allow_sha1=1"
1097P_CLI="$P_CLI allow_sha1=1"
1098
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001099# Also pick a unique name for intermediate files
1100SRV_OUT="srv_out.$$"
1101CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001102PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001103SESSION="session.$$"
1104
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001105SKIP_NEXT="NO"
1106
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001107trap cleanup INT TERM HUP
1108
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001109# Basic test
1110
Hanno Becker91900362019-07-03 13:22:59 +01001111run_test "Default" \
1112 "$P_SRV debug_level=3" \
1113 "$P_CLI" \
1114 0
1115
1116run_test "Default, DTLS" \
1117 "$P_SRV dtls=1" \
1118 "$P_CLI dtls=1" \
1119 0
1120
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001121# Checks that:
1122# - things work with all ciphersuites active (used with config-full in all.sh)
1123# - the expected (highest security) parameters are selected
1124# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Hanno Becker91900362019-07-03 13:22:59 +01001125requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1126requires_config_enabled MBEDTLS_SHA512_C
1127requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1128requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1129run_test "Default, choose highest security suite and hash" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001130 "$P_SRV debug_level=3" \
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03001131 "$P_CLI" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001132 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001133 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001134 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001135 -s "client hello v3, signature_algorithm ext: 6" \
1136 -s "ECDHE curve: secp521r1" \
1137 -S "error" \
1138 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001139
Hanno Becker91900362019-07-03 13:22:59 +01001140requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1141requires_config_enabled MBEDTLS_SHA512_C
1142requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1143requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1144run_test "Default, choose highest security suite and hash, DTLS" \
1145 "$P_SRV debug_level=3 dtls=1" \
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001146 "$P_CLI dtls=1" \
1147 0 \
1148 -s "Protocol is DTLSv1.2" \
Hanno Becker91900362019-07-03 13:22:59 +01001149 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
1150 -s "client hello v3, signature_algorithm ext: 6" \
1151 -s "ECDHE curve: secp521r1"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001152
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001153# Test current time in ServerHello
1154requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001155run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001156 "$P_SRV debug_level=3" \
1157 "$P_CLI debug_level=3" \
1158 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001159 -f "check_server_hello_time" \
1160 -F "check_server_hello_time"
1161
Simon Butcher8e004102016-10-14 00:48:33 +01001162# Test for uniqueness of IVs in AEAD ciphersuites
1163run_test "Unique IV in GCM" \
1164 "$P_SRV exchanges=20 debug_level=4" \
1165 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1166 0 \
1167 -u "IV used" \
1168 -U "IV used"
1169
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001170# Tests for rc4 option
1171
Simon Butchera410af52016-05-19 22:12:18 +01001172requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001173run_test "RC4: server disabled, client enabled" \
1174 "$P_SRV" \
1175 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1176 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001177 -s "SSL - The server has no ciphersuites in common"
1178
Simon Butchera410af52016-05-19 22:12:18 +01001179requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001180run_test "RC4: server half, client enabled" \
1181 "$P_SRV arc4=1" \
1182 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1183 1 \
1184 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001185
1186run_test "RC4: server enabled, client disabled" \
1187 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1188 "$P_CLI" \
1189 1 \
1190 -s "SSL - The server has no ciphersuites in common"
1191
1192run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001193 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001194 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1195 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001196 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001197 -S "SSL - The server has no ciphersuites in common"
1198
Hanno Beckerd26bb202018-08-17 09:54:10 +01001199# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1200
1201requires_gnutls
1202requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1203run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1204 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001205 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001206 0
1207
1208requires_gnutls
1209requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1210run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1211 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001212 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001213 0
1214
Gilles Peskinebc70a182017-05-09 15:59:24 +02001215# Tests for SHA-1 support
1216
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001217requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001218requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001219requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001220run_test "SHA-1 forbidden by default in server certificate" \
1221 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1222 "$P_CLI debug_level=2 allow_sha1=0" \
1223 1 \
1224 -c "The certificate is signed with an unacceptable hash"
1225
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001226requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1227run_test "SHA-1 forbidden by default in server certificate" \
1228 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1229 "$P_CLI debug_level=2 allow_sha1=0" \
1230 0
1231
Gilles Peskinebc70a182017-05-09 15:59:24 +02001232run_test "SHA-1 explicitly allowed in server certificate" \
1233 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1234 "$P_CLI allow_sha1=1" \
1235 0
1236
1237run_test "SHA-256 allowed by default in server certificate" \
1238 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1239 "$P_CLI allow_sha1=0" \
1240 0
1241
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001242requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001243requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001244requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001245run_test "SHA-1 forbidden by default in client certificate" \
1246 "$P_SRV auth_mode=required allow_sha1=0" \
1247 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1248 1 \
1249 -s "The certificate is signed with an unacceptable hash"
1250
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001251requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1252run_test "SHA-1 forbidden 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-sha1.crt" \
1255 0
1256
Gilles Peskinebc70a182017-05-09 15:59:24 +02001257run_test "SHA-1 explicitly allowed in client certificate" \
1258 "$P_SRV auth_mode=required allow_sha1=1" \
1259 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1260 0
1261
1262run_test "SHA-256 allowed by default in client certificate" \
1263 "$P_SRV auth_mode=required allow_sha1=0" \
1264 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1265 0
1266
Hanno Becker7ae8a762018-08-14 15:43:35 +01001267# Tests for datagram packing
1268run_test "DTLS: multiple records in same datagram, client and server" \
1269 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1270 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1271 0 \
1272 -c "next record in same datagram" \
1273 -s "next record in same datagram"
1274
1275run_test "DTLS: multiple records in same datagram, client only" \
1276 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1277 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1278 0 \
1279 -s "next record in same datagram" \
1280 -C "next record in same datagram"
1281
1282run_test "DTLS: multiple records in same datagram, server only" \
1283 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1284 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1285 0 \
1286 -S "next record in same datagram" \
1287 -c "next record in same datagram"
1288
1289run_test "DTLS: multiple records in same datagram, neither client nor server" \
1290 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1291 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1292 0 \
1293 -S "next record in same datagram" \
1294 -C "next record in same datagram"
1295
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001296# Tests for Truncated HMAC extension
1297
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001298run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001299 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001300 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001301 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001302 -s "dumping 'expected mac' (20 bytes)" \
1303 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001304
Hanno Becker32c55012017-11-10 08:42:54 +00001305requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001306run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001307 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001308 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001309 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001310 -s "dumping 'expected mac' (20 bytes)" \
1311 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001312
Hanno Becker32c55012017-11-10 08:42:54 +00001313requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001314run_test "Truncated HMAC: client enabled, server default" \
1315 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001316 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001317 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001318 -s "dumping 'expected mac' (20 bytes)" \
1319 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001320
Hanno Becker32c55012017-11-10 08:42:54 +00001321requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001322run_test "Truncated HMAC: client enabled, server disabled" \
1323 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001324 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001325 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001326 -s "dumping 'expected mac' (20 bytes)" \
1327 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001328
Hanno Becker32c55012017-11-10 08:42:54 +00001329requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001330run_test "Truncated HMAC: client disabled, server enabled" \
1331 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001332 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001333 0 \
1334 -s "dumping 'expected mac' (20 bytes)" \
1335 -S "dumping 'expected mac' (10 bytes)"
1336
1337requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001338run_test "Truncated HMAC: client enabled, server enabled" \
1339 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001340 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001341 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001342 -S "dumping 'expected mac' (20 bytes)" \
1343 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001344
Jarno Lamsa33281d52019-10-18 10:54:35 +03001345requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker4c4f4102017-11-10 09:16:05 +00001346run_test "Truncated HMAC, DTLS: client default, server default" \
1347 "$P_SRV dtls=1 debug_level=4" \
1348 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1349 0 \
1350 -s "dumping 'expected mac' (20 bytes)" \
1351 -S "dumping 'expected mac' (10 bytes)"
1352
1353requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1354run_test "Truncated HMAC, DTLS: client disabled, server default" \
1355 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001356 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001357 0 \
1358 -s "dumping 'expected mac' (20 bytes)" \
1359 -S "dumping 'expected mac' (10 bytes)"
1360
1361requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1362run_test "Truncated HMAC, DTLS: client enabled, server default" \
1363 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001364 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001365 0 \
1366 -s "dumping 'expected mac' (20 bytes)" \
1367 -S "dumping 'expected mac' (10 bytes)"
1368
1369requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1370run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1371 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001372 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001373 0 \
1374 -s "dumping 'expected mac' (20 bytes)" \
1375 -S "dumping 'expected mac' (10 bytes)"
1376
1377requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1378run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1379 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001380 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001381 0 \
1382 -s "dumping 'expected mac' (20 bytes)" \
1383 -S "dumping 'expected mac' (10 bytes)"
1384
1385requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1386run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1387 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001388 "$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 +01001389 0 \
1390 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001391 -s "dumping 'expected mac' (10 bytes)"
1392
Jarno Lamsafa45e602019-06-04 11:33:23 +03001393# Tests for Context serialization
1394
1395requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001396run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001397 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001398 "$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 +03001399 0 \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001400 -c "Deserializing connection..." \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001401 -S "Deserializing connection..."
1402
1403requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001404run_test "Context serialization, client serializes, ChaChaPoly" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001405 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001406 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001407 0 \
1408 -c "Deserializing connection..." \
1409 -S "Deserializing connection..."
1410
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001411requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001412run_test "Context serialization, client serializes, GCM" \
1413 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1414 "$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 +03001415 0 \
1416 -c "Deserializing connection..." \
1417 -S "Deserializing connection..."
Jarno Lamsacc281b82019-06-04 15:21:13 +03001418
Jarno Lamsafa45e602019-06-04 11:33:23 +03001419requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001420requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1421run_test "Context serialization, client serializes, with CID" \
1422 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1423 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1424 0 \
1425 -c "Deserializing connection..." \
1426 -S "Deserializing connection..."
1427
1428requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001429run_test "Context serialization, server serializes, CCM" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001430 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001431 "$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 +03001432 0 \
1433 -C "Deserializing connection..." \
1434 -s "Deserializing connection..."
1435
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001436requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001437run_test "Context serialization, server serializes, ChaChaPoly" \
1438 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1439 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1440 0 \
1441 -C "Deserializing connection..." \
1442 -s "Deserializing connection..."
1443
1444requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1445run_test "Context serialization, server serializes, GCM" \
1446 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1447 "$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 +03001448 0 \
1449 -C "Deserializing connection..." \
Jarno Lamsacc281b82019-06-04 15:21:13 +03001450 -s "Deserializing connection..."
Jarno Lamsafa45e602019-06-04 11:33:23 +03001451
1452requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001453requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1454run_test "Context serialization, server serializes, with CID" \
1455 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1456 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1457 0 \
1458 -C "Deserializing connection..." \
1459 -s "Deserializing connection..."
1460
1461requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001462run_test "Context serialization, both serialize, CCM" \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001463 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001464 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1465 0 \
1466 -c "Deserializing connection..." \
1467 -s "Deserializing connection..."
1468
1469requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1470run_test "Context serialization, both serialize, ChaChaPoly" \
1471 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1472 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1473 0 \
1474 -c "Deserializing connection..." \
1475 -s "Deserializing connection..."
1476
1477requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1478run_test "Context serialization, both serialize, GCM" \
1479 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1480 "$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 +03001481 0 \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001482 -c "Deserializing connection..." \
1483 -s "Deserializing connection..."
1484
1485requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001486requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1487run_test "Context serialization, both serialize, with CID" \
1488 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1489 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1490 0 \
1491 -c "Deserializing connection..." \
1492 -s "Deserializing connection..."
1493
1494requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001495run_test "Context serialization, re-init, client serializes, CCM" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001496 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001497 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1498 0 \
1499 -c "Deserializing connection..." \
1500 -S "Deserializing connection..."
1501
1502requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1503run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1504 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1505 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1506 0 \
1507 -c "Deserializing connection..." \
1508 -S "Deserializing connection..."
1509
1510requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1511run_test "Context serialization, re-init, client serializes, GCM" \
1512 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1513 "$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 +03001514 0 \
1515 -c "Deserializing connection..." \
1516 -S "Deserializing connection..."
1517
1518requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001519requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1520run_test "Context serialization, re-init, client serializes, with CID" \
1521 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1522 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1523 0 \
1524 -c "Deserializing connection..." \
1525 -S "Deserializing connection..."
1526
1527requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001528run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001529 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001530 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1531 0 \
1532 -C "Deserializing connection..." \
1533 -s "Deserializing connection..."
1534
1535requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1536run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1537 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1538 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1539 0 \
1540 -C "Deserializing connection..." \
1541 -s "Deserializing connection..."
1542
1543requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1544run_test "Context serialization, re-init, server serializes, GCM" \
1545 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1546 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001547 0 \
1548 -C "Deserializing connection..." \
1549 -s "Deserializing connection..."
1550
1551requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001552requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1553run_test "Context serialization, re-init, server serializes, with CID" \
1554 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1555 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1556 0 \
1557 -C "Deserializing connection..." \
1558 -s "Deserializing connection..."
1559
1560requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001561run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001562 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001563 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1564 0 \
1565 -c "Deserializing connection..." \
1566 -s "Deserializing connection..."
1567
1568requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1569run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1570 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1571 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1572 0 \
1573 -c "Deserializing connection..." \
1574 -s "Deserializing connection..."
1575
1576requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1577run_test "Context serialization, re-init, both serialize, GCM" \
1578 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1579 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001580 0 \
1581 -c "Deserializing connection..." \
1582 -s "Deserializing connection..."
1583
Hanno Beckere80c1b02019-08-30 11:18:59 +01001584requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1585requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1586run_test "Context serialization, re-init, both serialize, with CID" \
1587 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1588 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001589 0 \
1590 -c "Deserializing connection..." \
Hanno Becker73455992019-04-25 17:01:43 +01001591 -s "Deserializing connection..."
Hanno Beckerc008cb52019-04-26 14:17:56 +01001592
Hanno Becker4eb05872019-04-26 16:00:29 +01001593# Tests for DTLS Connection ID extension
Hanno Beckercf2a5652019-04-26 16:13:31 +01001594
Hanno Becker5e2cd142019-04-26 16:23:52 +01001595# So far, the CID API isn't implemented, so we can't
1596# grep for output witnessing its use. This needs to be
Hanno Becker6a3ff282019-04-26 17:19:46 +01001597# changed once the CID extension is implemented.
Hanno Beckerad8e2c92019-05-08 13:19:53 +01001598
Hanno Becker2dcdc922019-04-09 18:08:47 +01001599requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckera5a2b082019-05-15 14:03:01 +01001600run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001601 "$P_SRV debug_level=3 dtls=1 cid=0" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03001602 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=dead" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001603 0 \
1604 -s "Disable use of CID extension." \
1605 -s "found CID extension" \
1606 -s "Client sent CID extension, but CID disabled" \
1607 -c "Enable use of CID extension." \
1608 -c "client hello, adding CID extension" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001609 -S "server hello, adding CID extension" \
1610 -C "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001611 -S "Copy CIDs into SSL transform" \
1612 -C "Copy CIDs into SSL transform" \
1613 -c "Use of Connection ID was rejected by the server"
1614
1615requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1616run_test "Connection ID: Cli disabled, Srv enabled" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03001617 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001618 "$P_CLI debug_level=3 dtls=1 cid=0" \
1619 0 \
1620 -c "Disable use of CID extension." \
1621 -C "client hello, adding CID extension" \
1622 -S "found CID extension" \
1623 -s "Enable use of CID extension." \
1624 -S "server hello, adding CID extension" \
1625 -C "found CID extension" \
1626 -S "Copy CIDs into SSL transform" \
1627 -C "Copy CIDs into SSL transform" \
1628 -s "Use of Connection ID was not offered by client"
1629
1630requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb60c85c2019-04-23 12:02:34 +01001631run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001632 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1633 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1634 0 \
1635 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001636 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001637 -c "client hello, adding CID extension" \
1638 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001639 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001640 -s "server hello, adding CID extension" \
1641 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001642 -c "Use of CID extension negotiated" \
1643 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001644 -c "Copy CIDs into SSL transform" \
1645 -c "Peer CID (length 2 Bytes): de ad" \
1646 -s "Peer CID (length 2 Bytes): be ef" \
1647 -s "Use of Connection ID has been negotiated" \
1648 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001649
Hanno Beckera5a2b082019-05-15 14:03:01 +01001650requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001651run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001652 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001653 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1654 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1655 0 \
1656 -c "Enable use of CID extension." \
1657 -s "Enable use of CID extension." \
1658 -c "client hello, adding CID extension" \
1659 -s "found CID extension" \
1660 -s "Use of CID extension negotiated" \
1661 -s "server hello, adding CID extension" \
1662 -c "found CID extension" \
1663 -c "Use of CID extension negotiated" \
1664 -s "Copy CIDs into SSL transform" \
1665 -c "Copy CIDs into SSL transform" \
1666 -c "Peer CID (length 2 Bytes): de ad" \
1667 -s "Peer CID (length 2 Bytes): be ef" \
1668 -s "Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001669 -c "Use of Connection ID has been negotiated" \
1670 -c "ignoring unexpected CID" \
1671 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01001672
Hanno Beckera5a2b082019-05-15 14:03:01 +01001673requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001674run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1675 -p "$P_PXY mtu=800" \
1676 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1677 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1678 0 \
1679 -c "Enable use of CID extension." \
1680 -s "Enable use of CID extension." \
1681 -c "client hello, adding CID extension" \
1682 -s "found CID extension" \
1683 -s "Use of CID extension negotiated" \
1684 -s "server hello, adding CID extension" \
1685 -c "found CID extension" \
1686 -c "Use of CID extension negotiated" \
1687 -s "Copy CIDs into SSL transform" \
1688 -c "Copy CIDs into SSL transform" \
1689 -c "Peer CID (length 2 Bytes): de ad" \
1690 -s "Peer CID (length 2 Bytes): be ef" \
1691 -s "Use of Connection ID has been negotiated" \
1692 -c "Use of Connection ID has been negotiated"
1693
Hanno Beckera5a2b082019-05-15 14:03:01 +01001694requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001695run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001696 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001697 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1698 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1699 0 \
1700 -c "Enable use of CID extension." \
1701 -s "Enable use of CID extension." \
1702 -c "client hello, adding CID extension" \
1703 -s "found CID extension" \
1704 -s "Use of CID extension negotiated" \
1705 -s "server hello, adding CID extension" \
1706 -c "found CID extension" \
1707 -c "Use of CID extension negotiated" \
1708 -s "Copy CIDs into SSL transform" \
1709 -c "Copy CIDs into SSL transform" \
1710 -c "Peer CID (length 2 Bytes): de ad" \
1711 -s "Peer CID (length 2 Bytes): be ef" \
1712 -s "Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001713 -c "Use of Connection ID has been negotiated" \
1714 -c "ignoring unexpected CID" \
1715 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01001716
Hanno Beckera5a2b082019-05-15 14:03:01 +01001717requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001718requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001719run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001720 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1721 "$P_CLI debug_level=3 dtls=1 cid=1" \
1722 0 \
1723 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001724 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001725 -c "client hello, adding CID extension" \
1726 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001727 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001728 -s "server hello, adding CID extension" \
1729 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001730 -c "Use of CID extension negotiated" \
1731 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001732 -c "Copy CIDs into SSL transform" \
1733 -c "Peer CID (length 4 Bytes): de ad be ef" \
1734 -s "Peer CID (length 0 Bytes):" \
1735 -s "Use of Connection ID has been negotiated" \
1736 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001737
Hanno Beckera5a2b082019-05-15 14:03:01 +01001738requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001739requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001740run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001741 "$P_SRV debug_level=3 dtls=1 cid=1" \
1742 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1743 0 \
1744 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001745 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001746 -c "client hello, adding CID extension" \
1747 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001748 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001749 -s "server hello, adding CID extension" \
1750 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001751 -c "Use of CID extension negotiated" \
1752 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001753 -c "Copy CIDs into SSL transform" \
1754 -s "Peer CID (length 4 Bytes): de ad be ef" \
1755 -c "Peer CID (length 0 Bytes):" \
1756 -s "Use of Connection ID has been negotiated" \
1757 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001758
Hanno Beckera5a2b082019-05-15 14:03:01 +01001759requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001760requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001761run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001762 "$P_SRV debug_level=3 dtls=1 cid=1" \
1763 "$P_CLI debug_level=3 dtls=1 cid=1" \
1764 0 \
1765 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001766 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001767 -c "client hello, adding CID extension" \
1768 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001769 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001770 -s "server hello, adding CID extension" \
1771 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001772 -c "Use of CID extension negotiated" \
1773 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001774 -c "Copy CIDs into SSL transform" \
1775 -S "Use of Connection ID has been negotiated" \
1776 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001777
Hanno Beckera5a2b082019-05-15 14:03:01 +01001778requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001779run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001780 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1781 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1782 0 \
1783 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001784 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001785 -c "client hello, adding CID extension" \
1786 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001787 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001788 -s "server hello, adding CID extension" \
1789 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001790 -c "Use of CID extension negotiated" \
1791 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001792 -c "Copy CIDs into SSL transform" \
1793 -c "Peer CID (length 2 Bytes): de ad" \
1794 -s "Peer CID (length 2 Bytes): be ef" \
1795 -s "Use of Connection ID has been negotiated" \
1796 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001797
Hanno Beckera5a2b082019-05-15 14:03:01 +01001798requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001799requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001800run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001801 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1802 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1803 0 \
1804 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001805 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001806 -c "client hello, adding CID extension" \
1807 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001808 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001809 -s "server hello, adding CID extension" \
1810 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001811 -c "Use of CID extension negotiated" \
1812 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001813 -c "Copy CIDs into SSL transform" \
1814 -c "Peer CID (length 4 Bytes): de ad be ef" \
1815 -s "Peer CID (length 0 Bytes):" \
1816 -s "Use of Connection ID has been negotiated" \
1817 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001818
Hanno Beckera5a2b082019-05-15 14:03:01 +01001819requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001820requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001821run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001822 "$P_SRV debug_level=3 dtls=1 cid=1" \
1823 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1824 0 \
1825 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001826 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001827 -c "client hello, adding CID extension" \
1828 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001829 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001830 -s "server hello, adding CID extension" \
1831 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001832 -c "Use of CID extension negotiated" \
1833 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001834 -c "Copy CIDs into SSL transform" \
1835 -s "Peer CID (length 4 Bytes): de ad be ef" \
1836 -c "Peer CID (length 0 Bytes):" \
1837 -s "Use of Connection ID has been negotiated" \
1838 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001839
Hanno Beckera5a2b082019-05-15 14:03:01 +01001840requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001841requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001842run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001843 "$P_SRV debug_level=3 dtls=1 cid=1" \
1844 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1845 0 \
1846 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001847 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001848 -c "client hello, adding CID extension" \
1849 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001850 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001851 -s "server hello, adding CID extension" \
1852 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001853 -c "Use of CID extension negotiated" \
1854 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001855 -c "Copy CIDs into SSL transform" \
1856 -S "Use of Connection ID has been negotiated" \
1857 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001858
Hanno Beckera5a2b082019-05-15 14:03:01 +01001859requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001860requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001861run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001862 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1863 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1864 0 \
1865 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001866 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001867 -c "client hello, adding CID extension" \
1868 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001869 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001870 -s "server hello, adding CID extension" \
1871 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001872 -c "Use of CID extension negotiated" \
1873 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001874 -c "Copy CIDs into SSL transform" \
1875 -c "Peer CID (length 2 Bytes): de ad" \
1876 -s "Peer CID (length 2 Bytes): be ef" \
1877 -s "Use of Connection ID has been negotiated" \
1878 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001879
Hanno Beckera5a2b082019-05-15 14:03:01 +01001880requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001881requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1882requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001883run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001884 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1885 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1886 0 \
1887 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001888 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001889 -c "client hello, adding CID extension" \
1890 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001891 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001892 -s "server hello, adding CID extension" \
1893 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001894 -c "Use of CID extension negotiated" \
1895 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001896 -c "Copy CIDs into SSL transform" \
1897 -c "Peer CID (length 4 Bytes): de ad be ef" \
1898 -s "Peer CID (length 0 Bytes):" \
1899 -s "Use of Connection ID has been negotiated" \
1900 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001901
Hanno Beckera5a2b082019-05-15 14:03:01 +01001902requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001903requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1904requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001905run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001906 "$P_SRV debug_level=3 dtls=1 cid=1" \
1907 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1908 0 \
1909 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001910 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001911 -c "client hello, adding CID extension" \
1912 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001913 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001914 -s "server hello, adding CID extension" \
1915 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001916 -c "Use of CID extension negotiated" \
1917 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001918 -c "Copy CIDs into SSL transform" \
1919 -s "Peer CID (length 4 Bytes): de ad be ef" \
1920 -c "Peer CID (length 0 Bytes):" \
1921 -s "Use of Connection ID has been negotiated" \
1922 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001923
Hanno Beckera5a2b082019-05-15 14:03:01 +01001924requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001925requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1926requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001927run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001928 "$P_SRV debug_level=3 dtls=1 cid=1" \
1929 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1930 0 \
1931 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001932 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001933 -c "client hello, adding CID extension" \
1934 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001935 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001936 -s "server hello, adding CID extension" \
1937 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001938 -c "Use of CID extension negotiated" \
1939 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001940 -c "Copy CIDs into SSL transform" \
1941 -S "Use of Connection ID has been negotiated" \
1942 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001943
Hanno Beckera5a2b082019-05-15 14:03:01 +01001944requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker963cb352019-04-23 11:52:44 +01001945requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001946run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001947 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1948 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1949 0 \
Hanno Becker96870292019-05-03 17:30:59 +01001950 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1951 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1952 -s "(initial handshake) Use of Connection ID has been negotiated" \
1953 -c "(initial handshake) Use of Connection ID has been negotiated" \
1954 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1955 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1956 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1957 -c "(after renegotiation) Use of Connection ID has been negotiated"
1958
Hanno Beckera5a2b082019-05-15 14:03:01 +01001959requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001960requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001961run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Becker96870292019-05-03 17:30:59 +01001962 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
1963 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1964 0 \
1965 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1966 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1967 -s "(initial handshake) Use of Connection ID has been negotiated" \
1968 -c "(initial handshake) Use of Connection ID has been negotiated" \
1969 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1970 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1971 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1972 -c "(after renegotiation) Use of Connection ID has been negotiated"
1973
Hanno Beckera5a2b082019-05-15 14:03:01 +01001974requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001975requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01001976run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
1977 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
1978 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1979 0 \
1980 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1981 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1982 -s "(initial handshake) Use of Connection ID has been negotiated" \
1983 -c "(initial handshake) Use of Connection ID has been negotiated" \
1984 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1985 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1986 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1987 -c "(after renegotiation) Use of Connection ID has been negotiated"
1988
Hanno Beckera5a2b082019-05-15 14:03:01 +01001989requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01001990requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001991run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001992 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001993 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
1994 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1995 0 \
1996 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1997 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1998 -s "(initial handshake) Use of Connection ID has been negotiated" \
1999 -c "(initial handshake) Use of Connection ID has been negotiated" \
2000 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2001 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2002 -s "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002003 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2004 -c "ignoring unexpected CID" \
2005 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002006
Hanno Beckera5a2b082019-05-15 14:03:01 +01002007requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002008requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2009run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Becker96870292019-05-03 17:30:59 +01002010 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2011 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2012 0 \
2013 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2014 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2015 -s "(initial handshake) Use of Connection ID has been negotiated" \
2016 -c "(initial handshake) Use of Connection ID has been negotiated" \
2017 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2018 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2019 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2020 -S "(after renegotiation) Use of Connection ID has been negotiated"
2021
Hanno Beckera5a2b082019-05-15 14:03:01 +01002022requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002023requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01002024run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
2025 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2026 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2027 0 \
2028 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2029 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2030 -s "(initial handshake) Use of Connection ID has been negotiated" \
2031 -c "(initial handshake) Use of Connection ID has been negotiated" \
2032 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2033 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2034 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2035 -S "(after renegotiation) Use of Connection ID has been negotiated"
2036
Hanno Beckera5a2b082019-05-15 14:03:01 +01002037requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01002038requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002039run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002040 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002041 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2042 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2043 0 \
2044 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2045 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2046 -s "(initial handshake) Use of Connection ID has been negotiated" \
2047 -c "(initial handshake) Use of Connection ID has been negotiated" \
2048 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2049 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2050 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002051 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2052 -c "ignoring unexpected CID" \
2053 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002054
Hanno Beckera5a2b082019-05-15 14:03:01 +01002055requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002056requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2057run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002058 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2059 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2060 0 \
2061 -S "(initial handshake) Use of Connection ID has been negotiated" \
2062 -C "(initial handshake) Use of Connection ID has been negotiated" \
2063 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2064 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2065 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2066 -s "(after renegotiation) Use of Connection ID has been negotiated"
2067
Hanno Beckera5a2b082019-05-15 14:03:01 +01002068requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002069requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01002070run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2071 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2072 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2073 0 \
2074 -S "(initial handshake) Use of Connection ID has been negotiated" \
2075 -C "(initial handshake) Use of Connection ID has been negotiated" \
2076 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2077 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2078 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2079 -s "(after renegotiation) Use of Connection ID has been negotiated"
2080
Hanno Beckera5a2b082019-05-15 14:03:01 +01002081requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01002082requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002083run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002084 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002085 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2086 "$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" \
2087 0 \
2088 -S "(initial handshake) Use of Connection ID has been negotiated" \
2089 -C "(initial handshake) Use of Connection ID has been negotiated" \
2090 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2091 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2092 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002093 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2094 -c "ignoring unexpected CID" \
2095 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002096
Hanno Beckera5a2b082019-05-15 14:03:01 +01002097requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002098requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2099run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002100 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2101 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2102 0 \
2103 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2104 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2105 -s "(initial handshake) Use of Connection ID has been negotiated" \
2106 -c "(initial handshake) Use of Connection ID has been negotiated" \
2107 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2108 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2109 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2110 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2111 -s "(after renegotiation) Use of Connection ID was not offered by client"
2112
Hanno Beckera5a2b082019-05-15 14:03:01 +01002113requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002114requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002115run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002116 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002117 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2118 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2119 0 \
2120 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2121 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2122 -s "(initial handshake) Use of Connection ID has been negotiated" \
2123 -c "(initial handshake) Use of Connection ID has been negotiated" \
2124 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2125 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2126 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2127 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002128 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2129 -c "ignoring unexpected CID" \
2130 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002131
Hanno Beckera5a2b082019-05-15 14:03:01 +01002132requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002133requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2134run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2135 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2136 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2137 0 \
2138 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2139 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2140 -s "(initial handshake) Use of Connection ID has been negotiated" \
2141 -c "(initial handshake) Use of Connection ID has been negotiated" \
2142 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2143 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2144 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2145 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2146 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2147
Hanno Beckera5a2b082019-05-15 14:03:01 +01002148requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002149requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2150run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002151 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker96870292019-05-03 17:30:59 +01002152 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2153 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2154 0 \
2155 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2156 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2157 -s "(initial handshake) Use of Connection ID has been negotiated" \
2158 -c "(initial handshake) Use of Connection ID has been negotiated" \
2159 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2160 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2161 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2162 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002163 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2164 -c "ignoring unexpected CID" \
2165 -s "ignoring unexpected CID"
Hanno Becker2dcdc922019-04-09 18:08:47 +01002166
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002167# Tests for Encrypt-then-MAC extension
2168
2169run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002170 "$P_SRV debug_level=3 \
2171 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002172 "$P_CLI debug_level=3" \
2173 0 \
2174 -c "client hello, adding encrypt_then_mac extension" \
2175 -s "found encrypt then mac extension" \
2176 -s "server hello, adding encrypt then mac extension" \
2177 -c "found encrypt_then_mac extension" \
2178 -c "using encrypt then mac" \
2179 -s "using encrypt then mac"
2180
2181run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002182 "$P_SRV debug_level=3 etm=0 \
2183 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002184 "$P_CLI debug_level=3 etm=1" \
2185 0 \
2186 -c "client hello, adding encrypt_then_mac extension" \
2187 -s "found encrypt then mac extension" \
2188 -S "server hello, adding encrypt then mac extension" \
2189 -C "found encrypt_then_mac extension" \
2190 -C "using encrypt then mac" \
2191 -S "using encrypt then mac"
2192
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002193run_test "Encrypt then MAC: client enabled, aead cipher" \
2194 "$P_SRV debug_level=3 etm=1 \
2195 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2196 "$P_CLI debug_level=3 etm=1" \
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" \
2201 -C "found encrypt_then_mac extension" \
2202 -C "using encrypt then mac" \
2203 -S "using encrypt then mac"
2204
2205run_test "Encrypt then MAC: client enabled, stream cipher" \
2206 "$P_SRV debug_level=3 etm=1 \
2207 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002208 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002209 0 \
2210 -c "client hello, adding encrypt_then_mac extension" \
2211 -s "found encrypt then mac extension" \
2212 -S "server hello, adding encrypt then mac extension" \
2213 -C "found encrypt_then_mac extension" \
2214 -C "using encrypt then mac" \
2215 -S "using encrypt then mac"
2216
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002217run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002218 "$P_SRV debug_level=3 etm=1 \
2219 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002220 "$P_CLI debug_level=3 etm=0" \
2221 0 \
2222 -C "client hello, adding encrypt_then_mac extension" \
2223 -S "found encrypt then mac extension" \
2224 -S "server hello, adding encrypt then mac extension" \
2225 -C "found encrypt_then_mac extension" \
2226 -C "using encrypt then mac" \
2227 -S "using encrypt then mac"
2228
Janos Follathe2681a42016-03-07 15:57:05 +00002229requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002230run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002231 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002232 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002233 "$P_CLI debug_level=3 force_version=ssl3" \
2234 0 \
2235 -C "client hello, adding encrypt_then_mac extension" \
2236 -S "found encrypt then mac extension" \
2237 -S "server hello, adding encrypt then mac extension" \
2238 -C "found encrypt_then_mac extension" \
2239 -C "using encrypt then mac" \
2240 -S "using encrypt then mac"
2241
Janos Follathe2681a42016-03-07 15:57:05 +00002242requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002243run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002244 "$P_SRV debug_level=3 force_version=ssl3 \
2245 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002246 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002247 0 \
2248 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002249 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002250 -S "server hello, adding encrypt then mac extension" \
2251 -C "found encrypt_then_mac extension" \
2252 -C "using encrypt then mac" \
2253 -S "using encrypt then mac"
2254
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002255# Tests for Extended Master Secret extension
2256
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002257run_test "Extended Master Secret: default (not enforcing)" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002258 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0 " \
2259 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002260 0 \
2261 -c "client hello, adding extended_master_secret extension" \
2262 -s "found extended master secret extension" \
2263 -s "server hello, adding extended master secret extension" \
2264 -c "found extended_master_secret extension" \
2265 -c "session hash for extended master secret" \
2266 -s "session hash for extended master secret"
2267
2268run_test "Extended Master Secret: both enabled, both enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002269 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2270 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002271 0 \
2272 -c "client hello, adding extended_master_secret extension" \
2273 -s "found extended master secret extension" \
2274 -s "server hello, adding extended master secret extension" \
2275 -c "found extended_master_secret extension" \
2276 -c "session hash for extended master secret" \
2277 -s "session hash for extended master secret"
2278
Jarno Lamsa20095af2019-06-11 17:16:58 +03002279run_test "Extended Master Secret: both enabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002280 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2281 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002282 0 \
2283 -c "client hello, adding extended_master_secret extension" \
2284 -s "found extended master secret extension" \
2285 -s "server hello, adding extended master secret extension" \
2286 -c "found extended_master_secret extension" \
2287 -c "session hash for extended master secret" \
2288 -s "session hash for extended master secret"
2289
2290run_test "Extended Master Secret: both enabled, server enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002291 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2292 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002293 0 \
2294 -c "client hello, adding extended_master_secret extension" \
2295 -s "found extended master secret extension" \
2296 -s "server hello, adding extended master secret extension" \
2297 -c "found extended_master_secret extension" \
2298 -c "session hash for extended master secret" \
2299 -s "session hash for extended master secret"
2300
2301run_test "Extended Master Secret: client enabled, server disabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002302 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002303 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2304 1 \
2305 -c "client hello, adding extended_master_secret extension" \
2306 -s "found extended master secret extension" \
2307 -S "server hello, adding extended master secret extension" \
2308 -C "found extended_master_secret extension" \
2309 -c "Peer not offering extended master secret, while it is enforced"
2310
Jarno Lamsa20095af2019-06-11 17:16:58 +03002311run_test "Extended Master Secret enforced: client disabled, server enabled, server enforcing" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002312 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002313 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002314 1 \
2315 -C "client hello, adding extended_master_secret extension" \
2316 -S "found extended master secret extension" \
2317 -S "server hello, adding extended master secret extension" \
2318 -C "found extended_master_secret extension" \
2319 -s "Peer not offering extended master secret, while it is enforced"
2320
Jarno Lamsa20095af2019-06-11 17:16:58 +03002321run_test "Extended Master Secret: client enabled, server disabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002322 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2323 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002324 0 \
2325 -c "client hello, adding extended_master_secret extension" \
2326 -s "found extended master secret extension" \
2327 -S "server hello, adding extended master secret extension" \
2328 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002329 -C "session hash for extended master secret" \
2330 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002331
Jarno Lamsa20095af2019-06-11 17:16:58 +03002332run_test "Extended Master Secret: client disabled, server enabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002333 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2334 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002335 0 \
2336 -C "client hello, adding extended_master_secret extension" \
2337 -S "found extended master secret extension" \
2338 -S "server hello, adding extended master secret extension" \
2339 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002340 -C "session hash for extended master secret" \
2341 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002342
Jarno Lamsa20095af2019-06-11 17:16:58 +03002343run_test "Extended Master Secret: client disabled, server disabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002344 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2345 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002346 0 \
2347 -C "client hello, adding extended_master_secret extension" \
2348 -S "found extended master secret extension" \
2349 -S "server hello, adding extended master secret extension" \
2350 -C "found extended_master_secret extension" \
2351 -C "session hash for extended master secret" \
2352 -S "session hash for extended master secret"
2353
Janos Follathe2681a42016-03-07 15:57:05 +00002354requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002355run_test "Extended Master Secret: client SSLv3, server enabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002356 "$P_SRV debug_level=3 min_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2357 "$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 +02002358 0 \
2359 -C "client hello, adding extended_master_secret extension" \
2360 -S "found extended master secret extension" \
2361 -S "server hello, adding extended master secret extension" \
2362 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002363 -C "session hash for extended master secret" \
2364 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002365
Janos Follathe2681a42016-03-07 15:57:05 +00002366requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002367run_test "Extended Master Secret: client enabled, server SSLv3" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002368 "$P_SRV debug_level=3 force_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2369 "$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 +02002370 0 \
2371 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002372 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002373 -S "server hello, adding extended master secret extension" \
2374 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002375 -C "session hash for extended master secret" \
2376 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002377
Jarno Lamsaff434c22019-10-25 12:21:54 +03002378run_test "Extended Master Secret: both enabled, both enforcing, DTLS" \
2379 "$P_SRV dtls=1 debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2380 "$P_CLI dtls=1 debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2381 0 \
2382 -c "client hello, adding extended_master_secret extension" \
2383 -s "found extended master secret extension" \
2384 -s "server hello, adding extended master secret extension" \
2385 -c "found extended_master_secret extension" \
2386 -c "session hash for extended master secret" \
2387 -s "session hash for extended master secret"
2388
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002389# Tests for FALLBACK_SCSV
2390
2391run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002392 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002393 "$P_CLI debug_level=3 force_version=tls1_1" \
2394 0 \
2395 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002396 -S "received FALLBACK_SCSV" \
2397 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002398 -C "is a fatal alert message (msg 86)"
2399
2400run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002401 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002402 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2403 0 \
2404 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002405 -S "received FALLBACK_SCSV" \
2406 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002407 -C "is a fatal alert message (msg 86)"
2408
2409run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002410 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002411 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002412 1 \
2413 -c "adding FALLBACK_SCSV" \
2414 -s "received FALLBACK_SCSV" \
2415 -s "inapropriate fallback" \
2416 -c "is a fatal alert message (msg 86)"
2417
2418run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002419 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002420 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002421 0 \
2422 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002423 -s "received FALLBACK_SCSV" \
2424 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002425 -C "is a fatal alert message (msg 86)"
2426
2427requires_openssl_with_fallback_scsv
2428run_test "Fallback SCSV: default, openssl server" \
2429 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002430 "$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 +02002431 0 \
2432 -C "adding FALLBACK_SCSV" \
2433 -C "is a fatal alert message (msg 86)"
2434
2435requires_openssl_with_fallback_scsv
2436run_test "Fallback SCSV: enabled, openssl server" \
2437 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002438 "$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 +02002439 1 \
2440 -c "adding FALLBACK_SCSV" \
2441 -c "is a fatal alert message (msg 86)"
2442
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002443requires_openssl_with_fallback_scsv
2444run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002445 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002446 "$O_CLI -tls1_1" \
2447 0 \
2448 -S "received FALLBACK_SCSV" \
2449 -S "inapropriate fallback"
2450
2451requires_openssl_with_fallback_scsv
2452run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002453 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002454 "$O_CLI -tls1_1 -fallback_scsv" \
2455 1 \
2456 -s "received FALLBACK_SCSV" \
2457 -s "inapropriate fallback"
2458
2459requires_openssl_with_fallback_scsv
2460run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002461 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002462 "$O_CLI -fallback_scsv" \
2463 0 \
2464 -s "received FALLBACK_SCSV" \
2465 -S "inapropriate fallback"
2466
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002467# Test sending and receiving empty application data records
2468
2469run_test "Encrypt then MAC: empty application data record" \
2470 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2471 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2472 0 \
2473 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2474 -s "dumping 'input payload after decrypt' (0 bytes)" \
2475 -c "0 bytes written in 1 fragments"
2476
2477run_test "Default, no Encrypt then MAC: empty application data record" \
2478 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2479 "$P_CLI auth_mode=none etm=0 request_size=0" \
2480 0 \
2481 -s "dumping 'input payload after decrypt' (0 bytes)" \
2482 -c "0 bytes written in 1 fragments"
2483
2484run_test "Encrypt then MAC, DTLS: empty application data record" \
2485 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2486 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2487 0 \
2488 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2489 -s "dumping 'input payload after decrypt' (0 bytes)" \
2490 -c "0 bytes written in 1 fragments"
2491
2492run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
2493 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2494 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2495 0 \
2496 -s "dumping 'input payload after decrypt' (0 bytes)" \
2497 -c "0 bytes written in 1 fragments"
2498
Gilles Peskined50177f2017-05-16 17:53:03 +02002499## ClientHello generated with
2500## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2501## then manually twiddling the ciphersuite list.
2502## The ClientHello content is spelled out below as a hex string as
2503## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2504## The expected response is an inappropriate_fallback alert.
2505requires_openssl_with_fallback_scsv
2506run_test "Fallback SCSV: beginning of list" \
2507 "$P_SRV debug_level=2" \
2508 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2509 0 \
2510 -s "received FALLBACK_SCSV" \
2511 -s "inapropriate fallback"
2512
2513requires_openssl_with_fallback_scsv
2514run_test "Fallback SCSV: end of list" \
2515 "$P_SRV debug_level=2" \
2516 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2517 0 \
2518 -s "received FALLBACK_SCSV" \
2519 -s "inapropriate fallback"
2520
2521## Here the expected response is a valid ServerHello prefix, up to the random.
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02002522## Due to the way the clienthello was generated, this currently needs the
2523## server to have support for session tickets.
2524requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Gilles Peskined50177f2017-05-16 17:53:03 +02002525requires_openssl_with_fallback_scsv
2526run_test "Fallback SCSV: not in list" \
2527 "$P_SRV debug_level=2" \
2528 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2529 0 \
2530 -S "received FALLBACK_SCSV" \
2531 -S "inapropriate fallback"
2532
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002533# Tests for CBC 1/n-1 record splitting
2534
2535run_test "CBC Record splitting: TLS 1.2, no splitting" \
2536 "$P_SRV" \
2537 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2538 request_size=123 force_version=tls1_2" \
2539 0 \
2540 -s "Read from client: 123 bytes read" \
2541 -S "Read from client: 1 bytes read" \
2542 -S "122 bytes read"
2543
2544run_test "CBC Record splitting: TLS 1.1, no splitting" \
2545 "$P_SRV" \
2546 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2547 request_size=123 force_version=tls1_1" \
2548 0 \
2549 -s "Read from client: 123 bytes read" \
2550 -S "Read from client: 1 bytes read" \
2551 -S "122 bytes read"
2552
2553run_test "CBC Record splitting: TLS 1.0, splitting" \
2554 "$P_SRV" \
2555 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2556 request_size=123 force_version=tls1" \
2557 0 \
2558 -S "Read from client: 123 bytes read" \
2559 -s "Read from client: 1 bytes read" \
2560 -s "122 bytes read"
2561
Janos Follathe2681a42016-03-07 15:57:05 +00002562requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002563run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002564 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002565 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2566 request_size=123 force_version=ssl3" \
2567 0 \
2568 -S "Read from client: 123 bytes read" \
2569 -s "Read from client: 1 bytes read" \
2570 -s "122 bytes read"
2571
2572run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002573 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002574 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2575 request_size=123 force_version=tls1" \
2576 0 \
2577 -s "Read from client: 123 bytes read" \
2578 -S "Read from client: 1 bytes read" \
2579 -S "122 bytes read"
2580
2581run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2582 "$P_SRV" \
2583 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2584 request_size=123 force_version=tls1 recsplit=0" \
2585 0 \
2586 -s "Read from client: 123 bytes read" \
2587 -S "Read from client: 1 bytes read" \
2588 -S "122 bytes read"
2589
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002590run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2591 "$P_SRV nbio=2" \
2592 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2593 request_size=123 force_version=tls1" \
2594 0 \
2595 -S "Read from client: 123 bytes read" \
2596 -s "Read from client: 1 bytes read" \
2597 -s "122 bytes read"
2598
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002599# Tests for Session Tickets
2600
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002601requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002602requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002603run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002604 "$P_SRV debug_level=3 tickets=1" \
2605 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002606 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002607 -c "client hello, adding session ticket extension" \
2608 -s "found session ticket extension" \
2609 -s "server hello, adding session ticket extension" \
2610 -c "found session_ticket extension" \
2611 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002612 -S "session successfully restored from cache" \
2613 -s "session successfully restored from ticket" \
2614 -s "a session has been resumed" \
2615 -c "a session has been resumed"
2616
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002617requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002618requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002619run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002620 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2621 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002622 0 \
2623 -c "client hello, adding session ticket extension" \
2624 -s "found session ticket extension" \
2625 -s "server hello, adding session ticket extension" \
2626 -c "found session_ticket extension" \
2627 -c "parse new session ticket" \
2628 -S "session successfully restored from cache" \
2629 -s "session successfully restored from ticket" \
2630 -s "a session has been resumed" \
2631 -c "a session has been resumed"
2632
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002633requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002634requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002635run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002636 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2637 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002638 0 \
2639 -c "client hello, adding session ticket extension" \
2640 -s "found session ticket extension" \
2641 -s "server hello, adding session ticket extension" \
2642 -c "found session_ticket extension" \
2643 -c "parse new session ticket" \
2644 -S "session successfully restored from cache" \
2645 -S "session successfully restored from ticket" \
2646 -S "a session has been resumed" \
2647 -C "a session has been resumed"
2648
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002649requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002650requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002651run_test "Session resume using tickets: session copy" \
2652 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2653 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2654 0 \
2655 -c "client hello, adding session ticket extension" \
2656 -s "found session ticket extension" \
2657 -s "server hello, adding session ticket extension" \
2658 -c "found session_ticket extension" \
2659 -c "parse new session ticket" \
2660 -S "session successfully restored from cache" \
2661 -s "session successfully restored from ticket" \
2662 -s "a session has been resumed" \
2663 -c "a session has been resumed"
2664
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002665requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002666requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002667run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002668 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002669 "$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 +01002670 0 \
2671 -c "client hello, adding session ticket extension" \
2672 -c "found session_ticket extension" \
2673 -c "parse new session ticket" \
2674 -c "a session has been resumed"
2675
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002676requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002677requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002678run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002679 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002680 "( $O_CLI -sess_out $SESSION; \
2681 $O_CLI -sess_in $SESSION; \
2682 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002683 0 \
2684 -s "found session ticket extension" \
2685 -s "server hello, adding session ticket extension" \
2686 -S "session successfully restored from cache" \
2687 -s "session successfully restored from ticket" \
2688 -s "a session has been resumed"
2689
Hanno Becker1d739932018-08-21 13:55:22 +01002690# Tests for Session Tickets with DTLS
2691
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002692requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002693requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002694run_test "Session resume using tickets, DTLS: basic" \
2695 "$P_SRV debug_level=3 dtls=1 tickets=1" \
2696 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2697 0 \
2698 -c "client hello, adding session ticket extension" \
2699 -s "found session ticket extension" \
2700 -s "server hello, adding session ticket extension" \
2701 -c "found session_ticket extension" \
2702 -c "parse new session ticket" \
2703 -S "session successfully restored from cache" \
2704 -s "session successfully restored from ticket" \
2705 -s "a session has been resumed" \
2706 -c "a session has been resumed"
2707
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002708requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002709requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002710run_test "Session resume using tickets, DTLS: cache disabled" \
2711 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2712 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2713 0 \
2714 -c "client hello, adding session ticket extension" \
2715 -s "found session ticket extension" \
2716 -s "server hello, adding session ticket extension" \
2717 -c "found session_ticket extension" \
2718 -c "parse new session ticket" \
2719 -S "session successfully restored from cache" \
2720 -s "session successfully restored from ticket" \
2721 -s "a session has been resumed" \
2722 -c "a session has been resumed"
2723
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002724requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002725requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002726run_test "Session resume using tickets, DTLS: timeout" \
2727 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
2728 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \
2729 0 \
2730 -c "client hello, adding session ticket extension" \
2731 -s "found session ticket extension" \
2732 -s "server hello, adding session ticket extension" \
2733 -c "found session_ticket extension" \
2734 -c "parse new session ticket" \
2735 -S "session successfully restored from cache" \
2736 -S "session successfully restored from ticket" \
2737 -S "a session has been resumed" \
2738 -C "a session has been resumed"
2739
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002740requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002741requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002742run_test "Session resume using tickets, DTLS: session copy" \
2743 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2744 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_mode=0" \
2745 0 \
2746 -c "client hello, adding session ticket extension" \
2747 -s "found session ticket extension" \
2748 -s "server hello, adding session ticket extension" \
2749 -c "found session_ticket extension" \
2750 -c "parse new session ticket" \
2751 -S "session successfully restored from cache" \
2752 -s "session successfully restored from ticket" \
2753 -s "a session has been resumed" \
2754 -c "a session has been resumed"
2755
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002756requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002757requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002758run_test "Session resume using tickets, DTLS: openssl server" \
2759 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002760 "$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 +01002761 0 \
2762 -c "client hello, adding session ticket extension" \
2763 -c "found session_ticket extension" \
2764 -c "parse new session ticket" \
2765 -c "a session has been resumed"
2766
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002767requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002768requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002769run_test "Session resume using tickets, DTLS: openssl client" \
2770 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2771 "( $O_CLI -dtls1 -sess_out $SESSION; \
2772 $O_CLI -dtls1 -sess_in $SESSION; \
2773 rm -f $SESSION )" \
2774 0 \
2775 -s "found session ticket extension" \
2776 -s "server hello, adding session ticket extension" \
2777 -S "session successfully restored from cache" \
2778 -s "session successfully restored from ticket" \
2779 -s "a session has been resumed"
2780
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002781# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002782
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002783requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002784requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002785requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002786run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002787 "$P_SRV debug_level=3 tickets=0" \
2788 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002789 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002790 -c "client hello, adding session ticket extension" \
2791 -s "found session ticket extension" \
2792 -S "server hello, adding session ticket extension" \
2793 -C "found session_ticket extension" \
2794 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002795 -s "session successfully restored from cache" \
2796 -S "session successfully restored from ticket" \
2797 -s "a session has been resumed" \
2798 -c "a session has been resumed"
2799
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002800requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002801requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002802requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002803run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002804 "$P_SRV debug_level=3 tickets=1" \
2805 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002806 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002807 -C "client hello, adding session ticket extension" \
2808 -S "found session ticket extension" \
2809 -S "server hello, adding session ticket extension" \
2810 -C "found session_ticket extension" \
2811 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002812 -s "session successfully restored from cache" \
2813 -S "session successfully restored from ticket" \
2814 -s "a session has been resumed" \
2815 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002816
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002817requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2818requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002819run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002820 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2821 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002822 0 \
2823 -S "session successfully restored from cache" \
2824 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002825 -S "a session has been resumed" \
2826 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002827
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002828requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2829requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002830run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002831 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2832 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002833 0 \
2834 -s "session successfully restored from cache" \
2835 -S "session successfully restored from ticket" \
2836 -s "a session has been resumed" \
2837 -c "a session has been resumed"
2838
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002839requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2840requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002841run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002842 "$P_SRV debug_level=3 tickets=0" \
2843 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002844 0 \
2845 -s "session successfully restored from cache" \
2846 -S "session successfully restored from ticket" \
2847 -s "a session has been resumed" \
2848 -c "a session has been resumed"
2849
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002850requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2851requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002852run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002853 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2854 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002855 0 \
2856 -S "session successfully restored from cache" \
2857 -S "session successfully restored from ticket" \
2858 -S "a session has been resumed" \
2859 -C "a session has been resumed"
2860
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002861requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2862requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002863run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002864 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2865 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002866 0 \
2867 -s "session successfully restored from cache" \
2868 -S "session successfully restored from ticket" \
2869 -s "a session has been resumed" \
2870 -c "a session has been resumed"
2871
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002872requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2873requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002874run_test "Session resume using cache: session copy" \
2875 "$P_SRV debug_level=3 tickets=0" \
2876 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2877 0 \
2878 -s "session successfully restored from cache" \
2879 -S "session successfully restored from ticket" \
2880 -s "a session has been resumed" \
2881 -c "a session has been resumed"
2882
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002883requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2884requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002885run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002886 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002887 "( $O_CLI -sess_out $SESSION; \
2888 $O_CLI -sess_in $SESSION; \
2889 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002890 0 \
2891 -s "found session ticket extension" \
2892 -S "server hello, adding session ticket extension" \
2893 -s "session successfully restored from cache" \
2894 -S "session successfully restored from ticket" \
2895 -s "a session has been resumed"
2896
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002897requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2898requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002899run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002900 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002901 "$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 +01002902 0 \
2903 -C "found session_ticket extension" \
2904 -C "parse new session ticket" \
2905 -c "a session has been resumed"
2906
Hanno Becker1d739932018-08-21 13:55:22 +01002907# Tests for Session Resume based on session-ID and cache, DTLS
2908
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002909requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002910requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002911requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002912run_test "Session resume using cache, DTLS: tickets enabled on client" \
2913 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2914 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2915 0 \
2916 -c "client hello, adding session ticket extension" \
2917 -s "found session ticket extension" \
2918 -S "server hello, adding session ticket extension" \
2919 -C "found session_ticket extension" \
2920 -C "parse new session ticket" \
2921 -s "session successfully restored from cache" \
2922 -S "session successfully restored from ticket" \
2923 -s "a session has been resumed" \
2924 -c "a session has been resumed"
2925
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002926requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002927requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002928requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002929run_test "Session resume using cache, DTLS: tickets enabled on server" \
2930 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2931 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2932 0 \
2933 -C "client hello, adding session ticket extension" \
2934 -S "found session ticket extension" \
2935 -S "server hello, adding session ticket extension" \
2936 -C "found session_ticket extension" \
2937 -C "parse new session ticket" \
2938 -s "session successfully restored from cache" \
2939 -S "session successfully restored from ticket" \
2940 -s "a session has been resumed" \
2941 -c "a session has been resumed"
2942
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002943requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2944requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002945run_test "Session resume using cache, DTLS: cache_max=0" \
2946 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
2947 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2948 0 \
2949 -S "session successfully restored from cache" \
2950 -S "session successfully restored from ticket" \
2951 -S "a session has been resumed" \
2952 -C "a session has been resumed"
2953
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002954requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2955requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002956run_test "Session resume using cache, DTLS: cache_max=1" \
2957 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
2958 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2959 0 \
2960 -s "session successfully restored from cache" \
2961 -S "session successfully restored from ticket" \
2962 -s "a session has been resumed" \
2963 -c "a session has been resumed"
2964
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002965requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2966requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002967run_test "Session resume using cache, DTLS: timeout > delay" \
2968 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2969 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
2970 0 \
2971 -s "session successfully restored from cache" \
2972 -S "session successfully restored from ticket" \
2973 -s "a session has been resumed" \
2974 -c "a session has been resumed"
2975
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002976requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2977requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002978run_test "Session resume using cache, DTLS: timeout < delay" \
2979 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
2980 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2981 0 \
2982 -S "session successfully restored from cache" \
2983 -S "session successfully restored from ticket" \
2984 -S "a session has been resumed" \
2985 -C "a session has been resumed"
2986
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002987requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2988requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002989run_test "Session resume using cache, DTLS: no timeout" \
2990 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
2991 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2992 0 \
2993 -s "session successfully restored from cache" \
2994 -S "session successfully restored from ticket" \
2995 -s "a session has been resumed" \
2996 -c "a session has been resumed"
2997
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002998requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2999requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02003000run_test "Session resume using cache, DTLS: session copy" \
3001 "$P_SRV dtls=1 debug_level=3 tickets=0" \
3002 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
3003 0 \
3004 -s "session successfully restored from cache" \
3005 -S "session successfully restored from ticket" \
3006 -s "a session has been resumed" \
3007 -c "a session has been resumed"
3008
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03003009requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3010requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01003011run_test "Session resume using cache, DTLS: openssl client" \
3012 "$P_SRV dtls=1 debug_level=3 tickets=0" \
3013 "( $O_CLI -dtls1 -sess_out $SESSION; \
3014 $O_CLI -dtls1 -sess_in $SESSION; \
3015 rm -f $SESSION )" \
3016 0 \
3017 -s "found session ticket extension" \
3018 -S "server hello, adding session ticket extension" \
3019 -s "session successfully restored from cache" \
3020 -S "session successfully restored from ticket" \
3021 -s "a session has been resumed"
3022
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03003023requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3024requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01003025run_test "Session resume using cache, DTLS: openssl server" \
3026 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003027 "$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 +01003028 0 \
3029 -C "found session_ticket extension" \
3030 -C "parse new session ticket" \
3031 -c "a session has been resumed"
3032
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003033# Tests for Max Fragment Length extension
3034
Angus Grattonc4dd0732018-04-11 16:28:39 +10003035if [ $MAX_CONTENT_LEN -ne 16384 ]; then
3036 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
3037fi
3038
Hanno Becker4aed27e2017-09-18 15:00:34 +01003039requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003040run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003041 "$P_SRV debug_level=3" \
3042 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003043 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003044 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3045 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003046 -C "client hello, adding max_fragment_length extension" \
3047 -S "found max fragment length extension" \
3048 -S "server hello, max_fragment_length extension" \
3049 -C "found max_fragment_length extension"
3050
Hanno Becker4aed27e2017-09-18 15:00:34 +01003051requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003052run_test "Max fragment length: enabled, default, larger message" \
3053 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003054 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003055 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003056 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3057 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003058 -C "client hello, adding max_fragment_length extension" \
3059 -S "found max fragment length extension" \
3060 -S "server hello, max_fragment_length extension" \
3061 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003062 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3063 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003064 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003065
3066requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003067requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Hanno Beckerc5266962017-09-18 15:01:50 +01003068run_test "Max fragment length, DTLS: enabled, default, larger message" \
3069 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003070 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003071 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003072 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3073 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003074 -C "client hello, adding max_fragment_length extension" \
3075 -S "found max fragment length extension" \
3076 -S "server hello, max_fragment_length extension" \
3077 -C "found max_fragment_length extension" \
3078 -c "fragment larger than.*maximum "
3079
Angus Grattonc4dd0732018-04-11 16:28:39 +10003080# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3081# (session fragment length will be 16384 regardless of mbedtls
3082# content length configuration.)
3083
Hanno Beckerc5266962017-09-18 15:01:50 +01003084requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003085requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 16384
Hanno Beckerc5266962017-09-18 15:01:50 +01003086run_test "Max fragment length: disabled, larger message" \
3087 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003088 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003089 0 \
3090 -C "Maximum fragment length is 16384" \
3091 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003092 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3093 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003094 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003095
3096requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003097requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 16384
Hanno Beckerc5266962017-09-18 15:01:50 +01003098run_test "Max fragment length DTLS: disabled, larger message" \
3099 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003100 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003101 1 \
3102 -C "Maximum fragment length is 16384" \
3103 -S "Maximum fragment length is 16384" \
3104 -c "fragment larger than.*maximum "
3105
3106requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003107requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003108run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003109 "$P_SRV debug_level=3" \
3110 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003111 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003112 -c "Maximum fragment length is 4096" \
3113 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003114 -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
Hanno Becker4aed27e2017-09-18 15:00:34 +01003119requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003120requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003121run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003122 "$P_SRV debug_level=3 max_frag_len=4096" \
3123 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003124 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003125 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003126 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003127 -C "client hello, adding max_fragment_length extension" \
3128 -S "found max fragment length extension" \
3129 -S "server hello, max_fragment_length extension" \
3130 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003131
Hanno Becker4aed27e2017-09-18 15:00:34 +01003132requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003133requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003134requires_gnutls
3135run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003136 "$G_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003137 "$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 +02003138 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003139 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003140 -c "client hello, adding max_fragment_length extension" \
3141 -c "found max_fragment_length extension"
3142
Hanno Becker4aed27e2017-09-18 15:00:34 +01003143requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003144requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003145run_test "Max fragment length: client, message just fits" \
3146 "$P_SRV debug_level=3" \
3147 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3148 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003149 -c "Maximum fragment length is 2048" \
3150 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003151 -c "client hello, adding max_fragment_length extension" \
3152 -s "found max fragment length extension" \
3153 -s "server hello, max_fragment_length extension" \
3154 -c "found max_fragment_length extension" \
3155 -c "2048 bytes written in 1 fragments" \
3156 -s "2048 bytes read"
3157
Hanno Becker4aed27e2017-09-18 15:00:34 +01003158requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003159requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003160run_test "Max fragment length: client, larger message" \
3161 "$P_SRV debug_level=3" \
3162 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3163 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003164 -c "Maximum fragment length is 2048" \
3165 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003166 -c "client hello, adding max_fragment_length extension" \
3167 -s "found max fragment length extension" \
3168 -s "server hello, max_fragment_length extension" \
3169 -c "found max_fragment_length extension" \
3170 -c "2345 bytes written in 2 fragments" \
3171 -s "2048 bytes read" \
3172 -s "297 bytes read"
3173
Hanno Becker4aed27e2017-09-18 15:00:34 +01003174requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003175requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003176run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003177 "$P_SRV debug_level=3 dtls=1" \
3178 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3179 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003180 -c "Maximum fragment length is 2048" \
3181 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003182 -c "client hello, adding max_fragment_length extension" \
3183 -s "found max fragment length extension" \
3184 -s "server hello, max_fragment_length extension" \
3185 -c "found max_fragment_length extension" \
3186 -c "fragment larger than.*maximum"
3187
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003188# Tests for renegotiation
3189
Hanno Becker6a243642017-10-12 15:18:45 +01003190# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003191run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003192 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003193 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003194 0 \
3195 -C "client hello, adding renegotiation extension" \
3196 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3197 -S "found renegotiation extension" \
3198 -s "server hello, secure renegotiation extension" \
3199 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003200 -C "=> renegotiate" \
3201 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003202 -S "write hello request"
3203
Hanno Becker6a243642017-10-12 15:18:45 +01003204requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003205run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003206 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003207 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003208 0 \
3209 -c "client hello, adding renegotiation extension" \
3210 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3211 -s "found renegotiation extension" \
3212 -s "server hello, secure renegotiation extension" \
3213 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003214 -c "=> renegotiate" \
3215 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003216 -S "write hello request"
3217
Hanno Becker6a243642017-10-12 15:18:45 +01003218requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003219run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003220 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003221 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003222 0 \
3223 -c "client hello, adding renegotiation extension" \
3224 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3225 -s "found renegotiation extension" \
3226 -s "server hello, secure renegotiation extension" \
3227 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003228 -c "=> renegotiate" \
3229 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003230 -s "write hello request"
3231
Janos Follathb0f148c2017-10-05 12:29:42 +01003232# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3233# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3234# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003235requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003236run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3237 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3238 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3239 0 \
3240 -c "client hello, adding renegotiation extension" \
3241 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3242 -s "found renegotiation extension" \
3243 -s "server hello, secure renegotiation extension" \
3244 -c "found renegotiation extension" \
3245 -c "=> renegotiate" \
3246 -s "=> renegotiate" \
3247 -S "write hello request" \
3248 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3249
3250# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3251# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3252# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003253requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003254run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3255 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3256 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3257 0 \
3258 -c "client hello, adding renegotiation extension" \
3259 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3260 -s "found renegotiation extension" \
3261 -s "server hello, secure renegotiation extension" \
3262 -c "found renegotiation extension" \
3263 -c "=> renegotiate" \
3264 -s "=> renegotiate" \
3265 -s "write hello request" \
3266 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3267
Hanno Becker6a243642017-10-12 15:18:45 +01003268requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003269run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003270 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003271 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003272 0 \
3273 -c "client hello, adding renegotiation extension" \
3274 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3275 -s "found renegotiation extension" \
3276 -s "server hello, secure renegotiation extension" \
3277 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003278 -c "=> renegotiate" \
3279 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003280 -s "write hello request"
3281
Hanno Becker6a243642017-10-12 15:18:45 +01003282requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003283run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003284 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003285 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003286 1 \
3287 -c "client hello, adding renegotiation extension" \
3288 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3289 -S "found renegotiation extension" \
3290 -s "server hello, secure renegotiation extension" \
3291 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003292 -c "=> renegotiate" \
3293 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003294 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003295 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003296 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003297
Hanno Becker6a243642017-10-12 15:18:45 +01003298requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003299run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003300 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003301 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003302 0 \
3303 -C "client hello, adding renegotiation extension" \
3304 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3305 -S "found renegotiation extension" \
3306 -s "server hello, secure renegotiation extension" \
3307 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003308 -C "=> renegotiate" \
3309 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003310 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003311 -S "SSL - An unexpected message was received from our peer" \
3312 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003313
Hanno Becker6a243642017-10-12 15:18:45 +01003314requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003315run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003316 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003317 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003318 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003319 0 \
3320 -C "client hello, adding renegotiation extension" \
3321 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3322 -S "found renegotiation extension" \
3323 -s "server hello, secure renegotiation extension" \
3324 -c "found renegotiation extension" \
3325 -C "=> renegotiate" \
3326 -S "=> renegotiate" \
3327 -s "write hello request" \
3328 -S "SSL - An unexpected message was received from our peer" \
3329 -S "failed"
3330
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003331# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003332requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003333run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003334 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003335 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003336 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003337 0 \
3338 -C "client hello, adding renegotiation extension" \
3339 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3340 -S "found renegotiation extension" \
3341 -s "server hello, secure renegotiation extension" \
3342 -c "found renegotiation extension" \
3343 -C "=> renegotiate" \
3344 -S "=> renegotiate" \
3345 -s "write hello request" \
3346 -S "SSL - An unexpected message was received from our peer" \
3347 -S "failed"
3348
Hanno Becker6a243642017-10-12 15:18:45 +01003349requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003350run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003351 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003352 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003353 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003354 0 \
3355 -C "client hello, adding renegotiation extension" \
3356 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3357 -S "found renegotiation extension" \
3358 -s "server hello, secure renegotiation extension" \
3359 -c "found renegotiation extension" \
3360 -C "=> renegotiate" \
3361 -S "=> renegotiate" \
3362 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003363 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003364
Hanno Becker6a243642017-10-12 15:18:45 +01003365requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003366run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003367 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003368 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003369 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003370 0 \
3371 -c "client hello, adding renegotiation extension" \
3372 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3373 -s "found renegotiation extension" \
3374 -s "server hello, secure renegotiation extension" \
3375 -c "found renegotiation extension" \
3376 -c "=> renegotiate" \
3377 -s "=> renegotiate" \
3378 -s "write hello request" \
3379 -S "SSL - An unexpected message was received from our peer" \
3380 -S "failed"
3381
Hanno Becker6a243642017-10-12 15:18:45 +01003382requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003383run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003384 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003385 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3386 0 \
3387 -C "client hello, adding renegotiation extension" \
3388 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3389 -S "found renegotiation extension" \
3390 -s "server hello, secure renegotiation extension" \
3391 -c "found renegotiation extension" \
3392 -S "record counter limit reached: renegotiate" \
3393 -C "=> renegotiate" \
3394 -S "=> renegotiate" \
3395 -S "write hello request" \
3396 -S "SSL - An unexpected message was received from our peer" \
3397 -S "failed"
3398
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003399# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003400requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003401run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003402 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003403 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003404 0 \
3405 -c "client hello, adding renegotiation extension" \
3406 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3407 -s "found renegotiation extension" \
3408 -s "server hello, secure renegotiation extension" \
3409 -c "found renegotiation extension" \
3410 -s "record counter limit reached: renegotiate" \
3411 -c "=> renegotiate" \
3412 -s "=> renegotiate" \
3413 -s "write hello request" \
3414 -S "SSL - An unexpected message was received from our peer" \
3415 -S "failed"
3416
Hanno Becker6a243642017-10-12 15:18:45 +01003417requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003418run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003419 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003420 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003421 0 \
3422 -c "client hello, adding renegotiation extension" \
3423 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3424 -s "found renegotiation extension" \
3425 -s "server hello, secure renegotiation extension" \
3426 -c "found renegotiation extension" \
3427 -s "record counter limit reached: renegotiate" \
3428 -c "=> renegotiate" \
3429 -s "=> renegotiate" \
3430 -s "write hello request" \
3431 -S "SSL - An unexpected message was received from our peer" \
3432 -S "failed"
3433
Hanno Becker6a243642017-10-12 15:18:45 +01003434requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003435run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003436 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003437 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3438 0 \
3439 -C "client hello, adding renegotiation extension" \
3440 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3441 -S "found renegotiation extension" \
3442 -s "server hello, secure renegotiation extension" \
3443 -c "found renegotiation extension" \
3444 -S "record counter limit reached: renegotiate" \
3445 -C "=> renegotiate" \
3446 -S "=> renegotiate" \
3447 -S "write hello request" \
3448 -S "SSL - An unexpected message was received from our peer" \
3449 -S "failed"
3450
Hanno Becker6a243642017-10-12 15:18:45 +01003451requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003452run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003453 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003454 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003455 0 \
3456 -c "client hello, adding renegotiation extension" \
3457 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3458 -s "found renegotiation extension" \
3459 -s "server hello, secure renegotiation extension" \
3460 -c "found renegotiation extension" \
3461 -c "=> renegotiate" \
3462 -s "=> renegotiate" \
3463 -S "write hello request"
3464
Hanno Becker6a243642017-10-12 15:18:45 +01003465requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003466run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003467 "$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 +02003468 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003469 0 \
3470 -c "client hello, adding renegotiation extension" \
3471 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3472 -s "found renegotiation extension" \
3473 -s "server hello, secure renegotiation extension" \
3474 -c "found renegotiation extension" \
3475 -c "=> renegotiate" \
3476 -s "=> renegotiate" \
3477 -s "write hello request"
3478
Hanno Becker6a243642017-10-12 15:18:45 +01003479requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003480run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003481 "$O_SRV -www" \
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é-Gonnard51362962014-08-30 21:22:47 +02003483 0 \
3484 -c "client hello, adding renegotiation extension" \
3485 -c "found renegotiation extension" \
3486 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003487 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003488 -C "error" \
3489 -c "HTTP/1.0 200 [Oo][Kk]"
3490
Paul Bakker539d9722015-02-08 16:18:35 +01003491requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003492requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003493run_test "Renegotiation: gnutls server strict, client-initiated" \
3494 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003495 "$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 +02003496 0 \
3497 -c "client hello, adding renegotiation extension" \
3498 -c "found renegotiation extension" \
3499 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003500 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003501 -C "error" \
3502 -c "HTTP/1.0 200 [Oo][Kk]"
3503
Paul Bakker539d9722015-02-08 16:18:35 +01003504requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003505requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003506run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3507 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003508 "$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 +01003509 1 \
3510 -c "client hello, adding renegotiation extension" \
3511 -C "found renegotiation extension" \
3512 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003513 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003514 -c "error" \
3515 -C "HTTP/1.0 200 [Oo][Kk]"
3516
Paul Bakker539d9722015-02-08 16:18:35 +01003517requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003518requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003519run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3520 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003521 "$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 +01003522 allow_legacy=0" \
3523 1 \
3524 -c "client hello, adding renegotiation extension" \
3525 -C "found renegotiation extension" \
3526 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003527 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003528 -c "error" \
3529 -C "HTTP/1.0 200 [Oo][Kk]"
3530
Paul Bakker539d9722015-02-08 16:18:35 +01003531requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003532requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003533run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3534 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003535 "$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 +01003536 allow_legacy=1" \
3537 0 \
3538 -c "client hello, adding renegotiation extension" \
3539 -C "found renegotiation extension" \
3540 -c "=> renegotiate" \
3541 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003542 -C "error" \
3543 -c "HTTP/1.0 200 [Oo][Kk]"
3544
Hanno Becker6a243642017-10-12 15:18:45 +01003545requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003546run_test "Renegotiation: DTLS, client-initiated" \
3547 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3548 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3549 0 \
3550 -c "client hello, adding renegotiation extension" \
3551 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3552 -s "found renegotiation extension" \
3553 -s "server hello, secure renegotiation extension" \
3554 -c "found renegotiation extension" \
3555 -c "=> renegotiate" \
3556 -s "=> renegotiate" \
3557 -S "write hello request"
3558
Hanno Becker6a243642017-10-12 15:18:45 +01003559requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003560run_test "Renegotiation: DTLS, server-initiated" \
3561 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003562 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3563 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003564 0 \
3565 -c "client hello, adding renegotiation extension" \
3566 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3567 -s "found renegotiation extension" \
3568 -s "server hello, secure renegotiation extension" \
3569 -c "found renegotiation extension" \
3570 -c "=> renegotiate" \
3571 -s "=> renegotiate" \
3572 -s "write hello request"
3573
Hanno Becker6a243642017-10-12 15:18:45 +01003574requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003575run_test "Renegotiation: DTLS, renego_period overflow" \
3576 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3577 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3578 0 \
3579 -c "client hello, adding renegotiation extension" \
3580 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3581 -s "found renegotiation extension" \
3582 -s "server hello, secure renegotiation extension" \
3583 -s "record counter limit reached: renegotiate" \
3584 -c "=> renegotiate" \
3585 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003586 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003587
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003588requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003589requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003590run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3591 "$G_SRV -u --mtu 4096" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003592 "$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 +02003593 0 \
3594 -c "client hello, adding renegotiation extension" \
3595 -c "found renegotiation extension" \
3596 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003597 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003598 -C "error" \
3599 -s "Extra-header:"
3600
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003601# Test for the "secure renegotation" extension only (no actual renegotiation)
3602
Paul Bakker539d9722015-02-08 16:18:35 +01003603requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003604run_test "Renego ext: gnutls server strict, client default" \
3605 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003606 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003607 0 \
3608 -c "found renegotiation extension" \
3609 -C "error" \
3610 -c "HTTP/1.0 200 [Oo][Kk]"
3611
Paul Bakker539d9722015-02-08 16:18:35 +01003612requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003613run_test "Renego ext: gnutls server unsafe, client default" \
3614 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003615 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003616 0 \
3617 -C "found renegotiation extension" \
3618 -C "error" \
3619 -c "HTTP/1.0 200 [Oo][Kk]"
3620
Paul Bakker539d9722015-02-08 16:18:35 +01003621requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003622run_test "Renego ext: gnutls server unsafe, client break legacy" \
3623 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3624 "$P_CLI debug_level=3 allow_legacy=-1" \
3625 1 \
3626 -C "found renegotiation extension" \
3627 -c "error" \
3628 -C "HTTP/1.0 200 [Oo][Kk]"
3629
Paul Bakker539d9722015-02-08 16:18:35 +01003630requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003631run_test "Renego ext: gnutls client strict, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003632 "$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 +02003633 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003634 0 \
3635 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3636 -s "server hello, secure renegotiation extension"
3637
Paul Bakker539d9722015-02-08 16:18:35 +01003638requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003639run_test "Renego ext: gnutls client unsafe, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003640 "$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 +02003641 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003642 0 \
3643 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3644 -S "server hello, secure renegotiation extension"
3645
Paul Bakker539d9722015-02-08 16:18:35 +01003646requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003647run_test "Renego ext: gnutls client unsafe, server break legacy" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003648 "$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 +02003649 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003650 1 \
3651 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3652 -S "server hello, secure renegotiation extension"
3653
Janos Follath0b242342016-02-17 10:11:21 +00003654# Tests for silently dropping trailing extra bytes in .der certificates
3655
3656requires_gnutls
3657run_test "DER format: no trailing bytes" \
3658 "$P_SRV crt_file=data_files/server5-der0.crt \
3659 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003660 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003661 0 \
3662 -c "Handshake was completed" \
3663
3664requires_gnutls
3665run_test "DER format: with a trailing zero byte" \
3666 "$P_SRV crt_file=data_files/server5-der1a.crt \
3667 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003668 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003669 0 \
3670 -c "Handshake was completed" \
3671
3672requires_gnutls
3673run_test "DER format: with a trailing random byte" \
3674 "$P_SRV crt_file=data_files/server5-der1b.crt \
3675 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003676 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003677 0 \
3678 -c "Handshake was completed" \
3679
3680requires_gnutls
3681run_test "DER format: with 2 trailing random bytes" \
3682 "$P_SRV crt_file=data_files/server5-der2.crt \
3683 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003684 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003685 0 \
3686 -c "Handshake was completed" \
3687
3688requires_gnutls
3689run_test "DER format: with 4 trailing random bytes" \
3690 "$P_SRV crt_file=data_files/server5-der4.crt \
3691 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003692 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003693 0 \
3694 -c "Handshake was completed" \
3695
3696requires_gnutls
3697run_test "DER format: with 8 trailing random bytes" \
3698 "$P_SRV crt_file=data_files/server5-der8.crt \
3699 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003700 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003701 0 \
3702 -c "Handshake was completed" \
3703
3704requires_gnutls
3705run_test "DER format: with 9 trailing random bytes" \
3706 "$P_SRV crt_file=data_files/server5-der9.crt \
3707 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003708 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003709 0 \
3710 -c "Handshake was completed" \
3711
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003712# Tests for auth_mode
3713
Hanno Becker4a156fc2019-06-14 17:07:06 +01003714requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003715requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003716run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003717 "$P_SRV crt_file=data_files/server5-badsign.crt \
3718 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003719 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003720 1 \
3721 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003722 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003723 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003724 -c "X509 - Certificate verification failed"
3725
Hanno Becker4a156fc2019-06-14 17:07:06 +01003726requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003727requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003728run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003729 "$P_SRV crt_file=data_files/server5-badsign.crt \
3730 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003731 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003732 0 \
3733 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003734 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003735 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003736 -C "X509 - Certificate verification failed"
3737
Hanno Becker4a156fc2019-06-14 17:07:06 +01003738requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003739requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003740run_test "Authentication: server goodcert, client optional, no trusted CA" \
3741 "$P_SRV" \
3742 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3743 0 \
3744 -c "x509_verify_cert() returned" \
3745 -c "! The certificate is not correctly signed by the trusted CA" \
3746 -c "! Certificate verification flags"\
3747 -C "! mbedtls_ssl_handshake returned" \
3748 -C "X509 - Certificate verification failed" \
3749 -C "SSL - No CA Chain is set, but required to operate"
3750
Hanno Becker4a156fc2019-06-14 17:07:06 +01003751requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003752requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003753run_test "Authentication: server goodcert, client required, no trusted CA" \
3754 "$P_SRV" \
3755 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3756 1 \
3757 -c "x509_verify_cert() returned" \
3758 -c "! The certificate is not correctly signed by the trusted CA" \
3759 -c "! Certificate verification flags"\
3760 -c "! mbedtls_ssl_handshake returned" \
3761 -c "SSL - No CA Chain is set, but required to operate"
3762
3763# The purpose of the next two tests is to test the client's behaviour when receiving a server
3764# certificate with an unsupported elliptic curve. This should usually not happen because
3765# the client informs the server about the supported curves - it does, though, in the
3766# corner case of a static ECDH suite, because the server doesn't check the curve on that
3767# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3768# different means to have the server ignoring the client's supported curve list.
3769
3770requires_config_enabled MBEDTLS_ECP_C
3771run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3772 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3773 crt_file=data_files/server5.ku-ka.crt" \
3774 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3775 1 \
3776 -c "bad certificate (EC key curve)"\
3777 -c "! Certificate verification flags"\
3778 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3779
3780requires_config_enabled MBEDTLS_ECP_C
3781run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3782 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3783 crt_file=data_files/server5.ku-ka.crt" \
3784 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3785 1 \
3786 -c "bad certificate (EC key curve)"\
3787 -c "! Certificate verification flags"\
3788 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003790run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003791 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003792 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003793 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003794 0 \
3795 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003796 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003797 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003798 -C "X509 - Certificate verification failed"
3799
Simon Butcher99000142016-10-13 17:21:01 +01003800run_test "Authentication: client SHA256, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003801 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003802 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3803 key_file=data_files/server6.key \
3804 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3805 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003806 -c "Supported Signature Algorithm found: 5,"
3807
3808run_test "Authentication: client SHA384, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003809 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003810 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3811 key_file=data_files/server6.key \
3812 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3813 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003814 -c "Supported Signature Algorithm found: 5,"
3815
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003816requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3817run_test "Authentication: client has no cert, server required (SSLv3)" \
3818 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3819 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3820 key_file=data_files/server5.key" \
3821 1 \
3822 -S "skip write certificate request" \
3823 -C "skip parse certificate request" \
3824 -c "got a certificate request" \
3825 -c "got no certificate to send" \
3826 -S "x509_verify_cert() returned" \
3827 -s "client has no certificate" \
3828 -s "! mbedtls_ssl_handshake returned" \
3829 -c "! mbedtls_ssl_handshake returned" \
3830 -s "No client certification received from the client, but required by the authentication mode"
3831
3832run_test "Authentication: client has no cert, server required (TLS)" \
3833 "$P_SRV debug_level=3 auth_mode=required" \
3834 "$P_CLI debug_level=3 crt_file=none \
3835 key_file=data_files/server5.key" \
3836 1 \
3837 -S "skip write certificate request" \
3838 -C "skip parse certificate request" \
3839 -c "got a certificate request" \
3840 -c "= write certificate$" \
3841 -C "skip write certificate$" \
3842 -S "x509_verify_cert() returned" \
3843 -s "client has no certificate" \
3844 -s "! mbedtls_ssl_handshake returned" \
3845 -c "! mbedtls_ssl_handshake returned" \
3846 -s "No client certification received from the client, but required by the authentication mode"
3847
Hanno Becker4a156fc2019-06-14 17:07:06 +01003848requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003849requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003850run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003851 "$P_SRV debug_level=3 auth_mode=required" \
3852 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003853 key_file=data_files/server5.key" \
3854 1 \
3855 -S "skip write certificate request" \
3856 -C "skip parse certificate request" \
3857 -c "got a certificate request" \
3858 -C "skip write certificate" \
3859 -C "skip write certificate verify" \
3860 -S "skip parse certificate verify" \
3861 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003862 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003863 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003864 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003865 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003866 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003867# We don't check that the client receives the alert because it might
3868# detect that its write end of the connection is closed and abort
3869# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003870
Hanno Becker4a156fc2019-06-14 17:07:06 +01003871requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003872requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01003873run_test "Authentication: client cert not trusted, server required" \
3874 "$P_SRV debug_level=3 auth_mode=required" \
3875 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3876 key_file=data_files/server5.key" \
3877 1 \
3878 -S "skip write certificate request" \
3879 -C "skip parse certificate request" \
3880 -c "got a certificate request" \
3881 -C "skip write certificate" \
3882 -C "skip write certificate verify" \
3883 -S "skip parse certificate verify" \
3884 -s "x509_verify_cert() returned" \
3885 -s "! The certificate is not correctly signed by the trusted CA" \
3886 -s "! mbedtls_ssl_handshake returned" \
3887 -c "! mbedtls_ssl_handshake returned" \
3888 -s "X509 - Certificate verification failed"
3889
Hanno Becker4a156fc2019-06-14 17:07:06 +01003890requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003891requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003892run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003893 "$P_SRV debug_level=3 auth_mode=optional" \
3894 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003895 key_file=data_files/server5.key" \
3896 0 \
3897 -S "skip write certificate request" \
3898 -C "skip parse certificate request" \
3899 -c "got a certificate request" \
3900 -C "skip write certificate" \
3901 -C "skip write certificate verify" \
3902 -S "skip parse certificate verify" \
3903 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003904 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003905 -S "! mbedtls_ssl_handshake returned" \
3906 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003907 -S "X509 - Certificate verification failed"
3908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003909run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003910 "$P_SRV debug_level=3 auth_mode=none" \
3911 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003912 key_file=data_files/server5.key" \
3913 0 \
3914 -s "skip write certificate request" \
3915 -C "skip parse certificate request" \
3916 -c "got no certificate request" \
3917 -c "skip write certificate" \
3918 -c "skip write certificate verify" \
3919 -s "skip parse certificate verify" \
3920 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003921 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003922 -S "! mbedtls_ssl_handshake returned" \
3923 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003924 -S "X509 - Certificate verification failed"
3925
Hanno Becker4a156fc2019-06-14 17:07:06 +01003926requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003927requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003928run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003929 "$P_SRV debug_level=3 auth_mode=optional" \
3930 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003931 0 \
3932 -S "skip write certificate request" \
3933 -C "skip parse certificate request" \
3934 -c "got a certificate request" \
3935 -C "skip write certificate$" \
3936 -C "got no certificate to send" \
3937 -S "SSLv3 client has no certificate" \
3938 -c "skip write certificate verify" \
3939 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003940 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003941 -S "! mbedtls_ssl_handshake returned" \
3942 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003943 -S "X509 - Certificate verification failed"
3944
Hanno Becker4a156fc2019-06-14 17:07:06 +01003945requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003946requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003947run_test "Authentication: openssl client no cert, server optional" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003948 "$P_SRV debug_level=3 auth_mode=optional ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003949 "$O_CLI" \
3950 0 \
3951 -S "skip write certificate request" \
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" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003955 -S "X509 - Certificate verification failed"
3956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003957run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003958 "$O_SRV -verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003959 "$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 +01003960 0 \
3961 -C "skip parse certificate request" \
3962 -c "got a certificate request" \
3963 -C "skip write certificate$" \
3964 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003965 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003966
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003967run_test "Authentication: client no cert, openssl server required" \
3968 "$O_SRV -Verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003969 "$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 +02003970 1 \
3971 -C "skip parse certificate request" \
3972 -c "got a certificate request" \
3973 -C "skip write certificate$" \
3974 -c "skip write certificate verify" \
3975 -c "! mbedtls_ssl_handshake returned"
3976
Janos Follathe2681a42016-03-07 15:57:05 +00003977requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Hanno Beckerb2c63832019-06-17 08:35:16 +01003978requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003979requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003980run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003981 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003982 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003983 0 \
3984 -S "skip write certificate request" \
3985 -C "skip parse certificate request" \
3986 -c "got a certificate request" \
3987 -C "skip write certificate$" \
3988 -c "skip write certificate verify" \
3989 -c "got no certificate to send" \
3990 -s "SSLv3 client has no certificate" \
3991 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003992 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003993 -S "! mbedtls_ssl_handshake returned" \
3994 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003995 -S "X509 - Certificate verification failed"
3996
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02003997# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
3998# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003999
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004000MAX_IM_CA='8'
Arto Kinnunen78213522019-09-26 11:06:39 +03004001MAX_IM_CA_CONFIG="$( get_config_value_or_default MBEDTLS_X509_MAX_INTERMEDIATE_CA )"
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004002
Angus Grattonc4dd0732018-04-11 16:28:39 +10004003requires_full_size_output_buffer
Arto Kinnunenc457ab12019-09-27 12:00:51 +03004004requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004005run_test "Authentication: server max_int chain, client default" \
4006 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4007 key_file=data_files/dir-maxpath/09.key" \
4008 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4009 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004010 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004011
Angus Grattonc4dd0732018-04-11 16:28:39 +10004012requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004013requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004014run_test "Authentication: server max_int+1 chain, client default" \
4015 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4016 key_file=data_files/dir-maxpath/10.key" \
4017 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4018 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004019 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004020
Angus Grattonc4dd0732018-04-11 16:28:39 +10004021requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004022requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004023run_test "Authentication: server max_int+1 chain, client optional" \
4024 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4025 key_file=data_files/dir-maxpath/10.key" \
4026 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4027 auth_mode=optional" \
4028 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004029 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004030
Angus Grattonc4dd0732018-04-11 16:28:39 +10004031requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004032requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004033run_test "Authentication: server max_int+1 chain, client none" \
4034 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4035 key_file=data_files/dir-maxpath/10.key" \
4036 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4037 auth_mode=none" \
4038 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004039 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004040
Angus Grattonc4dd0732018-04-11 16:28:39 +10004041requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004042run_test "Authentication: client max_int+1 chain, server default" \
4043 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4044 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4045 key_file=data_files/dir-maxpath/10.key" \
4046 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004047 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004048
Angus Grattonc4dd0732018-04-11 16:28:39 +10004049requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004050run_test "Authentication: client max_int+1 chain, server optional" \
4051 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4052 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4053 key_file=data_files/dir-maxpath/10.key" \
4054 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004055 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004056
Angus Grattonc4dd0732018-04-11 16:28:39 +10004057requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004058run_test "Authentication: client max_int+1 chain, server required" \
4059 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4060 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4061 key_file=data_files/dir-maxpath/10.key" \
4062 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004063 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004064
Angus Grattonc4dd0732018-04-11 16:28:39 +10004065requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004066run_test "Authentication: client max_int chain, server required" \
4067 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4068 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4069 key_file=data_files/dir-maxpath/09.key" \
4070 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004071 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004072
Janos Follath89baba22017-04-10 14:34:35 +01004073# Tests for CA list in CertificateRequest messages
4074
4075run_test "Authentication: send CA list in CertificateRequest (default)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004076 "$P_SRV debug_level=3 auth_mode=required ca_file=data_files/test-ca2.crt" \
Janos Follath89baba22017-04-10 14:34:35 +01004077 "$P_CLI crt_file=data_files/server6.crt \
4078 key_file=data_files/server6.key" \
4079 0 \
4080 -s "requested DN"
4081
4082run_test "Authentication: do not send CA list in CertificateRequest" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004083 "$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 +01004084 "$P_CLI crt_file=data_files/server6.crt \
4085 key_file=data_files/server6.key" \
4086 0 \
4087 -S "requested DN"
4088
Hanno Becker4a156fc2019-06-14 17:07:06 +01004089requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004090requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01004091run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4092 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4093 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4094 key_file=data_files/server5.key" \
4095 1 \
4096 -S "requested DN" \
4097 -s "x509_verify_cert() returned" \
4098 -s "! The certificate is not correctly signed by the trusted CA" \
4099 -s "! mbedtls_ssl_handshake returned" \
4100 -c "! mbedtls_ssl_handshake returned" \
4101 -s "X509 - Certificate verification failed"
4102
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004103# Tests for certificate selection based on SHA verson
4104
Hanno Becker4a156fc2019-06-14 17:07:06 +01004105requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004106requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004107run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4108 "$P_SRV crt_file=data_files/server5.crt \
4109 key_file=data_files/server5.key \
4110 crt_file2=data_files/server5-sha1.crt \
4111 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004112 "$P_CLI force_version=tls1_2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004113 0 \
4114 -c "signed using.*ECDSA with SHA256" \
4115 -C "signed using.*ECDSA with SHA1"
4116
Hanno Becker4a156fc2019-06-14 17:07:06 +01004117requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004118requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004119run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4120 "$P_SRV crt_file=data_files/server5.crt \
4121 key_file=data_files/server5.key \
4122 crt_file2=data_files/server5-sha1.crt \
4123 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004124 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004125 0 \
4126 -C "signed using.*ECDSA with SHA256" \
4127 -c "signed using.*ECDSA with SHA1"
4128
Hanno Becker4a156fc2019-06-14 17:07:06 +01004129requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004130requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004131run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4132 "$P_SRV crt_file=data_files/server5.crt \
4133 key_file=data_files/server5.key \
4134 crt_file2=data_files/server5-sha1.crt \
4135 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004136 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004137 0 \
4138 -C "signed using.*ECDSA with SHA256" \
4139 -c "signed using.*ECDSA with SHA1"
4140
Hanno Becker4a156fc2019-06-14 17:07:06 +01004141requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004142requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004143run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4144 "$P_SRV crt_file=data_files/server5.crt \
4145 key_file=data_files/server5.key \
4146 crt_file2=data_files/server6.crt \
4147 key_file2=data_files/server6.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004148 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004149 0 \
4150 -c "serial number.*09" \
4151 -c "signed using.*ECDSA with SHA256" \
4152 -C "signed using.*ECDSA with SHA1"
4153
Hanno Becker4a156fc2019-06-14 17:07:06 +01004154requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004155requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004156run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4157 "$P_SRV crt_file=data_files/server6.crt \
4158 key_file=data_files/server6.key \
4159 crt_file2=data_files/server5.crt \
4160 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004161 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004162 0 \
4163 -c "serial number.*0A" \
4164 -c "signed using.*ECDSA with SHA256" \
4165 -C "signed using.*ECDSA with SHA1"
4166
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004167# tests for SNI
4168
Hanno Becker4a156fc2019-06-14 17:07:06 +01004169requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004170requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004171run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004172 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004173 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004174 "$P_CLI server_name=localhost ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004175 0 \
4176 -S "parse ServerName extension" \
4177 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4178 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004179
Hanno Becker4a156fc2019-06-14 17:07:06 +01004180requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004181requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004182requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004183run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004184 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004185 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004186 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 +01004187 "$P_CLI server_name=localhost ca_file=data_files/test-ca.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004188 0 \
4189 -s "parse ServerName extension" \
4190 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4191 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004192
Hanno Becker4a156fc2019-06-14 17:07:06 +01004193requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004194requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004195requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004196run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004197 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004198 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004199 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 +02004200 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004201 0 \
4202 -s "parse ServerName extension" \
4203 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4204 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004205
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004206requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004207run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004208 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004209 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004210 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 +02004211 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004212 1 \
4213 -s "parse ServerName extension" \
4214 -s "ssl_sni_wrapper() returned" \
4215 -s "mbedtls_ssl_handshake returned" \
4216 -c "mbedtls_ssl_handshake returned" \
4217 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004218
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004219run_test "SNI: client auth no override: optional" \
4220 "$P_SRV debug_level=3 auth_mode=optional \
4221 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4222 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4223 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004224 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004225 -S "skip write certificate request" \
4226 -C "skip parse certificate request" \
4227 -c "got a certificate request" \
4228 -C "skip write certificate" \
4229 -C "skip write certificate verify" \
4230 -S "skip parse certificate verify"
4231
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004232requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004233run_test "SNI: client auth override: none -> optional" \
4234 "$P_SRV debug_level=3 auth_mode=none \
4235 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4236 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4237 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004238 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004239 -S "skip write certificate request" \
4240 -C "skip parse certificate request" \
4241 -c "got a certificate request" \
4242 -C "skip write certificate" \
4243 -C "skip write certificate verify" \
4244 -S "skip parse certificate verify"
4245
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004246requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004247run_test "SNI: client auth override: optional -> none" \
4248 "$P_SRV debug_level=3 auth_mode=optional \
4249 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4250 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4251 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004252 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004253 -s "skip write certificate request" \
4254 -C "skip parse certificate request" \
4255 -c "got no certificate request" \
4256 -c "skip write certificate" \
4257 -c "skip write certificate verify" \
4258 -s "skip parse certificate verify"
4259
Hanno Becker4a156fc2019-06-14 17:07:06 +01004260requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004261requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004262requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004263run_test "SNI: CA no override" \
4264 "$P_SRV debug_level=3 auth_mode=optional \
4265 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4266 ca_file=data_files/test-ca.crt \
4267 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4268 "$P_CLI debug_level=3 server_name=localhost \
4269 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4270 1 \
4271 -S "skip write certificate request" \
4272 -C "skip parse certificate request" \
4273 -c "got a certificate request" \
4274 -C "skip write certificate" \
4275 -C "skip write certificate verify" \
4276 -S "skip parse certificate verify" \
4277 -s "x509_verify_cert() returned" \
4278 -s "! The certificate is not correctly signed by the trusted CA" \
4279 -S "The certificate has been revoked (is on a CRL)"
4280
Hanno Becker4a156fc2019-06-14 17:07:06 +01004281requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004282requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004283requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004284run_test "SNI: CA override" \
4285 "$P_SRV debug_level=3 auth_mode=optional \
4286 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4287 ca_file=data_files/test-ca.crt \
4288 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4289 "$P_CLI debug_level=3 server_name=localhost \
4290 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4291 0 \
4292 -S "skip write certificate request" \
4293 -C "skip parse certificate request" \
4294 -c "got a certificate request" \
4295 -C "skip write certificate" \
4296 -C "skip write certificate verify" \
4297 -S "skip parse certificate verify" \
4298 -S "x509_verify_cert() returned" \
4299 -S "! The certificate is not correctly signed by the trusted CA" \
4300 -S "The certificate has been revoked (is on a CRL)"
4301
Hanno Becker4a156fc2019-06-14 17:07:06 +01004302requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004303requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004304requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004305run_test "SNI: CA override with CRL" \
4306 "$P_SRV debug_level=3 auth_mode=optional \
4307 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4308 ca_file=data_files/test-ca.crt \
4309 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4310 "$P_CLI debug_level=3 server_name=localhost \
4311 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4312 1 \
4313 -S "skip write certificate request" \
4314 -C "skip parse certificate request" \
4315 -c "got a certificate request" \
4316 -C "skip write certificate" \
4317 -C "skip write certificate verify" \
4318 -S "skip parse certificate verify" \
4319 -s "x509_verify_cert() returned" \
4320 -S "! The certificate is not correctly signed by the trusted CA" \
4321 -s "The certificate has been revoked (is on a CRL)"
4322
Andres AG1a834452016-12-07 10:01:30 +00004323# Tests for SNI and DTLS
4324
Hanno Becker4a156fc2019-06-14 17:07:06 +01004325requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004326requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004327run_test "SNI: DTLS, no SNI callback" \
4328 "$P_SRV debug_level=3 dtls=1 \
4329 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004330 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca2.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004331 0 \
4332 -S "parse ServerName extension" \
4333 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4334 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4335
Hanno Becker4a156fc2019-06-14 17:07:06 +01004336requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004337requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004338requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004339run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004340 "$P_SRV debug_level=3 dtls=1 \
4341 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4342 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 +01004343 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca.crt" \
Andres AG1a834452016-12-07 10:01:30 +00004344 0 \
4345 -s "parse ServerName extension" \
4346 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4347 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4348
Hanno Becker4a156fc2019-06-14 17:07:06 +01004349requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004350requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004351requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004352run_test "SNI: DTLS, matching cert 2" \
4353 "$P_SRV debug_level=3 dtls=1 \
4354 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4355 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 +01004356 "$P_CLI server_name=polarssl.example dtls=1 ca_file=data_files/test-ca.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004357 0 \
4358 -s "parse ServerName extension" \
4359 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4360 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4361
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004362requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004363run_test "SNI: DTLS, no matching cert" \
4364 "$P_SRV debug_level=3 dtls=1 \
4365 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4366 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4367 "$P_CLI server_name=nonesuch.example dtls=1" \
4368 1 \
4369 -s "parse ServerName extension" \
4370 -s "ssl_sni_wrapper() returned" \
4371 -s "mbedtls_ssl_handshake returned" \
4372 -c "mbedtls_ssl_handshake returned" \
4373 -c "SSL - A fatal alert message was received from our peer"
4374
4375run_test "SNI: DTLS, client auth no override: optional" \
4376 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4377 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4378 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4379 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4380 0 \
4381 -S "skip write certificate request" \
4382 -C "skip parse certificate request" \
4383 -c "got a certificate request" \
4384 -C "skip write certificate" \
4385 -C "skip write certificate verify" \
4386 -S "skip parse certificate verify"
4387
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004388requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004389run_test "SNI: DTLS, client auth override: none -> optional" \
4390 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4391 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4392 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4393 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4394 0 \
4395 -S "skip write certificate request" \
4396 -C "skip parse certificate request" \
4397 -c "got a certificate request" \
4398 -C "skip write certificate" \
4399 -C "skip write certificate verify" \
4400 -S "skip parse certificate verify"
4401
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004402requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004403run_test "SNI: DTLS, client auth override: optional -> none" \
4404 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4405 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4406 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4407 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4408 0 \
4409 -s "skip write certificate request" \
4410 -C "skip parse certificate request" \
4411 -c "got no certificate request" \
4412 -c "skip write certificate" \
4413 -c "skip write certificate verify" \
4414 -s "skip parse certificate verify"
4415
Hanno Becker4a156fc2019-06-14 17:07:06 +01004416requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004417requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004418requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004419run_test "SNI: DTLS, CA no override" \
4420 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4421 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4422 ca_file=data_files/test-ca.crt \
4423 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4424 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4425 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4426 1 \
4427 -S "skip write certificate request" \
4428 -C "skip parse certificate request" \
4429 -c "got a certificate request" \
4430 -C "skip write certificate" \
4431 -C "skip write certificate verify" \
4432 -S "skip parse certificate verify" \
4433 -s "x509_verify_cert() returned" \
4434 -s "! The certificate is not correctly signed by the trusted CA" \
4435 -S "The certificate has been revoked (is on a CRL)"
4436
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004437requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004438run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004439 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4440 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4441 ca_file=data_files/test-ca.crt \
4442 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4443 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4444 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4445 0 \
4446 -S "skip write certificate request" \
4447 -C "skip parse certificate request" \
4448 -c "got a certificate request" \
4449 -C "skip write certificate" \
4450 -C "skip write certificate verify" \
4451 -S "skip parse certificate verify" \
4452 -S "x509_verify_cert() returned" \
4453 -S "! The certificate is not correctly signed by the trusted CA" \
4454 -S "The certificate has been revoked (is on a CRL)"
4455
Hanno Becker4a156fc2019-06-14 17:07:06 +01004456requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004457requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004458requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004459run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004460 "$P_SRV debug_level=3 auth_mode=optional \
4461 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4462 ca_file=data_files/test-ca.crt \
4463 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4464 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4465 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4466 1 \
4467 -S "skip write certificate request" \
4468 -C "skip parse certificate request" \
4469 -c "got a certificate request" \
4470 -C "skip write certificate" \
4471 -C "skip write certificate verify" \
4472 -S "skip parse certificate verify" \
4473 -s "x509_verify_cert() returned" \
4474 -S "! The certificate is not correctly signed by the trusted CA" \
4475 -s "The certificate has been revoked (is on a CRL)"
4476
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004477# Tests for non-blocking I/O: exercise a variety of handshake flows
4478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004479run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004480 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4481 "$P_CLI nbio=2 tickets=0" \
4482 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004483 -S "mbedtls_ssl_handshake returned" \
4484 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004485 -c "Read from server: .* bytes read"
4486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004487run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004488 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4489 "$P_CLI nbio=2 tickets=0" \
4490 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004491 -S "mbedtls_ssl_handshake returned" \
4492 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004493 -c "Read from server: .* bytes read"
4494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004495run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004496 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4497 "$P_CLI nbio=2 tickets=1" \
4498 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004499 -S "mbedtls_ssl_handshake returned" \
4500 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004501 -c "Read from server: .* bytes read"
4502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004503run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004504 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4505 "$P_CLI nbio=2 tickets=1" \
4506 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004507 -S "mbedtls_ssl_handshake returned" \
4508 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004509 -c "Read from server: .* bytes read"
4510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004511run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004512 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4513 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4514 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004515 -S "mbedtls_ssl_handshake returned" \
4516 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004517 -c "Read from server: .* bytes read"
4518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004519run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004520 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4521 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4522 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004523 -S "mbedtls_ssl_handshake returned" \
4524 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004525 -c "Read from server: .* bytes read"
4526
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004527run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004528 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4529 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4530 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004531 -S "mbedtls_ssl_handshake returned" \
4532 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004533 -c "Read from server: .* bytes read"
4534
Hanno Becker00076712017-11-15 16:39:08 +00004535# Tests for event-driven I/O: exercise a variety of handshake flows
4536
4537run_test "Event-driven I/O: basic handshake" \
4538 "$P_SRV event=1 tickets=0 auth_mode=none" \
4539 "$P_CLI event=1 tickets=0" \
4540 0 \
4541 -S "mbedtls_ssl_handshake returned" \
4542 -C "mbedtls_ssl_handshake returned" \
4543 -c "Read from server: .* bytes read"
4544
4545run_test "Event-driven I/O: client auth" \
4546 "$P_SRV event=1 tickets=0 auth_mode=required" \
4547 "$P_CLI event=1 tickets=0" \
4548 0 \
4549 -S "mbedtls_ssl_handshake returned" \
4550 -C "mbedtls_ssl_handshake returned" \
4551 -c "Read from server: .* bytes read"
4552
4553run_test "Event-driven I/O: ticket" \
4554 "$P_SRV event=1 tickets=1 auth_mode=none" \
4555 "$P_CLI event=1 tickets=1" \
4556 0 \
4557 -S "mbedtls_ssl_handshake returned" \
4558 -C "mbedtls_ssl_handshake returned" \
4559 -c "Read from server: .* bytes read"
4560
4561run_test "Event-driven I/O: ticket + client auth" \
4562 "$P_SRV event=1 tickets=1 auth_mode=required" \
4563 "$P_CLI event=1 tickets=1" \
4564 0 \
4565 -S "mbedtls_ssl_handshake returned" \
4566 -C "mbedtls_ssl_handshake returned" \
4567 -c "Read from server: .* bytes read"
4568
4569run_test "Event-driven I/O: ticket + client auth + resume" \
4570 "$P_SRV event=1 tickets=1 auth_mode=required" \
4571 "$P_CLI event=1 tickets=1 reconnect=1" \
4572 0 \
4573 -S "mbedtls_ssl_handshake returned" \
4574 -C "mbedtls_ssl_handshake returned" \
4575 -c "Read from server: .* bytes read"
4576
4577run_test "Event-driven I/O: ticket + resume" \
4578 "$P_SRV event=1 tickets=1 auth_mode=none" \
4579 "$P_CLI event=1 tickets=1 reconnect=1" \
4580 0 \
4581 -S "mbedtls_ssl_handshake returned" \
4582 -C "mbedtls_ssl_handshake returned" \
4583 -c "Read from server: .* bytes read"
4584
4585run_test "Event-driven I/O: session-id resume" \
4586 "$P_SRV event=1 tickets=0 auth_mode=none" \
4587 "$P_CLI event=1 tickets=0 reconnect=1" \
4588 0 \
4589 -S "mbedtls_ssl_handshake returned" \
4590 -C "mbedtls_ssl_handshake returned" \
4591 -c "Read from server: .* bytes read"
4592
Hanno Becker6a33f592018-03-13 11:38:46 +00004593run_test "Event-driven I/O, DTLS: basic handshake" \
4594 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4595 "$P_CLI dtls=1 event=1 tickets=0" \
4596 0 \
4597 -c "Read from server: .* bytes read"
4598
4599run_test "Event-driven I/O, DTLS: client auth" \
4600 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4601 "$P_CLI dtls=1 event=1 tickets=0" \
4602 0 \
4603 -c "Read from server: .* bytes read"
4604
4605run_test "Event-driven I/O, DTLS: ticket" \
4606 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4607 "$P_CLI dtls=1 event=1 tickets=1" \
4608 0 \
4609 -c "Read from server: .* bytes read"
4610
4611run_test "Event-driven I/O, DTLS: ticket + client auth" \
4612 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4613 "$P_CLI dtls=1 event=1 tickets=1" \
4614 0 \
4615 -c "Read from server: .* bytes read"
4616
4617run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4618 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4619 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4620 0 \
4621 -c "Read from server: .* bytes read"
4622
4623run_test "Event-driven I/O, DTLS: ticket + resume" \
4624 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4625 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4626 0 \
4627 -c "Read from server: .* bytes read"
4628
4629run_test "Event-driven I/O, DTLS: session-id resume" \
4630 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4631 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4632 0 \
4633 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004634
4635# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4636# During session resumption, the client will send its ApplicationData record
4637# within the same datagram as the Finished messages. In this situation, the
4638# server MUST NOT idle on the underlying transport after handshake completion,
4639# because the ApplicationData request has already been queued internally.
4640run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004641 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004642 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4643 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4644 0 \
4645 -c "Read from server: .* bytes read"
4646
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004647# Tests for version negotiation
4648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004649run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004650 "$P_SRV" \
4651 "$P_CLI" \
4652 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004653 -S "mbedtls_ssl_handshake returned" \
4654 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004655 -s "Protocol is TLSv1.2" \
4656 -c "Protocol is TLSv1.2"
4657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004658run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004659 "$P_SRV" \
4660 "$P_CLI max_version=tls1_1" \
4661 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004662 -S "mbedtls_ssl_handshake returned" \
4663 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004664 -s "Protocol is TLSv1.1" \
4665 -c "Protocol is TLSv1.1"
4666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004667run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004668 "$P_SRV max_version=tls1_1" \
4669 "$P_CLI" \
4670 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004671 -S "mbedtls_ssl_handshake returned" \
4672 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004673 -s "Protocol is TLSv1.1" \
4674 -c "Protocol is TLSv1.1"
4675
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004676run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004677 "$P_SRV max_version=tls1_1" \
4678 "$P_CLI max_version=tls1_1" \
4679 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004680 -S "mbedtls_ssl_handshake returned" \
4681 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004682 -s "Protocol is TLSv1.1" \
4683 -c "Protocol is TLSv1.1"
4684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004685run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004686 "$P_SRV min_version=tls1_1" \
4687 "$P_CLI max_version=tls1_1" \
4688 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004689 -S "mbedtls_ssl_handshake returned" \
4690 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004691 -s "Protocol is TLSv1.1" \
4692 -c "Protocol is TLSv1.1"
4693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004694run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004695 "$P_SRV max_version=tls1_1" \
4696 "$P_CLI min_version=tls1_1" \
4697 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004698 -S "mbedtls_ssl_handshake returned" \
4699 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004700 -s "Protocol is TLSv1.1" \
4701 -c "Protocol is TLSv1.1"
4702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004703run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004704 "$P_SRV max_version=tls1_1" \
4705 "$P_CLI min_version=tls1_2" \
4706 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004707 -s "mbedtls_ssl_handshake returned" \
4708 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004709 -c "SSL - Handshake protocol not within min/max boundaries"
4710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004711run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004712 "$P_SRV min_version=tls1_2" \
4713 "$P_CLI max_version=tls1_1" \
4714 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004715 -s "mbedtls_ssl_handshake returned" \
4716 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004717 -s "SSL - Handshake protocol not within min/max boundaries"
4718
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004719# Tests for ALPN extension
4720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004721run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004722 "$P_SRV debug_level=3" \
4723 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004724 0 \
4725 -C "client hello, adding alpn extension" \
4726 -S "found alpn extension" \
4727 -C "got an alert message, type: \\[2:120]" \
4728 -S "server hello, adding alpn extension" \
4729 -C "found alpn extension " \
4730 -C "Application Layer Protocol is" \
4731 -S "Application Layer Protocol is"
4732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004733run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004734 "$P_SRV debug_level=3" \
4735 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004736 0 \
4737 -c "client hello, adding alpn extension" \
4738 -s "found alpn extension" \
4739 -C "got an alert message, type: \\[2:120]" \
4740 -S "server hello, adding alpn extension" \
4741 -C "found alpn extension " \
4742 -c "Application Layer Protocol is (none)" \
4743 -S "Application Layer Protocol is"
4744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004745run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004746 "$P_SRV debug_level=3 alpn=abc,1234" \
4747 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004748 0 \
4749 -C "client hello, adding alpn extension" \
4750 -S "found alpn extension" \
4751 -C "got an alert message, type: \\[2:120]" \
4752 -S "server hello, adding alpn extension" \
4753 -C "found alpn extension " \
4754 -C "Application Layer Protocol is" \
4755 -s "Application Layer Protocol is (none)"
4756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004757run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004758 "$P_SRV debug_level=3 alpn=abc,1234" \
4759 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004760 0 \
4761 -c "client hello, adding alpn extension" \
4762 -s "found alpn extension" \
4763 -C "got an alert message, type: \\[2:120]" \
4764 -s "server hello, adding alpn extension" \
4765 -c "found alpn extension" \
4766 -c "Application Layer Protocol is abc" \
4767 -s "Application Layer Protocol is abc"
4768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004769run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004770 "$P_SRV debug_level=3 alpn=abc,1234" \
4771 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004772 0 \
4773 -c "client hello, adding alpn extension" \
4774 -s "found alpn extension" \
4775 -C "got an alert message, type: \\[2:120]" \
4776 -s "server hello, adding alpn extension" \
4777 -c "found alpn extension" \
4778 -c "Application Layer Protocol is abc" \
4779 -s "Application Layer Protocol is abc"
4780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004781run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004782 "$P_SRV debug_level=3 alpn=abc,1234" \
4783 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004784 0 \
4785 -c "client hello, adding alpn extension" \
4786 -s "found alpn extension" \
4787 -C "got an alert message, type: \\[2:120]" \
4788 -s "server hello, adding alpn extension" \
4789 -c "found alpn extension" \
4790 -c "Application Layer Protocol is 1234" \
4791 -s "Application Layer Protocol is 1234"
4792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004793run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004794 "$P_SRV debug_level=3 alpn=abc,123" \
4795 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004796 1 \
4797 -c "client hello, adding alpn extension" \
4798 -s "found alpn extension" \
4799 -c "got an alert message, type: \\[2:120]" \
4800 -S "server hello, adding alpn extension" \
4801 -C "found alpn extension" \
4802 -C "Application Layer Protocol is 1234" \
4803 -S "Application Layer Protocol is 1234"
4804
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02004805
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004806# Tests for keyUsage in leaf certificates, part 1:
4807# server-side certificate/suite selection
4808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004809run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004810 "$P_SRV key_file=data_files/server2.key \
4811 crt_file=data_files/server2.ku-ds.crt" \
4812 "$P_CLI" \
4813 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02004814 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004815
4816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004817run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004818 "$P_SRV key_file=data_files/server2.key \
4819 crt_file=data_files/server2.ku-ke.crt" \
4820 "$P_CLI" \
4821 0 \
4822 -c "Ciphersuite is TLS-RSA-WITH-"
4823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004824run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004825 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004826 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004827 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004828 1 \
4829 -C "Ciphersuite is "
4830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004831run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004832 "$P_SRV key_file=data_files/server5.key \
4833 crt_file=data_files/server5.ku-ds.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004834 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004835 0 \
4836 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
4837
Jarno Lamsac5118b72019-10-28 10:30:58 +02004838run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA p256" \
4839 "$P_SRV dtls=1 key_file=data_files/server11.key.der \
4840 crt_file=data_files/server11.crt.der" \
4841 "$P_CLI dtls=1 ca_file=data_files/test-ca3.crt.der" \
4842 0 \
4843 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004845run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004846 "$P_SRV key_file=data_files/server5.key \
4847 crt_file=data_files/server5.ku-ka.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004848 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004849 0 \
4850 -c "Ciphersuite is TLS-ECDH-"
4851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004852run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004853 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004854 crt_file=data_files/server5.ku-ke.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004855 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004856 1 \
4857 -C "Ciphersuite is "
4858
4859# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004860# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004862run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004863 "$O_SRV -key data_files/server2.key \
4864 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004865 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004866 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4867 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004868 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004869 -C "Processing of the Certificate handshake message failed" \
4870 -c "Ciphersuite is TLS-"
4871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004872run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004873 "$O_SRV -key data_files/server2.key \
4874 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004875 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004876 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4877 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004878 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004879 -C "Processing of the Certificate handshake message failed" \
4880 -c "Ciphersuite is TLS-"
4881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004882run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004883 "$O_SRV -key data_files/server2.key \
4884 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004885 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004886 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4887 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004888 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004889 -C "Processing of the Certificate handshake message failed" \
4890 -c "Ciphersuite is TLS-"
4891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004892run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004893 "$O_SRV -key data_files/server2.key \
4894 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004895 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004896 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4897 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004898 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004899 -c "Processing of the Certificate handshake message failed" \
4900 -C "Ciphersuite is TLS-"
4901
Hanno Becker4a156fc2019-06-14 17:07:06 +01004902requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004903requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004904run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
4905 "$O_SRV -key data_files/server2.key \
4906 -cert data_files/server2.ku-ke.crt" \
4907 "$P_CLI debug_level=1 auth_mode=optional \
4908 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4909 0 \
4910 -c "bad certificate (usage extensions)" \
4911 -C "Processing of the Certificate handshake message failed" \
4912 -c "Ciphersuite is TLS-" \
4913 -c "! Usage does not match the keyUsage extension"
4914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004915run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004916 "$O_SRV -key data_files/server2.key \
4917 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004918 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004919 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4920 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004921 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004922 -C "Processing of the Certificate handshake message failed" \
4923 -c "Ciphersuite is TLS-"
4924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004925run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004926 "$O_SRV -key data_files/server2.key \
4927 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004928 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004929 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4930 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004931 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004932 -c "Processing of the Certificate handshake message failed" \
4933 -C "Ciphersuite is TLS-"
4934
Hanno Becker4a156fc2019-06-14 17:07:06 +01004935requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004936requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004937run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
4938 "$O_SRV -key data_files/server2.key \
4939 -cert data_files/server2.ku-ds.crt" \
4940 "$P_CLI debug_level=1 auth_mode=optional \
4941 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4942 0 \
4943 -c "bad certificate (usage extensions)" \
4944 -C "Processing of the Certificate handshake message failed" \
4945 -c "Ciphersuite is TLS-" \
4946 -c "! Usage does not match the keyUsage extension"
4947
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004948# Tests for keyUsage in leaf certificates, part 3:
4949# server-side checking of client cert
4950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004951run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004952 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004953 "$O_CLI -key data_files/server2.key \
4954 -cert data_files/server2.ku-ds.crt" \
4955 0 \
4956 -S "bad certificate (usage extensions)" \
4957 -S "Processing of the Certificate handshake message failed"
4958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004959run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004960 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004961 "$O_CLI -key data_files/server2.key \
4962 -cert data_files/server2.ku-ke.crt" \
4963 0 \
4964 -s "bad certificate (usage extensions)" \
4965 -S "Processing of the Certificate handshake message failed"
4966
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004967run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004968 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004969 "$O_CLI -key data_files/server2.key \
4970 -cert data_files/server2.ku-ke.crt" \
4971 1 \
4972 -s "bad certificate (usage extensions)" \
4973 -s "Processing of the Certificate handshake message failed"
4974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004975run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004976 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004977 "$O_CLI -key data_files/server5.key \
4978 -cert data_files/server5.ku-ds.crt" \
4979 0 \
4980 -S "bad certificate (usage extensions)" \
4981 -S "Processing of the Certificate handshake message failed"
4982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004983run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004984 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004985 "$O_CLI -key data_files/server5.key \
4986 -cert data_files/server5.ku-ka.crt" \
4987 0 \
4988 -s "bad certificate (usage extensions)" \
4989 -S "Processing of the Certificate handshake message failed"
4990
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004991# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
4992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004993run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004994 "$P_SRV key_file=data_files/server5.key \
4995 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004996 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004997 0
4998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004999run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005000 "$P_SRV key_file=data_files/server5.key \
5001 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005002 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005003 0
5004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005005run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005006 "$P_SRV key_file=data_files/server5.key \
5007 crt_file=data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005008 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005009 0
5010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005011run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005012 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005013 crt_file=data_files/server5.eku-cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005014 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005015 1
5016
5017# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005019run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005020 "$O_SRV -key data_files/server5.key \
5021 -cert data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005022 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005023 0 \
5024 -C "bad certificate (usage extensions)" \
5025 -C "Processing of the Certificate handshake message failed" \
5026 -c "Ciphersuite is TLS-"
5027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005028run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005029 "$O_SRV -key data_files/server5.key \
5030 -cert data_files/server5.eku-srv_cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005031 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005032 0 \
5033 -C "bad certificate (usage extensions)" \
5034 -C "Processing of the Certificate handshake message failed" \
5035 -c "Ciphersuite is TLS-"
5036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005037run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005038 "$O_SRV -key data_files/server5.key \
5039 -cert data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005040 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005041 0 \
5042 -C "bad certificate (usage extensions)" \
5043 -C "Processing of the Certificate handshake message failed" \
5044 -c "Ciphersuite is TLS-"
5045
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005046run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005047 "$O_SRV -key data_files/server5.key \
5048 -cert data_files/server5.eku-cs.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005049 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005050 1 \
5051 -c "bad certificate (usage extensions)" \
5052 -c "Processing of the Certificate handshake message failed" \
5053 -C "Ciphersuite is TLS-"
5054
5055# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005057run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005058 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005059 "$O_CLI -key data_files/server5.key \
5060 -cert data_files/server5.eku-cli.crt" \
5061 0 \
5062 -S "bad certificate (usage extensions)" \
5063 -S "Processing of the Certificate handshake message failed"
5064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005065run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005066 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005067 "$O_CLI -key data_files/server5.key \
5068 -cert data_files/server5.eku-srv_cli.crt" \
5069 0 \
5070 -S "bad certificate (usage extensions)" \
5071 -S "Processing of the Certificate handshake message failed"
5072
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005073run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005074 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005075 "$O_CLI -key data_files/server5.key \
5076 -cert data_files/server5.eku-cs_any.crt" \
5077 0 \
5078 -S "bad certificate (usage extensions)" \
5079 -S "Processing of the Certificate handshake message failed"
5080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005081run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005082 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005083 "$O_CLI -key data_files/server5.key \
5084 -cert data_files/server5.eku-cs.crt" \
5085 0 \
5086 -s "bad certificate (usage extensions)" \
5087 -S "Processing of the Certificate handshake message failed"
5088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005089run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005090 "$P_SRV debug_level=1 auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005091 "$O_CLI -key data_files/server5.key \
5092 -cert data_files/server5.eku-cs.crt" \
5093 1 \
5094 -s "bad certificate (usage extensions)" \
5095 -s "Processing of the Certificate handshake message failed"
5096
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005097# Tests for DHM parameters loading
5098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005099run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005100 "$P_SRV" \
5101 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5102 debug_level=3" \
5103 0 \
5104 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005105 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005107run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005108 "$P_SRV dhm_file=data_files/dhparams.pem" \
5109 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5110 debug_level=3" \
5111 0 \
5112 -c "value of 'DHM: P ' (1024 bits)" \
5113 -c "value of 'DHM: G ' (2 bits)"
5114
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005115# Tests for DHM client-side size checking
5116
5117run_test "DHM size: server default, client default, OK" \
5118 "$P_SRV" \
5119 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5120 debug_level=1" \
5121 0 \
5122 -C "DHM prime too short:"
5123
5124run_test "DHM size: server default, client 2048, OK" \
5125 "$P_SRV" \
5126 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5127 debug_level=1 dhmlen=2048" \
5128 0 \
5129 -C "DHM prime too short:"
5130
5131run_test "DHM size: server 1024, client default, OK" \
5132 "$P_SRV dhm_file=data_files/dhparams.pem" \
5133 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5134 debug_level=1" \
5135 0 \
5136 -C "DHM prime too short:"
5137
5138run_test "DHM size: server 1000, client default, rejected" \
5139 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5140 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5141 debug_level=1" \
5142 1 \
5143 -c "DHM prime too short:"
5144
5145run_test "DHM size: server default, client 2049, rejected" \
5146 "$P_SRV" \
5147 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5148 debug_level=1 dhmlen=2049" \
5149 1 \
5150 -c "DHM prime too short:"
5151
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005152# Tests for PSK callback
5153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005154run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005155 "$P_SRV psk=abc123 psk_identity=foo" \
5156 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5157 psk_identity=foo psk=abc123" \
5158 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005159 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005160 -S "SSL - Unknown identity received" \
5161 -S "SSL - Verification of the message MAC failed"
5162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005163run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005164 "$P_SRV" \
5165 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5166 psk_identity=foo psk=abc123" \
5167 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005168 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005169 -S "SSL - Unknown identity received" \
5170 -S "SSL - Verification of the message MAC failed"
5171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005172run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005173 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5174 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5175 psk_identity=foo psk=abc123" \
5176 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005177 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005178 -s "SSL - Unknown identity received" \
5179 -S "SSL - Verification of the message MAC failed"
5180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005181run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005182 "$P_SRV psk_list=abc,dead,def,beef" \
5183 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5184 psk_identity=abc psk=dead" \
5185 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005186 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005187 -S "SSL - Unknown identity received" \
5188 -S "SSL - Verification of the message MAC failed"
5189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005190run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005191 "$P_SRV psk_list=abc,dead,def,beef" \
5192 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5193 psk_identity=def psk=beef" \
5194 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005195 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005196 -S "SSL - Unknown identity received" \
5197 -S "SSL - Verification of the message MAC failed"
5198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005199run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005200 "$P_SRV psk_list=abc,dead,def,beef" \
5201 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5202 psk_identity=ghi psk=beef" \
5203 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005204 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005205 -s "SSL - Unknown identity received" \
5206 -S "SSL - Verification of the message MAC failed"
5207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005208run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005209 "$P_SRV psk_list=abc,dead,def,beef" \
5210 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5211 psk_identity=abc psk=beef" \
5212 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005213 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005214 -S "SSL - Unknown identity received" \
5215 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005216
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005217# Tests for EC J-PAKE
5218
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005219requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005220run_test "ECJPAKE: client not configured" \
5221 "$P_SRV debug_level=3" \
5222 "$P_CLI debug_level=3" \
5223 0 \
5224 -C "add ciphersuite: c0ff" \
5225 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005226 -S "found ecjpake kkpp extension" \
5227 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005228 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005229 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005230 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005231 -S "None of the common ciphersuites is usable"
5232
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005233requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005234run_test "ECJPAKE: server not configured" \
5235 "$P_SRV debug_level=3" \
5236 "$P_CLI debug_level=3 ecjpake_pw=bla \
5237 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5238 1 \
5239 -c "add ciphersuite: c0ff" \
5240 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005241 -s "found ecjpake kkpp extension" \
5242 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005243 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005244 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005245 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005246 -s "None of the common ciphersuites is usable"
5247
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005248requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005249run_test "ECJPAKE: working, TLS" \
5250 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5251 "$P_CLI debug_level=3 ecjpake_pw=bla \
5252 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005253 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005254 -c "add ciphersuite: c0ff" \
5255 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005256 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005257 -s "found ecjpake kkpp extension" \
5258 -S "skip ecjpake kkpp extension" \
5259 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005260 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005261 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005262 -S "None of the common ciphersuites is usable" \
5263 -S "SSL - Verification of the message MAC failed"
5264
Janos Follath74537a62016-09-02 13:45:28 +01005265server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005266requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005267run_test "ECJPAKE: password mismatch, TLS" \
5268 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5269 "$P_CLI debug_level=3 ecjpake_pw=bad \
5270 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5271 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005272 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005273 -s "SSL - Verification of the message MAC failed"
5274
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005275requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005276run_test "ECJPAKE: working, DTLS" \
5277 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5278 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5279 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5280 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005281 -c "re-using cached ecjpake parameters" \
5282 -S "SSL - Verification of the message MAC failed"
5283
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005284requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005285run_test "ECJPAKE: working, DTLS, no cookie" \
5286 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5287 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5288 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5289 0 \
5290 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005291 -S "SSL - Verification of the message MAC failed"
5292
Janos Follath74537a62016-09-02 13:45:28 +01005293server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005294requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005295run_test "ECJPAKE: password mismatch, DTLS" \
5296 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5297 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5298 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5299 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005300 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005301 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005302
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005303# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005304requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005305run_test "ECJPAKE: working, DTLS, nolog" \
5306 "$P_SRV dtls=1 ecjpake_pw=bla" \
5307 "$P_CLI dtls=1 ecjpake_pw=bla \
5308 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5309 0
5310
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005311# Tests for ciphersuites per version
5312
Janos Follathe2681a42016-03-07 15:57:05 +00005313requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005314requires_config_enabled MBEDTLS_CAMELLIA_C
5315requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005316run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005317 "$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 +02005318 "$P_CLI force_version=ssl3" \
5319 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005320 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005321
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005322requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5323requires_config_enabled MBEDTLS_CAMELLIA_C
5324requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005325run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005326 "$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 +01005327 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005328 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005329 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005330
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005331requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5332requires_config_enabled MBEDTLS_CAMELLIA_C
5333requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005334run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005335 "$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 +02005336 "$P_CLI force_version=tls1_1" \
5337 0 \
5338 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5339
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005340requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5341requires_config_enabled MBEDTLS_CAMELLIA_C
5342requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005343run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005344 "$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 +02005345 "$P_CLI force_version=tls1_2" \
5346 0 \
5347 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5348
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005349# Test for ClientHello without extensions
5350
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005351requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005352run_test "ClientHello without extensions, SHA-1 allowed" \
Ron Eldorb76e7652019-01-16 23:14:41 +02005353 "$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 +02005354 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005355 0 \
5356 -s "dumping 'client hello extensions' (0 bytes)"
5357
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005358requires_gnutls
5359run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
5360 "$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 +02005361 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005362 0 \
5363 -s "dumping 'client hello extensions' (0 bytes)"
5364
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005365# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005366
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005367run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005368 "$P_SRV" \
5369 "$P_CLI request_size=100" \
5370 0 \
5371 -s "Read from client: 100 bytes read$"
5372
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005373run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005374 "$P_SRV" \
5375 "$P_CLI request_size=500" \
5376 0 \
5377 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005378
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005379# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005380
Janos Follathe2681a42016-03-07 15:57:05 +00005381requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005382run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005383 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005384 "$P_CLI request_size=1 force_version=ssl3 \
5385 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5386 0 \
5387 -s "Read from client: 1 bytes read"
5388
Janos Follathe2681a42016-03-07 15:57:05 +00005389requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005390run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005391 "$P_SRV min_version=ssl3 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=ssl3 \
5393 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 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005398 "$P_SRV" \
5399 "$P_CLI request_size=1 force_version=tls1 \
5400 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5401 0 \
5402 -s "Read from client: 1 bytes read"
5403
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005404run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005405 "$P_SRV" \
5406 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5407 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5408 0 \
5409 -s "Read from client: 1 bytes read"
5410
Hanno Becker32c55012017-11-10 08:42:54 +00005411requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005412run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005413 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005414 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005415 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005416 0 \
5417 -s "Read from client: 1 bytes read"
5418
Hanno Becker32c55012017-11-10 08:42:54 +00005419requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005420run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005421 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005422 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005423 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005424 0 \
5425 -s "Read from client: 1 bytes read"
5426
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005427run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005428 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005429 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005430 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5431 0 \
5432 -s "Read from client: 1 bytes read"
5433
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005434run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005435 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5436 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005437 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005438 0 \
5439 -s "Read from client: 1 bytes read"
5440
5441requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005442run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005443 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005444 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005445 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005446 0 \
5447 -s "Read from client: 1 bytes read"
5448
Hanno Becker8501f982017-11-10 08:59:04 +00005449requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005450run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005451 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5452 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5453 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005454 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 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005458 "$P_SRV" \
5459 "$P_CLI request_size=1 force_version=tls1_1 \
5460 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5461 0 \
5462 -s "Read from client: 1 bytes read"
5463
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005464run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005465 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005466 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005467 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005468 0 \
5469 -s "Read from client: 1 bytes read"
5470
5471requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005472run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005473 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005474 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005475 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005476 0 \
5477 -s "Read from client: 1 bytes read"
5478
5479requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005480run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005481 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005482 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005483 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005484 0 \
5485 -s "Read from client: 1 bytes read"
5486
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005487run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005488 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005489 "$P_CLI request_size=1 force_version=tls1_1 \
5490 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5491 0 \
5492 -s "Read from client: 1 bytes read"
5493
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005494run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005495 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005496 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005497 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005498 0 \
5499 -s "Read from client: 1 bytes read"
5500
Hanno Becker8501f982017-11-10 08:59:04 +00005501requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005502run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005503 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005504 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005505 force_ciphersuite=TLS-RSA-WITH-RC4-128-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 Becker32c55012017-11-10 08:42:54 +00005509requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005510run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005511 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005512 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005513 force_ciphersuite=TLS-RSA-WITH-RC4-128-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 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005518 "$P_SRV" \
5519 "$P_CLI request_size=1 force_version=tls1_2 \
5520 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-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 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005525 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005526 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005527 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005528 0 \
5529 -s "Read from client: 1 bytes read"
5530
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005531run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005532 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005533 "$P_CLI request_size=1 force_version=tls1_2 \
5534 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005535 0 \
5536 -s "Read from client: 1 bytes read"
5537
Hanno Becker32c55012017-11-10 08:42:54 +00005538requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005539run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005540 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005541 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005542 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005543 0 \
5544 -s "Read from client: 1 bytes read"
5545
Hanno Becker8501f982017-11-10 08:59:04 +00005546requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005547run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005548 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005549 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005550 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005551 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 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005555 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005556 "$P_CLI request_size=1 force_version=tls1_2 \
5557 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5558 0 \
5559 -s "Read from client: 1 bytes read"
5560
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005561run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005562 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005563 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005564 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005565 0 \
5566 -s "Read from client: 1 bytes read"
5567
Hanno Becker32c55012017-11-10 08:42:54 +00005568requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005569run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005570 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005571 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005572 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005573 0 \
5574 -s "Read from client: 1 bytes read"
5575
Hanno Becker8501f982017-11-10 08:59:04 +00005576requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005577run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005578 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005579 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005580 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005581 0 \
5582 -s "Read from client: 1 bytes read"
5583
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005584run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005585 "$P_SRV" \
5586 "$P_CLI request_size=1 force_version=tls1_2 \
5587 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5588 0 \
5589 -s "Read from client: 1 bytes read"
5590
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005591run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005592 "$P_SRV" \
5593 "$P_CLI request_size=1 force_version=tls1_2 \
5594 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5595 0 \
5596 -s "Read from client: 1 bytes read"
5597
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005598# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005599
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005600run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005601 "$P_SRV dtls=1 force_version=dtls1" \
5602 "$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
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005607run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00005608 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
5609 "$P_CLI dtls=1 request_size=1 \
5610 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5611 0 \
5612 -s "Read from client: 1 bytes read"
5613
Hanno Beckere2148042017-11-10 08:59:18 +00005614requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005615run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005616 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
5617 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00005618 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5619 0 \
5620 -s "Read from client: 1 bytes read"
5621
Hanno Beckere2148042017-11-10 08:59:18 +00005622requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005623run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005624 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005625 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005626 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005627 0 \
5628 -s "Read from client: 1 bytes read"
5629
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005630run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00005631 "$P_SRV dtls=1 force_version=dtls1_2" \
5632 "$P_CLI dtls=1 request_size=1 \
5633 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5634 0 \
5635 -s "Read from client: 1 bytes read"
5636
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005637run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005638 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005639 "$P_CLI dtls=1 request_size=1 \
5640 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5641 0 \
5642 -s "Read from client: 1 bytes read"
5643
Hanno Beckere2148042017-11-10 08:59:18 +00005644requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005645run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005646 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005647 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005648 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005649 0 \
5650 -s "Read from client: 1 bytes read"
5651
Hanno Beckere2148042017-11-10 08:59:18 +00005652requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005653run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005654 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005655 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005656 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005657 0 \
5658 -s "Read from client: 1 bytes read"
5659
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005660# Tests for small server packets
5661
5662requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5663run_test "Small server packet SSLv3 BlockCipher" \
5664 "$P_SRV response_size=1 min_version=ssl3" \
5665 "$P_CLI force_version=ssl3 \
5666 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5667 0 \
5668 -c "Read from server: 1 bytes read"
5669
5670requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5671run_test "Small server packet SSLv3 StreamCipher" \
5672 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5673 "$P_CLI force_version=ssl3 \
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 BlockCipher" \
5679 "$P_SRV response_size=1" \
5680 "$P_CLI force_version=tls1 \
5681 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5682 0 \
5683 -c "Read from server: 1 bytes read"
5684
5685run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
5686 "$P_SRV response_size=1" \
5687 "$P_CLI force_version=tls1 etm=0 \
5688 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5689 0 \
5690 -c "Read from server: 1 bytes read"
5691
5692requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5693run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
5694 "$P_SRV response_size=1 trunc_hmac=1" \
5695 "$P_CLI force_version=tls1 \
5696 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5697 0 \
5698 -c "Read from server: 1 bytes read"
5699
5700requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5701run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
5702 "$P_SRV response_size=1 trunc_hmac=1" \
5703 "$P_CLI force_version=tls1 \
5704 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5705 0 \
5706 -c "Read from server: 1 bytes read"
5707
5708run_test "Small server packet TLS 1.0 StreamCipher" \
5709 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5710 "$P_CLI force_version=tls1 \
5711 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5712 0 \
5713 -c "Read from server: 1 bytes read"
5714
5715run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
5716 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5717 "$P_CLI force_version=tls1 \
5718 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5719 0 \
5720 -c "Read from server: 1 bytes read"
5721
5722requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5723run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
5724 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5725 "$P_CLI force_version=tls1 \
5726 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5727 0 \
5728 -c "Read from server: 1 bytes read"
5729
5730requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5731run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5732 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5733 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5734 trunc_hmac=1 etm=0" \
5735 0 \
5736 -c "Read from server: 1 bytes read"
5737
5738run_test "Small server packet TLS 1.1 BlockCipher" \
5739 "$P_SRV response_size=1" \
5740 "$P_CLI force_version=tls1_1 \
5741 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5742 0 \
5743 -c "Read from server: 1 bytes read"
5744
5745run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
5746 "$P_SRV response_size=1" \
5747 "$P_CLI force_version=tls1_1 \
5748 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5749 0 \
5750 -c "Read from server: 1 bytes read"
5751
5752requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5753run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
5754 "$P_SRV response_size=1 trunc_hmac=1" \
5755 "$P_CLI force_version=tls1_1 \
5756 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5757 0 \
5758 -c "Read from server: 1 bytes read"
5759
5760requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5761run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5762 "$P_SRV response_size=1 trunc_hmac=1" \
5763 "$P_CLI force_version=tls1_1 \
5764 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5765 0 \
5766 -c "Read from server: 1 bytes read"
5767
5768run_test "Small server packet TLS 1.1 StreamCipher" \
5769 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5770 "$P_CLI force_version=tls1_1 \
5771 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5772 0 \
5773 -c "Read from server: 1 bytes read"
5774
5775run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
5776 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5777 "$P_CLI force_version=tls1_1 \
5778 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
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.1 StreamCipher, truncated MAC" \
5784 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5785 "$P_CLI force_version=tls1_1 \
5786 force_ciphersuite=TLS-RSA-WITH-RC4-128-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.1 StreamCipher, without EtM, truncated MAC" \
5792 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5793 "$P_CLI force_version=tls1_1 \
5794 force_ciphersuite=TLS-RSA-WITH-RC4-128-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 BlockCipher" \
5799 "$P_SRV response_size=1" \
5800 "$P_CLI force_version=tls1_2 \
5801 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5802 0 \
5803 -c "Read from server: 1 bytes read"
5804
5805run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5806 "$P_SRV response_size=1" \
5807 "$P_CLI force_version=tls1_2 \
5808 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5809 0 \
5810 -c "Read from server: 1 bytes read"
5811
5812run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5813 "$P_SRV response_size=1" \
5814 "$P_CLI force_version=tls1_2 \
5815 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5816 0 \
5817 -c "Read from server: 1 bytes read"
5818
5819requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5820run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5821 "$P_SRV response_size=1 trunc_hmac=1" \
5822 "$P_CLI force_version=tls1_2 \
5823 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5824 0 \
5825 -c "Read from server: 1 bytes read"
5826
5827requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5828run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5829 "$P_SRV response_size=1 trunc_hmac=1" \
5830 "$P_CLI force_version=tls1_2 \
5831 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5832 0 \
5833 -c "Read from server: 1 bytes read"
5834
5835run_test "Small server packet TLS 1.2 StreamCipher" \
5836 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5837 "$P_CLI force_version=tls1_2 \
5838 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5839 0 \
5840 -c "Read from server: 1 bytes read"
5841
5842run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
5843 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5844 "$P_CLI force_version=tls1_2 \
5845 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5846 0 \
5847 -c "Read from server: 1 bytes read"
5848
5849requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5850run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
5851 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5852 "$P_CLI force_version=tls1_2 \
5853 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5854 0 \
5855 -c "Read from server: 1 bytes read"
5856
5857requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5858run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5859 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5860 "$P_CLI force_version=tls1_2 \
5861 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5862 0 \
5863 -c "Read from server: 1 bytes read"
5864
5865run_test "Small server packet TLS 1.2 AEAD" \
5866 "$P_SRV response_size=1" \
5867 "$P_CLI force_version=tls1_2 \
5868 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5869 0 \
5870 -c "Read from server: 1 bytes read"
5871
5872run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5873 "$P_SRV response_size=1" \
5874 "$P_CLI force_version=tls1_2 \
5875 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5876 0 \
5877 -c "Read from server: 1 bytes read"
5878
5879# Tests for small server packets in DTLS
5880
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005881run_test "Small server packet DTLS 1.0" \
5882 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
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 -04005888run_test "Small server packet DTLS 1.0, without EtM" \
5889 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
5890 "$P_CLI dtls=1 \
5891 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5892 0 \
5893 -c "Read from server: 1 bytes read"
5894
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005895requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5896run_test "Small server packet DTLS 1.0, truncated hmac" \
5897 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
5898 "$P_CLI dtls=1 trunc_hmac=1 \
5899 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5900 0 \
5901 -c "Read from server: 1 bytes read"
5902
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005903requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5904run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
5905 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
5906 "$P_CLI dtls=1 \
5907 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5908 0 \
5909 -c "Read from server: 1 bytes read"
5910
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005911run_test "Small server packet DTLS 1.2" \
5912 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
5913 "$P_CLI dtls=1 \
5914 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5915 0 \
5916 -c "Read from server: 1 bytes read"
5917
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005918run_test "Small server packet DTLS 1.2, without EtM" \
5919 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5920 "$P_CLI dtls=1 \
5921 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5922 0 \
5923 -c "Read from server: 1 bytes read"
5924
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005925requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5926run_test "Small server packet DTLS 1.2, truncated hmac" \
5927 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5928 "$P_CLI dtls=1 \
5929 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5930 0 \
5931 -c "Read from server: 1 bytes read"
5932
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005933requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5934run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5935 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5936 "$P_CLI dtls=1 \
5937 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5938 0 \
5939 -c "Read from server: 1 bytes read"
5940
Janos Follath00efff72016-05-06 13:48:23 +01005941# A test for extensions in SSLv3
5942
5943requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5944run_test "SSLv3 with extensions, server side" \
5945 "$P_SRV min_version=ssl3 debug_level=3" \
5946 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
5947 0 \
5948 -S "dumping 'client hello extensions'" \
5949 -S "server hello, total extension length:"
5950
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005951# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005952
Angus Grattonc4dd0732018-04-11 16:28:39 +10005953# How many fragments do we expect to write $1 bytes?
5954fragments_for_write() {
5955 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
5956}
5957
Janos Follathe2681a42016-03-07 15:57:05 +00005958requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005959run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005960 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005961 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005962 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5963 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005964 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5965 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005966
Janos Follathe2681a42016-03-07 15:57:05 +00005967requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005968run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005969 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005970 "$P_CLI request_size=16384 force_version=ssl3 \
5971 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5972 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005973 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5974 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005975
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005976run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005977 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005978 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005979 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5980 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005981 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5982 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005983
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005984run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005985 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005986 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
5987 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5988 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005989 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005990
Hanno Becker32c55012017-11-10 08:42:54 +00005991requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005992run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005993 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005994 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005995 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005996 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005997 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5998 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005999
Hanno Becker32c55012017-11-10 08:42:54 +00006000requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006001run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006002 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006003 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006004 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006005 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006006 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006007
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006008run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006009 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006010 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006011 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6012 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006013 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006014
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006015run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006016 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6017 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006018 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006019 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006020 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006021
6022requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006023run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006024 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006025 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006026 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006027 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006028 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006029
Hanno Becker278fc7a2017-11-10 09:16:28 +00006030requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006031run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006032 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006033 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006034 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006035 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006036 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6037 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006038
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006039run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006040 "$P_SRV" \
6041 "$P_CLI request_size=16384 force_version=tls1_1 \
6042 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6043 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006044 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6045 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006046
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006047run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006048 "$P_SRV" \
6049 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6050 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006051 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006052 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006053
Hanno Becker32c55012017-11-10 08:42:54 +00006054requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006055run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006056 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006057 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006058 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006059 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006060 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006061
Hanno Becker32c55012017-11-10 08:42:54 +00006062requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006063run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006064 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006065 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006066 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006067 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006068 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006069
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006070run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006071 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6072 "$P_CLI request_size=16384 force_version=tls1_1 \
6073 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6074 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006075 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6076 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006077
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006078run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006079 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006080 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006081 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006082 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006083 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6084 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006085
Hanno Becker278fc7a2017-11-10 09:16:28 +00006086requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006087run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006088 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006089 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006090 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006091 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006092 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006093
Hanno Becker278fc7a2017-11-10 09:16:28 +00006094requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006095run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006096 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006097 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006098 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006099 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006100 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6101 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006102
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006103run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006104 "$P_SRV" \
6105 "$P_CLI request_size=16384 force_version=tls1_2 \
6106 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6107 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006108 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6109 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006110
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006111run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006112 "$P_SRV" \
6113 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6114 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6115 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006116 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006117
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006118run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006119 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006120 "$P_CLI request_size=16384 force_version=tls1_2 \
6121 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006122 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006123 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6124 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006125
Hanno Becker32c55012017-11-10 08:42:54 +00006126requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006127run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006128 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006129 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006130 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006131 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006132 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006133
Hanno Becker278fc7a2017-11-10 09:16:28 +00006134requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006135run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006136 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006137 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006138 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006139 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006140 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6141 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006142
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006143run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006144 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006145 "$P_CLI request_size=16384 force_version=tls1_2 \
6146 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6147 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006148 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6149 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006150
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006151run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006152 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006153 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006154 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6155 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006156 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006157
Hanno Becker32c55012017-11-10 08:42:54 +00006158requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006159run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006160 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006161 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006162 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006163 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006164 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006165
Hanno Becker278fc7a2017-11-10 09:16:28 +00006166requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006167run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006168 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006169 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006170 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006171 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006172 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6173 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006174
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006175run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006176 "$P_SRV" \
6177 "$P_CLI request_size=16384 force_version=tls1_2 \
6178 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6179 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006180 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6181 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006182
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006183run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006184 "$P_SRV" \
6185 "$P_CLI request_size=16384 force_version=tls1_2 \
6186 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6187 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006188 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6189 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006190
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006191# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006192requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6193run_test "Large server packet SSLv3 StreamCipher" \
6194 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6195 "$P_CLI force_version=ssl3 \
6196 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6197 0 \
6198 -c "Read from server: 16384 bytes read"
6199
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006200# Checking next 4 tests logs for 1n-1 split against BEAST too
6201requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6202run_test "Large server packet SSLv3 BlockCipher" \
6203 "$P_SRV response_size=16384 min_version=ssl3" \
6204 "$P_CLI force_version=ssl3 recsplit=0 \
6205 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6206 0 \
6207 -c "Read from server: 1 bytes read"\
6208 -c "16383 bytes read"\
6209 -C "Read from server: 16384 bytes read"
6210
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006211run_test "Large server packet TLS 1.0 BlockCipher" \
6212 "$P_SRV response_size=16384" \
6213 "$P_CLI force_version=tls1 recsplit=0 \
6214 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6215 0 \
6216 -c "Read from server: 1 bytes read"\
6217 -c "16383 bytes read"\
6218 -C "Read from server: 16384 bytes read"
6219
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006220run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6221 "$P_SRV response_size=16384" \
6222 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6223 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6224 0 \
6225 -c "Read from server: 1 bytes read"\
6226 -c "16383 bytes read"\
6227 -C "Read from server: 16384 bytes read"
6228
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006229requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6230run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6231 "$P_SRV response_size=16384" \
6232 "$P_CLI force_version=tls1 recsplit=0 \
6233 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6234 trunc_hmac=1" \
6235 0 \
6236 -c "Read from server: 1 bytes read"\
6237 -c "16383 bytes read"\
6238 -C "Read from server: 16384 bytes read"
6239
6240requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6241run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6242 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6243 "$P_CLI force_version=tls1 \
6244 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6245 trunc_hmac=1" \
6246 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006247 -s "16384 bytes written in 1 fragments" \
6248 -c "Read from server: 16384 bytes read"
6249
6250run_test "Large server packet TLS 1.0 StreamCipher" \
6251 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6252 "$P_CLI force_version=tls1 \
6253 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6254 0 \
6255 -s "16384 bytes written in 1 fragments" \
6256 -c "Read from server: 16384 bytes read"
6257
6258run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6259 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6260 "$P_CLI force_version=tls1 \
6261 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6262 0 \
6263 -s "16384 bytes written in 1 fragments" \
6264 -c "Read from server: 16384 bytes read"
6265
6266requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6267run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6268 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6269 "$P_CLI force_version=tls1 \
6270 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6271 0 \
6272 -s "16384 bytes written in 1 fragments" \
6273 -c "Read from server: 16384 bytes read"
6274
6275requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6276run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6277 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6278 "$P_CLI force_version=tls1 \
6279 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6280 0 \
6281 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006282 -c "Read from server: 16384 bytes read"
6283
6284run_test "Large server packet TLS 1.1 BlockCipher" \
6285 "$P_SRV response_size=16384" \
6286 "$P_CLI force_version=tls1_1 \
6287 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6288 0 \
6289 -c "Read from server: 16384 bytes read"
6290
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006291run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6292 "$P_SRV response_size=16384" \
6293 "$P_CLI force_version=tls1_1 etm=0 \
6294 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006295 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006296 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006297 -c "Read from server: 16384 bytes read"
6298
6299requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6300run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6301 "$P_SRV response_size=16384" \
6302 "$P_CLI force_version=tls1_1 \
6303 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6304 trunc_hmac=1" \
6305 0 \
6306 -c "Read from server: 16384 bytes read"
6307
6308requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006309run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6310 "$P_SRV response_size=16384 trunc_hmac=1" \
6311 "$P_CLI force_version=tls1_1 \
6312 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6313 0 \
6314 -s "16384 bytes written in 1 fragments" \
6315 -c "Read from server: 16384 bytes read"
6316
6317run_test "Large server packet TLS 1.1 StreamCipher" \
6318 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6319 "$P_CLI force_version=tls1_1 \
6320 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6321 0 \
6322 -c "Read from server: 16384 bytes read"
6323
6324run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6325 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6326 "$P_CLI force_version=tls1_1 \
6327 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6328 0 \
6329 -s "16384 bytes written in 1 fragments" \
6330 -c "Read from server: 16384 bytes read"
6331
6332requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006333run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6334 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6335 "$P_CLI force_version=tls1_1 \
6336 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6337 trunc_hmac=1" \
6338 0 \
6339 -c "Read from server: 16384 bytes read"
6340
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006341run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6342 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6343 "$P_CLI force_version=tls1_1 \
6344 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6345 0 \
6346 -s "16384 bytes written in 1 fragments" \
6347 -c "Read from server: 16384 bytes read"
6348
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006349run_test "Large server packet TLS 1.2 BlockCipher" \
6350 "$P_SRV response_size=16384" \
6351 "$P_CLI force_version=tls1_2 \
6352 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6353 0 \
6354 -c "Read from server: 16384 bytes read"
6355
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006356run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6357 "$P_SRV response_size=16384" \
6358 "$P_CLI force_version=tls1_2 etm=0 \
6359 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6360 0 \
6361 -s "16384 bytes written in 1 fragments" \
6362 -c "Read from server: 16384 bytes read"
6363
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006364run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6365 "$P_SRV response_size=16384" \
6366 "$P_CLI force_version=tls1_2 \
6367 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6368 0 \
6369 -c "Read from server: 16384 bytes read"
6370
6371requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6372run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6373 "$P_SRV response_size=16384" \
6374 "$P_CLI force_version=tls1_2 \
6375 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6376 trunc_hmac=1" \
6377 0 \
6378 -c "Read from server: 16384 bytes read"
6379
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006380run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6381 "$P_SRV response_size=16384 trunc_hmac=1" \
6382 "$P_CLI force_version=tls1_2 \
6383 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6384 0 \
6385 -s "16384 bytes written in 1 fragments" \
6386 -c "Read from server: 16384 bytes read"
6387
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006388run_test "Large server packet TLS 1.2 StreamCipher" \
6389 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6390 "$P_CLI force_version=tls1_2 \
6391 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6392 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006393 -s "16384 bytes written in 1 fragments" \
6394 -c "Read from server: 16384 bytes read"
6395
6396run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6397 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6398 "$P_CLI force_version=tls1_2 \
6399 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6400 0 \
6401 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006402 -c "Read from server: 16384 bytes read"
6403
6404requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6405run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6406 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6407 "$P_CLI force_version=tls1_2 \
6408 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6409 trunc_hmac=1" \
6410 0 \
6411 -c "Read from server: 16384 bytes read"
6412
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006413requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6414run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6415 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6416 "$P_CLI force_version=tls1_2 \
6417 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6418 0 \
6419 -s "16384 bytes written in 1 fragments" \
6420 -c "Read from server: 16384 bytes read"
6421
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006422run_test "Large server packet TLS 1.2 AEAD" \
6423 "$P_SRV response_size=16384" \
6424 "$P_CLI force_version=tls1_2 \
6425 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6426 0 \
6427 -c "Read from server: 16384 bytes read"
6428
6429run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6430 "$P_SRV response_size=16384" \
6431 "$P_CLI force_version=tls1_2 \
6432 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6433 0 \
6434 -c "Read from server: 16384 bytes read"
6435
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006436# Tests for restartable ECC
6437
6438requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6439run_test "EC restart: TLS, default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006440 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006441 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006442 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006443 debug_level=1" \
6444 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006445 -C "x509_verify_cert.*4b00" \
6446 -C "mbedtls_pk_verify.*4b00" \
6447 -C "mbedtls_ecdh_make_public.*4b00" \
6448 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006449
6450requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6451run_test "EC restart: TLS, max_ops=0" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006452 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006453 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006454 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006455 debug_level=1 ec_max_ops=0" \
6456 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006457 -C "x509_verify_cert.*4b00" \
6458 -C "mbedtls_pk_verify.*4b00" \
6459 -C "mbedtls_ecdh_make_public.*4b00" \
6460 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006461
6462requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6463run_test "EC restart: TLS, max_ops=65535" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006464 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006465 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006466 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006467 debug_level=1 ec_max_ops=65535" \
6468 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006469 -C "x509_verify_cert.*4b00" \
6470 -C "mbedtls_pk_verify.*4b00" \
6471 -C "mbedtls_ecdh_make_public.*4b00" \
6472 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006473
6474requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6475run_test "EC restart: TLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006476 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006477 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006478 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006479 debug_level=1 ec_max_ops=1000" \
6480 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006481 -c "x509_verify_cert.*4b00" \
6482 -c "mbedtls_pk_verify.*4b00" \
6483 -c "mbedtls_ecdh_make_public.*4b00" \
6484 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006485
6486requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Hanno Becker4a156fc2019-06-14 17:07:06 +01006487requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006488run_test "EC restart: TLS, max_ops=1000, badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006489 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006490 crt_file=data_files/server5-badsign.crt \
6491 key_file=data_files/server5.key" \
6492 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker03d77462019-08-27 16:24:56 +01006493 key_file=data_files/server5.key crt_file=data_files/server5.crt ca_file=data_files/test-ca2.crt \
6494 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6495 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006496 -c "x509_verify_cert.*4b00" \
Hanno Becker03d77462019-08-27 16:24:56 +01006497 -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" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006501
Hanno Becker4a156fc2019-06-14 17:07:06 +01006502requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006503requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6504run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006505 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006506 crt_file=data_files/server5-badsign.crt \
6507 key_file=data_files/server5.key" \
6508 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6509 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006510 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006511 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6512 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006513 -c "x509_verify_cert.*4b00" \
6514 -c "mbedtls_pk_verify.*4b00" \
6515 -c "mbedtls_ecdh_make_public.*4b00" \
6516 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006517 -c "! The certificate is not correctly signed by the trusted CA" \
6518 -C "! mbedtls_ssl_handshake returned" \
6519 -C "X509 - Certificate verification failed"
6520
Hanno Becker4a156fc2019-06-14 17:07:06 +01006521requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006522requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006523requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6524run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006525 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006526 crt_file=data_files/server5-badsign.crt \
6527 key_file=data_files/server5.key" \
6528 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006529 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006530 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6531 debug_level=1 ec_max_ops=1000 auth_mode=none" \
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é-Gonnard3bf49c42017-08-15 13:47:06 +02006537 -C "! The certificate is not correctly signed by the trusted CA" \
6538 -C "! mbedtls_ssl_handshake returned" \
6539 -C "X509 - Certificate verification failed"
6540
6541requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006542run_test "EC restart: DTLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006543 "$P_SRV auth_mode=required dtls=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006544 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006545 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006546 dtls=1 debug_level=1 ec_max_ops=1000" \
6547 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006548 -c "x509_verify_cert.*4b00" \
6549 -c "mbedtls_pk_verify.*4b00" \
6550 -c "mbedtls_ecdh_make_public.*4b00" \
6551 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006552
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006553requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6554run_test "EC restart: TLS, max_ops=1000 no client auth" \
6555 "$P_SRV" \
6556 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6557 debug_level=1 ec_max_ops=1000" \
6558 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006559 -c "x509_verify_cert.*4b00" \
6560 -c "mbedtls_pk_verify.*4b00" \
6561 -c "mbedtls_ecdh_make_public.*4b00" \
6562 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006563
6564requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6565run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6566 "$P_SRV psk=abc123" \
6567 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6568 psk=abc123 debug_level=1 ec_max_ops=1000" \
6569 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006570 -C "x509_verify_cert.*4b00" \
6571 -C "mbedtls_pk_verify.*4b00" \
6572 -C "mbedtls_ecdh_make_public.*4b00" \
6573 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006574
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006575# Tests of asynchronous private key support in SSL
6576
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006577requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006578run_test "SSL async private: sign, delay=0" \
6579 "$P_SRV \
6580 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006581 "$P_CLI" \
6582 0 \
6583 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006584 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006585
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006586requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006587run_test "SSL async private: sign, delay=1" \
6588 "$P_SRV \
6589 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006590 "$P_CLI" \
6591 0 \
6592 -s "Async sign callback: using key slot " \
6593 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006594 -s "Async resume (slot [0-9]): sign done, status=0"
6595
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006596requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6597run_test "SSL async private: sign, delay=2" \
6598 "$P_SRV \
6599 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6600 "$P_CLI" \
6601 0 \
6602 -s "Async sign callback: using key slot " \
6603 -U "Async sign callback: using key slot " \
6604 -s "Async resume (slot [0-9]): call 1 more times." \
6605 -s "Async resume (slot [0-9]): call 0 more times." \
6606 -s "Async resume (slot [0-9]): sign done, status=0"
6607
Gilles Peskined3268832018-04-26 06:23:59 +02006608# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
6609# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
6610requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6611requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6612run_test "SSL async private: sign, RSA, TLS 1.1" \
6613 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
6614 async_operations=s async_private_delay1=0 async_private_delay2=0" \
6615 "$P_CLI force_version=tls1_1" \
6616 0 \
6617 -s "Async sign callback: using key slot " \
6618 -s "Async resume (slot [0-9]): sign done, status=0"
6619
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006620requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerb2c63832019-06-17 08:35:16 +01006621requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03006622requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006623requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskine807d74a2018-04-30 10:30:49 +02006624run_test "SSL async private: sign, SNI" \
6625 "$P_SRV debug_level=3 \
6626 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6627 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6628 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6629 "$P_CLI server_name=polarssl.example" \
6630 0 \
6631 -s "Async sign callback: using key slot " \
6632 -s "Async resume (slot [0-9]): sign done, status=0" \
6633 -s "parse ServerName extension" \
6634 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6635 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6636
6637requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006638run_test "SSL async private: decrypt, delay=0" \
6639 "$P_SRV \
6640 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6641 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6642 0 \
6643 -s "Async decrypt callback: using key slot " \
6644 -s "Async resume (slot [0-9]): decrypt done, status=0"
6645
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006646requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006647run_test "SSL async private: decrypt, delay=1" \
6648 "$P_SRV \
6649 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6650 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6651 0 \
6652 -s "Async decrypt callback: using key slot " \
6653 -s "Async resume (slot [0-9]): call 0 more times." \
6654 -s "Async resume (slot [0-9]): decrypt done, status=0"
6655
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006656requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006657run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6658 "$P_SRV psk=abc123 \
6659 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6660 "$P_CLI psk=abc123 \
6661 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6662 0 \
6663 -s "Async decrypt callback: using key slot " \
6664 -s "Async resume (slot [0-9]): decrypt done, status=0"
6665
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006666requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006667run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6668 "$P_SRV psk=abc123 \
6669 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6670 "$P_CLI psk=abc123 \
6671 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6672 0 \
6673 -s "Async decrypt callback: using key slot " \
6674 -s "Async resume (slot [0-9]): call 0 more times." \
6675 -s "Async resume (slot [0-9]): decrypt done, status=0"
6676
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006677requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006678run_test "SSL async private: sign callback not present" \
6679 "$P_SRV \
6680 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6681 "$P_CLI; [ \$? -eq 1 ] &&
6682 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6683 0 \
6684 -S "Async sign callback" \
6685 -s "! mbedtls_ssl_handshake returned" \
6686 -s "The own private key or pre-shared key is not set, but needed" \
6687 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6688 -s "Successful connection"
6689
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006690requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006691run_test "SSL async private: decrypt callback not present" \
6692 "$P_SRV debug_level=1 \
6693 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6694 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6695 [ \$? -eq 1 ] && $P_CLI" \
6696 0 \
6697 -S "Async decrypt callback" \
6698 -s "! mbedtls_ssl_handshake returned" \
6699 -s "got no RSA private key" \
6700 -s "Async resume (slot [0-9]): sign done, status=0" \
6701 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006702
6703# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006704requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006705run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006706 "$P_SRV \
6707 async_operations=s async_private_delay1=1 \
6708 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6709 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006710 "$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 +01006711 0 \
6712 -s "Async sign callback: using key slot 0," \
6713 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006714 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006715
6716# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006717requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006718run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006719 "$P_SRV \
6720 async_operations=s async_private_delay2=1 \
6721 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6722 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006723 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6724 0 \
6725 -s "Async sign callback: using key slot 0," \
6726 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006727 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006728
6729# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006730requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006731run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006732 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006733 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006734 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6735 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006736 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6737 0 \
6738 -s "Async sign callback: using key slot 1," \
6739 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006740 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006741
6742# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006743requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006744run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006745 "$P_SRV \
6746 async_operations=s async_private_delay1=1 \
6747 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6748 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006749 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6750 0 \
6751 -s "Async sign callback: no key matches this certificate."
6752
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006753requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006754run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006755 "$P_SRV \
6756 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6757 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006758 "$P_CLI" \
6759 1 \
6760 -s "Async sign callback: injected error" \
6761 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006762 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006763 -s "! mbedtls_ssl_handshake returned"
6764
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006765requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006766run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006767 "$P_SRV \
6768 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6769 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006770 "$P_CLI" \
6771 1 \
6772 -s "Async sign callback: using key slot " \
6773 -S "Async resume" \
6774 -s "Async cancel"
6775
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006776requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006777run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006778 "$P_SRV \
6779 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6780 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006781 "$P_CLI" \
6782 1 \
6783 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006784 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006785 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006786 -s "! mbedtls_ssl_handshake returned"
6787
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006788requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006789run_test "SSL async private: decrypt, error in start" \
6790 "$P_SRV \
6791 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6792 async_private_error=1" \
6793 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6794 1 \
6795 -s "Async decrypt callback: injected error" \
6796 -S "Async resume" \
6797 -S "Async cancel" \
6798 -s "! mbedtls_ssl_handshake returned"
6799
6800requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6801run_test "SSL async private: decrypt, cancel after start" \
6802 "$P_SRV \
6803 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6804 async_private_error=2" \
6805 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6806 1 \
6807 -s "Async decrypt callback: using key slot " \
6808 -S "Async resume" \
6809 -s "Async cancel"
6810
6811requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6812run_test "SSL async private: decrypt, error in resume" \
6813 "$P_SRV \
6814 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6815 async_private_error=3" \
6816 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6817 1 \
6818 -s "Async decrypt callback: using key slot " \
6819 -s "Async resume callback: decrypt done but injected error" \
6820 -S "Async cancel" \
6821 -s "! mbedtls_ssl_handshake returned"
6822
6823requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006824run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006825 "$P_SRV \
6826 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6827 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006828 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6829 0 \
6830 -s "Async cancel" \
6831 -s "! mbedtls_ssl_handshake returned" \
6832 -s "Async resume" \
6833 -s "Successful connection"
6834
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006835requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006836run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006837 "$P_SRV \
6838 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6839 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006840 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6841 0 \
6842 -s "! mbedtls_ssl_handshake returned" \
6843 -s "Async resume" \
6844 -s "Successful connection"
6845
6846# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006847requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006848run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006849 "$P_SRV \
6850 async_operations=s async_private_delay1=1 async_private_error=-2 \
6851 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6852 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006853 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6854 [ \$? -eq 1 ] &&
6855 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6856 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006857 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006858 -S "Async resume" \
6859 -s "Async cancel" \
6860 -s "! mbedtls_ssl_handshake returned" \
6861 -s "Async sign callback: no key matches this certificate." \
6862 -s "Successful connection"
6863
6864# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006865requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006866run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006867 "$P_SRV \
6868 async_operations=s async_private_delay1=1 async_private_error=-3 \
6869 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6870 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006871 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6872 [ \$? -eq 1 ] &&
6873 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6874 0 \
6875 -s "Async resume" \
6876 -s "! mbedtls_ssl_handshake returned" \
6877 -s "Async sign callback: no key matches this certificate." \
6878 -s "Successful connection"
6879
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006880requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006881requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006882run_test "SSL async private: renegotiation: client-initiated; sign" \
6883 "$P_SRV \
6884 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006885 exchanges=2 renegotiation=1" \
6886 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6887 0 \
6888 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006889 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006890
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006891requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006892requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006893run_test "SSL async private: renegotiation: server-initiated; sign" \
6894 "$P_SRV \
6895 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006896 exchanges=2 renegotiation=1 renegotiate=1" \
6897 "$P_CLI exchanges=2 renegotiation=1" \
6898 0 \
6899 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006900 -s "Async resume (slot [0-9]): sign done, status=0"
6901
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006902requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006903requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6904run_test "SSL async private: renegotiation: client-initiated; decrypt" \
6905 "$P_SRV \
6906 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6907 exchanges=2 renegotiation=1" \
6908 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6909 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6910 0 \
6911 -s "Async decrypt callback: using key slot " \
6912 -s "Async resume (slot [0-9]): decrypt done, status=0"
6913
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006914requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006915requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6916run_test "SSL async private: renegotiation: server-initiated; decrypt" \
6917 "$P_SRV \
6918 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6919 exchanges=2 renegotiation=1 renegotiate=1" \
6920 "$P_CLI exchanges=2 renegotiation=1 \
6921 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6922 0 \
6923 -s "Async decrypt callback: using key slot " \
6924 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006925
Ron Eldor58093c82018-06-28 13:22:05 +03006926# Tests for ECC extensions (rfc 4492)
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_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006932run_test "Force a non ECC ciphersuite in the client side" \
6933 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006934 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006935 0 \
6936 -C "client hello, adding supported_elliptic_curves extension" \
6937 -C "client hello, adding supported_point_formats extension" \
6938 -S "found supported elliptic curves extension" \
6939 -S "found supported point formats extension"
6940
Ron Eldor643df7c2018-06-28 16:17:00 +03006941requires_config_enabled MBEDTLS_AES_C
6942requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6943requires_config_enabled MBEDTLS_SHA256_C
6944requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006945run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006946 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006947 "$P_CLI debug_level=3" \
6948 0 \
6949 -C "found supported_point_formats extension" \
6950 -S "server hello, supported_point_formats extension"
6951
Ron Eldor643df7c2018-06-28 16:17:00 +03006952requires_config_enabled MBEDTLS_AES_C
6953requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6954requires_config_enabled MBEDTLS_SHA256_C
6955requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006956run_test "Force an ECC ciphersuite in the client side" \
6957 "$P_SRV debug_level=3" \
6958 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6959 0 \
6960 -c "client hello, adding supported_elliptic_curves extension" \
6961 -c "client hello, adding supported_point_formats extension" \
6962 -s "found supported elliptic curves extension" \
6963 -s "found supported point formats extension"
6964
Ron Eldor643df7c2018-06-28 16:17:00 +03006965requires_config_enabled MBEDTLS_AES_C
6966requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6967requires_config_enabled MBEDTLS_SHA256_C
6968requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006969run_test "Force an ECC ciphersuite in the server side" \
6970 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6971 "$P_CLI debug_level=3" \
6972 0 \
6973 -c "found supported_point_formats extension" \
6974 -s "server hello, supported_point_formats extension"
6975
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006976# Tests for DTLS HelloVerifyRequest
6977
6978run_test "DTLS cookie: enabled" \
6979 "$P_SRV dtls=1 debug_level=2" \
6980 "$P_CLI dtls=1 debug_level=2" \
6981 0 \
6982 -s "cookie verification failed" \
6983 -s "cookie verification passed" \
6984 -S "cookie verification skipped" \
6985 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006986 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006987 -S "SSL - The requested feature is not available"
6988
6989run_test "DTLS cookie: disabled" \
6990 "$P_SRV dtls=1 debug_level=2 cookies=0" \
6991 "$P_CLI dtls=1 debug_level=2" \
6992 0 \
6993 -S "cookie verification failed" \
6994 -S "cookie verification passed" \
6995 -s "cookie verification skipped" \
6996 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006997 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006998 -S "SSL - The requested feature is not available"
6999
Jarno Lamsa33281d52019-10-18 10:54:35 +03007000requires_config_enabled MBEDTLS_ERROR_C
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007001run_test "DTLS cookie: default (failing)" \
7002 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
7003 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
7004 1 \
7005 -s "cookie verification failed" \
7006 -S "cookie verification passed" \
7007 -S "cookie verification skipped" \
7008 -C "received hello verify request" \
7009 -S "hello verification requested" \
7010 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007011
7012requires_ipv6
7013run_test "DTLS cookie: enabled, IPv6" \
7014 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
7015 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
7016 0 \
7017 -s "cookie verification failed" \
7018 -s "cookie verification passed" \
7019 -S "cookie verification skipped" \
7020 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007021 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007022 -S "SSL - The requested feature is not available"
7023
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007024run_test "DTLS cookie: enabled, nbio" \
7025 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7026 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7027 0 \
7028 -s "cookie verification failed" \
7029 -s "cookie verification passed" \
7030 -S "cookie verification skipped" \
7031 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007032 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007033 -S "SSL - The requested feature is not available"
7034
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007035# Tests for client reconnecting from the same port with DTLS
7036
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007037not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007038requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007039run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007040 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7041 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007042 0 \
7043 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007044 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007045 -S "Client initiated reconnection from same port"
7046
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007047not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007048requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007049run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007050 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7051 "$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 +02007052 0 \
7053 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007054 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007055 -s "Client initiated reconnection from same port"
7056
Paul Bakker362689d2016-05-13 10:33:25 +01007057not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
Jarno Lamsa33281d52019-10-18 10:54:35 +03007058requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007059run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007060 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7061 "$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 +02007062 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007063 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007064 -s "Client initiated reconnection from same port"
7065
Paul Bakker362689d2016-05-13 10:33:25 +01007066only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
Jarno Lamsa33281d52019-10-18 10:54:35 +03007067requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007068run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7069 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7070 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7071 0 \
7072 -S "The operation timed out" \
7073 -s "Client initiated reconnection from same port"
7074
Jarno Lamsa33281d52019-10-18 10:54:35 +03007075requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007076run_test "DTLS client reconnect from same port: no cookies" \
7077 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007078 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7079 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007080 -s "The operation timed out" \
7081 -S "Client initiated reconnection from same port"
7082
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007083# Tests for various cases of client authentication with DTLS
7084# (focused on handshake flows and message parsing)
7085
7086run_test "DTLS client auth: required" \
7087 "$P_SRV dtls=1 auth_mode=required" \
7088 "$P_CLI dtls=1" \
7089 0 \
7090 -s "Verifying peer X.509 certificate... ok"
7091
Hanno Becker4a156fc2019-06-14 17:07:06 +01007092requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007093requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007094run_test "DTLS client auth: optional, client has no cert" \
7095 "$P_SRV dtls=1 auth_mode=optional" \
7096 "$P_CLI dtls=1 crt_file=none key_file=none" \
7097 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007098 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007099
Hanno Becker4a156fc2019-06-14 17:07:06 +01007100requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007101requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007102run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007103 "$P_SRV dtls=1 auth_mode=none" \
7104 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7105 0 \
7106 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007107 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007108
Jarno Lamsa33281d52019-10-18 10:54:35 +03007109requires_ciphersuite_enabled TLS-PSK-WITH-AES-128-GCM-SHA256
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007110run_test "DTLS wrong PSK: badmac alert" \
7111 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7112 "$P_CLI dtls=1 psk=abc124" \
7113 1 \
7114 -s "SSL - Verification of the message MAC failed" \
7115 -c "SSL - A fatal alert message was received from our peer"
7116
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007117# Tests for receiving fragmented handshake messages with DTLS
7118
7119requires_gnutls
7120run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7121 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007122 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007123 0 \
7124 -C "found fragmented DTLS handshake message" \
7125 -C "error"
7126
7127requires_gnutls
7128run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7129 "$G_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007130 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007131 0 \
7132 -c "found fragmented DTLS handshake message" \
7133 -C "error"
7134
7135requires_gnutls
7136run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7137 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007138 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007139 0 \
7140 -c "found fragmented DTLS handshake message" \
7141 -C "error"
7142
7143requires_gnutls
7144run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7145 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007146 "$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 +02007147 0 \
7148 -c "found fragmented DTLS handshake message" \
7149 -C "error"
7150
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007151requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007152requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007153run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7154 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007155 "$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 +02007156 0 \
7157 -c "found fragmented DTLS handshake message" \
7158 -c "client hello, adding renegotiation extension" \
7159 -c "found renegotiation extension" \
7160 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007161 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007162 -C "error" \
7163 -s "Extra-header:"
7164
7165requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007166requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007167run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7168 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007169 "$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 +02007170 0 \
7171 -c "found fragmented DTLS handshake message" \
7172 -c "client hello, adding renegotiation extension" \
7173 -c "found renegotiation extension" \
7174 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007175 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007176 -C "error" \
7177 -s "Extra-header:"
7178
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007179run_test "DTLS reassembly: no fragmentation (openssl server)" \
7180 "$O_SRV -dtls1 -mtu 2048" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007181 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007182 0 \
7183 -C "found fragmented DTLS handshake message" \
7184 -C "error"
7185
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007186run_test "DTLS reassembly: some fragmentation (openssl server)" \
7187 "$O_SRV -dtls1 -mtu 768" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007188 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007189 0 \
7190 -c "found fragmented DTLS handshake message" \
7191 -C "error"
7192
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007193run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007194 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007195 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007196 0 \
7197 -c "found fragmented DTLS handshake message" \
7198 -C "error"
7199
7200run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7201 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007202 "$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 +02007203 0 \
7204 -c "found fragmented DTLS handshake message" \
7205 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007206
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007207# Tests for sending fragmented handshake messages with DTLS
7208#
7209# Use client auth when we need the client to send large messages,
7210# and use large cert chains on both sides too (the long chains we have all use
7211# both RSA and ECDSA, but ideally we should have long chains with either).
7212# Sizes reached (UDP payload):
7213# - 2037B for server certificate
7214# - 1542B for client certificate
7215# - 1013B for newsessionticket
7216# - all others below 512B
7217# All those tests assume MAX_CONTENT_LEN is at least 2048
7218
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007219requires_config_enabled MBEDTLS_RSA_C
7220requires_config_enabled MBEDTLS_ECDSA_C
7221requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7222run_test "DTLS fragmenting: none (for reference)" \
7223 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7224 crt_file=data_files/server7_int-ca.crt \
7225 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007226 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007227 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007228 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007229 "$P_CLI dtls=1 debug_level=2 \
7230 crt_file=data_files/server8_int-ca2.crt \
7231 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007232 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007233 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007234 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007235 0 \
7236 -S "found fragmented DTLS handshake message" \
7237 -C "found fragmented DTLS handshake message" \
7238 -C "error"
7239
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007240requires_config_enabled MBEDTLS_RSA_C
7241requires_config_enabled MBEDTLS_ECDSA_C
7242requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007243run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007244 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7245 crt_file=data_files/server7_int-ca.crt \
7246 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007247 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007248 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007249 max_frag_len=1024" \
7250 "$P_CLI dtls=1 debug_level=2 \
7251 crt_file=data_files/server8_int-ca2.crt \
7252 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007253 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007254 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007255 max_frag_len=2048" \
7256 0 \
7257 -S "found fragmented DTLS handshake message" \
7258 -c "found fragmented DTLS handshake message" \
7259 -C "error"
7260
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007261# With the MFL extension, the server has no way of forcing
7262# the client to not exceed a certain MTU; hence, the following
7263# test can't be replicated with an MTU proxy such as the one
7264# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007265requires_config_enabled MBEDTLS_RSA_C
7266requires_config_enabled MBEDTLS_ECDSA_C
7267requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007268run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007269 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7270 crt_file=data_files/server7_int-ca.crt \
7271 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007272 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007273 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007274 max_frag_len=512" \
7275 "$P_CLI dtls=1 debug_level=2 \
7276 crt_file=data_files/server8_int-ca2.crt \
7277 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007278 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007279 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007280 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007281 0 \
7282 -S "found fragmented DTLS handshake message" \
7283 -c "found fragmented DTLS handshake message" \
7284 -C "error"
7285
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007286requires_config_enabled MBEDTLS_RSA_C
7287requires_config_enabled MBEDTLS_ECDSA_C
7288requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007289run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007290 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7291 crt_file=data_files/server7_int-ca.crt \
7292 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007293 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007294 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007295 max_frag_len=2048" \
7296 "$P_CLI dtls=1 debug_level=2 \
7297 crt_file=data_files/server8_int-ca2.crt \
7298 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007299 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007300 hs_timeout=2500-60000 \
7301 max_frag_len=1024" \
7302 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007303 -S "found fragmented DTLS handshake message" \
7304 -c "found fragmented DTLS handshake message" \
7305 -C "error"
7306
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007307# While not required by the standard defining the MFL extension
7308# (according to which it only applies to records, not to datagrams),
7309# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7310# as otherwise there wouldn't be any means to communicate MTU restrictions
7311# to the peer.
7312# The next test checks that no datagrams significantly larger than the
7313# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007314requires_config_enabled MBEDTLS_RSA_C
7315requires_config_enabled MBEDTLS_ECDSA_C
7316requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7317run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007318 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007319 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7320 crt_file=data_files/server7_int-ca.crt \
7321 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007322 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007323 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007324 max_frag_len=2048" \
7325 "$P_CLI dtls=1 debug_level=2 \
7326 crt_file=data_files/server8_int-ca2.crt \
7327 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007328 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007329 hs_timeout=2500-60000 \
7330 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007331 0 \
7332 -S "found fragmented DTLS handshake message" \
7333 -c "found fragmented DTLS handshake message" \
7334 -C "error"
7335
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007336requires_config_enabled MBEDTLS_RSA_C
7337requires_config_enabled MBEDTLS_ECDSA_C
7338requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007339run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007340 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7341 crt_file=data_files/server7_int-ca.crt \
7342 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007343 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007344 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007345 max_frag_len=2048" \
7346 "$P_CLI dtls=1 debug_level=2 \
7347 crt_file=data_files/server8_int-ca2.crt \
7348 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007349 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007350 hs_timeout=2500-60000 \
7351 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007352 0 \
7353 -s "found fragmented DTLS handshake message" \
7354 -c "found fragmented DTLS handshake message" \
7355 -C "error"
7356
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007357# While not required by the standard defining the MFL extension
7358# (according to which it only applies to records, not to datagrams),
7359# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7360# as otherwise there wouldn't be any means to communicate MTU restrictions
7361# to the peer.
7362# The next test checks that no datagrams significantly larger than the
7363# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007364requires_config_enabled MBEDTLS_RSA_C
7365requires_config_enabled MBEDTLS_ECDSA_C
7366requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7367run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007368 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007369 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7370 crt_file=data_files/server7_int-ca.crt \
7371 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007372 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007373 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007374 max_frag_len=2048" \
7375 "$P_CLI dtls=1 debug_level=2 \
7376 crt_file=data_files/server8_int-ca2.crt \
7377 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007378 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007379 hs_timeout=2500-60000 \
7380 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007381 0 \
7382 -s "found fragmented DTLS handshake message" \
7383 -c "found fragmented DTLS handshake message" \
7384 -C "error"
7385
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007386requires_config_enabled MBEDTLS_RSA_C
7387requires_config_enabled MBEDTLS_ECDSA_C
7388run_test "DTLS fragmenting: none (for reference) (MTU)" \
7389 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7390 crt_file=data_files/server7_int-ca.crt \
7391 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007392 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007393 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007394 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007395 "$P_CLI dtls=1 debug_level=2 \
7396 crt_file=data_files/server8_int-ca2.crt \
7397 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007398 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007399 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007400 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007401 0 \
7402 -S "found fragmented DTLS handshake message" \
7403 -C "found fragmented DTLS handshake message" \
7404 -C "error"
7405
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007406requires_config_enabled MBEDTLS_RSA_C
7407requires_config_enabled MBEDTLS_ECDSA_C
7408run_test "DTLS fragmenting: client (MTU)" \
7409 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7410 crt_file=data_files/server7_int-ca.crt \
7411 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007412 ca_file=data_files/test-ca.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007413 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007414 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007415 "$P_CLI dtls=1 debug_level=2 \
7416 crt_file=data_files/server8_int-ca2.crt \
7417 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007418 ca_file=data_files/test-ca2.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007419 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007420 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007421 0 \
7422 -s "found fragmented DTLS handshake message" \
7423 -C "found fragmented DTLS handshake message" \
7424 -C "error"
7425
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007426requires_config_enabled MBEDTLS_RSA_C
7427requires_config_enabled MBEDTLS_ECDSA_C
7428run_test "DTLS fragmenting: server (MTU)" \
7429 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7430 crt_file=data_files/server7_int-ca.crt \
7431 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007432 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007433 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007434 mtu=512" \
7435 "$P_CLI dtls=1 debug_level=2 \
7436 crt_file=data_files/server8_int-ca2.crt \
7437 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007438 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007439 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007440 mtu=2048" \
7441 0 \
7442 -S "found fragmented DTLS handshake message" \
7443 -c "found fragmented DTLS handshake message" \
7444 -C "error"
7445
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007446requires_config_enabled MBEDTLS_RSA_C
7447requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007448run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007449 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007450 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7451 crt_file=data_files/server7_int-ca.crt \
7452 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007453 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007454 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007455 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007456 "$P_CLI dtls=1 debug_level=2 \
7457 crt_file=data_files/server8_int-ca2.crt \
7458 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007459 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007460 hs_timeout=2500-60000 \
7461 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007462 0 \
7463 -s "found fragmented DTLS handshake message" \
7464 -c "found fragmented DTLS handshake message" \
7465 -C "error"
7466
Andrzej Kurek77826052018-10-11 07:34:08 -04007467# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007468requires_config_enabled MBEDTLS_RSA_C
7469requires_config_enabled MBEDTLS_ECDSA_C
7470requires_config_enabled MBEDTLS_SHA256_C
7471requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7472requires_config_enabled MBEDTLS_AES_C
7473requires_config_enabled MBEDTLS_GCM_C
7474run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007475 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007476 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7477 crt_file=data_files/server7_int-ca.crt \
7478 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007479 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007480 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007481 mtu=512" \
7482 "$P_CLI dtls=1 debug_level=2 \
7483 crt_file=data_files/server8_int-ca2.crt \
7484 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007485 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007486 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7487 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007488 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007489 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007490 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007491 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007492 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007493
Andrzej Kurek7311c782018-10-11 06:49:41 -04007494# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007495# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007496# The ratio of max/min timeout should ideally equal 4 to accept two
7497# retransmissions, but in some cases (like both the server and client using
7498# fragmentation and auto-reduction) an extra retransmission might occur,
7499# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007500not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007501requires_config_enabled MBEDTLS_RSA_C
7502requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007503requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7504requires_config_enabled MBEDTLS_AES_C
7505requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007506run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7507 -p "$P_PXY mtu=508" \
7508 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7509 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007510 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007511 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007512 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007513 "$P_CLI dtls=1 debug_level=2 \
7514 crt_file=data_files/server8_int-ca2.crt \
7515 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007516 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007517 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7518 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007519 0 \
7520 -s "found fragmented DTLS handshake message" \
7521 -c "found fragmented DTLS handshake message" \
7522 -C "error"
7523
Andrzej Kurek77826052018-10-11 07:34:08 -04007524# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007525only_with_valgrind
Hanno Becker108992e2018-08-29 17:04:18 +01007526requires_config_enabled MBEDTLS_RSA_C
7527requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007528requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7529requires_config_enabled MBEDTLS_AES_C
7530requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01007531run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7532 -p "$P_PXY mtu=508" \
7533 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7534 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007535 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007536 ca_file=data_files/test-ca.crt \
Hanno Becker108992e2018-08-29 17:04:18 +01007537 hs_timeout=250-10000" \
7538 "$P_CLI dtls=1 debug_level=2 \
7539 crt_file=data_files/server8_int-ca2.crt \
7540 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007541 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007542 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007543 hs_timeout=250-10000" \
7544 0 \
7545 -s "found fragmented DTLS handshake message" \
7546 -c "found fragmented DTLS handshake message" \
7547 -C "error"
7548
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007549# 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 +02007550# OTOH the client might resend if the server is to slow to reset after sending
7551# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007552not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007553requires_config_enabled MBEDTLS_RSA_C
7554requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007555run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007556 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007557 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7558 crt_file=data_files/server7_int-ca.crt \
7559 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007560 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007561 hs_timeout=10000-60000 \
7562 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007563 "$P_CLI dtls=1 debug_level=2 \
7564 crt_file=data_files/server8_int-ca2.crt \
7565 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007566 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007567 hs_timeout=10000-60000 \
7568 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007569 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007570 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007571 -s "found fragmented DTLS handshake message" \
7572 -c "found fragmented DTLS handshake message" \
7573 -C "error"
7574
Andrzej Kurek77826052018-10-11 07:34:08 -04007575# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007576# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7577# OTOH the client might resend if the server is to slow to reset after sending
7578# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007579not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007580requires_config_enabled MBEDTLS_RSA_C
7581requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007582requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7583requires_config_enabled MBEDTLS_AES_C
7584requires_config_enabled MBEDTLS_GCM_C
7585run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007586 -p "$P_PXY mtu=512" \
7587 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7588 crt_file=data_files/server7_int-ca.crt \
7589 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007590 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007591 hs_timeout=10000-60000 \
7592 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007593 "$P_CLI dtls=1 debug_level=2 \
7594 crt_file=data_files/server8_int-ca2.crt \
7595 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007596 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007597 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7598 hs_timeout=10000-60000 \
7599 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007600 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007601 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007602 -s "found fragmented DTLS handshake message" \
7603 -c "found fragmented DTLS handshake message" \
7604 -C "error"
7605
Andrzej Kurek7311c782018-10-11 06:49:41 -04007606not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007607requires_config_enabled MBEDTLS_RSA_C
7608requires_config_enabled MBEDTLS_ECDSA_C
7609run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007610 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007611 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7612 crt_file=data_files/server7_int-ca.crt \
7613 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007614 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007615 hs_timeout=10000-60000 \
7616 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007617 "$P_CLI dtls=1 debug_level=2 \
7618 crt_file=data_files/server8_int-ca2.crt \
7619 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007620 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007621 hs_timeout=10000-60000 \
7622 mtu=1024 nbio=2" \
7623 0 \
7624 -S "autoreduction" \
7625 -s "found fragmented DTLS handshake message" \
7626 -c "found fragmented DTLS handshake message" \
7627 -C "error"
7628
Andrzej Kurek77826052018-10-11 07:34:08 -04007629# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007630not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007631requires_config_enabled MBEDTLS_RSA_C
7632requires_config_enabled MBEDTLS_ECDSA_C
7633requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7634requires_config_enabled MBEDTLS_AES_C
7635requires_config_enabled MBEDTLS_GCM_C
7636run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7637 -p "$P_PXY mtu=512" \
7638 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7639 crt_file=data_files/server7_int-ca.crt \
7640 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007641 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007642 hs_timeout=10000-60000 \
7643 mtu=512 nbio=2" \
7644 "$P_CLI dtls=1 debug_level=2 \
7645 crt_file=data_files/server8_int-ca2.crt \
7646 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007647 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007648 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7649 hs_timeout=10000-60000 \
7650 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007651 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007652 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007653 -s "found fragmented DTLS handshake message" \
7654 -c "found fragmented DTLS handshake message" \
7655 -C "error"
7656
Andrzej Kurek77826052018-10-11 07:34:08 -04007657# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007658# This ensures things still work after session_reset().
7659# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007660# Since we don't support reading fragmented ClientHello yet,
7661# up the MTU to 1450 (larger than ClientHello with session ticket,
7662# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007663# An autoreduction on the client-side might happen if the server is
7664# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007665# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007666# resumed listening, which would result in a spurious autoreduction.
7667not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007668requires_config_enabled MBEDTLS_RSA_C
7669requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007670requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7671requires_config_enabled MBEDTLS_AES_C
7672requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007673run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7674 -p "$P_PXY mtu=1450" \
7675 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7676 crt_file=data_files/server7_int-ca.crt \
7677 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007678 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007679 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007680 mtu=1450" \
7681 "$P_CLI dtls=1 debug_level=2 \
7682 crt_file=data_files/server8_int-ca2.crt \
7683 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007684 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007685 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007686 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007687 mtu=1450 reconnect=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007688 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007689 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007690 -s "found fragmented DTLS handshake message" \
7691 -c "found fragmented DTLS handshake message" \
7692 -C "error"
7693
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007694# An autoreduction on the client-side might happen if the server is
7695# slow to reset, therefore omitting '-C "autoreduction"' below.
7696not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007697requires_config_enabled MBEDTLS_RSA_C
7698requires_config_enabled MBEDTLS_ECDSA_C
7699requires_config_enabled MBEDTLS_SHA256_C
7700requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7701requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7702requires_config_enabled MBEDTLS_CHACHAPOLY_C
7703run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7704 -p "$P_PXY mtu=512" \
7705 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7706 crt_file=data_files/server7_int-ca.crt \
7707 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007708 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007709 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007710 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007711 mtu=512" \
7712 "$P_CLI dtls=1 debug_level=2 \
7713 crt_file=data_files/server8_int-ca2.crt \
7714 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007715 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007716 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007717 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007718 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007719 mtu=512" \
7720 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007721 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007722 -s "found fragmented DTLS handshake message" \
7723 -c "found fragmented DTLS handshake message" \
7724 -C "error"
7725
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007726# An autoreduction on the client-side might happen if the server is
7727# slow to reset, therefore omitting '-C "autoreduction"' below.
7728not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007729requires_config_enabled MBEDTLS_RSA_C
7730requires_config_enabled MBEDTLS_ECDSA_C
7731requires_config_enabled MBEDTLS_SHA256_C
7732requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7733requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7734requires_config_enabled MBEDTLS_AES_C
7735requires_config_enabled MBEDTLS_GCM_C
7736run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7737 -p "$P_PXY mtu=512" \
7738 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7739 crt_file=data_files/server7_int-ca.crt \
7740 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007741 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007742 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007743 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007744 mtu=512" \
7745 "$P_CLI dtls=1 debug_level=2 \
7746 crt_file=data_files/server8_int-ca2.crt \
7747 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007748 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007749 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007750 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007751 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007752 mtu=512" \
7753 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007754 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007755 -s "found fragmented DTLS handshake message" \
7756 -c "found fragmented DTLS handshake message" \
7757 -C "error"
7758
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007759# An autoreduction on the client-side might happen if the server is
7760# slow to reset, therefore omitting '-C "autoreduction"' below.
7761not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007762requires_config_enabled MBEDTLS_RSA_C
7763requires_config_enabled MBEDTLS_ECDSA_C
7764requires_config_enabled MBEDTLS_SHA256_C
7765requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7766requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7767requires_config_enabled MBEDTLS_AES_C
7768requires_config_enabled MBEDTLS_CCM_C
7769run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007770 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007771 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7772 crt_file=data_files/server7_int-ca.crt \
7773 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007774 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007775 exchanges=2 renegotiation=1 \
7776 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007777 hs_timeout=10000-60000 \
7778 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007779 "$P_CLI dtls=1 debug_level=2 \
7780 crt_file=data_files/server8_int-ca2.crt \
7781 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007782 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007783 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007784 hs_timeout=10000-60000 \
7785 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007786 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007787 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007788 -s "found fragmented DTLS handshake message" \
7789 -c "found fragmented DTLS handshake message" \
7790 -C "error"
7791
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007792# An autoreduction on the client-side might happen if the server is
7793# slow to reset, therefore omitting '-C "autoreduction"' below.
7794not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007795requires_config_enabled MBEDTLS_RSA_C
7796requires_config_enabled MBEDTLS_ECDSA_C
7797requires_config_enabled MBEDTLS_SHA256_C
7798requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7799requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7800requires_config_enabled MBEDTLS_AES_C
7801requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7802requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7803run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007804 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007805 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7806 crt_file=data_files/server7_int-ca.crt \
7807 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007808 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007809 exchanges=2 renegotiation=1 \
7810 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007811 hs_timeout=10000-60000 \
7812 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007813 "$P_CLI dtls=1 debug_level=2 \
7814 crt_file=data_files/server8_int-ca2.crt \
7815 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007816 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007817 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007818 hs_timeout=10000-60000 \
7819 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007820 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007821 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007822 -s "found fragmented DTLS handshake message" \
7823 -c "found fragmented DTLS handshake message" \
7824 -C "error"
7825
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007826# An autoreduction on the client-side might happen if the server is
7827# slow to reset, therefore omitting '-C "autoreduction"' below.
7828not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007829requires_config_enabled MBEDTLS_RSA_C
7830requires_config_enabled MBEDTLS_ECDSA_C
7831requires_config_enabled MBEDTLS_SHA256_C
7832requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7833requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7834requires_config_enabled MBEDTLS_AES_C
7835requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7836run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007837 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007838 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7839 crt_file=data_files/server7_int-ca.crt \
7840 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007841 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007842 exchanges=2 renegotiation=1 \
7843 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007844 hs_timeout=10000-60000 \
7845 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007846 "$P_CLI dtls=1 debug_level=2 \
7847 crt_file=data_files/server8_int-ca2.crt \
7848 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007849 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007850 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007851 hs_timeout=10000-60000 \
7852 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007853 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007854 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007855 -s "found fragmented DTLS handshake message" \
7856 -c "found fragmented DTLS handshake message" \
7857 -C "error"
7858
Andrzej Kurek77826052018-10-11 07:34:08 -04007859# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007860requires_config_enabled MBEDTLS_RSA_C
7861requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007862requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7863requires_config_enabled MBEDTLS_AES_C
7864requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007865client_needs_more_time 2
7866run_test "DTLS fragmenting: proxy MTU + 3d" \
7867 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007868 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007869 crt_file=data_files/server7_int-ca.crt \
7870 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007871 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007872 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007873 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007874 crt_file=data_files/server8_int-ca2.crt \
7875 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007876 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007877 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007878 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007879 0 \
7880 -s "found fragmented DTLS handshake message" \
7881 -c "found fragmented DTLS handshake message" \
7882 -C "error"
7883
Andrzej Kurek77826052018-10-11 07:34:08 -04007884# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007885requires_config_enabled MBEDTLS_RSA_C
7886requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007887requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7888requires_config_enabled MBEDTLS_AES_C
7889requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007890client_needs_more_time 2
7891run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7892 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7893 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7894 crt_file=data_files/server7_int-ca.crt \
7895 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007896 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007897 hs_timeout=250-10000 mtu=512 nbio=2" \
7898 "$P_CLI dtls=1 debug_level=2 \
7899 crt_file=data_files/server8_int-ca2.crt \
7900 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007901 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007902 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007903 hs_timeout=250-10000 mtu=512 nbio=2" \
7904 0 \
7905 -s "found fragmented DTLS handshake message" \
7906 -c "found fragmented DTLS handshake message" \
7907 -C "error"
7908
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007909# interop tests for DTLS fragmentating with reliable connection
7910#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007911# here and below we just want to test that the we fragment in a way that
7912# pleases other implementations, so we don't need the peer to fragment
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007913requires_config_enabled MBEDTLS_RSA_C
7914requires_config_enabled MBEDTLS_ECDSA_C
7915requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007916requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007917run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7918 "$G_SRV -u" \
7919 "$P_CLI dtls=1 debug_level=2 \
7920 crt_file=data_files/server8_int-ca2.crt \
7921 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007922 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007923 mtu=512 force_version=dtls1_2" \
7924 0 \
7925 -c "fragmenting handshake message" \
7926 -C "error"
7927
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007928requires_config_enabled MBEDTLS_RSA_C
7929requires_config_enabled MBEDTLS_ECDSA_C
7930requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007931requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007932run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
7933 "$G_SRV -u" \
7934 "$P_CLI dtls=1 debug_level=2 \
7935 crt_file=data_files/server8_int-ca2.crt \
7936 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007937 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007938 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007939 0 \
7940 -c "fragmenting handshake message" \
7941 -C "error"
7942
Hanno Beckerb9a00862018-08-28 10:20:22 +01007943# We use --insecure for the GnuTLS client because it expects
7944# the hostname / IP it connects to to be the name used in the
7945# certificate obtained from the server. Here, however, it
7946# connects to 127.0.0.1 while our test certificates use 'localhost'
7947# as the server name in the certificate. This will make the
7948# certifiate validation fail, but passing --insecure makes
7949# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007950requires_config_enabled MBEDTLS_RSA_C
7951requires_config_enabled MBEDTLS_ECDSA_C
7952requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007953requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007954requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007955run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007956 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007957 crt_file=data_files/server7_int-ca.crt \
7958 key_file=data_files/server7.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_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007961 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007962 0 \
7963 -s "fragmenting handshake message"
7964
Hanno Beckerb9a00862018-08-28 10:20:22 +01007965# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007966requires_config_enabled MBEDTLS_RSA_C
7967requires_config_enabled MBEDTLS_ECDSA_C
7968requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007969requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007970requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007971run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007972 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007973 crt_file=data_files/server7_int-ca.crt \
7974 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007975 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007976 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007977 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007978 0 \
7979 -s "fragmenting handshake message"
7980
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007981requires_config_enabled MBEDTLS_RSA_C
7982requires_config_enabled MBEDTLS_ECDSA_C
7983requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7984run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
7985 "$O_SRV -dtls1_2 -verify 10" \
7986 "$P_CLI dtls=1 debug_level=2 \
7987 crt_file=data_files/server8_int-ca2.crt \
7988 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007989 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007990 mtu=512 force_version=dtls1_2" \
7991 0 \
7992 -c "fragmenting handshake message" \
7993 -C "error"
7994
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007995requires_config_enabled MBEDTLS_RSA_C
7996requires_config_enabled MBEDTLS_ECDSA_C
7997requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7998run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
7999 "$O_SRV -dtls1 -verify 10" \
8000 "$P_CLI dtls=1 debug_level=2 \
8001 crt_file=data_files/server8_int-ca2.crt \
8002 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008003 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008004 mtu=512 force_version=dtls1" \
8005 0 \
8006 -c "fragmenting handshake message" \
8007 -C "error"
8008
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008009requires_config_enabled MBEDTLS_RSA_C
8010requires_config_enabled MBEDTLS_ECDSA_C
8011requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8012run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
8013 "$P_SRV dtls=1 debug_level=2 \
8014 crt_file=data_files/server7_int-ca.crt \
8015 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008016 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008017 mtu=512 force_version=dtls1_2" \
8018 "$O_CLI -dtls1_2" \
8019 0 \
8020 -s "fragmenting handshake message"
8021
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008022requires_config_enabled MBEDTLS_RSA_C
8023requires_config_enabled MBEDTLS_ECDSA_C
8024requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8025run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8026 "$P_SRV dtls=1 debug_level=2 \
8027 crt_file=data_files/server7_int-ca.crt \
8028 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008029 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008030 mtu=512 force_version=dtls1" \
8031 "$O_CLI -dtls1" \
8032 0 \
8033 -s "fragmenting handshake message"
8034
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008035# interop tests for DTLS fragmentating with unreliable connection
8036#
8037# again we just want to test that the we fragment in a way that
8038# pleases other implementations, so we don't need the peer to fragment
8039requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008040requires_config_enabled MBEDTLS_RSA_C
8041requires_config_enabled MBEDTLS_ECDSA_C
8042requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008043client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008044run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8045 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8046 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008047 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008048 crt_file=data_files/server8_int-ca2.crt \
8049 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008050 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008051 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008052 0 \
8053 -c "fragmenting handshake message" \
8054 -C "error"
8055
8056requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008057requires_config_enabled MBEDTLS_RSA_C
8058requires_config_enabled MBEDTLS_ECDSA_C
8059requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008060client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008061run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8062 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8063 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008064 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008065 crt_file=data_files/server8_int-ca2.crt \
8066 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008067 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008068 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008069 0 \
8070 -c "fragmenting handshake message" \
8071 -C "error"
8072
k-stachowiakabb843e2019-02-18 16:14:03 +01008073requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008074requires_config_enabled MBEDTLS_RSA_C
8075requires_config_enabled MBEDTLS_ECDSA_C
8076requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8077client_needs_more_time 4
8078run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8079 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8080 "$P_SRV dtls=1 debug_level=2 \
8081 crt_file=data_files/server7_int-ca.crt \
8082 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008083 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008084 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008085 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008086 0 \
8087 -s "fragmenting handshake message"
8088
k-stachowiakabb843e2019-02-18 16:14:03 +01008089requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008090requires_config_enabled MBEDTLS_RSA_C
8091requires_config_enabled MBEDTLS_ECDSA_C
8092requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8093client_needs_more_time 4
8094run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8095 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8096 "$P_SRV dtls=1 debug_level=2 \
8097 crt_file=data_files/server7_int-ca.crt \
8098 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008099 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008100 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008101 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008102 0 \
8103 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008104
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008105## Interop test with OpenSSL might trigger a bug in recent versions (including
8106## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008107## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008108## They should be re-enabled once a fixed version of OpenSSL is available
8109## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008110skip_next_test
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008111requires_config_enabled MBEDTLS_RSA_C
8112requires_config_enabled MBEDTLS_ECDSA_C
8113requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8114client_needs_more_time 4
8115run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8116 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8117 "$O_SRV -dtls1_2 -verify 10" \
8118 "$P_CLI dtls=1 debug_level=2 \
8119 crt_file=data_files/server8_int-ca2.crt \
8120 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008121 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008122 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8123 0 \
8124 -c "fragmenting handshake message" \
8125 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008126
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008127skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008128requires_config_enabled MBEDTLS_RSA_C
8129requires_config_enabled MBEDTLS_ECDSA_C
8130requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008131client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008132run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8133 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008134 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008135 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008136 crt_file=data_files/server8_int-ca2.crt \
8137 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008138 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008139 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008140 0 \
8141 -c "fragmenting handshake message" \
8142 -C "error"
8143
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008144skip_next_test
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008145requires_config_enabled MBEDTLS_RSA_C
8146requires_config_enabled MBEDTLS_ECDSA_C
8147requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8148client_needs_more_time 4
8149run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8150 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8151 "$P_SRV dtls=1 debug_level=2 \
8152 crt_file=data_files/server7_int-ca.crt \
8153 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008154 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008155 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8156 "$O_CLI -dtls1_2" \
8157 0 \
8158 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008159
8160# -nbio is added to prevent s_client from blocking in case of duplicated
8161# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008162skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008163requires_config_enabled MBEDTLS_RSA_C
8164requires_config_enabled MBEDTLS_ECDSA_C
8165requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008166client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008167run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8168 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008169 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008170 crt_file=data_files/server7_int-ca.crt \
8171 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008172 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008173 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008174 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008175 0 \
8176 -s "fragmenting handshake message"
8177
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008178# Tests for specific things with "unreliable" UDP connection
8179
8180not_with_valgrind # spurious resend due to timeout
8181run_test "DTLS proxy: reference" \
8182 -p "$P_PXY" \
8183 "$P_SRV dtls=1 debug_level=2" \
8184 "$P_CLI dtls=1 debug_level=2" \
8185 0 \
8186 -C "replayed record" \
8187 -S "replayed record" \
Hanno Beckere03eb7b2019-07-19 15:43:09 +01008188 -C "Buffer record from epoch" \
8189 -S "Buffer record from epoch" \
8190 -C "ssl_buffer_message" \
8191 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008192 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008193 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008194 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008195 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008196 -c "HTTP/1.0 200 OK"
8197
8198not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008199run_test "DTLS proxy: duplicate every packet" \
8200 -p "$P_PXY duplicate=1" \
Hanno Becker7f376f42019-06-12 16:20:48 +01008201 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008202 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008203 0 \
8204 -c "replayed record" \
8205 -s "replayed record" \
8206 -c "record from another epoch" \
8207 -s "record from another epoch" \
8208 -S "resend" \
8209 -s "Extra-header:" \
8210 -c "HTTP/1.0 200 OK"
8211
8212run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8213 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008214 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8215 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008216 0 \
8217 -c "replayed record" \
8218 -S "replayed record" \
8219 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008220 -s "record from another epoch" \
8221 -c "resend" \
8222 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008223 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008224 -c "HTTP/1.0 200 OK"
8225
8226run_test "DTLS proxy: multiple records in same datagram" \
8227 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008228 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8229 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008230 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008231 -c "next record in same datagram" \
8232 -s "next record in same datagram"
8233
8234run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8235 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008236 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8237 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008238 0 \
8239 -c "next record in same datagram" \
8240 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008241
Jarno Lamsa33281d52019-10-18 10:54:35 +03008242requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008243run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8244 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008245 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8246 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008247 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008248 -c "discarding invalid record (mac)" \
8249 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008250 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008251 -c "HTTP/1.0 200 OK" \
8252 -S "too many records with bad MAC" \
8253 -S "Verification of the message MAC failed"
8254
Jarno Lamsa33281d52019-10-18 10:54:35 +03008255requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008256run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8257 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008258 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8259 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008260 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008261 -C "discarding invalid record (mac)" \
8262 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008263 -S "Extra-header:" \
8264 -C "HTTP/1.0 200 OK" \
8265 -s "too many records with bad MAC" \
8266 -s "Verification of the message MAC failed"
8267
Jarno Lamsa33281d52019-10-18 10:54:35 +03008268requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008269run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8270 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008271 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8272 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008273 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008274 -c "discarding invalid record (mac)" \
8275 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008276 -s "Extra-header:" \
8277 -c "HTTP/1.0 200 OK" \
8278 -S "too many records with bad MAC" \
8279 -S "Verification of the message MAC failed"
8280
Jarno Lamsa33281d52019-10-18 10:54:35 +03008281requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008282run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8283 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008284 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8285 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008286 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008287 -c "discarding invalid record (mac)" \
8288 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008289 -s "Extra-header:" \
8290 -c "HTTP/1.0 200 OK" \
8291 -s "too many records with bad MAC" \
8292 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008293
8294run_test "DTLS proxy: delay ChangeCipherSpec" \
8295 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008296 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8297 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008298 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008299 -c "record from another epoch" \
8300 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008301 -s "Extra-header:" \
8302 -c "HTTP/1.0 200 OK"
8303
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008304# Tests for reordering support with DTLS
8305
Hanno Becker56cdfd12018-08-17 13:42:15 +01008306run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8307 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008308 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8309 hs_timeout=2500-60000" \
8310 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8311 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008312 0 \
8313 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008314 -c "Next handshake message has been buffered - load"\
8315 -S "Buffering HS message" \
8316 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008317 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008318 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008319 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008320 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008321
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008322run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8323 -p "$P_PXY delay_srv=ServerHello" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03008324 "$P_SRV mtu=256 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008325 hs_timeout=2500-60000" \
8326 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8327 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008328 0 \
8329 -c "Buffering HS message" \
8330 -c "found fragmented DTLS handshake message"\
8331 -c "Next handshake message 1 not or only partially bufffered" \
8332 -c "Next handshake message has been buffered - load"\
8333 -S "Buffering HS message" \
8334 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008335 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008336 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008337 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008338 -S "Remember CCS message"
8339
Hanno Beckera1adcca2018-08-24 14:41:07 +01008340# The client buffers the ServerKeyExchange before receiving the fragmented
8341# Certificate message; at the time of writing, together these are aroudn 1200b
8342# in size, so that the bound below ensures that the certificate can be reassembled
8343# while keeping the ServerKeyExchange.
8344requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8345run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008346 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008347 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8348 hs_timeout=2500-60000" \
8349 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8350 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008351 0 \
8352 -c "Buffering HS message" \
8353 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008354 -C "attempt to make space by freeing buffered messages" \
8355 -S "Buffering HS message" \
8356 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008357 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008358 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008359 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008360 -S "Remember CCS message"
8361
8362# The size constraints ensure that the delayed certificate message can't
8363# be reassembled while keeping the ServerKeyExchange message, but it can
8364# when dropping it first.
8365requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8366requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8367run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8368 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008369 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8370 hs_timeout=2500-60000" \
8371 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8372 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008373 0 \
8374 -c "Buffering HS message" \
8375 -c "attempt to make space by freeing buffered future messages" \
8376 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008377 -S "Buffering HS message" \
8378 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008379 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008380 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008381 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008382 -S "Remember CCS message"
8383
Hanno Becker56cdfd12018-08-17 13:42:15 +01008384run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8385 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008386 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8387 hs_timeout=2500-60000" \
8388 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8389 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008390 0 \
8391 -C "Buffering HS message" \
8392 -C "Next handshake message has been buffered - load"\
8393 -s "Buffering HS message" \
8394 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008395 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008396 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008397 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008398 -S "Remember CCS message"
8399
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02008400# This needs session tickets; otherwise CCS is the first message in its flight
8401requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008402run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8403 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008404 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8405 hs_timeout=2500-60000" \
8406 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8407 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008408 0 \
8409 -C "Buffering HS message" \
8410 -C "Next handshake message has been buffered - load"\
8411 -S "Buffering HS message" \
8412 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008413 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008414 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008415 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008416 -S "Remember CCS message"
8417
Jarno Lamsa33281d52019-10-18 10:54:35 +03008418# This needs session tickets; otherwise CCS is the first message in its flight
8419requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008420run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8421 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008422 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8423 hs_timeout=2500-60000" \
8424 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8425 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008426 0 \
8427 -C "Buffering HS message" \
8428 -C "Next handshake message has been buffered - load"\
8429 -S "Buffering HS message" \
8430 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008431 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008432 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008433 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008434 -s "Remember CCS message"
8435
Hanno Beckera1adcca2018-08-24 14:41:07 +01008436run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008437 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008438 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8439 hs_timeout=2500-60000" \
8440 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8441 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008442 0 \
8443 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008444 -s "Found buffered record from current epoch - load" \
8445 -c "Buffer record from epoch 1" \
8446 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008447
Hanno Beckera1adcca2018-08-24 14:41:07 +01008448# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8449# from the server are delayed, so that the encrypted Finished message
8450# is received and buffered. When the fragmented NewSessionTicket comes
8451# in afterwards, the encrypted Finished message must be freed in order
8452# to make space for the NewSessionTicket to be reassembled.
8453# This works only in very particular circumstances:
8454# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8455# of the NewSessionTicket, but small enough to also allow buffering of
8456# the encrypted Finished message.
8457# - The MTU setting on the server must be so small that the NewSessionTicket
8458# needs to be fragmented.
8459# - All messages sent by the server must be small enough to be either sent
8460# without fragmentation or be reassembled within the bounds of
8461# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8462# handshake, omitting CRTs.
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008463requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8464requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008465run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8466 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008467 "$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 +01008468 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8469 0 \
8470 -s "Buffer record from epoch 1" \
8471 -s "Found buffered record from current epoch - load" \
8472 -c "Buffer record from epoch 1" \
8473 -C "Found buffered record from current epoch - load" \
8474 -c "Enough space available after freeing future epoch record"
8475
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008476# Tests for "randomly unreliable connection": try a variety of flows and peers
8477
8478client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008479run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8480 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008481 "$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 +02008482 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008483 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008484 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8485 0 \
8486 -s "Extra-header:" \
8487 -c "HTTP/1.0 200 OK"
8488
Janos Follath74537a62016-09-02 13:45:28 +01008489client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008490run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8491 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008492 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8493 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008494 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8495 0 \
8496 -s "Extra-header:" \
8497 -c "HTTP/1.0 200 OK"
8498
Janos Follath74537a62016-09-02 13:45:28 +01008499client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008500run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8501 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008502 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8503 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008504 0 \
8505 -s "Extra-header:" \
8506 -c "HTTP/1.0 200 OK"
8507
Janos Follath74537a62016-09-02 13:45:28 +01008508client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008509run_test "DTLS proxy: 3d, FS, client auth" \
8510 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008511 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8512 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008513 0 \
8514 -s "Extra-header:" \
8515 -c "HTTP/1.0 200 OK"
8516
Janos Follath74537a62016-09-02 13:45:28 +01008517client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008518run_test "DTLS proxy: 3d, FS, ticket" \
8519 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008520 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8521 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008522 0 \
8523 -s "Extra-header:" \
8524 -c "HTTP/1.0 200 OK"
8525
Janos Follath74537a62016-09-02 13:45:28 +01008526client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008527run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8528 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008529 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8530 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008531 0 \
8532 -s "Extra-header:" \
8533 -c "HTTP/1.0 200 OK"
8534
Janos Follath74537a62016-09-02 13:45:28 +01008535client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008536run_test "DTLS proxy: 3d, max handshake, nbio" \
8537 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008538 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008539 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008540 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008541 0 \
8542 -s "Extra-header:" \
8543 -c "HTTP/1.0 200 OK"
8544
Janos Follath74537a62016-09-02 13:45:28 +01008545client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008546requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008547requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008548requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008549run_test "DTLS proxy: 3d, min handshake, resumption" \
8550 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008551 "$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 +02008552 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008553 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008554 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8555 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8556 0 \
8557 -s "a session has been resumed" \
8558 -c "a session has been resumed" \
8559 -s "Extra-header:" \
8560 -c "HTTP/1.0 200 OK"
8561
Janos Follath74537a62016-09-02 13:45:28 +01008562client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008563requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008564requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008565requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008566run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8567 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008568 "$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 +02008569 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008570 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008571 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8572 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8573 0 \
8574 -s "a session has been resumed" \
8575 -c "a session has been resumed" \
8576 -s "Extra-header:" \
8577 -c "HTTP/1.0 200 OK"
8578
Janos Follath74537a62016-09-02 13:45:28 +01008579client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008580requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008581run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008582 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008583 "$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 +02008584 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008585 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008586 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008587 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8588 0 \
8589 -c "=> renegotiate" \
8590 -s "=> renegotiate" \
8591 -s "Extra-header:" \
8592 -c "HTTP/1.0 200 OK"
8593
Janos Follath74537a62016-09-02 13:45:28 +01008594client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008595requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008596run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8597 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008598 "$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 +02008599 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008600 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008601 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008602 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8603 0 \
8604 -c "=> renegotiate" \
8605 -s "=> renegotiate" \
8606 -s "Extra-header:" \
8607 -c "HTTP/1.0 200 OK"
8608
Janos Follath74537a62016-09-02 13:45:28 +01008609client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008610requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008611run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008612 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008613 "$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 +02008614 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008615 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008616 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008617 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008618 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8619 0 \
8620 -c "=> renegotiate" \
8621 -s "=> renegotiate" \
8622 -s "Extra-header:" \
8623 -c "HTTP/1.0 200 OK"
8624
Janos Follath74537a62016-09-02 13:45:28 +01008625client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008626requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008627run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008628 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008629 "$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 +02008630 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008631 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008632 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008633 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008634 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8635 0 \
8636 -c "=> renegotiate" \
8637 -s "=> renegotiate" \
8638 -s "Extra-header:" \
8639 -c "HTTP/1.0 200 OK"
8640
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008641## Interop tests with OpenSSL might trigger a bug in recent versions (including
8642## all versions installed on the CI machines), reported here:
8643## Bug report: https://github.com/openssl/openssl/issues/6902
8644## They should be re-enabled once a fixed version of OpenSSL is available
8645## (this should happen in some 1.1.1_ release according to the ticket).
8646skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008647client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008648not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008649run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008650 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8651 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008652 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008653 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008654 -c "HTTP/1.0 200 OK"
8655
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008656skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008657client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008658not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008659run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8660 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8661 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008662 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008663 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008664 -c "HTTP/1.0 200 OK"
8665
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008666skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008667client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008668not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008669run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8670 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8671 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008672 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008673 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008674 -c "HTTP/1.0 200 OK"
8675
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008676requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008677client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008678not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008679run_test "DTLS proxy: 3d, gnutls server" \
8680 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8681 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008682 "$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 +02008683 0 \
8684 -s "Extra-header:" \
8685 -c "Extra-header:"
8686
k-stachowiakabb843e2019-02-18 16:14:03 +01008687requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008688client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008689not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008690run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8691 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008692 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008693 "$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 +02008694 0 \
8695 -s "Extra-header:" \
8696 -c "Extra-header:"
8697
k-stachowiakabb843e2019-02-18 16:14:03 +01008698requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008699client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008700not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008701run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8702 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008703 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008704 "$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 +02008705 0 \
8706 -s "Extra-header:" \
8707 -c "Extra-header:"
8708
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008709# Final report
8710
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008711echo "------------------------------------------------------------------------"
8712
8713if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008714 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008715else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008716 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008717fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008718PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008719echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008720
8721exit $FAILS