blob: 94bd495b35f09f2499f22326bd0d1226ef4a902f [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
Jarno Lamsa0ed68082019-10-28 14:10:59 +02005660run_test "Small client packet DTLS, ECDHE-ECDSA" \
5661 "$P_SRV dtls=1" \
5662 "$P_CLI dtls=1 request_size=1 \
5663 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
5664 0 \
5665 -s "Read from client: 1 bytes read"
5666
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005667# Tests for small server packets
5668
5669requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5670run_test "Small server packet SSLv3 BlockCipher" \
5671 "$P_SRV response_size=1 min_version=ssl3" \
5672 "$P_CLI force_version=ssl3 \
5673 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5674 0 \
5675 -c "Read from server: 1 bytes read"
5676
5677requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5678run_test "Small server packet SSLv3 StreamCipher" \
5679 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5680 "$P_CLI force_version=ssl3 \
5681 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5682 0 \
5683 -c "Read from server: 1 bytes read"
5684
5685run_test "Small server packet TLS 1.0 BlockCipher" \
5686 "$P_SRV response_size=1" \
5687 "$P_CLI force_version=tls1 \
5688 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5689 0 \
5690 -c "Read from server: 1 bytes read"
5691
5692run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
5693 "$P_SRV response_size=1" \
5694 "$P_CLI force_version=tls1 etm=0 \
5695 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5696 0 \
5697 -c "Read from server: 1 bytes read"
5698
5699requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5700run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
5701 "$P_SRV response_size=1 trunc_hmac=1" \
5702 "$P_CLI force_version=tls1 \
5703 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5704 0 \
5705 -c "Read from server: 1 bytes read"
5706
5707requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5708run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
5709 "$P_SRV response_size=1 trunc_hmac=1" \
5710 "$P_CLI force_version=tls1 \
5711 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5712 0 \
5713 -c "Read from server: 1 bytes read"
5714
5715run_test "Small server packet TLS 1.0 StreamCipher" \
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" \
5719 0 \
5720 -c "Read from server: 1 bytes read"
5721
5722run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
5723 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5724 "$P_CLI force_version=tls1 \
5725 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5726 0 \
5727 -c "Read from server: 1 bytes read"
5728
5729requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5730run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
5731 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5732 "$P_CLI force_version=tls1 \
5733 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5734 0 \
5735 -c "Read from server: 1 bytes read"
5736
5737requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5738run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5739 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5740 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5741 trunc_hmac=1 etm=0" \
5742 0 \
5743 -c "Read from server: 1 bytes read"
5744
5745run_test "Small server packet TLS 1.1 BlockCipher" \
5746 "$P_SRV response_size=1" \
5747 "$P_CLI force_version=tls1_1 \
5748 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5749 0 \
5750 -c "Read from server: 1 bytes read"
5751
5752run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
5753 "$P_SRV response_size=1" \
5754 "$P_CLI force_version=tls1_1 \
5755 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5756 0 \
5757 -c "Read from server: 1 bytes read"
5758
5759requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5760run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
5761 "$P_SRV response_size=1 trunc_hmac=1" \
5762 "$P_CLI force_version=tls1_1 \
5763 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5764 0 \
5765 -c "Read from server: 1 bytes read"
5766
5767requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5768run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5769 "$P_SRV response_size=1 trunc_hmac=1" \
5770 "$P_CLI force_version=tls1_1 \
5771 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5772 0 \
5773 -c "Read from server: 1 bytes read"
5774
5775run_test "Small server packet TLS 1.1 StreamCipher" \
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" \
5779 0 \
5780 -c "Read from server: 1 bytes read"
5781
5782run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
5783 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5784 "$P_CLI force_version=tls1_1 \
5785 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5786 0 \
5787 -c "Read from server: 1 bytes read"
5788
5789requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5790run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
5791 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5792 "$P_CLI force_version=tls1_1 \
5793 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5794 0 \
5795 -c "Read from server: 1 bytes read"
5796
5797requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5798run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5799 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5800 "$P_CLI force_version=tls1_1 \
5801 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5802 0 \
5803 -c "Read from server: 1 bytes read"
5804
5805run_test "Small server packet TLS 1.2 BlockCipher" \
5806 "$P_SRV response_size=1" \
5807 "$P_CLI force_version=tls1_2 \
5808 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5809 0 \
5810 -c "Read from server: 1 bytes read"
5811
5812run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5813 "$P_SRV response_size=1" \
5814 "$P_CLI force_version=tls1_2 \
5815 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5816 0 \
5817 -c "Read from server: 1 bytes read"
5818
5819run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5820 "$P_SRV response_size=1" \
5821 "$P_CLI force_version=tls1_2 \
5822 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5823 0 \
5824 -c "Read from server: 1 bytes read"
5825
5826requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5827run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5828 "$P_SRV response_size=1 trunc_hmac=1" \
5829 "$P_CLI force_version=tls1_2 \
5830 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5831 0 \
5832 -c "Read from server: 1 bytes read"
5833
5834requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5835run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5836 "$P_SRV response_size=1 trunc_hmac=1" \
5837 "$P_CLI force_version=tls1_2 \
5838 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5839 0 \
5840 -c "Read from server: 1 bytes read"
5841
5842run_test "Small server packet TLS 1.2 StreamCipher" \
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" \
5846 0 \
5847 -c "Read from server: 1 bytes read"
5848
5849run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
5850 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5851 "$P_CLI force_version=tls1_2 \
5852 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5853 0 \
5854 -c "Read from server: 1 bytes read"
5855
5856requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5857run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
5858 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5859 "$P_CLI force_version=tls1_2 \
5860 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5861 0 \
5862 -c "Read from server: 1 bytes read"
5863
5864requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5865run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5866 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5867 "$P_CLI force_version=tls1_2 \
5868 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5869 0 \
5870 -c "Read from server: 1 bytes read"
5871
5872run_test "Small server packet TLS 1.2 AEAD" \
5873 "$P_SRV response_size=1" \
5874 "$P_CLI force_version=tls1_2 \
5875 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5876 0 \
5877 -c "Read from server: 1 bytes read"
5878
5879run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5880 "$P_SRV response_size=1" \
5881 "$P_CLI force_version=tls1_2 \
5882 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5883 0 \
5884 -c "Read from server: 1 bytes read"
5885
5886# Tests for small server packets in DTLS
5887
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005888run_test "Small server packet DTLS 1.0" \
5889 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
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 -04005895run_test "Small server packet DTLS 1.0, without EtM" \
5896 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
5897 "$P_CLI dtls=1 \
5898 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5899 0 \
5900 -c "Read from server: 1 bytes read"
5901
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005902requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5903run_test "Small server packet DTLS 1.0, truncated hmac" \
5904 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
5905 "$P_CLI dtls=1 trunc_hmac=1 \
5906 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5907 0 \
5908 -c "Read from server: 1 bytes read"
5909
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005910requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5911run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
5912 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
5913 "$P_CLI dtls=1 \
5914 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
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" \
5919 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
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 -04005925run_test "Small server packet DTLS 1.2, without EtM" \
5926 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5927 "$P_CLI dtls=1 \
5928 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5929 0 \
5930 -c "Read from server: 1 bytes read"
5931
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005932requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5933run_test "Small server packet DTLS 1.2, truncated hmac" \
5934 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5935 "$P_CLI dtls=1 \
5936 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5937 0 \
5938 -c "Read from server: 1 bytes read"
5939
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005940requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5941run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5942 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5943 "$P_CLI dtls=1 \
5944 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5945 0 \
5946 -c "Read from server: 1 bytes read"
5947
Jarno Lamsac40184b2019-10-28 14:16:12 +02005948run_test "Small server packet DTLS, ECDHE-ECDSA" \
5949 "$P_SRV dtls=1 response_size=1" \
5950 "$P_CLI dtls=1 \
5951 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
5952 0 \
5953 -c "Read from server: 1 bytes read"
5954
Janos Follath00efff72016-05-06 13:48:23 +01005955# A test for extensions in SSLv3
5956
5957requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5958run_test "SSLv3 with extensions, server side" \
5959 "$P_SRV min_version=ssl3 debug_level=3" \
5960 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
5961 0 \
5962 -S "dumping 'client hello extensions'" \
5963 -S "server hello, total extension length:"
5964
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005965# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005966
Angus Grattonc4dd0732018-04-11 16:28:39 +10005967# How many fragments do we expect to write $1 bytes?
5968fragments_for_write() {
5969 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
5970}
5971
Janos Follathe2681a42016-03-07 15:57:05 +00005972requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005973run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005974 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005975 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005976 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5977 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005978 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5979 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005980
Janos Follathe2681a42016-03-07 15:57:05 +00005981requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005982run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005983 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005984 "$P_CLI request_size=16384 force_version=ssl3 \
5985 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5986 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005987 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5988 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005989
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005990run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005991 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005992 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005993 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5994 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005995 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5996 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005997
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005998run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005999 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006000 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
6001 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6002 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006003 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006004
Hanno Becker32c55012017-11-10 08:42:54 +00006005requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006006run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006007 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006008 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006009 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006010 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006011 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6012 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006013
Hanno Becker32c55012017-11-10 08:42:54 +00006014requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006015run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006016 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006017 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006018 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
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
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006022run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006023 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006024 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006025 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6026 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006027 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006028
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006029run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006030 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6031 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006032 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006033 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006034 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006035
6036requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006037run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006038 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006039 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006040 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006041 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006042 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006043
Hanno Becker278fc7a2017-11-10 09:16:28 +00006044requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006045run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006046 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006047 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006048 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006049 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006050 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6051 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006052
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006053run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006054 "$P_SRV" \
6055 "$P_CLI request_size=16384 force_version=tls1_1 \
6056 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6057 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006058 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6059 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006060
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006061run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006062 "$P_SRV" \
6063 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6064 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006065 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006066 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006067
Hanno Becker32c55012017-11-10 08:42:54 +00006068requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006069run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006070 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006071 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006072 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006073 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006074 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006075
Hanno Becker32c55012017-11-10 08:42:54 +00006076requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006077run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006078 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006079 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006080 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006081 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006082 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006083
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006084run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006085 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6086 "$P_CLI request_size=16384 force_version=tls1_1 \
6087 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6088 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006089 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6090 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006091
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006092run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006093 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006094 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006095 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006096 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006097 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6098 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006099
Hanno Becker278fc7a2017-11-10 09:16:28 +00006100requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006101run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006102 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006103 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006104 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006105 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006106 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006107
Hanno Becker278fc7a2017-11-10 09:16:28 +00006108requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006109run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006110 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006111 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006112 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006113 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006114 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6115 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006116
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006117run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006118 "$P_SRV" \
6119 "$P_CLI request_size=16384 force_version=tls1_2 \
6120 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6121 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006122 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6123 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006124
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006125run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006126 "$P_SRV" \
6127 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6128 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6129 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006130 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006131
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006132run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006133 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006134 "$P_CLI request_size=16384 force_version=tls1_2 \
6135 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006136 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006137 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6138 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006139
Hanno Becker32c55012017-11-10 08:42:54 +00006140requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006141run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006142 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006143 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006144 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006145 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006146 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006147
Hanno Becker278fc7a2017-11-10 09:16:28 +00006148requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006149run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006150 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006151 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006152 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006153 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006154 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6155 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006156
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006157run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006158 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006159 "$P_CLI request_size=16384 force_version=tls1_2 \
6160 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6161 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006162 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6163 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006164
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006165run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006166 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006167 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006168 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6169 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006170 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006171
Hanno Becker32c55012017-11-10 08:42:54 +00006172requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006173run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006174 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006175 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006176 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006177 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006178 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006179
Hanno Becker278fc7a2017-11-10 09:16:28 +00006180requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006181run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006182 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006183 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006184 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006185 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006186 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6187 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006188
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006189run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006190 "$P_SRV" \
6191 "$P_CLI request_size=16384 force_version=tls1_2 \
6192 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6193 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006194 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6195 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006196
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006197run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006198 "$P_SRV" \
6199 "$P_CLI request_size=16384 force_version=tls1_2 \
6200 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6201 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006202 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6203 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006204
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006205# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006206requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6207run_test "Large server packet SSLv3 StreamCipher" \
6208 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6209 "$P_CLI force_version=ssl3 \
6210 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6211 0 \
6212 -c "Read from server: 16384 bytes read"
6213
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006214# Checking next 4 tests logs for 1n-1 split against BEAST too
6215requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6216run_test "Large server packet SSLv3 BlockCipher" \
6217 "$P_SRV response_size=16384 min_version=ssl3" \
6218 "$P_CLI force_version=ssl3 recsplit=0 \
6219 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6220 0 \
6221 -c "Read from server: 1 bytes read"\
6222 -c "16383 bytes read"\
6223 -C "Read from server: 16384 bytes read"
6224
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006225run_test "Large server packet TLS 1.0 BlockCipher" \
6226 "$P_SRV response_size=16384" \
6227 "$P_CLI force_version=tls1 recsplit=0 \
6228 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6229 0 \
6230 -c "Read from server: 1 bytes read"\
6231 -c "16383 bytes read"\
6232 -C "Read from server: 16384 bytes read"
6233
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006234run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6235 "$P_SRV response_size=16384" \
6236 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6237 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6238 0 \
6239 -c "Read from server: 1 bytes read"\
6240 -c "16383 bytes read"\
6241 -C "Read from server: 16384 bytes read"
6242
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006243requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6244run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6245 "$P_SRV response_size=16384" \
6246 "$P_CLI force_version=tls1 recsplit=0 \
6247 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6248 trunc_hmac=1" \
6249 0 \
6250 -c "Read from server: 1 bytes read"\
6251 -c "16383 bytes read"\
6252 -C "Read from server: 16384 bytes read"
6253
6254requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6255run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6256 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6257 "$P_CLI force_version=tls1 \
6258 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6259 trunc_hmac=1" \
6260 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006261 -s "16384 bytes written in 1 fragments" \
6262 -c "Read from server: 16384 bytes read"
6263
6264run_test "Large server packet TLS 1.0 StreamCipher" \
6265 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6266 "$P_CLI force_version=tls1 \
6267 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6268 0 \
6269 -s "16384 bytes written in 1 fragments" \
6270 -c "Read from server: 16384 bytes read"
6271
6272run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6273 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6274 "$P_CLI force_version=tls1 \
6275 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6276 0 \
6277 -s "16384 bytes written in 1 fragments" \
6278 -c "Read from server: 16384 bytes read"
6279
6280requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6281run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6282 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6283 "$P_CLI force_version=tls1 \
6284 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6285 0 \
6286 -s "16384 bytes written in 1 fragments" \
6287 -c "Read from server: 16384 bytes read"
6288
6289requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6290run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6291 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6292 "$P_CLI force_version=tls1 \
6293 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6294 0 \
6295 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006296 -c "Read from server: 16384 bytes read"
6297
6298run_test "Large server packet TLS 1.1 BlockCipher" \
6299 "$P_SRV response_size=16384" \
6300 "$P_CLI force_version=tls1_1 \
6301 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6302 0 \
6303 -c "Read from server: 16384 bytes read"
6304
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006305run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6306 "$P_SRV response_size=16384" \
6307 "$P_CLI force_version=tls1_1 etm=0 \
6308 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006309 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006310 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006311 -c "Read from server: 16384 bytes read"
6312
6313requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6314run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6315 "$P_SRV response_size=16384" \
6316 "$P_CLI force_version=tls1_1 \
6317 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6318 trunc_hmac=1" \
6319 0 \
6320 -c "Read from server: 16384 bytes read"
6321
6322requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006323run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6324 "$P_SRV response_size=16384 trunc_hmac=1" \
6325 "$P_CLI force_version=tls1_1 \
6326 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6327 0 \
6328 -s "16384 bytes written in 1 fragments" \
6329 -c "Read from server: 16384 bytes read"
6330
6331run_test "Large server packet TLS 1.1 StreamCipher" \
6332 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6333 "$P_CLI force_version=tls1_1 \
6334 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6335 0 \
6336 -c "Read from server: 16384 bytes read"
6337
6338run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6339 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6340 "$P_CLI force_version=tls1_1 \
6341 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6342 0 \
6343 -s "16384 bytes written in 1 fragments" \
6344 -c "Read from server: 16384 bytes read"
6345
6346requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006347run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6348 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6349 "$P_CLI force_version=tls1_1 \
6350 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6351 trunc_hmac=1" \
6352 0 \
6353 -c "Read from server: 16384 bytes read"
6354
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006355run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6356 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6357 "$P_CLI force_version=tls1_1 \
6358 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6359 0 \
6360 -s "16384 bytes written in 1 fragments" \
6361 -c "Read from server: 16384 bytes read"
6362
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006363run_test "Large server packet TLS 1.2 BlockCipher" \
6364 "$P_SRV response_size=16384" \
6365 "$P_CLI force_version=tls1_2 \
6366 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6367 0 \
6368 -c "Read from server: 16384 bytes read"
6369
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006370run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6371 "$P_SRV response_size=16384" \
6372 "$P_CLI force_version=tls1_2 etm=0 \
6373 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6374 0 \
6375 -s "16384 bytes written in 1 fragments" \
6376 -c "Read from server: 16384 bytes read"
6377
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006378run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6379 "$P_SRV response_size=16384" \
6380 "$P_CLI force_version=tls1_2 \
6381 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6382 0 \
6383 -c "Read from server: 16384 bytes read"
6384
6385requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6386run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6387 "$P_SRV response_size=16384" \
6388 "$P_CLI force_version=tls1_2 \
6389 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6390 trunc_hmac=1" \
6391 0 \
6392 -c "Read from server: 16384 bytes read"
6393
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006394run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6395 "$P_SRV response_size=16384 trunc_hmac=1" \
6396 "$P_CLI force_version=tls1_2 \
6397 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6398 0 \
6399 -s "16384 bytes written in 1 fragments" \
6400 -c "Read from server: 16384 bytes read"
6401
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006402run_test "Large server packet TLS 1.2 StreamCipher" \
6403 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6404 "$P_CLI force_version=tls1_2 \
6405 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6406 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006407 -s "16384 bytes written in 1 fragments" \
6408 -c "Read from server: 16384 bytes read"
6409
6410run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6411 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6412 "$P_CLI force_version=tls1_2 \
6413 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6414 0 \
6415 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006416 -c "Read from server: 16384 bytes read"
6417
6418requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6419run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6420 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6421 "$P_CLI force_version=tls1_2 \
6422 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6423 trunc_hmac=1" \
6424 0 \
6425 -c "Read from server: 16384 bytes read"
6426
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006427requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6428run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6429 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6430 "$P_CLI force_version=tls1_2 \
6431 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6432 0 \
6433 -s "16384 bytes written in 1 fragments" \
6434 -c "Read from server: 16384 bytes read"
6435
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006436run_test "Large server packet TLS 1.2 AEAD" \
6437 "$P_SRV response_size=16384" \
6438 "$P_CLI force_version=tls1_2 \
6439 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6440 0 \
6441 -c "Read from server: 16384 bytes read"
6442
6443run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6444 "$P_SRV response_size=16384" \
6445 "$P_CLI force_version=tls1_2 \
6446 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6447 0 \
6448 -c "Read from server: 16384 bytes read"
6449
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006450# Tests for restartable ECC
6451
6452requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6453run_test "EC restart: TLS, default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006454 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006455 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006456 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006457 debug_level=1" \
6458 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006459 -C "x509_verify_cert.*4b00" \
6460 -C "mbedtls_pk_verify.*4b00" \
6461 -C "mbedtls_ecdh_make_public.*4b00" \
6462 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006463
6464requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6465run_test "EC restart: TLS, max_ops=0" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006466 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006467 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006468 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006469 debug_level=1 ec_max_ops=0" \
6470 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006471 -C "x509_verify_cert.*4b00" \
6472 -C "mbedtls_pk_verify.*4b00" \
6473 -C "mbedtls_ecdh_make_public.*4b00" \
6474 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006475
6476requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6477run_test "EC restart: TLS, max_ops=65535" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006478 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006479 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006480 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006481 debug_level=1 ec_max_ops=65535" \
6482 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006483 -C "x509_verify_cert.*4b00" \
6484 -C "mbedtls_pk_verify.*4b00" \
6485 -C "mbedtls_ecdh_make_public.*4b00" \
6486 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006487
6488requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6489run_test "EC restart: TLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006490 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006491 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006492 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006493 debug_level=1 ec_max_ops=1000" \
6494 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006495 -c "x509_verify_cert.*4b00" \
6496 -c "mbedtls_pk_verify.*4b00" \
6497 -c "mbedtls_ecdh_make_public.*4b00" \
6498 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006499
6500requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Hanno Becker4a156fc2019-06-14 17:07:06 +01006501requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006502run_test "EC restart: TLS, max_ops=1000, badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006503 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006504 crt_file=data_files/server5-badsign.crt \
6505 key_file=data_files/server5.key" \
6506 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker03d77462019-08-27 16:24:56 +01006507 key_file=data_files/server5.key crt_file=data_files/server5.crt ca_file=data_files/test-ca2.crt \
6508 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6509 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006510 -c "x509_verify_cert.*4b00" \
Hanno Becker03d77462019-08-27 16:24:56 +01006511 -c "mbedtls_pk_verify.*4b00" \
6512 -c "mbedtls_ecdh_make_public.*4b00" \
6513 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006514 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006515
Hanno Becker4a156fc2019-06-14 17:07:06 +01006516requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006517requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6518run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006519 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006520 crt_file=data_files/server5-badsign.crt \
6521 key_file=data_files/server5.key" \
6522 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6523 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006524 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006525 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6526 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006527 -c "x509_verify_cert.*4b00" \
6528 -c "mbedtls_pk_verify.*4b00" \
6529 -c "mbedtls_ecdh_make_public.*4b00" \
6530 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006531 -c "! The certificate is not correctly signed by the trusted CA" \
6532 -C "! mbedtls_ssl_handshake returned" \
6533 -C "X509 - Certificate verification failed"
6534
Hanno Becker4a156fc2019-06-14 17:07:06 +01006535requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006536requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006537requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6538run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006539 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006540 crt_file=data_files/server5-badsign.crt \
6541 key_file=data_files/server5.key" \
6542 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006543 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006544 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6545 debug_level=1 ec_max_ops=1000 auth_mode=none" \
6546 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006547 -C "x509_verify_cert.*4b00" \
6548 -c "mbedtls_pk_verify.*4b00" \
6549 -c "mbedtls_ecdh_make_public.*4b00" \
6550 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006551 -C "! The certificate is not correctly signed by the trusted CA" \
6552 -C "! mbedtls_ssl_handshake returned" \
6553 -C "X509 - Certificate verification failed"
6554
6555requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006556run_test "EC restart: DTLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006557 "$P_SRV auth_mode=required dtls=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006558 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006559 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006560 dtls=1 debug_level=1 ec_max_ops=1000" \
6561 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006562 -c "x509_verify_cert.*4b00" \
6563 -c "mbedtls_pk_verify.*4b00" \
6564 -c "mbedtls_ecdh_make_public.*4b00" \
6565 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006566
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006567requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6568run_test "EC restart: TLS, max_ops=1000 no client auth" \
6569 "$P_SRV" \
6570 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6571 debug_level=1 ec_max_ops=1000" \
6572 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006573 -c "x509_verify_cert.*4b00" \
6574 -c "mbedtls_pk_verify.*4b00" \
6575 -c "mbedtls_ecdh_make_public.*4b00" \
6576 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006577
6578requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6579run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6580 "$P_SRV psk=abc123" \
6581 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6582 psk=abc123 debug_level=1 ec_max_ops=1000" \
6583 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006584 -C "x509_verify_cert.*4b00" \
6585 -C "mbedtls_pk_verify.*4b00" \
6586 -C "mbedtls_ecdh_make_public.*4b00" \
6587 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006588
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006589# Tests of asynchronous private key support in SSL
6590
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006591requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006592run_test "SSL async private: sign, delay=0" \
6593 "$P_SRV \
6594 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006595 "$P_CLI" \
6596 0 \
6597 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006598 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006599
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006600requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006601run_test "SSL async private: sign, delay=1" \
6602 "$P_SRV \
6603 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006604 "$P_CLI" \
6605 0 \
6606 -s "Async sign callback: using key slot " \
6607 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006608 -s "Async resume (slot [0-9]): sign done, status=0"
6609
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006610requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6611run_test "SSL async private: sign, delay=2" \
6612 "$P_SRV \
6613 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6614 "$P_CLI" \
6615 0 \
6616 -s "Async sign callback: using key slot " \
6617 -U "Async sign callback: using key slot " \
6618 -s "Async resume (slot [0-9]): call 1 more times." \
6619 -s "Async resume (slot [0-9]): call 0 more times." \
6620 -s "Async resume (slot [0-9]): sign done, status=0"
6621
Gilles Peskined3268832018-04-26 06:23:59 +02006622# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
6623# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
6624requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6625requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6626run_test "SSL async private: sign, RSA, TLS 1.1" \
6627 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
6628 async_operations=s async_private_delay1=0 async_private_delay2=0" \
6629 "$P_CLI force_version=tls1_1" \
6630 0 \
6631 -s "Async sign callback: using key slot " \
6632 -s "Async resume (slot [0-9]): sign done, status=0"
6633
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006634requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerb2c63832019-06-17 08:35:16 +01006635requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03006636requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006637requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskine807d74a2018-04-30 10:30:49 +02006638run_test "SSL async private: sign, SNI" \
6639 "$P_SRV debug_level=3 \
6640 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6641 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6642 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6643 "$P_CLI server_name=polarssl.example" \
6644 0 \
6645 -s "Async sign callback: using key slot " \
6646 -s "Async resume (slot [0-9]): sign done, status=0" \
6647 -s "parse ServerName extension" \
6648 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6649 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6650
6651requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006652run_test "SSL async private: decrypt, delay=0" \
6653 "$P_SRV \
6654 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6655 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6656 0 \
6657 -s "Async decrypt callback: using key slot " \
6658 -s "Async resume (slot [0-9]): decrypt done, status=0"
6659
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006660requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006661run_test "SSL async private: decrypt, delay=1" \
6662 "$P_SRV \
6663 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6664 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6665 0 \
6666 -s "Async decrypt callback: using key slot " \
6667 -s "Async resume (slot [0-9]): call 0 more times." \
6668 -s "Async resume (slot [0-9]): decrypt done, status=0"
6669
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006670requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006671run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6672 "$P_SRV psk=abc123 \
6673 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6674 "$P_CLI psk=abc123 \
6675 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6676 0 \
6677 -s "Async decrypt callback: using key slot " \
6678 -s "Async resume (slot [0-9]): decrypt done, status=0"
6679
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006680requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006681run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6682 "$P_SRV psk=abc123 \
6683 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6684 "$P_CLI psk=abc123 \
6685 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6686 0 \
6687 -s "Async decrypt callback: using key slot " \
6688 -s "Async resume (slot [0-9]): call 0 more times." \
6689 -s "Async resume (slot [0-9]): decrypt done, status=0"
6690
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006691requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006692run_test "SSL async private: sign callback not present" \
6693 "$P_SRV \
6694 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6695 "$P_CLI; [ \$? -eq 1 ] &&
6696 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6697 0 \
6698 -S "Async sign callback" \
6699 -s "! mbedtls_ssl_handshake returned" \
6700 -s "The own private key or pre-shared key is not set, but needed" \
6701 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6702 -s "Successful connection"
6703
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006704requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006705run_test "SSL async private: decrypt callback not present" \
6706 "$P_SRV debug_level=1 \
6707 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6708 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6709 [ \$? -eq 1 ] && $P_CLI" \
6710 0 \
6711 -S "Async decrypt callback" \
6712 -s "! mbedtls_ssl_handshake returned" \
6713 -s "got no RSA private key" \
6714 -s "Async resume (slot [0-9]): sign done, status=0" \
6715 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006716
6717# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006718requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006719run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006720 "$P_SRV \
6721 async_operations=s async_private_delay1=1 \
6722 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6723 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006724 "$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 +01006725 0 \
6726 -s "Async sign callback: using key slot 0," \
6727 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006728 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006729
6730# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006731requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006732run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006733 "$P_SRV \
6734 async_operations=s async_private_delay2=1 \
6735 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6736 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006737 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6738 0 \
6739 -s "Async sign callback: using key slot 0," \
6740 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006741 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006742
6743# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006744requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006745run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006746 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006747 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006748 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6749 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006750 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6751 0 \
6752 -s "Async sign callback: using key slot 1," \
6753 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006754 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006755
6756# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006757requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006758run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006759 "$P_SRV \
6760 async_operations=s async_private_delay1=1 \
6761 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6762 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006763 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6764 0 \
6765 -s "Async sign callback: no key matches this certificate."
6766
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006767requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006768run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006769 "$P_SRV \
6770 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6771 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006772 "$P_CLI" \
6773 1 \
6774 -s "Async sign callback: injected error" \
6775 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006776 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006777 -s "! mbedtls_ssl_handshake returned"
6778
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006779requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006780run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006781 "$P_SRV \
6782 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6783 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006784 "$P_CLI" \
6785 1 \
6786 -s "Async sign callback: using key slot " \
6787 -S "Async resume" \
6788 -s "Async cancel"
6789
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006790requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006791run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006792 "$P_SRV \
6793 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6794 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006795 "$P_CLI" \
6796 1 \
6797 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006798 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006799 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006800 -s "! mbedtls_ssl_handshake returned"
6801
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006802requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006803run_test "SSL async private: decrypt, error in start" \
6804 "$P_SRV \
6805 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6806 async_private_error=1" \
6807 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6808 1 \
6809 -s "Async decrypt callback: injected error" \
6810 -S "Async resume" \
6811 -S "Async cancel" \
6812 -s "! mbedtls_ssl_handshake returned"
6813
6814requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6815run_test "SSL async private: decrypt, cancel after start" \
6816 "$P_SRV \
6817 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6818 async_private_error=2" \
6819 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6820 1 \
6821 -s "Async decrypt callback: using key slot " \
6822 -S "Async resume" \
6823 -s "Async cancel"
6824
6825requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6826run_test "SSL async private: decrypt, error in resume" \
6827 "$P_SRV \
6828 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6829 async_private_error=3" \
6830 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6831 1 \
6832 -s "Async decrypt callback: using key slot " \
6833 -s "Async resume callback: decrypt done but injected error" \
6834 -S "Async cancel" \
6835 -s "! mbedtls_ssl_handshake returned"
6836
6837requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006838run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006839 "$P_SRV \
6840 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6841 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006842 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6843 0 \
6844 -s "Async cancel" \
6845 -s "! mbedtls_ssl_handshake returned" \
6846 -s "Async resume" \
6847 -s "Successful connection"
6848
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006849requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006850run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006851 "$P_SRV \
6852 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6853 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006854 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6855 0 \
6856 -s "! mbedtls_ssl_handshake returned" \
6857 -s "Async resume" \
6858 -s "Successful connection"
6859
6860# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006861requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006862run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006863 "$P_SRV \
6864 async_operations=s async_private_delay1=1 async_private_error=-2 \
6865 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6866 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006867 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6868 [ \$? -eq 1 ] &&
6869 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6870 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006871 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006872 -S "Async resume" \
6873 -s "Async cancel" \
6874 -s "! mbedtls_ssl_handshake returned" \
6875 -s "Async sign callback: no key matches this certificate." \
6876 -s "Successful connection"
6877
6878# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006879requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006880run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006881 "$P_SRV \
6882 async_operations=s async_private_delay1=1 async_private_error=-3 \
6883 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6884 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006885 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6886 [ \$? -eq 1 ] &&
6887 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6888 0 \
6889 -s "Async resume" \
6890 -s "! mbedtls_ssl_handshake returned" \
6891 -s "Async sign callback: no key matches this certificate." \
6892 -s "Successful connection"
6893
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006894requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006895requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006896run_test "SSL async private: renegotiation: client-initiated; sign" \
6897 "$P_SRV \
6898 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006899 exchanges=2 renegotiation=1" \
6900 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6901 0 \
6902 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006903 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006904
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006905requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006906requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006907run_test "SSL async private: renegotiation: server-initiated; sign" \
6908 "$P_SRV \
6909 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006910 exchanges=2 renegotiation=1 renegotiate=1" \
6911 "$P_CLI exchanges=2 renegotiation=1" \
6912 0 \
6913 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006914 -s "Async resume (slot [0-9]): sign done, status=0"
6915
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006916requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006917requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6918run_test "SSL async private: renegotiation: client-initiated; decrypt" \
6919 "$P_SRV \
6920 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6921 exchanges=2 renegotiation=1" \
6922 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6923 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6924 0 \
6925 -s "Async decrypt callback: using key slot " \
6926 -s "Async resume (slot [0-9]): decrypt done, status=0"
6927
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006928requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006929requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6930run_test "SSL async private: renegotiation: server-initiated; decrypt" \
6931 "$P_SRV \
6932 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6933 exchanges=2 renegotiation=1 renegotiate=1" \
6934 "$P_CLI exchanges=2 renegotiation=1 \
6935 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6936 0 \
6937 -s "Async decrypt callback: using key slot " \
6938 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006939
Ron Eldor58093c82018-06-28 13:22:05 +03006940# Tests for ECC extensions (rfc 4492)
6941
Ron Eldor643df7c2018-06-28 16:17:00 +03006942requires_config_enabled MBEDTLS_AES_C
6943requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6944requires_config_enabled MBEDTLS_SHA256_C
6945requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006946run_test "Force a non ECC ciphersuite in the client side" \
6947 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006948 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006949 0 \
6950 -C "client hello, adding supported_elliptic_curves extension" \
6951 -C "client hello, adding supported_point_formats extension" \
6952 -S "found supported elliptic curves extension" \
6953 -S "found supported point formats extension"
6954
Ron Eldor643df7c2018-06-28 16:17:00 +03006955requires_config_enabled MBEDTLS_AES_C
6956requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6957requires_config_enabled MBEDTLS_SHA256_C
6958requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006959run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006960 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006961 "$P_CLI debug_level=3" \
6962 0 \
6963 -C "found supported_point_formats extension" \
6964 -S "server hello, supported_point_formats extension"
6965
Ron Eldor643df7c2018-06-28 16:17:00 +03006966requires_config_enabled MBEDTLS_AES_C
6967requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6968requires_config_enabled MBEDTLS_SHA256_C
6969requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006970run_test "Force an ECC ciphersuite in the client side" \
6971 "$P_SRV debug_level=3" \
6972 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6973 0 \
6974 -c "client hello, adding supported_elliptic_curves extension" \
6975 -c "client hello, adding supported_point_formats extension" \
6976 -s "found supported elliptic curves extension" \
6977 -s "found supported point formats extension"
6978
Ron Eldor643df7c2018-06-28 16:17:00 +03006979requires_config_enabled MBEDTLS_AES_C
6980requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6981requires_config_enabled MBEDTLS_SHA256_C
6982requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006983run_test "Force an ECC ciphersuite in the server side" \
6984 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6985 "$P_CLI debug_level=3" \
6986 0 \
6987 -c "found supported_point_formats extension" \
6988 -s "server hello, supported_point_formats extension"
6989
Jarno Lamsad3428052019-10-28 14:36:37 +02006990requires_config_enabled MBEDTLS_AES_C
6991requires_config_enabled MBEDTLS_CCM_C
6992requires_config_enabled MBEDTLS_SHA256_C
6993requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
6994run_test "Force an ECC ciphersuite with CCM in the client side" \
6995 "$P_SRV dtls=1 debug_level=3" \
6996 "$P_CLI dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
6997 0 \
6998 -c "client hello, adding supported_elliptic_curves extension" \
6999 -c "client hello, adding supported_point_formats extension" \
7000 -s "found supported elliptic curves extension" \
7001 -s "found supported point formats extension"
7002
7003requires_config_enabled MBEDTLS_AES_C
7004requires_config_enabled MBEDTLS_CCM_C
7005requires_config_enabled MBEDTLS_SHA256_C
7006requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
7007run_test "Force an ECC ciphersuite with CCM in the server side" \
7008 "$P_SRV dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
7009 "$P_CLI dtls=1 debug_level=3" \
7010 0 \
7011 -c "found supported_point_formats extension" \
7012 -s "server hello, supported_point_formats extension"
7013
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007014# Tests for DTLS HelloVerifyRequest
7015
7016run_test "DTLS cookie: enabled" \
7017 "$P_SRV dtls=1 debug_level=2" \
7018 "$P_CLI dtls=1 debug_level=2" \
7019 0 \
7020 -s "cookie verification failed" \
7021 -s "cookie verification passed" \
7022 -S "cookie verification skipped" \
7023 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007024 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007025 -S "SSL - The requested feature is not available"
7026
7027run_test "DTLS cookie: disabled" \
7028 "$P_SRV dtls=1 debug_level=2 cookies=0" \
7029 "$P_CLI dtls=1 debug_level=2" \
7030 0 \
7031 -S "cookie verification failed" \
7032 -S "cookie verification passed" \
7033 -s "cookie verification skipped" \
7034 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007035 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007036 -S "SSL - The requested feature is not available"
7037
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007038run_test "DTLS cookie: default (failing)" \
7039 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
7040 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
7041 1 \
7042 -s "cookie verification failed" \
7043 -S "cookie verification passed" \
7044 -S "cookie verification skipped" \
7045 -C "received hello verify request" \
Jarno Lamsab514cd32019-10-28 14:37:51 +02007046 -S "hello verification requested"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007047
7048requires_ipv6
7049run_test "DTLS cookie: enabled, IPv6" \
7050 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
7051 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
7052 0 \
7053 -s "cookie verification failed" \
7054 -s "cookie verification passed" \
7055 -S "cookie verification skipped" \
7056 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007057 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007058 -S "SSL - The requested feature is not available"
7059
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007060run_test "DTLS cookie: enabled, nbio" \
7061 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7062 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7063 0 \
7064 -s "cookie verification failed" \
7065 -s "cookie verification passed" \
7066 -S "cookie verification skipped" \
7067 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007068 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007069 -S "SSL - The requested feature is not available"
7070
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007071# Tests for client reconnecting from the same port with DTLS
7072
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007073not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007074requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007075run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007076 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7077 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007078 0 \
7079 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007080 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007081 -S "Client initiated reconnection from same port"
7082
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007083not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007084requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007085run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007086 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7087 "$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 +02007088 0 \
7089 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007090 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007091 -s "Client initiated reconnection from same port"
7092
Paul Bakker362689d2016-05-13 10:33:25 +01007093not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
Jarno Lamsa33281d52019-10-18 10:54:35 +03007094requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007095run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007096 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7097 "$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 +02007098 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007099 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007100 -s "Client initiated reconnection from same port"
7101
Paul Bakker362689d2016-05-13 10:33:25 +01007102only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
Jarno Lamsa33281d52019-10-18 10:54:35 +03007103requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007104run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7105 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7106 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7107 0 \
7108 -S "The operation timed out" \
7109 -s "Client initiated reconnection from same port"
7110
Jarno Lamsa33281d52019-10-18 10:54:35 +03007111requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007112run_test "DTLS client reconnect from same port: no cookies" \
7113 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007114 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7115 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007116 -s "The operation timed out" \
7117 -S "Client initiated reconnection from same port"
7118
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007119# Tests for various cases of client authentication with DTLS
7120# (focused on handshake flows and message parsing)
7121
7122run_test "DTLS client auth: required" \
7123 "$P_SRV dtls=1 auth_mode=required" \
7124 "$P_CLI dtls=1" \
7125 0 \
7126 -s "Verifying peer X.509 certificate... ok"
7127
Hanno Becker4a156fc2019-06-14 17:07:06 +01007128requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007129requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007130run_test "DTLS client auth: optional, client has no cert" \
7131 "$P_SRV dtls=1 auth_mode=optional" \
7132 "$P_CLI dtls=1 crt_file=none key_file=none" \
7133 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007134 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007135
Hanno Becker4a156fc2019-06-14 17:07:06 +01007136requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007137requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007138run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007139 "$P_SRV dtls=1 auth_mode=none" \
7140 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7141 0 \
7142 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007143 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007144
Jarno Lamsa33281d52019-10-18 10:54:35 +03007145requires_ciphersuite_enabled TLS-PSK-WITH-AES-128-GCM-SHA256
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007146run_test "DTLS wrong PSK: badmac alert" \
7147 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7148 "$P_CLI dtls=1 psk=abc124" \
7149 1 \
7150 -s "SSL - Verification of the message MAC failed" \
7151 -c "SSL - A fatal alert message was received from our peer"
7152
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007153# Tests for receiving fragmented handshake messages with DTLS
7154
7155requires_gnutls
7156run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7157 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007158 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007159 0 \
7160 -C "found fragmented DTLS handshake message" \
7161 -C "error"
7162
7163requires_gnutls
7164run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7165 "$G_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007166 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007167 0 \
7168 -c "found fragmented DTLS handshake message" \
7169 -C "error"
7170
7171requires_gnutls
7172run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7173 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007174 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007175 0 \
7176 -c "found fragmented DTLS handshake message" \
7177 -C "error"
7178
7179requires_gnutls
7180run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7181 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007182 "$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 +02007183 0 \
7184 -c "found fragmented DTLS handshake message" \
7185 -C "error"
7186
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007187requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007188requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007189run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7190 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007191 "$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 +02007192 0 \
7193 -c "found fragmented DTLS handshake message" \
7194 -c "client hello, adding renegotiation extension" \
7195 -c "found renegotiation extension" \
7196 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007197 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007198 -C "error" \
7199 -s "Extra-header:"
7200
7201requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007202requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007203run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7204 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007205 "$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 +02007206 0 \
7207 -c "found fragmented DTLS handshake message" \
7208 -c "client hello, adding renegotiation extension" \
7209 -c "found renegotiation extension" \
7210 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007211 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007212 -C "error" \
7213 -s "Extra-header:"
7214
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007215run_test "DTLS reassembly: no fragmentation (openssl server)" \
7216 "$O_SRV -dtls1 -mtu 2048" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007217 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007218 0 \
7219 -C "found fragmented DTLS handshake message" \
7220 -C "error"
7221
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007222run_test "DTLS reassembly: some fragmentation (openssl server)" \
7223 "$O_SRV -dtls1 -mtu 768" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007224 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007225 0 \
7226 -c "found fragmented DTLS handshake message" \
7227 -C "error"
7228
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007229run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007230 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007231 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007232 0 \
7233 -c "found fragmented DTLS handshake message" \
7234 -C "error"
7235
7236run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7237 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007238 "$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 +02007239 0 \
7240 -c "found fragmented DTLS handshake message" \
7241 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007242
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007243# Tests for sending fragmented handshake messages with DTLS
7244#
7245# Use client auth when we need the client to send large messages,
7246# and use large cert chains on both sides too (the long chains we have all use
7247# both RSA and ECDSA, but ideally we should have long chains with either).
7248# Sizes reached (UDP payload):
7249# - 2037B for server certificate
7250# - 1542B for client certificate
7251# - 1013B for newsessionticket
7252# - all others below 512B
7253# All those tests assume MAX_CONTENT_LEN is at least 2048
7254
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007255requires_config_enabled MBEDTLS_RSA_C
7256requires_config_enabled MBEDTLS_ECDSA_C
7257requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7258run_test "DTLS fragmenting: none (for reference)" \
7259 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7260 crt_file=data_files/server7_int-ca.crt \
7261 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007262 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007263 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007264 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007265 "$P_CLI dtls=1 debug_level=2 \
7266 crt_file=data_files/server8_int-ca2.crt \
7267 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007268 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007269 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007270 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007271 0 \
7272 -S "found fragmented DTLS handshake message" \
7273 -C "found fragmented DTLS handshake message" \
7274 -C "error"
7275
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007276requires_config_enabled MBEDTLS_RSA_C
7277requires_config_enabled MBEDTLS_ECDSA_C
7278requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007279run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007280 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7281 crt_file=data_files/server7_int-ca.crt \
7282 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007283 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007284 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007285 max_frag_len=1024" \
7286 "$P_CLI dtls=1 debug_level=2 \
7287 crt_file=data_files/server8_int-ca2.crt \
7288 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007289 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007290 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007291 max_frag_len=2048" \
7292 0 \
7293 -S "found fragmented DTLS handshake message" \
7294 -c "found fragmented DTLS handshake message" \
7295 -C "error"
7296
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007297# With the MFL extension, the server has no way of forcing
7298# the client to not exceed a certain MTU; hence, the following
7299# test can't be replicated with an MTU proxy such as the one
7300# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007301requires_config_enabled MBEDTLS_RSA_C
7302requires_config_enabled MBEDTLS_ECDSA_C
7303requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007304run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007305 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7306 crt_file=data_files/server7_int-ca.crt \
7307 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007308 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007309 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007310 max_frag_len=512" \
7311 "$P_CLI dtls=1 debug_level=2 \
7312 crt_file=data_files/server8_int-ca2.crt \
7313 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007314 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007315 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007316 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007317 0 \
7318 -S "found fragmented DTLS handshake message" \
7319 -c "found fragmented DTLS handshake message" \
7320 -C "error"
7321
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007322requires_config_enabled MBEDTLS_RSA_C
7323requires_config_enabled MBEDTLS_ECDSA_C
7324requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007325run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007326 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7327 crt_file=data_files/server7_int-ca.crt \
7328 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007329 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007330 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007331 max_frag_len=2048" \
7332 "$P_CLI dtls=1 debug_level=2 \
7333 crt_file=data_files/server8_int-ca2.crt \
7334 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007335 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007336 hs_timeout=2500-60000 \
7337 max_frag_len=1024" \
7338 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007339 -S "found fragmented DTLS handshake message" \
7340 -c "found fragmented DTLS handshake message" \
7341 -C "error"
7342
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007343# While not required by the standard defining the MFL extension
7344# (according to which it only applies to records, not to datagrams),
7345# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7346# as otherwise there wouldn't be any means to communicate MTU restrictions
7347# to the peer.
7348# The next test checks that no datagrams significantly larger than the
7349# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007350requires_config_enabled MBEDTLS_RSA_C
7351requires_config_enabled MBEDTLS_ECDSA_C
7352requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7353run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007354 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007355 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7356 crt_file=data_files/server7_int-ca.crt \
7357 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007358 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007359 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007360 max_frag_len=2048" \
7361 "$P_CLI dtls=1 debug_level=2 \
7362 crt_file=data_files/server8_int-ca2.crt \
7363 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007364 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007365 hs_timeout=2500-60000 \
7366 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007367 0 \
7368 -S "found fragmented DTLS handshake message" \
7369 -c "found fragmented DTLS handshake message" \
7370 -C "error"
7371
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007372requires_config_enabled MBEDTLS_RSA_C
7373requires_config_enabled MBEDTLS_ECDSA_C
7374requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007375run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007376 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7377 crt_file=data_files/server7_int-ca.crt \
7378 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007379 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007380 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007381 max_frag_len=2048" \
7382 "$P_CLI dtls=1 debug_level=2 \
7383 crt_file=data_files/server8_int-ca2.crt \
7384 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007385 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007386 hs_timeout=2500-60000 \
7387 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007388 0 \
7389 -s "found fragmented DTLS handshake message" \
7390 -c "found fragmented DTLS handshake message" \
7391 -C "error"
7392
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007393# While not required by the standard defining the MFL extension
7394# (according to which it only applies to records, not to datagrams),
7395# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7396# as otherwise there wouldn't be any means to communicate MTU restrictions
7397# to the peer.
7398# The next test checks that no datagrams significantly larger than the
7399# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007400requires_config_enabled MBEDTLS_RSA_C
7401requires_config_enabled MBEDTLS_ECDSA_C
7402requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7403run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007404 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007405 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7406 crt_file=data_files/server7_int-ca.crt \
7407 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007408 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007409 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007410 max_frag_len=2048" \
7411 "$P_CLI dtls=1 debug_level=2 \
7412 crt_file=data_files/server8_int-ca2.crt \
7413 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007414 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007415 hs_timeout=2500-60000 \
7416 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007417 0 \
7418 -s "found fragmented DTLS handshake message" \
7419 -c "found fragmented DTLS handshake message" \
7420 -C "error"
7421
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007422requires_config_enabled MBEDTLS_RSA_C
7423requires_config_enabled MBEDTLS_ECDSA_C
7424run_test "DTLS fragmenting: none (for reference) (MTU)" \
7425 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7426 crt_file=data_files/server7_int-ca.crt \
7427 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007428 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007429 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007430 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007431 "$P_CLI dtls=1 debug_level=2 \
7432 crt_file=data_files/server8_int-ca2.crt \
7433 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007434 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007435 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007436 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007437 0 \
7438 -S "found fragmented DTLS handshake message" \
7439 -C "found fragmented DTLS handshake message" \
7440 -C "error"
7441
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007442requires_config_enabled MBEDTLS_RSA_C
7443requires_config_enabled MBEDTLS_ECDSA_C
7444run_test "DTLS fragmenting: client (MTU)" \
7445 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7446 crt_file=data_files/server7_int-ca.crt \
7447 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007448 ca_file=data_files/test-ca.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007449 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007450 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007451 "$P_CLI dtls=1 debug_level=2 \
7452 crt_file=data_files/server8_int-ca2.crt \
7453 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007454 ca_file=data_files/test-ca2.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007455 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007456 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007457 0 \
7458 -s "found fragmented DTLS handshake message" \
7459 -C "found fragmented DTLS handshake message" \
7460 -C "error"
7461
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007462requires_config_enabled MBEDTLS_RSA_C
7463requires_config_enabled MBEDTLS_ECDSA_C
7464run_test "DTLS fragmenting: server (MTU)" \
7465 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7466 crt_file=data_files/server7_int-ca.crt \
7467 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007468 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007469 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007470 mtu=512" \
7471 "$P_CLI dtls=1 debug_level=2 \
7472 crt_file=data_files/server8_int-ca2.crt \
7473 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007474 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007475 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007476 mtu=2048" \
7477 0 \
7478 -S "found fragmented DTLS handshake message" \
7479 -c "found fragmented DTLS handshake message" \
7480 -C "error"
7481
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007482requires_config_enabled MBEDTLS_RSA_C
7483requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007484run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007485 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007486 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7487 crt_file=data_files/server7_int-ca.crt \
7488 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007489 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007490 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007491 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007492 "$P_CLI dtls=1 debug_level=2 \
7493 crt_file=data_files/server8_int-ca2.crt \
7494 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007495 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007496 hs_timeout=2500-60000 \
7497 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007498 0 \
7499 -s "found fragmented DTLS handshake message" \
7500 -c "found fragmented DTLS handshake message" \
7501 -C "error"
7502
Andrzej Kurek77826052018-10-11 07:34:08 -04007503# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007504requires_config_enabled MBEDTLS_RSA_C
7505requires_config_enabled MBEDTLS_ECDSA_C
7506requires_config_enabled MBEDTLS_SHA256_C
7507requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7508requires_config_enabled MBEDTLS_AES_C
7509requires_config_enabled MBEDTLS_GCM_C
7510run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007511 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007512 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7513 crt_file=data_files/server7_int-ca.crt \
7514 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007515 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007516 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007517 mtu=512" \
7518 "$P_CLI dtls=1 debug_level=2 \
7519 crt_file=data_files/server8_int-ca2.crt \
7520 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007521 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007522 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7523 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007524 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007525 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007526 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007527 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007528 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007529
Andrzej Kurek7311c782018-10-11 06:49:41 -04007530# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007531# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007532# The ratio of max/min timeout should ideally equal 4 to accept two
7533# retransmissions, but in some cases (like both the server and client using
7534# fragmentation and auto-reduction) an extra retransmission might occur,
7535# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007536not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007537requires_config_enabled MBEDTLS_RSA_C
7538requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007539requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7540requires_config_enabled MBEDTLS_AES_C
7541requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007542run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7543 -p "$P_PXY mtu=508" \
7544 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7545 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007546 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007547 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007548 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007549 "$P_CLI dtls=1 debug_level=2 \
7550 crt_file=data_files/server8_int-ca2.crt \
7551 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007552 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007553 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7554 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007555 0 \
7556 -s "found fragmented DTLS handshake message" \
7557 -c "found fragmented DTLS handshake message" \
7558 -C "error"
7559
Andrzej Kurek77826052018-10-11 07:34:08 -04007560# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007561only_with_valgrind
Hanno Becker108992e2018-08-29 17:04:18 +01007562requires_config_enabled MBEDTLS_RSA_C
7563requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007564requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7565requires_config_enabled MBEDTLS_AES_C
7566requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01007567run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7568 -p "$P_PXY mtu=508" \
7569 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7570 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007571 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007572 ca_file=data_files/test-ca.crt \
Hanno Becker108992e2018-08-29 17:04:18 +01007573 hs_timeout=250-10000" \
7574 "$P_CLI dtls=1 debug_level=2 \
7575 crt_file=data_files/server8_int-ca2.crt \
7576 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007577 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007578 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007579 hs_timeout=250-10000" \
7580 0 \
7581 -s "found fragmented DTLS handshake message" \
7582 -c "found fragmented DTLS handshake message" \
7583 -C "error"
7584
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007585# 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 +02007586# OTOH the client might resend if the server is to slow to reset after sending
7587# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007588not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007589requires_config_enabled MBEDTLS_RSA_C
7590requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007591run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007592 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007593 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7594 crt_file=data_files/server7_int-ca.crt \
7595 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007596 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007597 hs_timeout=10000-60000 \
7598 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007599 "$P_CLI dtls=1 debug_level=2 \
7600 crt_file=data_files/server8_int-ca2.crt \
7601 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007602 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007603 hs_timeout=10000-60000 \
7604 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007605 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007606 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007607 -s "found fragmented DTLS handshake message" \
7608 -c "found fragmented DTLS handshake message" \
7609 -C "error"
7610
Andrzej Kurek77826052018-10-11 07:34:08 -04007611# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007612# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7613# OTOH the client might resend if the server is to slow to reset after sending
7614# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007615not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007616requires_config_enabled MBEDTLS_RSA_C
7617requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007618requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7619requires_config_enabled MBEDTLS_AES_C
7620requires_config_enabled MBEDTLS_GCM_C
7621run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007622 -p "$P_PXY mtu=512" \
7623 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7624 crt_file=data_files/server7_int-ca.crt \
7625 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007626 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007627 hs_timeout=10000-60000 \
7628 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007629 "$P_CLI dtls=1 debug_level=2 \
7630 crt_file=data_files/server8_int-ca2.crt \
7631 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007632 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007633 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7634 hs_timeout=10000-60000 \
7635 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007636 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007637 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007638 -s "found fragmented DTLS handshake message" \
7639 -c "found fragmented DTLS handshake message" \
7640 -C "error"
7641
Andrzej Kurek7311c782018-10-11 06:49:41 -04007642not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007643requires_config_enabled MBEDTLS_RSA_C
7644requires_config_enabled MBEDTLS_ECDSA_C
7645run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007646 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007647 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7648 crt_file=data_files/server7_int-ca.crt \
7649 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007650 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007651 hs_timeout=10000-60000 \
7652 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007653 "$P_CLI dtls=1 debug_level=2 \
7654 crt_file=data_files/server8_int-ca2.crt \
7655 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007656 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007657 hs_timeout=10000-60000 \
7658 mtu=1024 nbio=2" \
7659 0 \
7660 -S "autoreduction" \
7661 -s "found fragmented DTLS handshake message" \
7662 -c "found fragmented DTLS handshake message" \
7663 -C "error"
7664
Andrzej Kurek77826052018-10-11 07:34:08 -04007665# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007666not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007667requires_config_enabled MBEDTLS_RSA_C
7668requires_config_enabled MBEDTLS_ECDSA_C
7669requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7670requires_config_enabled MBEDTLS_AES_C
7671requires_config_enabled MBEDTLS_GCM_C
7672run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7673 -p "$P_PXY mtu=512" \
7674 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7675 crt_file=data_files/server7_int-ca.crt \
7676 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007677 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007678 hs_timeout=10000-60000 \
7679 mtu=512 nbio=2" \
7680 "$P_CLI dtls=1 debug_level=2 \
7681 crt_file=data_files/server8_int-ca2.crt \
7682 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007683 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007684 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7685 hs_timeout=10000-60000 \
7686 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007687 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007688 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007689 -s "found fragmented DTLS handshake message" \
7690 -c "found fragmented DTLS handshake message" \
7691 -C "error"
7692
Andrzej Kurek77826052018-10-11 07:34:08 -04007693# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007694# This ensures things still work after session_reset().
7695# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007696# Since we don't support reading fragmented ClientHello yet,
7697# up the MTU to 1450 (larger than ClientHello with session ticket,
7698# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007699# An autoreduction on the client-side might happen if the server is
7700# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007701# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007702# resumed listening, which would result in a spurious autoreduction.
7703not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007704requires_config_enabled MBEDTLS_RSA_C
7705requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007706requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7707requires_config_enabled MBEDTLS_AES_C
7708requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007709run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7710 -p "$P_PXY mtu=1450" \
7711 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7712 crt_file=data_files/server7_int-ca.crt \
7713 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007714 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007715 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007716 mtu=1450" \
7717 "$P_CLI dtls=1 debug_level=2 \
7718 crt_file=data_files/server8_int-ca2.crt \
7719 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007720 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007721 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007722 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007723 mtu=1450 reconnect=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007724 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007725 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007726 -s "found fragmented DTLS handshake message" \
7727 -c "found fragmented DTLS handshake message" \
7728 -C "error"
7729
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007730# An autoreduction on the client-side might happen if the server is
7731# slow to reset, therefore omitting '-C "autoreduction"' below.
7732not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007733requires_config_enabled MBEDTLS_RSA_C
7734requires_config_enabled MBEDTLS_ECDSA_C
7735requires_config_enabled MBEDTLS_SHA256_C
7736requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7737requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7738requires_config_enabled MBEDTLS_CHACHAPOLY_C
7739run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7740 -p "$P_PXY mtu=512" \
7741 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7742 crt_file=data_files/server7_int-ca.crt \
7743 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007744 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007745 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007746 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007747 mtu=512" \
7748 "$P_CLI dtls=1 debug_level=2 \
7749 crt_file=data_files/server8_int-ca2.crt \
7750 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007751 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007752 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007753 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007754 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007755 mtu=512" \
7756 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007757 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007758 -s "found fragmented DTLS handshake message" \
7759 -c "found fragmented DTLS handshake message" \
7760 -C "error"
7761
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007762# An autoreduction on the client-side might happen if the server is
7763# slow to reset, therefore omitting '-C "autoreduction"' below.
7764not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007765requires_config_enabled MBEDTLS_RSA_C
7766requires_config_enabled MBEDTLS_ECDSA_C
7767requires_config_enabled MBEDTLS_SHA256_C
7768requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7769requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7770requires_config_enabled MBEDTLS_AES_C
7771requires_config_enabled MBEDTLS_GCM_C
7772run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7773 -p "$P_PXY mtu=512" \
7774 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7775 crt_file=data_files/server7_int-ca.crt \
7776 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007777 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007778 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007779 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007780 mtu=512" \
7781 "$P_CLI dtls=1 debug_level=2 \
7782 crt_file=data_files/server8_int-ca2.crt \
7783 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007784 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007785 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007786 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007787 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007788 mtu=512" \
7789 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007790 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007791 -s "found fragmented DTLS handshake message" \
7792 -c "found fragmented DTLS handshake message" \
7793 -C "error"
7794
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007795# An autoreduction on the client-side might happen if the server is
7796# slow to reset, therefore omitting '-C "autoreduction"' below.
7797not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007798requires_config_enabled MBEDTLS_RSA_C
7799requires_config_enabled MBEDTLS_ECDSA_C
7800requires_config_enabled MBEDTLS_SHA256_C
7801requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7802requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7803requires_config_enabled MBEDTLS_AES_C
7804requires_config_enabled MBEDTLS_CCM_C
7805run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007806 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007807 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7808 crt_file=data_files/server7_int-ca.crt \
7809 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007810 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007811 exchanges=2 renegotiation=1 \
7812 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007813 hs_timeout=10000-60000 \
7814 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007815 "$P_CLI dtls=1 debug_level=2 \
7816 crt_file=data_files/server8_int-ca2.crt \
7817 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007818 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007819 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007820 hs_timeout=10000-60000 \
7821 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007822 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007823 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007824 -s "found fragmented DTLS handshake message" \
7825 -c "found fragmented DTLS handshake message" \
7826 -C "error"
7827
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007828# An autoreduction on the client-side might happen if the server is
7829# slow to reset, therefore omitting '-C "autoreduction"' below.
7830not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007831requires_config_enabled MBEDTLS_RSA_C
7832requires_config_enabled MBEDTLS_ECDSA_C
7833requires_config_enabled MBEDTLS_SHA256_C
7834requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7835requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7836requires_config_enabled MBEDTLS_AES_C
7837requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7838requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7839run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007840 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007841 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7842 crt_file=data_files/server7_int-ca.crt \
7843 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007844 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007845 exchanges=2 renegotiation=1 \
7846 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007847 hs_timeout=10000-60000 \
7848 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007849 "$P_CLI dtls=1 debug_level=2 \
7850 crt_file=data_files/server8_int-ca2.crt \
7851 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007852 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007853 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007854 hs_timeout=10000-60000 \
7855 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007856 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007857 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007858 -s "found fragmented DTLS handshake message" \
7859 -c "found fragmented DTLS handshake message" \
7860 -C "error"
7861
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007862# An autoreduction on the client-side might happen if the server is
7863# slow to reset, therefore omitting '-C "autoreduction"' below.
7864not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007865requires_config_enabled MBEDTLS_RSA_C
7866requires_config_enabled MBEDTLS_ECDSA_C
7867requires_config_enabled MBEDTLS_SHA256_C
7868requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7869requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7870requires_config_enabled MBEDTLS_AES_C
7871requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7872run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007873 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007874 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7875 crt_file=data_files/server7_int-ca.crt \
7876 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007877 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007878 exchanges=2 renegotiation=1 \
7879 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007880 hs_timeout=10000-60000 \
7881 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007882 "$P_CLI dtls=1 debug_level=2 \
7883 crt_file=data_files/server8_int-ca2.crt \
7884 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007885 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007886 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007887 hs_timeout=10000-60000 \
7888 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007889 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007890 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007891 -s "found fragmented DTLS handshake message" \
7892 -c "found fragmented DTLS handshake message" \
7893 -C "error"
7894
Andrzej Kurek77826052018-10-11 07:34:08 -04007895# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007896requires_config_enabled MBEDTLS_RSA_C
7897requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007898requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7899requires_config_enabled MBEDTLS_AES_C
7900requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007901client_needs_more_time 2
7902run_test "DTLS fragmenting: proxy MTU + 3d" \
7903 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007904 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007905 crt_file=data_files/server7_int-ca.crt \
7906 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007907 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007908 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007909 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007910 crt_file=data_files/server8_int-ca2.crt \
7911 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007912 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007913 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007914 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007915 0 \
7916 -s "found fragmented DTLS handshake message" \
7917 -c "found fragmented DTLS handshake message" \
7918 -C "error"
7919
Andrzej Kurek77826052018-10-11 07:34:08 -04007920# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007921requires_config_enabled MBEDTLS_RSA_C
7922requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007923requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7924requires_config_enabled MBEDTLS_AES_C
7925requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007926client_needs_more_time 2
7927run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7928 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7929 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7930 crt_file=data_files/server7_int-ca.crt \
7931 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007932 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007933 hs_timeout=250-10000 mtu=512 nbio=2" \
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 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007938 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007939 hs_timeout=250-10000 mtu=512 nbio=2" \
7940 0 \
7941 -s "found fragmented DTLS handshake message" \
7942 -c "found fragmented DTLS handshake message" \
7943 -C "error"
7944
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007945# interop tests for DTLS fragmentating with reliable connection
7946#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007947# here and below we just want to test that the we fragment in a way that
7948# pleases other implementations, so we don't need the peer to fragment
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007949requires_config_enabled MBEDTLS_RSA_C
7950requires_config_enabled MBEDTLS_ECDSA_C
7951requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007952requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007953run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7954 "$G_SRV -u" \
7955 "$P_CLI dtls=1 debug_level=2 \
7956 crt_file=data_files/server8_int-ca2.crt \
7957 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007958 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007959 mtu=512 force_version=dtls1_2" \
7960 0 \
7961 -c "fragmenting handshake message" \
7962 -C "error"
7963
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007964requires_config_enabled MBEDTLS_RSA_C
7965requires_config_enabled MBEDTLS_ECDSA_C
7966requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007967requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007968run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
7969 "$G_SRV -u" \
7970 "$P_CLI dtls=1 debug_level=2 \
7971 crt_file=data_files/server8_int-ca2.crt \
7972 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007973 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007974 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007975 0 \
7976 -c "fragmenting handshake message" \
7977 -C "error"
7978
Hanno Beckerb9a00862018-08-28 10:20:22 +01007979# We use --insecure for the GnuTLS client because it expects
7980# the hostname / IP it connects to to be the name used in the
7981# certificate obtained from the server. Here, however, it
7982# connects to 127.0.0.1 while our test certificates use 'localhost'
7983# as the server name in the certificate. This will make the
7984# certifiate validation fail, but passing --insecure makes
7985# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007986requires_config_enabled MBEDTLS_RSA_C
7987requires_config_enabled MBEDTLS_ECDSA_C
7988requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007989requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007990requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007991run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007992 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007993 crt_file=data_files/server7_int-ca.crt \
7994 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007995 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007996 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007997 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007998 0 \
7999 -s "fragmenting handshake message"
8000
Hanno Beckerb9a00862018-08-28 10:20:22 +01008001# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008002requires_config_enabled MBEDTLS_RSA_C
8003requires_config_enabled MBEDTLS_ECDSA_C
8004requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008005requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008006requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008007run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008008 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008009 crt_file=data_files/server7_int-ca.crt \
8010 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008011 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008012 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008013 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008014 0 \
8015 -s "fragmenting handshake message"
8016
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008017requires_config_enabled MBEDTLS_RSA_C
8018requires_config_enabled MBEDTLS_ECDSA_C
8019requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8020run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
8021 "$O_SRV -dtls1_2 -verify 10" \
8022 "$P_CLI dtls=1 debug_level=2 \
8023 crt_file=data_files/server8_int-ca2.crt \
8024 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008025 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008026 mtu=512 force_version=dtls1_2" \
8027 0 \
8028 -c "fragmenting handshake message" \
8029 -C "error"
8030
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008031requires_config_enabled MBEDTLS_RSA_C
8032requires_config_enabled MBEDTLS_ECDSA_C
8033requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8034run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
8035 "$O_SRV -dtls1 -verify 10" \
8036 "$P_CLI dtls=1 debug_level=2 \
8037 crt_file=data_files/server8_int-ca2.crt \
8038 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008039 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008040 mtu=512 force_version=dtls1" \
8041 0 \
8042 -c "fragmenting handshake message" \
8043 -C "error"
8044
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008045requires_config_enabled MBEDTLS_RSA_C
8046requires_config_enabled MBEDTLS_ECDSA_C
8047requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8048run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
8049 "$P_SRV dtls=1 debug_level=2 \
8050 crt_file=data_files/server7_int-ca.crt \
8051 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008052 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008053 mtu=512 force_version=dtls1_2" \
8054 "$O_CLI -dtls1_2" \
8055 0 \
8056 -s "fragmenting handshake message"
8057
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008058requires_config_enabled MBEDTLS_RSA_C
8059requires_config_enabled MBEDTLS_ECDSA_C
8060requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8061run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8062 "$P_SRV dtls=1 debug_level=2 \
8063 crt_file=data_files/server7_int-ca.crt \
8064 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008065 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008066 mtu=512 force_version=dtls1" \
8067 "$O_CLI -dtls1" \
8068 0 \
8069 -s "fragmenting handshake message"
8070
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008071# interop tests for DTLS fragmentating with unreliable connection
8072#
8073# again we just want to test that the we fragment in a way that
8074# pleases other implementations, so we don't need the peer to fragment
8075requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008076requires_config_enabled MBEDTLS_RSA_C
8077requires_config_enabled MBEDTLS_ECDSA_C
8078requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008079client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008080run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8081 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8082 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008083 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008084 crt_file=data_files/server8_int-ca2.crt \
8085 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008086 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008087 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008088 0 \
8089 -c "fragmenting handshake message" \
8090 -C "error"
8091
8092requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008093requires_config_enabled MBEDTLS_RSA_C
8094requires_config_enabled MBEDTLS_ECDSA_C
8095requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008096client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008097run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8098 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8099 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008100 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008101 crt_file=data_files/server8_int-ca2.crt \
8102 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008103 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008104 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008105 0 \
8106 -c "fragmenting handshake message" \
8107 -C "error"
8108
k-stachowiakabb843e2019-02-18 16:14:03 +01008109requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008110requires_config_enabled MBEDTLS_RSA_C
8111requires_config_enabled MBEDTLS_ECDSA_C
8112requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8113client_needs_more_time 4
8114run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8115 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8116 "$P_SRV dtls=1 debug_level=2 \
8117 crt_file=data_files/server7_int-ca.crt \
8118 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008119 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008120 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008121 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008122 0 \
8123 -s "fragmenting handshake message"
8124
k-stachowiakabb843e2019-02-18 16:14:03 +01008125requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008126requires_config_enabled MBEDTLS_RSA_C
8127requires_config_enabled MBEDTLS_ECDSA_C
8128requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8129client_needs_more_time 4
8130run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8131 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8132 "$P_SRV dtls=1 debug_level=2 \
8133 crt_file=data_files/server7_int-ca.crt \
8134 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008135 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008136 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008137 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008138 0 \
8139 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008140
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008141## Interop test with OpenSSL might trigger a bug in recent versions (including
8142## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008143## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008144## They should be re-enabled once a fixed version of OpenSSL is available
8145## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008146skip_next_test
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008147requires_config_enabled MBEDTLS_RSA_C
8148requires_config_enabled MBEDTLS_ECDSA_C
8149requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8150client_needs_more_time 4
8151run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8152 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8153 "$O_SRV -dtls1_2 -verify 10" \
8154 "$P_CLI dtls=1 debug_level=2 \
8155 crt_file=data_files/server8_int-ca2.crt \
8156 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008157 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008158 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8159 0 \
8160 -c "fragmenting handshake message" \
8161 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008162
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008163skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008164requires_config_enabled MBEDTLS_RSA_C
8165requires_config_enabled MBEDTLS_ECDSA_C
8166requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008167client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008168run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8169 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008170 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008171 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008172 crt_file=data_files/server8_int-ca2.crt \
8173 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008174 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008175 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008176 0 \
8177 -c "fragmenting handshake message" \
8178 -C "error"
8179
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008180skip_next_test
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008181requires_config_enabled MBEDTLS_RSA_C
8182requires_config_enabled MBEDTLS_ECDSA_C
8183requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8184client_needs_more_time 4
8185run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8186 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8187 "$P_SRV dtls=1 debug_level=2 \
8188 crt_file=data_files/server7_int-ca.crt \
8189 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008190 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008191 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8192 "$O_CLI -dtls1_2" \
8193 0 \
8194 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008195
8196# -nbio is added to prevent s_client from blocking in case of duplicated
8197# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008198skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008199requires_config_enabled MBEDTLS_RSA_C
8200requires_config_enabled MBEDTLS_ECDSA_C
8201requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008202client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008203run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8204 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008205 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008206 crt_file=data_files/server7_int-ca.crt \
8207 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008208 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008209 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008210 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008211 0 \
8212 -s "fragmenting handshake message"
8213
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008214# Tests for specific things with "unreliable" UDP connection
8215
8216not_with_valgrind # spurious resend due to timeout
8217run_test "DTLS proxy: reference" \
8218 -p "$P_PXY" \
8219 "$P_SRV dtls=1 debug_level=2" \
8220 "$P_CLI dtls=1 debug_level=2" \
8221 0 \
8222 -C "replayed record" \
8223 -S "replayed record" \
Hanno Beckere03eb7b2019-07-19 15:43:09 +01008224 -C "Buffer record from epoch" \
8225 -S "Buffer record from epoch" \
8226 -C "ssl_buffer_message" \
8227 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008228 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008229 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008230 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008231 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008232 -c "HTTP/1.0 200 OK"
8233
8234not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008235run_test "DTLS proxy: duplicate every packet" \
8236 -p "$P_PXY duplicate=1" \
Hanno Becker7f376f42019-06-12 16:20:48 +01008237 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008238 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008239 0 \
8240 -c "replayed record" \
8241 -s "replayed record" \
8242 -c "record from another epoch" \
8243 -s "record from another epoch" \
8244 -S "resend" \
8245 -s "Extra-header:" \
8246 -c "HTTP/1.0 200 OK"
8247
8248run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8249 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008250 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8251 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008252 0 \
8253 -c "replayed record" \
8254 -S "replayed record" \
8255 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008256 -s "record from another epoch" \
8257 -c "resend" \
8258 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008259 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008260 -c "HTTP/1.0 200 OK"
8261
8262run_test "DTLS proxy: multiple records in same datagram" \
8263 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008264 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8265 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008266 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008267 -c "next record in same datagram" \
8268 -s "next record in same datagram"
8269
8270run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8271 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008272 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8273 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008274 0 \
8275 -c "next record in same datagram" \
8276 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008277
Jarno Lamsa33281d52019-10-18 10:54:35 +03008278requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008279run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8280 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008281 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8282 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008283 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008284 -c "discarding invalid record (mac)" \
8285 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008286 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008287 -c "HTTP/1.0 200 OK" \
8288 -S "too many records with bad MAC" \
8289 -S "Verification of the message MAC failed"
8290
Jarno Lamsa33281d52019-10-18 10:54:35 +03008291requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008292run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8293 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008294 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8295 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008296 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008297 -C "discarding invalid record (mac)" \
8298 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008299 -S "Extra-header:" \
8300 -C "HTTP/1.0 200 OK" \
8301 -s "too many records with bad MAC" \
8302 -s "Verification of the message MAC failed"
8303
Jarno Lamsa33281d52019-10-18 10:54:35 +03008304requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008305run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8306 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008307 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8308 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008309 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008310 -c "discarding invalid record (mac)" \
8311 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008312 -s "Extra-header:" \
8313 -c "HTTP/1.0 200 OK" \
8314 -S "too many records with bad MAC" \
8315 -S "Verification of the message MAC failed"
8316
Jarno Lamsa33281d52019-10-18 10:54:35 +03008317requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008318run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8319 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008320 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8321 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008322 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008323 -c "discarding invalid record (mac)" \
8324 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008325 -s "Extra-header:" \
8326 -c "HTTP/1.0 200 OK" \
8327 -s "too many records with bad MAC" \
8328 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008329
8330run_test "DTLS proxy: delay ChangeCipherSpec" \
8331 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008332 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8333 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008334 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008335 -c "record from another epoch" \
8336 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008337 -s "Extra-header:" \
8338 -c "HTTP/1.0 200 OK"
8339
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008340# Tests for reordering support with DTLS
8341
Hanno Becker56cdfd12018-08-17 13:42:15 +01008342run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8343 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008344 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8345 hs_timeout=2500-60000" \
8346 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8347 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008348 0 \
8349 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008350 -c "Next handshake message has been buffered - load"\
8351 -S "Buffering HS message" \
8352 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008353 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008354 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008355 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008356 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008357
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008358run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8359 -p "$P_PXY delay_srv=ServerHello" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03008360 "$P_SRV mtu=256 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008361 hs_timeout=2500-60000" \
8362 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8363 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008364 0 \
8365 -c "Buffering HS message" \
8366 -c "found fragmented DTLS handshake message"\
8367 -c "Next handshake message 1 not or only partially bufffered" \
8368 -c "Next handshake message has been buffered - load"\
8369 -S "Buffering HS message" \
8370 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008371 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008372 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008373 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008374 -S "Remember CCS message"
8375
Hanno Beckera1adcca2018-08-24 14:41:07 +01008376# The client buffers the ServerKeyExchange before receiving the fragmented
8377# Certificate message; at the time of writing, together these are aroudn 1200b
8378# in size, so that the bound below ensures that the certificate can be reassembled
8379# while keeping the ServerKeyExchange.
8380requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8381run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008382 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008383 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8384 hs_timeout=2500-60000" \
8385 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8386 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008387 0 \
8388 -c "Buffering HS message" \
8389 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008390 -C "attempt to make space by freeing buffered messages" \
8391 -S "Buffering HS message" \
8392 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008393 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008394 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008395 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008396 -S "Remember CCS message"
8397
8398# The size constraints ensure that the delayed certificate message can't
8399# be reassembled while keeping the ServerKeyExchange message, but it can
8400# when dropping it first.
8401requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8402requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8403run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8404 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008405 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8406 hs_timeout=2500-60000" \
8407 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8408 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008409 0 \
8410 -c "Buffering HS message" \
8411 -c "attempt to make space by freeing buffered future messages" \
8412 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008413 -S "Buffering HS message" \
8414 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008415 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008416 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008417 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008418 -S "Remember CCS message"
8419
Hanno Becker56cdfd12018-08-17 13:42:15 +01008420run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8421 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008422 "$P_SRV dgram_packing=0 auth_mode=required 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
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02008436# This needs session tickets; otherwise CCS is the first message in its flight
8437requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008438run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8439 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008440 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8441 hs_timeout=2500-60000" \
8442 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8443 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008444 0 \
8445 -C "Buffering HS message" \
8446 -C "Next handshake message has been buffered - load"\
8447 -S "Buffering HS message" \
8448 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008449 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008450 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008451 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008452 -S "Remember CCS message"
8453
Jarno Lamsa33281d52019-10-18 10:54:35 +03008454# This needs session tickets; otherwise CCS is the first message in its flight
8455requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008456run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8457 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008458 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8459 hs_timeout=2500-60000" \
8460 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8461 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008462 0 \
8463 -C "Buffering HS message" \
8464 -C "Next handshake message has been buffered - load"\
8465 -S "Buffering HS message" \
8466 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008467 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008468 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008469 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008470 -s "Remember CCS message"
8471
Hanno Beckera1adcca2018-08-24 14:41:07 +01008472run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008473 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008474 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8475 hs_timeout=2500-60000" \
8476 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8477 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008478 0 \
8479 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008480 -s "Found buffered record from current epoch - load" \
8481 -c "Buffer record from epoch 1" \
8482 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008483
Hanno Beckera1adcca2018-08-24 14:41:07 +01008484# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8485# from the server are delayed, so that the encrypted Finished message
8486# is received and buffered. When the fragmented NewSessionTicket comes
8487# in afterwards, the encrypted Finished message must be freed in order
8488# to make space for the NewSessionTicket to be reassembled.
8489# This works only in very particular circumstances:
8490# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8491# of the NewSessionTicket, but small enough to also allow buffering of
8492# the encrypted Finished message.
8493# - The MTU setting on the server must be so small that the NewSessionTicket
8494# needs to be fragmented.
8495# - All messages sent by the server must be small enough to be either sent
8496# without fragmentation or be reassembled within the bounds of
8497# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8498# handshake, omitting CRTs.
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008499requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8500requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008501run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8502 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008503 "$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 +01008504 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8505 0 \
8506 -s "Buffer record from epoch 1" \
8507 -s "Found buffered record from current epoch - load" \
8508 -c "Buffer record from epoch 1" \
8509 -C "Found buffered record from current epoch - load" \
8510 -c "Enough space available after freeing future epoch record"
8511
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008512# Tests for "randomly unreliable connection": try a variety of flows and peers
8513
8514client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008515run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8516 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008517 "$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 +02008518 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008519 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008520 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8521 0 \
8522 -s "Extra-header:" \
8523 -c "HTTP/1.0 200 OK"
8524
Janos Follath74537a62016-09-02 13:45:28 +01008525client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008526run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8527 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008528 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8529 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008530 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8531 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é-Gonnard18e519a2014-09-24 19:09:17 +02008536run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
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 tickets=0 auth_mode=none" \
8539 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008540 0 \
8541 -s "Extra-header:" \
8542 -c "HTTP/1.0 200 OK"
8543
Janos Follath74537a62016-09-02 13:45:28 +01008544client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008545run_test "DTLS proxy: 3d, FS, client auth" \
8546 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008547 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8548 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008549 0 \
8550 -s "Extra-header:" \
8551 -c "HTTP/1.0 200 OK"
8552
Janos Follath74537a62016-09-02 13:45:28 +01008553client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008554run_test "DTLS proxy: 3d, FS, ticket" \
8555 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008556 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8557 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008558 0 \
8559 -s "Extra-header:" \
8560 -c "HTTP/1.0 200 OK"
8561
Janos Follath74537a62016-09-02 13:45:28 +01008562client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008563run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8564 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008565 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8566 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008567 0 \
8568 -s "Extra-header:" \
8569 -c "HTTP/1.0 200 OK"
8570
Janos Follath74537a62016-09-02 13:45:28 +01008571client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008572run_test "DTLS proxy: 3d, max handshake, nbio" \
8573 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008574 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008575 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008576 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008577 0 \
8578 -s "Extra-header:" \
8579 -c "HTTP/1.0 200 OK"
8580
Janos Follath74537a62016-09-02 13:45:28 +01008581client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008582requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008583requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008584requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008585run_test "DTLS proxy: 3d, min handshake, resumption" \
8586 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008587 "$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 +02008588 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008589 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008590 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8591 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8592 0 \
8593 -s "a session has been resumed" \
8594 -c "a session has been resumed" \
8595 -s "Extra-header:" \
8596 -c "HTTP/1.0 200 OK"
8597
Janos Follath74537a62016-09-02 13:45:28 +01008598client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008599requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008600requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008601requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008602run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8603 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008604 "$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 +02008605 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008606 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008607 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8608 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8609 0 \
8610 -s "a session has been resumed" \
8611 -c "a session has been resumed" \
8612 -s "Extra-header:" \
8613 -c "HTTP/1.0 200 OK"
8614
Janos Follath74537a62016-09-02 13:45:28 +01008615client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008616requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008617run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008618 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008619 "$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 +02008620 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008621 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008622 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008623 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8624 0 \
8625 -c "=> renegotiate" \
8626 -s "=> renegotiate" \
8627 -s "Extra-header:" \
8628 -c "HTTP/1.0 200 OK"
8629
Janos Follath74537a62016-09-02 13:45:28 +01008630client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008631requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008632run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8633 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008634 "$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 +02008635 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008636 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008637 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008638 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8639 0 \
8640 -c "=> renegotiate" \
8641 -s "=> renegotiate" \
8642 -s "Extra-header:" \
8643 -c "HTTP/1.0 200 OK"
8644
Janos Follath74537a62016-09-02 13:45:28 +01008645client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008646requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008647run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008648 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008649 "$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 +02008650 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008651 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008652 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008653 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008654 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8655 0 \
8656 -c "=> renegotiate" \
8657 -s "=> renegotiate" \
8658 -s "Extra-header:" \
8659 -c "HTTP/1.0 200 OK"
8660
Janos Follath74537a62016-09-02 13:45:28 +01008661client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008662requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008663run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008664 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008665 "$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 +02008666 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008667 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008668 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008669 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008670 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8671 0 \
8672 -c "=> renegotiate" \
8673 -s "=> renegotiate" \
8674 -s "Extra-header:" \
8675 -c "HTTP/1.0 200 OK"
8676
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008677## Interop tests with OpenSSL might trigger a bug in recent versions (including
8678## all versions installed on the CI machines), reported here:
8679## Bug report: https://github.com/openssl/openssl/issues/6902
8680## They should be re-enabled once a fixed version of OpenSSL is available
8681## (this should happen in some 1.1.1_ release according to the ticket).
8682skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008683client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008684not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008685run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008686 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8687 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008688 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008689 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008690 -c "HTTP/1.0 200 OK"
8691
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008692skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008693client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008694not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008695run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8696 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8697 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008698 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008699 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008700 -c "HTTP/1.0 200 OK"
8701
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008702skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008703client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008704not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008705run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8706 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8707 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008708 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008709 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008710 -c "HTTP/1.0 200 OK"
8711
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008712requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008713client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008714not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008715run_test "DTLS proxy: 3d, gnutls server" \
8716 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8717 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008718 "$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 +02008719 0 \
8720 -s "Extra-header:" \
8721 -c "Extra-header:"
8722
k-stachowiakabb843e2019-02-18 16:14:03 +01008723requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008724client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008725not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008726run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8727 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008728 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008729 "$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 +02008730 0 \
8731 -s "Extra-header:" \
8732 -c "Extra-header:"
8733
k-stachowiakabb843e2019-02-18 16:14:03 +01008734requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008735client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008736not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008737run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8738 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008739 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008740 "$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 +02008741 0 \
8742 -s "Extra-header:" \
8743 -c "Extra-header:"
8744
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008745# Final report
8746
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008747echo "------------------------------------------------------------------------"
8748
8749if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008750 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008751else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008752 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008753fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008754PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008755echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008756
8757exit $FAILS