blob: a6ad765e7ef79c88fdfc7e76cb4205182e4bc297 [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
659 echo "FORCE SKIP"
660 SKIP_NEXT="YES"
661 fi
662
663 # OpenSSL cmd line
664
665 if echo "$CMD" | grep -e "-tls1\($\|[^_]\)" > /dev/null; then
666 if [ "$__VAL_MIN" != "1" ] || [ "$__VAL_MAX" != "1" ]; then
667 SKIP_NEXT="YES"
668 fi
669 fi
670
671 if echo "$CMD" | grep -e "-\(dtls1\($\|[^_]\)\|tls1_1\)" > /dev/null; then
672 if [ "$__VAL_MIN" != "2" ] || [ "$__VAL_MAX" != "2" ]; then
673 SKIP_NEXT="YES"
674 fi
675 fi
676
677 if echo "$CMD" | grep -e "-\(dtls1_2\($\|[^_]\)\|tls1_2\)" > /dev/null; then
678 if [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ]; then
679 SKIP_NEXT="YES"
680 fi
681 fi
682
683 fi
684}
685
Hanno Becker69c6cde2019-09-02 14:34:23 +0100686check_cmdline_crt_key_files_compat() {
687
688 # test-ca2.crt
689 if echo "$CMD" | grep -e "test-ca2" > /dev/null; then
690 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
691 fi
692
693 # Variants of server5.key and server5.crt
694 if echo "$CMD" | grep -e "server5" > /dev/null; then
695 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
696 fi
697
698 # Variants of server6.key and server6.crt
699 if echo "$CMD" | grep -e "server6" > /dev/null; then
700 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
701 fi
702
703}
704
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100705# Go through all options that can be hardcoded at compile-time and
706# detect whether the command line configures them in a conflicting
707# way. If so, skip the test. Otherwise, remove the corresponding
708# entry.
709# Parameter 1: Command line to inspect
710# Output: Modified command line
711# ENV I/O: SKIP_TEST set to 1 on mismatch.
712check_cmdline_compat() {
713 CMD="$1"
714
Hanno Becker69c6cde2019-09-02 14:34:23 +0100715 # Check that if we're specifying particular certificate and/or
716 # ECC key files, the corresponding curve is enabled.
717 check_cmdline_crt_key_files_compat
718
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100719 # ExtendedMasterSecret configuration
720 check_cmdline_param_compat "extended_ms" \
721 "MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET"
722 check_cmdline_param_compat "enforce_extended_master_secret" \
723 "MBEDTLS_SSL_CONF_ENFORCE_EXTENDED_MASTER_SECRET"
Hanno Becker7f376f42019-06-12 16:20:48 +0100724
725 # DTLS anti replay protection configuration
726 check_cmdline_param_compat "anti_replay" \
727 "MBEDTLS_SSL_CONF_ANTI_REPLAY"
728
Hanno Beckerde671542019-06-12 16:30:46 +0100729 # DTLS bad MAC limit
730 check_cmdline_param_compat "badmac_limit" \
731 "MBEDTLS_SSL_CONF_BADMAC_LIMIT"
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100732
Hanno Beckera43f85c2019-09-05 14:51:20 +0100733 # Skip tests relying on TLS/DTLS in configs that disable it.
734 check_cmdline_check_tls_dtls
Hanno Becker73b72d12019-07-26 12:00:38 +0100735
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100736 # Authentication mode
737 check_cmdline_authmode_compat
Hanno Beckerb0b2b672019-06-12 16:58:10 +0100738
739 # Legacy renegotiation
740 check_cmdline_legacy_renego_compat
Hanno Beckerd82a0302019-07-05 11:40:52 +0100741
742 # Version configuration
743 check_cmdline_min_minor_version_compat
744 check_cmdline_max_minor_version_compat
745 check_cmdline_force_version_compat
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100746}
747
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200748# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100749# Options: -s pattern pattern that must be present in server output
750# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100751# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100752# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100753# -S pattern pattern that must be absent in server output
754# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100755# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100756# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100757run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100758 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200759 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100760
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100761 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
762 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200763 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100764 return
765 fi
766
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100767 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100768
Paul Bakkerb7584a52016-05-10 10:50:43 +0100769 # Do we only run numbered tests?
770 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
771 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
772 else
773 SKIP_NEXT="YES"
774 fi
775
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200776 # does this test use a proxy?
777 if [ "X$1" = "X-p" ]; then
778 PXY_CMD="$2"
779 shift 2
780 else
781 PXY_CMD=""
782 fi
783
784 # get commands and client output
785 SRV_CMD="$1"
786 CLI_CMD="$2"
787 CLI_EXPECT="$3"
788 shift 3
789
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100790 check_cmdline_compat "$SRV_CMD"
791 SRV_CMD="$CMD"
792
793 check_cmdline_compat "$CLI_CMD"
794 CLI_CMD="$CMD"
795
Hanno Becker7a11e722019-05-10 14:38:42 +0100796 # Check if test uses files
797 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
798 if [ ! -z "$TEST_USES_FILES" ]; then
799 requires_config_enabled MBEDTLS_FS_IO
800 fi
801
802 # should we skip?
803 if [ "X$SKIP_NEXT" = "XYES" ]; then
804 SKIP_NEXT="NO"
805 echo "SKIP"
806 SKIPS=$(( $SKIPS + 1 ))
807 return
808 fi
809
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200810 # fix client port
811 if [ -n "$PXY_CMD" ]; then
812 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
813 else
814 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
815 fi
816
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200817 # update DTLS variable
818 detect_dtls "$SRV_CMD"
819
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100820 # prepend valgrind to our commands if active
821 if [ "$MEMCHECK" -gt 0 ]; then
822 if is_polar "$SRV_CMD"; then
823 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
824 fi
825 if is_polar "$CLI_CMD"; then
826 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
827 fi
828 fi
829
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200830 TIMES_LEFT=2
831 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200832 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200833
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200834 # run the commands
835 if [ -n "$PXY_CMD" ]; then
836 echo "$PXY_CMD" > $PXY_OUT
837 $PXY_CMD >> $PXY_OUT 2>&1 &
838 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400839 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200840 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200841
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200842 check_osrv_dtls
843 echo "$SRV_CMD" > $SRV_OUT
844 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
845 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100846 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200847
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200848 echo "$CLI_CMD" > $CLI_OUT
849 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
850 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100851
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100852 sleep 0.05
853
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200854 # terminate the server (and the proxy)
855 kill $SRV_PID
856 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100857
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200858 if [ -n "$PXY_CMD" ]; then
859 kill $PXY_PID >/dev/null 2>&1
860 wait $PXY_PID
861 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100862
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200863 # retry only on timeouts
864 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
865 printf "RETRY "
866 else
867 TIMES_LEFT=0
868 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200869 done
870
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100871 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200872 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100873 # expected client exit to incorrectly succeed in case of catastrophic
874 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100875 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200876 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100877 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100878 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100879 return
880 fi
881 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100882 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200883 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100884 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100885 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100886 return
887 fi
888 fi
889
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100890 # check server exit code
891 if [ $? != 0 ]; then
892 fail "server fail"
893 return
894 fi
895
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100896 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100897 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
898 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100899 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200900 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100901 return
902 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100903
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100904 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200905 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100906 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100907 while [ $# -gt 0 ]
908 do
909 case $1 in
910 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100911 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 +0100912 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100913 return
914 fi
915 ;;
916
917 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100918 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 +0100919 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100920 return
921 fi
922 ;;
923
924 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100925 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 +0100926 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100927 return
928 fi
929 ;;
930
931 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100932 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 +0100933 fail "pattern '$2' MUST NOT be present in the Client output"
934 return
935 fi
936 ;;
937
938 # The filtering in the following two options (-u and -U) do the following
939 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100940 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100941 # - keep one of each non-unique line
942 # - count how many lines remain
943 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
944 # if there were no duplicates.
945 "-U")
946 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
947 fail "lines following pattern '$2' must be unique in Server output"
948 return
949 fi
950 ;;
951
952 "-u")
953 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
954 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100955 return
956 fi
957 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100958 "-F")
959 if ! $2 "$SRV_OUT"; then
960 fail "function call to '$2' failed on Server output"
961 return
962 fi
963 ;;
964 "-f")
965 if ! $2 "$CLI_OUT"; then
966 fail "function call to '$2' failed on Client output"
967 return
968 fi
969 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100970
971 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200972 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100973 exit 1
974 esac
975 shift 2
976 done
977
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100978 # check valgrind's results
979 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200980 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100981 fail "Server has memory errors"
982 return
983 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200984 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100985 fail "Client has memory errors"
986 return
987 fi
988 fi
989
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100990 # if we're here, everything is ok
991 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100992 if [ "$PRESERVE_LOGS" -gt 0 ]; then
993 mv $SRV_OUT o-srv-${TESTS}.log
994 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100995 if [ -n "$PXY_CMD" ]; then
996 mv $PXY_OUT o-pxy-${TESTS}.log
997 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100998 fi
999
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001000 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001001}
1002
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001003cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001004 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +02001005 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
1006 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
1007 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
1008 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001009 exit 1
1010}
1011
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +01001012#
1013# MAIN
1014#
1015
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +01001016get_options "$@"
1017
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001018# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +01001019P_SRV_BIN="${P_SRV%%[ ]*}"
1020P_CLI_BIN="${P_CLI%%[ ]*}"
1021P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +01001022if [ ! -x "$P_SRV_BIN" ]; then
1023 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001024 exit 1
1025fi
Hanno Becker17c04932017-10-10 14:44:53 +01001026if [ ! -x "$P_CLI_BIN" ]; then
1027 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001028 exit 1
1029fi
Hanno Becker17c04932017-10-10 14:44:53 +01001030if [ ! -x "$P_PXY_BIN" ]; then
1031 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001032 exit 1
1033fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +01001034if [ "$MEMCHECK" -gt 0 ]; then
1035 if which valgrind >/dev/null 2>&1; then :; else
1036 echo "Memcheck not possible. Valgrind not found"
1037 exit 1
1038 fi
1039fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001040if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1041 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001042 exit 1
1043fi
1044
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001045# used by watchdog
1046MAIN_PID="$$"
1047
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001048# We use somewhat arbitrary delays for tests:
1049# - how long do we wait for the server to start (when lsof not available)?
1050# - how long do we allow for the client to finish?
1051# (not to check performance, just to avoid waiting indefinitely)
1052# Things are slower with valgrind, so give extra time here.
1053#
1054# Note: without lsof, there is a trade-off between the running time of this
1055# script and the risk of spurious errors because we didn't wait long enough.
1056# The watchdog delay on the other hand doesn't affect normal running time of
1057# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001058if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001059 START_DELAY=6
1060 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001061else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001062 START_DELAY=2
1063 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001064fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001065
1066# some particular tests need more time:
1067# - for the client, we multiply the usual watchdog limit by a factor
1068# - for the server, we sleep for a number of seconds after the client exits
1069# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001070CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001071SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001072
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001073# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001074# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001075P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1076P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001077P_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 +02001078O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001079O_CLI="$O_CLI -connect localhost:+SRV_PORT"
1080G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001081G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001082
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001083if [ -n "${OPENSSL_LEGACY:-}" ]; then
1084 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1085 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1086fi
1087
Hanno Becker58e9dc32018-08-17 15:53:21 +01001088if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001089 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1090fi
1091
Hanno Becker58e9dc32018-08-17 15:53:21 +01001092if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001093 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001094fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001095
Gilles Peskine62469d92017-05-10 10:13:59 +02001096# Allow SHA-1, because many of our test certificates use it
1097P_SRV="$P_SRV allow_sha1=1"
1098P_CLI="$P_CLI allow_sha1=1"
1099
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001100# Also pick a unique name for intermediate files
1101SRV_OUT="srv_out.$$"
1102CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001103PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001104SESSION="session.$$"
1105
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001106SKIP_NEXT="NO"
1107
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001108trap cleanup INT TERM HUP
1109
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001110# Basic test
1111
Hanno Becker91900362019-07-03 13:22:59 +01001112run_test "Default" \
1113 "$P_SRV debug_level=3" \
1114 "$P_CLI" \
1115 0
1116
1117run_test "Default, DTLS" \
1118 "$P_SRV dtls=1" \
1119 "$P_CLI dtls=1" \
1120 0
1121
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001122# Checks that:
1123# - things work with all ciphersuites active (used with config-full in all.sh)
1124# - the expected (highest security) parameters are selected
1125# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Hanno Becker91900362019-07-03 13:22:59 +01001126requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1127requires_config_enabled MBEDTLS_SHA512_C
1128requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1129requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1130run_test "Default, choose highest security suite and hash" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001131 "$P_SRV debug_level=3" \
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03001132 "$P_CLI" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001133 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001134 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001135 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001136 -s "client hello v3, signature_algorithm ext: 6" \
1137 -s "ECDHE curve: secp521r1" \
1138 -S "error" \
1139 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001140
Hanno Becker91900362019-07-03 13:22:59 +01001141requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1142requires_config_enabled MBEDTLS_SHA512_C
1143requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1144requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1145run_test "Default, choose highest security suite and hash, DTLS" \
1146 "$P_SRV debug_level=3 dtls=1" \
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001147 "$P_CLI dtls=1" \
1148 0 \
1149 -s "Protocol is DTLSv1.2" \
Hanno Becker91900362019-07-03 13:22:59 +01001150 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
1151 -s "client hello v3, signature_algorithm ext: 6" \
1152 -s "ECDHE curve: secp521r1"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001153
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001154# Test current time in ServerHello
1155requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001156run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001157 "$P_SRV debug_level=3" \
1158 "$P_CLI debug_level=3" \
1159 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001160 -f "check_server_hello_time" \
1161 -F "check_server_hello_time"
1162
Simon Butcher8e004102016-10-14 00:48:33 +01001163# Test for uniqueness of IVs in AEAD ciphersuites
1164run_test "Unique IV in GCM" \
1165 "$P_SRV exchanges=20 debug_level=4" \
1166 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1167 0 \
1168 -u "IV used" \
1169 -U "IV used"
1170
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001171# Tests for rc4 option
1172
Simon Butchera410af52016-05-19 22:12:18 +01001173requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001174run_test "RC4: server disabled, client enabled" \
1175 "$P_SRV" \
1176 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1177 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001178 -s "SSL - The server has no ciphersuites in common"
1179
Simon Butchera410af52016-05-19 22:12:18 +01001180requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001181run_test "RC4: server half, client enabled" \
1182 "$P_SRV arc4=1" \
1183 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1184 1 \
1185 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001186
1187run_test "RC4: server enabled, client disabled" \
1188 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1189 "$P_CLI" \
1190 1 \
1191 -s "SSL - The server has no ciphersuites in common"
1192
1193run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001194 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001195 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1196 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001197 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001198 -S "SSL - The server has no ciphersuites in common"
1199
Hanno Beckerd26bb202018-08-17 09:54:10 +01001200# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1201
1202requires_gnutls
1203requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1204run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1205 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001206 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001207 0
1208
1209requires_gnutls
1210requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1211run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1212 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001213 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001214 0
1215
Gilles Peskinebc70a182017-05-09 15:59:24 +02001216# Tests for SHA-1 support
1217
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001218requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001219requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001220requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001221run_test "SHA-1 forbidden by default in server certificate" \
1222 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1223 "$P_CLI debug_level=2 allow_sha1=0" \
1224 1 \
1225 -c "The certificate is signed with an unacceptable hash"
1226
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001227requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1228run_test "SHA-1 forbidden by default in server certificate" \
1229 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1230 "$P_CLI debug_level=2 allow_sha1=0" \
1231 0
1232
Gilles Peskinebc70a182017-05-09 15:59:24 +02001233run_test "SHA-1 explicitly allowed in server certificate" \
1234 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1235 "$P_CLI allow_sha1=1" \
1236 0
1237
1238run_test "SHA-256 allowed by default in server certificate" \
1239 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1240 "$P_CLI allow_sha1=0" \
1241 0
1242
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001243requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001244requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001245requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001246run_test "SHA-1 forbidden by default in client certificate" \
1247 "$P_SRV auth_mode=required allow_sha1=0" \
1248 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1249 1 \
1250 -s "The certificate is signed with an unacceptable hash"
1251
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001252requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1253run_test "SHA-1 forbidden by default in client certificate" \
1254 "$P_SRV auth_mode=required allow_sha1=0" \
1255 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1256 0
1257
Gilles Peskinebc70a182017-05-09 15:59:24 +02001258run_test "SHA-1 explicitly allowed in client certificate" \
1259 "$P_SRV auth_mode=required allow_sha1=1" \
1260 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1261 0
1262
1263run_test "SHA-256 allowed by default in client certificate" \
1264 "$P_SRV auth_mode=required allow_sha1=0" \
1265 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1266 0
1267
Hanno Becker7ae8a762018-08-14 15:43:35 +01001268# Tests for datagram packing
1269run_test "DTLS: multiple records in same datagram, client and server" \
1270 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1271 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1272 0 \
1273 -c "next record in same datagram" \
1274 -s "next record in same datagram"
1275
1276run_test "DTLS: multiple records in same datagram, client only" \
1277 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1278 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1279 0 \
1280 -s "next record in same datagram" \
1281 -C "next record in same datagram"
1282
1283run_test "DTLS: multiple records in same datagram, server only" \
1284 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1285 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1286 0 \
1287 -S "next record in same datagram" \
1288 -c "next record in same datagram"
1289
1290run_test "DTLS: multiple records in same datagram, neither client nor server" \
1291 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1292 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1293 0 \
1294 -S "next record in same datagram" \
1295 -C "next record in same datagram"
1296
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001297# Tests for Truncated HMAC extension
1298
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001299run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001300 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001301 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001302 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001303 -s "dumping 'expected mac' (20 bytes)" \
1304 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001305
Hanno Becker32c55012017-11-10 08:42:54 +00001306requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001307run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001308 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001309 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001310 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001311 -s "dumping 'expected mac' (20 bytes)" \
1312 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001313
Hanno Becker32c55012017-11-10 08:42:54 +00001314requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001315run_test "Truncated HMAC: client enabled, server default" \
1316 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001317 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001318 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001319 -s "dumping 'expected mac' (20 bytes)" \
1320 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001321
Hanno Becker32c55012017-11-10 08:42:54 +00001322requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001323run_test "Truncated HMAC: client enabled, server disabled" \
1324 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001325 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001326 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001327 -s "dumping 'expected mac' (20 bytes)" \
1328 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001329
Hanno Becker32c55012017-11-10 08:42:54 +00001330requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001331run_test "Truncated HMAC: client disabled, server enabled" \
1332 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001333 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001334 0 \
1335 -s "dumping 'expected mac' (20 bytes)" \
1336 -S "dumping 'expected mac' (10 bytes)"
1337
1338requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001339run_test "Truncated HMAC: client enabled, server enabled" \
1340 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001341 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001342 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001343 -S "dumping 'expected mac' (20 bytes)" \
1344 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001345
Jarno Lamsa33281d52019-10-18 10:54:35 +03001346requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker4c4f4102017-11-10 09:16:05 +00001347run_test "Truncated HMAC, DTLS: client default, server default" \
1348 "$P_SRV dtls=1 debug_level=4" \
1349 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1350 0 \
1351 -s "dumping 'expected mac' (20 bytes)" \
1352 -S "dumping 'expected mac' (10 bytes)"
1353
1354requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1355run_test "Truncated HMAC, DTLS: client disabled, server default" \
1356 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001357 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001358 0 \
1359 -s "dumping 'expected mac' (20 bytes)" \
1360 -S "dumping 'expected mac' (10 bytes)"
1361
1362requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1363run_test "Truncated HMAC, DTLS: client enabled, server default" \
1364 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001365 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001366 0 \
1367 -s "dumping 'expected mac' (20 bytes)" \
1368 -S "dumping 'expected mac' (10 bytes)"
1369
1370requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1371run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1372 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001373 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001374 0 \
1375 -s "dumping 'expected mac' (20 bytes)" \
1376 -S "dumping 'expected mac' (10 bytes)"
1377
1378requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1379run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1380 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001381 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001382 0 \
1383 -s "dumping 'expected mac' (20 bytes)" \
1384 -S "dumping 'expected mac' (10 bytes)"
1385
1386requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1387run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1388 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001389 "$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 +01001390 0 \
1391 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001392 -s "dumping 'expected mac' (10 bytes)"
1393
Jarno Lamsafa45e602019-06-04 11:33:23 +03001394# Tests for Context serialization
1395
1396requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001397run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001398 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001399 "$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 +03001400 0 \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001401 -c "Deserializing connection..." \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001402 -S "Deserializing connection..."
1403
1404requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001405run_test "Context serialization, client serializes, ChaChaPoly" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001406 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001407 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001408 0 \
1409 -c "Deserializing connection..." \
1410 -S "Deserializing connection..."
1411
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001412requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001413run_test "Context serialization, client serializes, GCM" \
1414 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1415 "$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 +03001416 0 \
1417 -c "Deserializing connection..." \
1418 -S "Deserializing connection..."
Jarno Lamsacc281b82019-06-04 15:21:13 +03001419
Jarno Lamsafa45e602019-06-04 11:33:23 +03001420requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001421requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1422run_test "Context serialization, client serializes, with CID" \
1423 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1424 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1425 0 \
1426 -c "Deserializing connection..." \
1427 -S "Deserializing connection..."
1428
1429requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001430run_test "Context serialization, server serializes, CCM" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001431 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001432 "$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 +03001433 0 \
1434 -C "Deserializing connection..." \
1435 -s "Deserializing connection..."
1436
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001437requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001438run_test "Context serialization, server serializes, ChaChaPoly" \
1439 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1440 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1441 0 \
1442 -C "Deserializing connection..." \
1443 -s "Deserializing connection..."
1444
1445requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1446run_test "Context serialization, server serializes, GCM" \
1447 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1448 "$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 +03001449 0 \
1450 -C "Deserializing connection..." \
Jarno Lamsacc281b82019-06-04 15:21:13 +03001451 -s "Deserializing connection..."
Jarno Lamsafa45e602019-06-04 11:33:23 +03001452
1453requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001454requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1455run_test "Context serialization, server serializes, with CID" \
1456 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1457 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1458 0 \
1459 -C "Deserializing connection..." \
1460 -s "Deserializing connection..."
1461
1462requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001463run_test "Context serialization, both serialize, CCM" \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001464 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001465 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1466 0 \
1467 -c "Deserializing connection..." \
1468 -s "Deserializing connection..."
1469
1470requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1471run_test "Context serialization, both serialize, ChaChaPoly" \
1472 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1473 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1474 0 \
1475 -c "Deserializing connection..." \
1476 -s "Deserializing connection..."
1477
1478requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1479run_test "Context serialization, both serialize, GCM" \
1480 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1481 "$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 +03001482 0 \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001483 -c "Deserializing connection..." \
1484 -s "Deserializing connection..."
1485
1486requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001487requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1488run_test "Context serialization, both serialize, with CID" \
1489 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1490 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1491 0 \
1492 -c "Deserializing connection..." \
1493 -s "Deserializing connection..."
1494
1495requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001496run_test "Context serialization, re-init, client serializes, CCM" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001497 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001498 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1499 0 \
1500 -c "Deserializing connection..." \
1501 -S "Deserializing connection..."
1502
1503requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1504run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1505 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1506 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1507 0 \
1508 -c "Deserializing connection..." \
1509 -S "Deserializing connection..."
1510
1511requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1512run_test "Context serialization, re-init, client serializes, GCM" \
1513 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1514 "$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 +03001515 0 \
1516 -c "Deserializing connection..." \
1517 -S "Deserializing connection..."
1518
1519requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001520requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1521run_test "Context serialization, re-init, client serializes, with CID" \
1522 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1523 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1524 0 \
1525 -c "Deserializing connection..." \
1526 -S "Deserializing connection..."
1527
1528requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001529run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001530 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001531 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1532 0 \
1533 -C "Deserializing connection..." \
1534 -s "Deserializing connection..."
1535
1536requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1537run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1538 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1539 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1540 0 \
1541 -C "Deserializing connection..." \
1542 -s "Deserializing connection..."
1543
1544requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1545run_test "Context serialization, re-init, server serializes, GCM" \
1546 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1547 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001548 0 \
1549 -C "Deserializing connection..." \
1550 -s "Deserializing connection..."
1551
1552requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001553requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1554run_test "Context serialization, re-init, server serializes, with CID" \
1555 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1556 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1557 0 \
1558 -C "Deserializing connection..." \
1559 -s "Deserializing connection..."
1560
1561requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001562run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001563 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001564 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1565 0 \
1566 -c "Deserializing connection..." \
1567 -s "Deserializing connection..."
1568
1569requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1570run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1571 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1572 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1573 0 \
1574 -c "Deserializing connection..." \
1575 -s "Deserializing connection..."
1576
1577requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1578run_test "Context serialization, re-init, both serialize, GCM" \
1579 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1580 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001581 0 \
1582 -c "Deserializing connection..." \
1583 -s "Deserializing connection..."
1584
Hanno Beckere80c1b02019-08-30 11:18:59 +01001585requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1586requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1587run_test "Context serialization, re-init, both serialize, with CID" \
1588 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1589 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001590 0 \
1591 -c "Deserializing connection..." \
Hanno Becker73455992019-04-25 17:01:43 +01001592 -s "Deserializing connection..."
Hanno Beckerc008cb52019-04-26 14:17:56 +01001593
Hanno Becker4eb05872019-04-26 16:00:29 +01001594# Tests for DTLS Connection ID extension
Hanno Beckercf2a5652019-04-26 16:13:31 +01001595
Hanno Becker5e2cd142019-04-26 16:23:52 +01001596# So far, the CID API isn't implemented, so we can't
1597# grep for output witnessing its use. This needs to be
Hanno Becker6a3ff282019-04-26 17:19:46 +01001598# changed once the CID extension is implemented.
Hanno Beckerad8e2c92019-05-08 13:19:53 +01001599
Hanno Becker2dcdc922019-04-09 18:08:47 +01001600requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckera5a2b082019-05-15 14:03:01 +01001601run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001602 "$P_SRV debug_level=3 dtls=1 cid=0" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03001603 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=dead" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001604 0 \
1605 -s "Disable use of CID extension." \
1606 -s "found CID extension" \
1607 -s "Client sent CID extension, but CID disabled" \
1608 -c "Enable use of CID extension." \
1609 -c "client hello, adding CID extension" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001610 -S "server hello, adding CID extension" \
1611 -C "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001612 -S "Copy CIDs into SSL transform" \
1613 -C "Copy CIDs into SSL transform" \
1614 -c "Use of Connection ID was rejected by the server"
1615
1616requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1617run_test "Connection ID: Cli disabled, Srv enabled" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03001618 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001619 "$P_CLI debug_level=3 dtls=1 cid=0" \
1620 0 \
1621 -c "Disable use of CID extension." \
1622 -C "client hello, adding CID extension" \
1623 -S "found CID extension" \
1624 -s "Enable use of CID extension." \
1625 -S "server hello, adding CID extension" \
1626 -C "found CID extension" \
1627 -S "Copy CIDs into SSL transform" \
1628 -C "Copy CIDs into SSL transform" \
1629 -s "Use of Connection ID was not offered by client"
1630
1631requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb60c85c2019-04-23 12:02:34 +01001632run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001633 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1634 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1635 0 \
1636 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001637 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001638 -c "client hello, adding CID extension" \
1639 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001640 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001641 -s "server hello, adding CID extension" \
1642 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001643 -c "Use of CID extension negotiated" \
1644 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001645 -c "Copy CIDs into SSL transform" \
1646 -c "Peer CID (length 2 Bytes): de ad" \
1647 -s "Peer CID (length 2 Bytes): be ef" \
1648 -s "Use of Connection ID has been negotiated" \
1649 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001650
Hanno Beckera5a2b082019-05-15 14:03:01 +01001651requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001652run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001653 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001654 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1655 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1656 0 \
1657 -c "Enable use of CID extension." \
1658 -s "Enable use of CID extension." \
1659 -c "client hello, adding CID extension" \
1660 -s "found CID extension" \
1661 -s "Use of CID extension negotiated" \
1662 -s "server hello, adding CID extension" \
1663 -c "found CID extension" \
1664 -c "Use of CID extension negotiated" \
1665 -s "Copy CIDs into SSL transform" \
1666 -c "Copy CIDs into SSL transform" \
1667 -c "Peer CID (length 2 Bytes): de ad" \
1668 -s "Peer CID (length 2 Bytes): be ef" \
1669 -s "Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001670 -c "Use of Connection ID has been negotiated" \
1671 -c "ignoring unexpected CID" \
1672 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01001673
Hanno Beckera5a2b082019-05-15 14:03:01 +01001674requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001675run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1676 -p "$P_PXY mtu=800" \
1677 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1678 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1679 0 \
1680 -c "Enable use of CID extension." \
1681 -s "Enable use of CID extension." \
1682 -c "client hello, adding CID extension" \
1683 -s "found CID extension" \
1684 -s "Use of CID extension negotiated" \
1685 -s "server hello, adding CID extension" \
1686 -c "found CID extension" \
1687 -c "Use of CID extension negotiated" \
1688 -s "Copy CIDs into SSL transform" \
1689 -c "Copy CIDs into SSL transform" \
1690 -c "Peer CID (length 2 Bytes): de ad" \
1691 -s "Peer CID (length 2 Bytes): be ef" \
1692 -s "Use of Connection ID has been negotiated" \
1693 -c "Use of Connection ID has been negotiated"
1694
Hanno Beckera5a2b082019-05-15 14:03:01 +01001695requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001696run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001697 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001698 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1699 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1700 0 \
1701 -c "Enable use of CID extension." \
1702 -s "Enable use of CID extension." \
1703 -c "client hello, adding CID extension" \
1704 -s "found CID extension" \
1705 -s "Use of CID extension negotiated" \
1706 -s "server hello, adding CID extension" \
1707 -c "found CID extension" \
1708 -c "Use of CID extension negotiated" \
1709 -s "Copy CIDs into SSL transform" \
1710 -c "Copy CIDs into SSL transform" \
1711 -c "Peer CID (length 2 Bytes): de ad" \
1712 -s "Peer CID (length 2 Bytes): be ef" \
1713 -s "Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001714 -c "Use of Connection ID has been negotiated" \
1715 -c "ignoring unexpected CID" \
1716 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01001717
Hanno Beckera5a2b082019-05-15 14:03:01 +01001718requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001719requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001720run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001721 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1722 "$P_CLI debug_level=3 dtls=1 cid=1" \
1723 0 \
1724 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001725 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001726 -c "client hello, adding CID extension" \
1727 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001728 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001729 -s "server hello, adding CID extension" \
1730 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001731 -c "Use of CID extension negotiated" \
1732 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001733 -c "Copy CIDs into SSL transform" \
1734 -c "Peer CID (length 4 Bytes): de ad be ef" \
1735 -s "Peer CID (length 0 Bytes):" \
1736 -s "Use of Connection ID has been negotiated" \
1737 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001738
Hanno Beckera5a2b082019-05-15 14:03:01 +01001739requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001740requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001741run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001742 "$P_SRV debug_level=3 dtls=1 cid=1" \
1743 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1744 0 \
1745 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001746 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001747 -c "client hello, adding CID extension" \
1748 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001749 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001750 -s "server hello, adding CID extension" \
1751 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001752 -c "Use of CID extension negotiated" \
1753 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001754 -c "Copy CIDs into SSL transform" \
1755 -s "Peer CID (length 4 Bytes): de ad be ef" \
1756 -c "Peer CID (length 0 Bytes):" \
1757 -s "Use of Connection ID has been negotiated" \
1758 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001759
Hanno Beckera5a2b082019-05-15 14:03:01 +01001760requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001761requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001762run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001763 "$P_SRV debug_level=3 dtls=1 cid=1" \
1764 "$P_CLI debug_level=3 dtls=1 cid=1" \
1765 0 \
1766 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001767 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001768 -c "client hello, adding CID extension" \
1769 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001770 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001771 -s "server hello, adding CID extension" \
1772 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001773 -c "Use of CID extension negotiated" \
1774 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001775 -c "Copy CIDs into SSL transform" \
1776 -S "Use of Connection ID has been negotiated" \
1777 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001778
Hanno Beckera5a2b082019-05-15 14:03:01 +01001779requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001780run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001781 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1782 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1783 0 \
1784 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001785 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001786 -c "client hello, adding CID extension" \
1787 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001788 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001789 -s "server hello, adding CID extension" \
1790 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001791 -c "Use of CID extension negotiated" \
1792 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001793 -c "Copy CIDs into SSL transform" \
1794 -c "Peer CID (length 2 Bytes): de ad" \
1795 -s "Peer CID (length 2 Bytes): be ef" \
1796 -s "Use of Connection ID has been negotiated" \
1797 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001798
Hanno Beckera5a2b082019-05-15 14:03:01 +01001799requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001800requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001801run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001802 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1803 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1804 0 \
1805 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001806 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001807 -c "client hello, adding CID extension" \
1808 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001809 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001810 -s "server hello, adding CID extension" \
1811 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001812 -c "Use of CID extension negotiated" \
1813 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001814 -c "Copy CIDs into SSL transform" \
1815 -c "Peer CID (length 4 Bytes): de ad be ef" \
1816 -s "Peer CID (length 0 Bytes):" \
1817 -s "Use of Connection ID has been negotiated" \
1818 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001819
Hanno Beckera5a2b082019-05-15 14:03:01 +01001820requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001821requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001822run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001823 "$P_SRV debug_level=3 dtls=1 cid=1" \
1824 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1825 0 \
1826 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001827 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001828 -c "client hello, adding CID extension" \
1829 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001830 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001831 -s "server hello, adding CID extension" \
1832 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001833 -c "Use of CID extension negotiated" \
1834 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001835 -c "Copy CIDs into SSL transform" \
1836 -s "Peer CID (length 4 Bytes): de ad be ef" \
1837 -c "Peer CID (length 0 Bytes):" \
1838 -s "Use of Connection ID has been negotiated" \
1839 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001840
Hanno Beckera5a2b082019-05-15 14:03:01 +01001841requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001842requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001843run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001844 "$P_SRV debug_level=3 dtls=1 cid=1" \
1845 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1846 0 \
1847 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001848 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001849 -c "client hello, adding CID extension" \
1850 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001851 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001852 -s "server hello, adding CID extension" \
1853 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001854 -c "Use of CID extension negotiated" \
1855 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001856 -c "Copy CIDs into SSL transform" \
1857 -S "Use of Connection ID has been negotiated" \
1858 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001859
Hanno Beckera5a2b082019-05-15 14:03:01 +01001860requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001861requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001862run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001863 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1864 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1865 0 \
1866 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001867 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001868 -c "client hello, adding CID extension" \
1869 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001870 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001871 -s "server hello, adding CID extension" \
1872 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001873 -c "Use of CID extension negotiated" \
1874 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001875 -c "Copy CIDs into SSL transform" \
1876 -c "Peer CID (length 2 Bytes): de ad" \
1877 -s "Peer CID (length 2 Bytes): be ef" \
1878 -s "Use of Connection ID has been negotiated" \
1879 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001880
Hanno Beckera5a2b082019-05-15 14:03:01 +01001881requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001882requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1883requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001884run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001885 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1886 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1887 0 \
1888 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001889 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001890 -c "client hello, adding CID extension" \
1891 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001892 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001893 -s "server hello, adding CID extension" \
1894 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001895 -c "Use of CID extension negotiated" \
1896 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001897 -c "Copy CIDs into SSL transform" \
1898 -c "Peer CID (length 4 Bytes): de ad be ef" \
1899 -s "Peer CID (length 0 Bytes):" \
1900 -s "Use of Connection ID has been negotiated" \
1901 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001902
Hanno Beckera5a2b082019-05-15 14:03:01 +01001903requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001904requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1905requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001906run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001907 "$P_SRV debug_level=3 dtls=1 cid=1" \
1908 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1909 0 \
1910 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001911 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001912 -c "client hello, adding CID extension" \
1913 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001914 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001915 -s "server hello, adding CID extension" \
1916 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001917 -c "Use of CID extension negotiated" \
1918 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001919 -c "Copy CIDs into SSL transform" \
1920 -s "Peer CID (length 4 Bytes): de ad be ef" \
1921 -c "Peer CID (length 0 Bytes):" \
1922 -s "Use of Connection ID has been negotiated" \
1923 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001924
Hanno Beckera5a2b082019-05-15 14:03:01 +01001925requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001926requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1927requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001928run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001929 "$P_SRV debug_level=3 dtls=1 cid=1" \
1930 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1931 0 \
1932 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001933 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001934 -c "client hello, adding CID extension" \
1935 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001936 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001937 -s "server hello, adding CID extension" \
1938 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001939 -c "Use of CID extension negotiated" \
1940 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001941 -c "Copy CIDs into SSL transform" \
1942 -S "Use of Connection ID has been negotiated" \
1943 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001944
Hanno Beckera5a2b082019-05-15 14:03:01 +01001945requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker963cb352019-04-23 11:52:44 +01001946requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001947run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001948 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1949 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1950 0 \
Hanno Becker96870292019-05-03 17:30:59 +01001951 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1952 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1953 -s "(initial handshake) Use of Connection ID has been negotiated" \
1954 -c "(initial handshake) Use of Connection ID has been negotiated" \
1955 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1956 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1957 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1958 -c "(after renegotiation) Use of Connection ID has been negotiated"
1959
Hanno Beckera5a2b082019-05-15 14:03:01 +01001960requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001961requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001962run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Becker96870292019-05-03 17:30:59 +01001963 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
1964 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1965 0 \
1966 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1967 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1968 -s "(initial handshake) Use of Connection ID has been negotiated" \
1969 -c "(initial handshake) Use of Connection ID has been negotiated" \
1970 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1971 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1972 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1973 -c "(after renegotiation) Use of Connection ID has been negotiated"
1974
Hanno Beckera5a2b082019-05-15 14:03:01 +01001975requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001976requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01001977run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
1978 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
1979 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1980 0 \
1981 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1982 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1983 -s "(initial handshake) Use of Connection ID has been negotiated" \
1984 -c "(initial handshake) Use of Connection ID has been negotiated" \
1985 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1986 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1987 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1988 -c "(after renegotiation) Use of Connection ID has been negotiated"
1989
Hanno Beckera5a2b082019-05-15 14:03:01 +01001990requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01001991requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001992run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001993 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001994 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
1995 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1996 0 \
1997 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1998 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1999 -s "(initial handshake) Use of Connection ID has been negotiated" \
2000 -c "(initial handshake) Use of Connection ID has been negotiated" \
2001 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2002 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2003 -s "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002004 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2005 -c "ignoring unexpected CID" \
2006 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002007
Hanno Beckera5a2b082019-05-15 14:03:01 +01002008requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002009requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2010run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Becker96870292019-05-03 17:30:59 +01002011 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2012 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2013 0 \
2014 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2015 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2016 -s "(initial handshake) Use of Connection ID has been negotiated" \
2017 -c "(initial handshake) Use of Connection ID has been negotiated" \
2018 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2019 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2020 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2021 -S "(after renegotiation) Use of Connection ID has been negotiated"
2022
Hanno Beckera5a2b082019-05-15 14:03:01 +01002023requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002024requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01002025run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
2026 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2027 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2028 0 \
2029 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2030 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2031 -s "(initial handshake) Use of Connection ID has been negotiated" \
2032 -c "(initial handshake) Use of Connection ID has been negotiated" \
2033 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2034 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2035 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2036 -S "(after renegotiation) Use of Connection ID has been negotiated"
2037
Hanno Beckera5a2b082019-05-15 14:03:01 +01002038requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01002039requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002040run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002041 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002042 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2043 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2044 0 \
2045 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2046 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2047 -s "(initial handshake) Use of Connection ID has been negotiated" \
2048 -c "(initial handshake) Use of Connection ID has been negotiated" \
2049 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2050 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2051 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002052 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2053 -c "ignoring unexpected CID" \
2054 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002055
Hanno Beckera5a2b082019-05-15 14:03:01 +01002056requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002057requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2058run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002059 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2060 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2061 0 \
2062 -S "(initial handshake) Use of Connection ID has been negotiated" \
2063 -C "(initial handshake) Use of Connection ID has been negotiated" \
2064 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2065 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2066 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2067 -s "(after renegotiation) Use of Connection ID has been negotiated"
2068
Hanno Beckera5a2b082019-05-15 14:03:01 +01002069requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002070requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01002071run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2072 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2073 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2074 0 \
2075 -S "(initial handshake) Use of Connection ID has been negotiated" \
2076 -C "(initial handshake) Use of Connection ID has been negotiated" \
2077 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2078 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2079 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2080 -s "(after renegotiation) Use of Connection ID has been negotiated"
2081
Hanno Beckera5a2b082019-05-15 14:03:01 +01002082requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01002083requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002084run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002085 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002086 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2087 "$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" \
2088 0 \
2089 -S "(initial handshake) Use of Connection ID has been negotiated" \
2090 -C "(initial handshake) Use of Connection ID has been negotiated" \
2091 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2092 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2093 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002094 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2095 -c "ignoring unexpected CID" \
2096 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002097
Hanno Beckera5a2b082019-05-15 14:03:01 +01002098requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002099requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2100run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002101 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2102 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2103 0 \
2104 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2105 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2106 -s "(initial handshake) Use of Connection ID has been negotiated" \
2107 -c "(initial handshake) Use of Connection ID has been negotiated" \
2108 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2109 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2110 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2111 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2112 -s "(after renegotiation) Use of Connection ID was not offered by client"
2113
Hanno Beckera5a2b082019-05-15 14:03:01 +01002114requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002115requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002116run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002117 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002118 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2119 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2120 0 \
2121 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2122 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2123 -s "(initial handshake) Use of Connection ID has been negotiated" \
2124 -c "(initial handshake) Use of Connection ID has been negotiated" \
2125 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2126 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2127 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2128 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002129 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2130 -c "ignoring unexpected CID" \
2131 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002132
Hanno Beckera5a2b082019-05-15 14:03:01 +01002133requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002134requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2135run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2136 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2137 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2138 0 \
2139 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2140 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2141 -s "(initial handshake) Use of Connection ID has been negotiated" \
2142 -c "(initial handshake) Use of Connection ID has been negotiated" \
2143 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2144 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2145 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2146 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2147 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2148
Hanno Beckera5a2b082019-05-15 14:03:01 +01002149requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002150requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2151run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002152 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker96870292019-05-03 17:30:59 +01002153 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2154 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2155 0 \
2156 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2157 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2158 -s "(initial handshake) Use of Connection ID has been negotiated" \
2159 -c "(initial handshake) Use of Connection ID has been negotiated" \
2160 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2161 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2162 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2163 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002164 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2165 -c "ignoring unexpected CID" \
2166 -s "ignoring unexpected CID"
Hanno Becker2dcdc922019-04-09 18:08:47 +01002167
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002168# Tests for Encrypt-then-MAC extension
2169
2170run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002171 "$P_SRV debug_level=3 \
2172 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002173 "$P_CLI debug_level=3" \
2174 0 \
2175 -c "client hello, adding encrypt_then_mac extension" \
2176 -s "found encrypt then mac extension" \
2177 -s "server hello, adding encrypt then mac extension" \
2178 -c "found encrypt_then_mac extension" \
2179 -c "using encrypt then mac" \
2180 -s "using encrypt then mac"
2181
2182run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002183 "$P_SRV debug_level=3 etm=0 \
2184 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002185 "$P_CLI debug_level=3 etm=1" \
2186 0 \
2187 -c "client hello, adding encrypt_then_mac extension" \
2188 -s "found encrypt then mac extension" \
2189 -S "server hello, adding encrypt then mac extension" \
2190 -C "found encrypt_then_mac extension" \
2191 -C "using encrypt then mac" \
2192 -S "using encrypt then mac"
2193
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002194run_test "Encrypt then MAC: client enabled, aead cipher" \
2195 "$P_SRV debug_level=3 etm=1 \
2196 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2197 "$P_CLI debug_level=3 etm=1" \
2198 0 \
2199 -c "client hello, adding encrypt_then_mac extension" \
2200 -s "found encrypt then mac extension" \
2201 -S "server hello, adding encrypt then mac extension" \
2202 -C "found encrypt_then_mac extension" \
2203 -C "using encrypt then mac" \
2204 -S "using encrypt then mac"
2205
2206run_test "Encrypt then MAC: client enabled, stream cipher" \
2207 "$P_SRV debug_level=3 etm=1 \
2208 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002209 "$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 +01002210 0 \
2211 -c "client hello, adding encrypt_then_mac extension" \
2212 -s "found encrypt then mac extension" \
2213 -S "server hello, adding encrypt then mac extension" \
2214 -C "found encrypt_then_mac extension" \
2215 -C "using encrypt then mac" \
2216 -S "using encrypt then mac"
2217
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002218run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002219 "$P_SRV debug_level=3 etm=1 \
2220 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002221 "$P_CLI debug_level=3 etm=0" \
2222 0 \
2223 -C "client hello, adding encrypt_then_mac extension" \
2224 -S "found encrypt then mac extension" \
2225 -S "server hello, adding encrypt then mac extension" \
2226 -C "found encrypt_then_mac extension" \
2227 -C "using encrypt then mac" \
2228 -S "using encrypt then mac"
2229
Janos Follathe2681a42016-03-07 15:57:05 +00002230requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002231run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002232 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002233 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002234 "$P_CLI debug_level=3 force_version=ssl3" \
2235 0 \
2236 -C "client hello, adding encrypt_then_mac extension" \
2237 -S "found encrypt then mac extension" \
2238 -S "server hello, adding encrypt then mac extension" \
2239 -C "found encrypt_then_mac extension" \
2240 -C "using encrypt then mac" \
2241 -S "using encrypt then mac"
2242
Janos Follathe2681a42016-03-07 15:57:05 +00002243requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002244run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002245 "$P_SRV debug_level=3 force_version=ssl3 \
2246 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002247 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002248 0 \
2249 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002250 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002251 -S "server hello, adding encrypt then mac extension" \
2252 -C "found encrypt_then_mac extension" \
2253 -C "using encrypt then mac" \
2254 -S "using encrypt then mac"
2255
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002256# Tests for Extended Master Secret extension
2257
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002258run_test "Extended Master Secret: default (not enforcing)" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002259 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0 " \
2260 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002261 0 \
2262 -c "client hello, adding extended_master_secret extension" \
2263 -s "found extended master secret extension" \
2264 -s "server hello, adding extended master secret extension" \
2265 -c "found extended_master_secret extension" \
2266 -c "session hash for extended master secret" \
2267 -s "session hash for extended master secret"
2268
2269run_test "Extended Master Secret: both enabled, both enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002270 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2271 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002272 0 \
2273 -c "client hello, adding extended_master_secret extension" \
2274 -s "found extended master secret extension" \
2275 -s "server hello, adding extended master secret extension" \
2276 -c "found extended_master_secret extension" \
2277 -c "session hash for extended master secret" \
2278 -s "session hash for extended master secret"
2279
Jarno Lamsa20095af2019-06-11 17:16:58 +03002280run_test "Extended Master Secret: both enabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002281 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2282 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002283 0 \
2284 -c "client hello, adding extended_master_secret extension" \
2285 -s "found extended master secret extension" \
2286 -s "server hello, adding extended master secret extension" \
2287 -c "found extended_master_secret extension" \
2288 -c "session hash for extended master secret" \
2289 -s "session hash for extended master secret"
2290
2291run_test "Extended Master Secret: both enabled, server enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002292 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2293 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002294 0 \
2295 -c "client hello, adding extended_master_secret extension" \
2296 -s "found extended master secret extension" \
2297 -s "server hello, adding extended master secret extension" \
2298 -c "found extended_master_secret extension" \
2299 -c "session hash for extended master secret" \
2300 -s "session hash for extended master secret"
2301
2302run_test "Extended Master Secret: client enabled, server disabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002303 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002304 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2305 1 \
2306 -c "client hello, adding extended_master_secret extension" \
2307 -s "found extended master secret extension" \
2308 -S "server hello, adding extended master secret extension" \
2309 -C "found extended_master_secret extension" \
2310 -c "Peer not offering extended master secret, while it is enforced"
2311
Jarno Lamsa20095af2019-06-11 17:16:58 +03002312run_test "Extended Master Secret enforced: client disabled, server enabled, server enforcing" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002313 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002314 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002315 1 \
2316 -C "client hello, adding extended_master_secret extension" \
2317 -S "found extended master secret extension" \
2318 -S "server hello, adding extended master secret extension" \
2319 -C "found extended_master_secret extension" \
2320 -s "Peer not offering extended master secret, while it is enforced"
2321
Jarno Lamsa20095af2019-06-11 17:16:58 +03002322run_test "Extended Master Secret: client enabled, server disabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002323 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2324 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002325 0 \
2326 -c "client hello, adding extended_master_secret extension" \
2327 -s "found extended master secret extension" \
2328 -S "server hello, adding extended master secret extension" \
2329 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002330 -C "session hash for extended master secret" \
2331 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002332
Jarno Lamsa20095af2019-06-11 17:16:58 +03002333run_test "Extended Master Secret: client disabled, server enabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002334 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2335 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002336 0 \
2337 -C "client hello, adding extended_master_secret extension" \
2338 -S "found extended master secret extension" \
2339 -S "server hello, adding extended master secret extension" \
2340 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002341 -C "session hash for extended master secret" \
2342 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002343
Jarno Lamsa20095af2019-06-11 17:16:58 +03002344run_test "Extended Master Secret: client disabled, server disabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002345 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2346 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002347 0 \
2348 -C "client hello, adding extended_master_secret extension" \
2349 -S "found extended master secret extension" \
2350 -S "server hello, adding extended master secret extension" \
2351 -C "found extended_master_secret extension" \
2352 -C "session hash for extended master secret" \
2353 -S "session hash for extended master secret"
2354
Janos Follathe2681a42016-03-07 15:57:05 +00002355requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002356run_test "Extended Master Secret: client SSLv3, server enabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002357 "$P_SRV debug_level=3 min_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2358 "$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 +02002359 0 \
2360 -C "client hello, adding extended_master_secret extension" \
2361 -S "found extended master secret extension" \
2362 -S "server hello, adding extended master secret extension" \
2363 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002364 -C "session hash for extended master secret" \
2365 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002366
Janos Follathe2681a42016-03-07 15:57:05 +00002367requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002368run_test "Extended Master Secret: client enabled, server SSLv3" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002369 "$P_SRV debug_level=3 force_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2370 "$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 +02002371 0 \
2372 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002373 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002374 -S "server hello, adding extended master secret extension" \
2375 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002376 -C "session hash for extended master secret" \
2377 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002378
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002379# Tests for FALLBACK_SCSV
2380
2381run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002382 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002383 "$P_CLI debug_level=3 force_version=tls1_1" \
2384 0 \
2385 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002386 -S "received FALLBACK_SCSV" \
2387 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002388 -C "is a fatal alert message (msg 86)"
2389
2390run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002391 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002392 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2393 0 \
2394 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002395 -S "received FALLBACK_SCSV" \
2396 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002397 -C "is a fatal alert message (msg 86)"
2398
2399run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002400 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002401 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002402 1 \
2403 -c "adding FALLBACK_SCSV" \
2404 -s "received FALLBACK_SCSV" \
2405 -s "inapropriate fallback" \
2406 -c "is a fatal alert message (msg 86)"
2407
2408run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002409 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002410 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002411 0 \
2412 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002413 -s "received FALLBACK_SCSV" \
2414 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002415 -C "is a fatal alert message (msg 86)"
2416
2417requires_openssl_with_fallback_scsv
2418run_test "Fallback SCSV: default, openssl server" \
2419 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002420 "$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 +02002421 0 \
2422 -C "adding FALLBACK_SCSV" \
2423 -C "is a fatal alert message (msg 86)"
2424
2425requires_openssl_with_fallback_scsv
2426run_test "Fallback SCSV: enabled, openssl server" \
2427 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002428 "$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 +02002429 1 \
2430 -c "adding FALLBACK_SCSV" \
2431 -c "is a fatal alert message (msg 86)"
2432
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002433requires_openssl_with_fallback_scsv
2434run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002435 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002436 "$O_CLI -tls1_1" \
2437 0 \
2438 -S "received FALLBACK_SCSV" \
2439 -S "inapropriate fallback"
2440
2441requires_openssl_with_fallback_scsv
2442run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002443 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002444 "$O_CLI -tls1_1 -fallback_scsv" \
2445 1 \
2446 -s "received FALLBACK_SCSV" \
2447 -s "inapropriate fallback"
2448
2449requires_openssl_with_fallback_scsv
2450run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002451 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002452 "$O_CLI -fallback_scsv" \
2453 0 \
2454 -s "received FALLBACK_SCSV" \
2455 -S "inapropriate fallback"
2456
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002457# Test sending and receiving empty application data records
2458
2459run_test "Encrypt then MAC: empty application data record" \
2460 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2461 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2462 0 \
2463 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2464 -s "dumping 'input payload after decrypt' (0 bytes)" \
2465 -c "0 bytes written in 1 fragments"
2466
2467run_test "Default, no Encrypt then MAC: empty application data record" \
2468 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2469 "$P_CLI auth_mode=none etm=0 request_size=0" \
2470 0 \
2471 -s "dumping 'input payload after decrypt' (0 bytes)" \
2472 -c "0 bytes written in 1 fragments"
2473
2474run_test "Encrypt then MAC, DTLS: empty application data record" \
2475 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2476 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2477 0 \
2478 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2479 -s "dumping 'input payload after decrypt' (0 bytes)" \
2480 -c "0 bytes written in 1 fragments"
2481
2482run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
2483 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2484 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2485 0 \
2486 -s "dumping 'input payload after decrypt' (0 bytes)" \
2487 -c "0 bytes written in 1 fragments"
2488
Gilles Peskined50177f2017-05-16 17:53:03 +02002489## ClientHello generated with
2490## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2491## then manually twiddling the ciphersuite list.
2492## The ClientHello content is spelled out below as a hex string as
2493## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2494## The expected response is an inappropriate_fallback alert.
2495requires_openssl_with_fallback_scsv
2496run_test "Fallback SCSV: beginning of list" \
2497 "$P_SRV debug_level=2" \
2498 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2499 0 \
2500 -s "received FALLBACK_SCSV" \
2501 -s "inapropriate fallback"
2502
2503requires_openssl_with_fallback_scsv
2504run_test "Fallback SCSV: end of list" \
2505 "$P_SRV debug_level=2" \
2506 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2507 0 \
2508 -s "received FALLBACK_SCSV" \
2509 -s "inapropriate fallback"
2510
2511## Here the expected response is a valid ServerHello prefix, up to the random.
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02002512## Due to the way the clienthello was generated, this currently needs the
2513## server to have support for session tickets.
2514requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Gilles Peskined50177f2017-05-16 17:53:03 +02002515requires_openssl_with_fallback_scsv
2516run_test "Fallback SCSV: not in list" \
2517 "$P_SRV debug_level=2" \
2518 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2519 0 \
2520 -S "received FALLBACK_SCSV" \
2521 -S "inapropriate fallback"
2522
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002523# Tests for CBC 1/n-1 record splitting
2524
2525run_test "CBC Record splitting: TLS 1.2, no splitting" \
2526 "$P_SRV" \
2527 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2528 request_size=123 force_version=tls1_2" \
2529 0 \
2530 -s "Read from client: 123 bytes read" \
2531 -S "Read from client: 1 bytes read" \
2532 -S "122 bytes read"
2533
2534run_test "CBC Record splitting: TLS 1.1, no splitting" \
2535 "$P_SRV" \
2536 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2537 request_size=123 force_version=tls1_1" \
2538 0 \
2539 -s "Read from client: 123 bytes read" \
2540 -S "Read from client: 1 bytes read" \
2541 -S "122 bytes read"
2542
2543run_test "CBC Record splitting: TLS 1.0, splitting" \
2544 "$P_SRV" \
2545 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2546 request_size=123 force_version=tls1" \
2547 0 \
2548 -S "Read from client: 123 bytes read" \
2549 -s "Read from client: 1 bytes read" \
2550 -s "122 bytes read"
2551
Janos Follathe2681a42016-03-07 15:57:05 +00002552requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002553run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002554 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002555 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2556 request_size=123 force_version=ssl3" \
2557 0 \
2558 -S "Read from client: 123 bytes read" \
2559 -s "Read from client: 1 bytes read" \
2560 -s "122 bytes read"
2561
2562run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002563 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002564 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2565 request_size=123 force_version=tls1" \
2566 0 \
2567 -s "Read from client: 123 bytes read" \
2568 -S "Read from client: 1 bytes read" \
2569 -S "122 bytes read"
2570
2571run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2572 "$P_SRV" \
2573 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2574 request_size=123 force_version=tls1 recsplit=0" \
2575 0 \
2576 -s "Read from client: 123 bytes read" \
2577 -S "Read from client: 1 bytes read" \
2578 -S "122 bytes read"
2579
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002580run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2581 "$P_SRV nbio=2" \
2582 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2583 request_size=123 force_version=tls1" \
2584 0 \
2585 -S "Read from client: 123 bytes read" \
2586 -s "Read from client: 1 bytes read" \
2587 -s "122 bytes read"
2588
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002589# Tests for Session Tickets
2590
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002591requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002592requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002593run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002594 "$P_SRV debug_level=3 tickets=1" \
2595 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002596 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002597 -c "client hello, adding session ticket extension" \
2598 -s "found session ticket extension" \
2599 -s "server hello, adding session ticket extension" \
2600 -c "found session_ticket extension" \
2601 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002602 -S "session successfully restored from cache" \
2603 -s "session successfully restored from ticket" \
2604 -s "a session has been resumed" \
2605 -c "a session has been resumed"
2606
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002607requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002608requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002609run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002610 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2611 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002612 0 \
2613 -c "client hello, adding session ticket extension" \
2614 -s "found session ticket extension" \
2615 -s "server hello, adding session ticket extension" \
2616 -c "found session_ticket extension" \
2617 -c "parse new session ticket" \
2618 -S "session successfully restored from cache" \
2619 -s "session successfully restored from ticket" \
2620 -s "a session has been resumed" \
2621 -c "a session has been resumed"
2622
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002623requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002624requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002625run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002626 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2627 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002628 0 \
2629 -c "client hello, adding session ticket extension" \
2630 -s "found session ticket extension" \
2631 -s "server hello, adding session ticket extension" \
2632 -c "found session_ticket extension" \
2633 -c "parse new session ticket" \
2634 -S "session successfully restored from cache" \
2635 -S "session successfully restored from ticket" \
2636 -S "a session has been resumed" \
2637 -C "a session has been resumed"
2638
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002639requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002640requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002641run_test "Session resume using tickets: session copy" \
2642 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2643 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2644 0 \
2645 -c "client hello, adding session ticket extension" \
2646 -s "found session ticket extension" \
2647 -s "server hello, adding session ticket extension" \
2648 -c "found session_ticket extension" \
2649 -c "parse new session ticket" \
2650 -S "session successfully restored from cache" \
2651 -s "session successfully restored from ticket" \
2652 -s "a session has been resumed" \
2653 -c "a session has been resumed"
2654
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002655requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002656requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002657run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002658 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002659 "$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 +01002660 0 \
2661 -c "client hello, adding session ticket extension" \
2662 -c "found session_ticket extension" \
2663 -c "parse new session ticket" \
2664 -c "a session has been resumed"
2665
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002666requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002667requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002668run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002669 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002670 "( $O_CLI -sess_out $SESSION; \
2671 $O_CLI -sess_in $SESSION; \
2672 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002673 0 \
2674 -s "found session ticket extension" \
2675 -s "server hello, adding session ticket extension" \
2676 -S "session successfully restored from cache" \
2677 -s "session successfully restored from ticket" \
2678 -s "a session has been resumed"
2679
Hanno Becker1d739932018-08-21 13:55:22 +01002680# Tests for Session Tickets with DTLS
2681
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002682requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002683requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002684run_test "Session resume using tickets, DTLS: basic" \
2685 "$P_SRV debug_level=3 dtls=1 tickets=1" \
2686 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2687 0 \
2688 -c "client hello, adding session ticket extension" \
2689 -s "found session ticket extension" \
2690 -s "server hello, adding session ticket extension" \
2691 -c "found session_ticket extension" \
2692 -c "parse new session ticket" \
2693 -S "session successfully restored from cache" \
2694 -s "session successfully restored from ticket" \
2695 -s "a session has been resumed" \
2696 -c "a session has been resumed"
2697
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002698requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002699requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002700run_test "Session resume using tickets, DTLS: cache disabled" \
2701 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2702 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2703 0 \
2704 -c "client hello, adding session ticket extension" \
2705 -s "found session ticket extension" \
2706 -s "server hello, adding session ticket extension" \
2707 -c "found session_ticket extension" \
2708 -c "parse new session ticket" \
2709 -S "session successfully restored from cache" \
2710 -s "session successfully restored from ticket" \
2711 -s "a session has been resumed" \
2712 -c "a session has been resumed"
2713
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002714requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002715requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002716run_test "Session resume using tickets, DTLS: timeout" \
2717 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
2718 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \
2719 0 \
2720 -c "client hello, adding session ticket extension" \
2721 -s "found session ticket extension" \
2722 -s "server hello, adding session ticket extension" \
2723 -c "found session_ticket extension" \
2724 -c "parse new session ticket" \
2725 -S "session successfully restored from cache" \
2726 -S "session successfully restored from ticket" \
2727 -S "a session has been resumed" \
2728 -C "a session has been resumed"
2729
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002730requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002731requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002732run_test "Session resume using tickets, DTLS: session copy" \
2733 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2734 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_mode=0" \
2735 0 \
2736 -c "client hello, adding session ticket extension" \
2737 -s "found session ticket extension" \
2738 -s "server hello, adding session ticket extension" \
2739 -c "found session_ticket extension" \
2740 -c "parse new session ticket" \
2741 -S "session successfully restored from cache" \
2742 -s "session successfully restored from ticket" \
2743 -s "a session has been resumed" \
2744 -c "a session has been resumed"
2745
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002746requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002747requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002748run_test "Session resume using tickets, DTLS: openssl server" \
2749 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002750 "$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 +01002751 0 \
2752 -c "client hello, adding session ticket extension" \
2753 -c "found session_ticket extension" \
2754 -c "parse new session ticket" \
2755 -c "a session has been resumed"
2756
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002757requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002758requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002759run_test "Session resume using tickets, DTLS: openssl client" \
2760 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2761 "( $O_CLI -dtls1 -sess_out $SESSION; \
2762 $O_CLI -dtls1 -sess_in $SESSION; \
2763 rm -f $SESSION )" \
2764 0 \
2765 -s "found session ticket extension" \
2766 -s "server hello, adding session ticket extension" \
2767 -S "session successfully restored from cache" \
2768 -s "session successfully restored from ticket" \
2769 -s "a session has been resumed"
2770
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002771# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002772
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002773requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002774requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002775requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002776run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002777 "$P_SRV debug_level=3 tickets=0" \
2778 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002779 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002780 -c "client hello, adding session ticket extension" \
2781 -s "found session ticket extension" \
2782 -S "server hello, adding session ticket extension" \
2783 -C "found session_ticket extension" \
2784 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002785 -s "session successfully restored from cache" \
2786 -S "session successfully restored from ticket" \
2787 -s "a session has been resumed" \
2788 -c "a session has been resumed"
2789
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002790requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002791requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002792requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002793run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002794 "$P_SRV debug_level=3 tickets=1" \
2795 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002796 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002797 -C "client hello, adding session ticket extension" \
2798 -S "found session ticket extension" \
2799 -S "server hello, adding session ticket extension" \
2800 -C "found session_ticket extension" \
2801 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002802 -s "session successfully restored from cache" \
2803 -S "session successfully restored from ticket" \
2804 -s "a session has been resumed" \
2805 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002806
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002807requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2808requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002809run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002810 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2811 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002812 0 \
2813 -S "session successfully restored from cache" \
2814 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002815 -S "a session has been resumed" \
2816 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002817
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002818requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2819requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002820run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002821 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2822 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002823 0 \
2824 -s "session successfully restored from cache" \
2825 -S "session successfully restored from ticket" \
2826 -s "a session has been resumed" \
2827 -c "a session has been resumed"
2828
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002829requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2830requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002831run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002832 "$P_SRV debug_level=3 tickets=0" \
2833 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002834 0 \
2835 -s "session successfully restored from cache" \
2836 -S "session successfully restored from ticket" \
2837 -s "a session has been resumed" \
2838 -c "a session has been resumed"
2839
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002840requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2841requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002842run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002843 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2844 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002845 0 \
2846 -S "session successfully restored from cache" \
2847 -S "session successfully restored from ticket" \
2848 -S "a session has been resumed" \
2849 -C "a session has been resumed"
2850
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002851requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2852requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002853run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002854 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2855 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002856 0 \
2857 -s "session successfully restored from cache" \
2858 -S "session successfully restored from ticket" \
2859 -s "a session has been resumed" \
2860 -c "a session has been resumed"
2861
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002862requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2863requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002864run_test "Session resume using cache: session copy" \
2865 "$P_SRV debug_level=3 tickets=0" \
2866 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2867 0 \
2868 -s "session successfully restored from cache" \
2869 -S "session successfully restored from ticket" \
2870 -s "a session has been resumed" \
2871 -c "a session has been resumed"
2872
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002873requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2874requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002875run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002876 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002877 "( $O_CLI -sess_out $SESSION; \
2878 $O_CLI -sess_in $SESSION; \
2879 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002880 0 \
2881 -s "found session ticket extension" \
2882 -S "server hello, adding session ticket extension" \
2883 -s "session successfully restored from cache" \
2884 -S "session successfully restored from ticket" \
2885 -s "a session has been resumed"
2886
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002887requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2888requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002889run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002890 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002891 "$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 +01002892 0 \
2893 -C "found session_ticket extension" \
2894 -C "parse new session ticket" \
2895 -c "a session has been resumed"
2896
Hanno Becker1d739932018-08-21 13:55:22 +01002897# Tests for Session Resume based on session-ID and cache, DTLS
2898
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002899requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002900requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002901requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002902run_test "Session resume using cache, DTLS: tickets enabled on client" \
2903 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2904 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2905 0 \
2906 -c "client hello, adding session ticket extension" \
2907 -s "found session ticket extension" \
2908 -S "server hello, adding session ticket extension" \
2909 -C "found session_ticket extension" \
2910 -C "parse new session ticket" \
2911 -s "session successfully restored from cache" \
2912 -S "session successfully restored from ticket" \
2913 -s "a session has been resumed" \
2914 -c "a session has been resumed"
2915
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002916requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002917requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002918requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002919run_test "Session resume using cache, DTLS: tickets enabled on server" \
2920 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2921 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2922 0 \
2923 -C "client hello, adding session ticket extension" \
2924 -S "found session ticket extension" \
2925 -S "server hello, adding session ticket extension" \
2926 -C "found session_ticket extension" \
2927 -C "parse new session ticket" \
2928 -s "session successfully restored from cache" \
2929 -S "session successfully restored from ticket" \
2930 -s "a session has been resumed" \
2931 -c "a session has been resumed"
2932
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002933requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2934requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002935run_test "Session resume using cache, DTLS: cache_max=0" \
2936 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
2937 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2938 0 \
2939 -S "session successfully restored from cache" \
2940 -S "session successfully restored from ticket" \
2941 -S "a session has been resumed" \
2942 -C "a session has been resumed"
2943
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002944requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2945requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002946run_test "Session resume using cache, DTLS: cache_max=1" \
2947 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
2948 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2949 0 \
2950 -s "session successfully restored from cache" \
2951 -S "session successfully restored from ticket" \
2952 -s "a session has been resumed" \
2953 -c "a session has been resumed"
2954
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002955requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2956requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002957run_test "Session resume using cache, DTLS: timeout > delay" \
2958 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2959 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
2960 0 \
2961 -s "session successfully restored from cache" \
2962 -S "session successfully restored from ticket" \
2963 -s "a session has been resumed" \
2964 -c "a session has been resumed"
2965
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002966requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2967requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002968run_test "Session resume using cache, DTLS: timeout < delay" \
2969 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
2970 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2971 0 \
2972 -S "session successfully restored from cache" \
2973 -S "session successfully restored from ticket" \
2974 -S "a session has been resumed" \
2975 -C "a session has been resumed"
2976
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002977requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2978requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002979run_test "Session resume using cache, DTLS: no timeout" \
2980 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
2981 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2982 0 \
2983 -s "session successfully restored from cache" \
2984 -S "session successfully restored from ticket" \
2985 -s "a session has been resumed" \
2986 -c "a session has been resumed"
2987
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002988requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2989requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002990run_test "Session resume using cache, DTLS: session copy" \
2991 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2992 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2993 0 \
2994 -s "session successfully restored from cache" \
2995 -S "session successfully restored from ticket" \
2996 -s "a session has been resumed" \
2997 -c "a session has been resumed"
2998
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002999requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3000requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01003001run_test "Session resume using cache, DTLS: openssl client" \
3002 "$P_SRV dtls=1 debug_level=3 tickets=0" \
3003 "( $O_CLI -dtls1 -sess_out $SESSION; \
3004 $O_CLI -dtls1 -sess_in $SESSION; \
3005 rm -f $SESSION )" \
3006 0 \
3007 -s "found session ticket extension" \
3008 -S "server hello, adding session ticket extension" \
3009 -s "session successfully restored from cache" \
3010 -S "session successfully restored from ticket" \
3011 -s "a session has been resumed"
3012
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03003013requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3014requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01003015run_test "Session resume using cache, DTLS: openssl server" \
3016 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003017 "$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 +01003018 0 \
3019 -C "found session_ticket extension" \
3020 -C "parse new session ticket" \
3021 -c "a session has been resumed"
3022
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003023# Tests for Max Fragment Length extension
3024
Angus Grattonc4dd0732018-04-11 16:28:39 +10003025if [ $MAX_CONTENT_LEN -ne 16384 ]; then
3026 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
3027fi
3028
Hanno Becker4aed27e2017-09-18 15:00:34 +01003029requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003030run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003031 "$P_SRV debug_level=3" \
3032 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003033 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003034 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3035 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003036 -C "client hello, adding max_fragment_length extension" \
3037 -S "found max fragment length extension" \
3038 -S "server hello, max_fragment_length extension" \
3039 -C "found max_fragment_length extension"
3040
Hanno Becker4aed27e2017-09-18 15:00:34 +01003041requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003042run_test "Max fragment length: enabled, default, larger message" \
3043 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003044 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003045 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003046 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3047 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003048 -C "client hello, adding max_fragment_length extension" \
3049 -S "found max fragment length extension" \
3050 -S "server hello, max_fragment_length extension" \
3051 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003052 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3053 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003054 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003055
3056requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003057requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Hanno Beckerc5266962017-09-18 15:01:50 +01003058run_test "Max fragment length, DTLS: enabled, default, larger message" \
3059 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003060 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003061 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003062 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3063 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003064 -C "client hello, adding max_fragment_length extension" \
3065 -S "found max fragment length extension" \
3066 -S "server hello, max_fragment_length extension" \
3067 -C "found max_fragment_length extension" \
3068 -c "fragment larger than.*maximum "
3069
Angus Grattonc4dd0732018-04-11 16:28:39 +10003070# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3071# (session fragment length will be 16384 regardless of mbedtls
3072# content length configuration.)
3073
Hanno Beckerc5266962017-09-18 15:01:50 +01003074requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003075requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 16384
Hanno Beckerc5266962017-09-18 15:01:50 +01003076run_test "Max fragment length: disabled, larger message" \
3077 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003078 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003079 0 \
3080 -C "Maximum fragment length is 16384" \
3081 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003082 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3083 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003084 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003085
3086requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003087requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 16384
Hanno Beckerc5266962017-09-18 15:01:50 +01003088run_test "Max fragment length DTLS: disabled, larger message" \
3089 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003090 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003091 1 \
3092 -C "Maximum fragment length is 16384" \
3093 -S "Maximum fragment length is 16384" \
3094 -c "fragment larger than.*maximum "
3095
3096requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003097requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003098run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003099 "$P_SRV debug_level=3" \
3100 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003101 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003102 -c "Maximum fragment length is 4096" \
3103 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003104 -c "client hello, adding max_fragment_length extension" \
3105 -s "found max fragment length extension" \
3106 -s "server hello, max_fragment_length extension" \
3107 -c "found max_fragment_length extension"
3108
Hanno Becker4aed27e2017-09-18 15:00:34 +01003109requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003110requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003111run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003112 "$P_SRV debug_level=3 max_frag_len=4096" \
3113 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003114 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003115 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003116 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003117 -C "client hello, adding max_fragment_length extension" \
3118 -S "found max fragment length extension" \
3119 -S "server hello, max_fragment_length extension" \
3120 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003121
Hanno Becker4aed27e2017-09-18 15:00:34 +01003122requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003123requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003124requires_gnutls
3125run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003126 "$G_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003127 "$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 +02003128 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003129 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003130 -c "client hello, adding max_fragment_length extension" \
3131 -c "found max_fragment_length extension"
3132
Hanno Becker4aed27e2017-09-18 15:00:34 +01003133requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003134requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003135run_test "Max fragment length: client, message just fits" \
3136 "$P_SRV debug_level=3" \
3137 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3138 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003139 -c "Maximum fragment length is 2048" \
3140 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003141 -c "client hello, adding max_fragment_length extension" \
3142 -s "found max fragment length extension" \
3143 -s "server hello, max_fragment_length extension" \
3144 -c "found max_fragment_length extension" \
3145 -c "2048 bytes written in 1 fragments" \
3146 -s "2048 bytes read"
3147
Hanno Becker4aed27e2017-09-18 15:00:34 +01003148requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003149requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003150run_test "Max fragment length: client, larger message" \
3151 "$P_SRV debug_level=3" \
3152 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3153 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003154 -c "Maximum fragment length is 2048" \
3155 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003156 -c "client hello, adding max_fragment_length extension" \
3157 -s "found max fragment length extension" \
3158 -s "server hello, max_fragment_length extension" \
3159 -c "found max_fragment_length extension" \
3160 -c "2345 bytes written in 2 fragments" \
3161 -s "2048 bytes read" \
3162 -s "297 bytes read"
3163
Hanno Becker4aed27e2017-09-18 15:00:34 +01003164requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003165requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003166run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003167 "$P_SRV debug_level=3 dtls=1" \
3168 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3169 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003170 -c "Maximum fragment length is 2048" \
3171 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003172 -c "client hello, adding max_fragment_length extension" \
3173 -s "found max fragment length extension" \
3174 -s "server hello, max_fragment_length extension" \
3175 -c "found max_fragment_length extension" \
3176 -c "fragment larger than.*maximum"
3177
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003178# Tests for renegotiation
3179
Hanno Becker6a243642017-10-12 15:18:45 +01003180# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003181run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003182 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003183 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003184 0 \
3185 -C "client hello, adding renegotiation extension" \
3186 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3187 -S "found renegotiation extension" \
3188 -s "server hello, secure renegotiation extension" \
3189 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003190 -C "=> renegotiate" \
3191 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003192 -S "write hello request"
3193
Hanno Becker6a243642017-10-12 15:18:45 +01003194requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003195run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003196 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003197 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003198 0 \
3199 -c "client hello, adding renegotiation extension" \
3200 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3201 -s "found renegotiation extension" \
3202 -s "server hello, secure renegotiation extension" \
3203 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003204 -c "=> renegotiate" \
3205 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003206 -S "write hello request"
3207
Hanno Becker6a243642017-10-12 15:18:45 +01003208requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003209run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003210 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003211 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003212 0 \
3213 -c "client hello, adding renegotiation extension" \
3214 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3215 -s "found renegotiation extension" \
3216 -s "server hello, secure renegotiation extension" \
3217 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003218 -c "=> renegotiate" \
3219 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003220 -s "write hello request"
3221
Janos Follathb0f148c2017-10-05 12:29:42 +01003222# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3223# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3224# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003225requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003226run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3227 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3228 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3229 0 \
3230 -c "client hello, adding renegotiation extension" \
3231 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3232 -s "found renegotiation extension" \
3233 -s "server hello, secure renegotiation extension" \
3234 -c "found renegotiation extension" \
3235 -c "=> renegotiate" \
3236 -s "=> renegotiate" \
3237 -S "write hello request" \
3238 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3239
3240# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3241# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3242# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003243requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003244run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3245 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3246 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3247 0 \
3248 -c "client hello, adding renegotiation extension" \
3249 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3250 -s "found renegotiation extension" \
3251 -s "server hello, secure renegotiation extension" \
3252 -c "found renegotiation extension" \
3253 -c "=> renegotiate" \
3254 -s "=> renegotiate" \
3255 -s "write hello request" \
3256 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3257
Hanno Becker6a243642017-10-12 15:18:45 +01003258requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003259run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003260 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003261 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003262 0 \
3263 -c "client hello, adding renegotiation extension" \
3264 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3265 -s "found renegotiation extension" \
3266 -s "server hello, secure renegotiation extension" \
3267 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003268 -c "=> renegotiate" \
3269 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003270 -s "write hello request"
3271
Hanno Becker6a243642017-10-12 15:18:45 +01003272requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003273run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003274 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003275 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003276 1 \
3277 -c "client hello, adding renegotiation extension" \
3278 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3279 -S "found renegotiation extension" \
3280 -s "server hello, secure renegotiation extension" \
3281 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003282 -c "=> renegotiate" \
3283 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003284 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003285 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003286 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003287
Hanno Becker6a243642017-10-12 15:18:45 +01003288requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003289run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003290 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003291 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003292 0 \
3293 -C "client hello, adding renegotiation extension" \
3294 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3295 -S "found renegotiation extension" \
3296 -s "server hello, secure renegotiation extension" \
3297 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003298 -C "=> renegotiate" \
3299 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003300 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003301 -S "SSL - An unexpected message was received from our peer" \
3302 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003303
Hanno Becker6a243642017-10-12 15:18:45 +01003304requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003305run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003306 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003307 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003308 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003309 0 \
3310 -C "client hello, adding renegotiation extension" \
3311 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3312 -S "found renegotiation extension" \
3313 -s "server hello, secure renegotiation extension" \
3314 -c "found renegotiation extension" \
3315 -C "=> renegotiate" \
3316 -S "=> renegotiate" \
3317 -s "write hello request" \
3318 -S "SSL - An unexpected message was received from our peer" \
3319 -S "failed"
3320
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003321# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003322requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003323run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003324 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003325 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003326 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003327 0 \
3328 -C "client hello, adding renegotiation extension" \
3329 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3330 -S "found renegotiation extension" \
3331 -s "server hello, secure renegotiation extension" \
3332 -c "found renegotiation extension" \
3333 -C "=> renegotiate" \
3334 -S "=> renegotiate" \
3335 -s "write hello request" \
3336 -S "SSL - An unexpected message was received from our peer" \
3337 -S "failed"
3338
Hanno Becker6a243642017-10-12 15:18:45 +01003339requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003340run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003341 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003342 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003343 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003344 0 \
3345 -C "client hello, adding renegotiation extension" \
3346 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3347 -S "found renegotiation extension" \
3348 -s "server hello, secure renegotiation extension" \
3349 -c "found renegotiation extension" \
3350 -C "=> renegotiate" \
3351 -S "=> renegotiate" \
3352 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003353 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003354
Hanno Becker6a243642017-10-12 15:18:45 +01003355requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003356run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003357 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003358 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003359 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003360 0 \
3361 -c "client hello, adding renegotiation extension" \
3362 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3363 -s "found renegotiation extension" \
3364 -s "server hello, secure renegotiation extension" \
3365 -c "found renegotiation extension" \
3366 -c "=> renegotiate" \
3367 -s "=> renegotiate" \
3368 -s "write hello request" \
3369 -S "SSL - An unexpected message was received from our peer" \
3370 -S "failed"
3371
Hanno Becker6a243642017-10-12 15:18:45 +01003372requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003373run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003374 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003375 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3376 0 \
3377 -C "client hello, adding renegotiation extension" \
3378 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3379 -S "found renegotiation extension" \
3380 -s "server hello, secure renegotiation extension" \
3381 -c "found renegotiation extension" \
3382 -S "record counter limit reached: renegotiate" \
3383 -C "=> renegotiate" \
3384 -S "=> renegotiate" \
3385 -S "write hello request" \
3386 -S "SSL - An unexpected message was received from our peer" \
3387 -S "failed"
3388
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003389# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003390requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003391run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003392 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003393 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003394 0 \
3395 -c "client hello, adding renegotiation extension" \
3396 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3397 -s "found renegotiation extension" \
3398 -s "server hello, secure renegotiation extension" \
3399 -c "found renegotiation extension" \
3400 -s "record counter limit reached: renegotiate" \
3401 -c "=> renegotiate" \
3402 -s "=> renegotiate" \
3403 -s "write hello request" \
3404 -S "SSL - An unexpected message was received from our peer" \
3405 -S "failed"
3406
Hanno Becker6a243642017-10-12 15:18:45 +01003407requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003408run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003409 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003410 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003411 0 \
3412 -c "client hello, adding renegotiation extension" \
3413 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3414 -s "found renegotiation extension" \
3415 -s "server hello, secure renegotiation extension" \
3416 -c "found renegotiation extension" \
3417 -s "record counter limit reached: renegotiate" \
3418 -c "=> renegotiate" \
3419 -s "=> renegotiate" \
3420 -s "write hello request" \
3421 -S "SSL - An unexpected message was received from our peer" \
3422 -S "failed"
3423
Hanno Becker6a243642017-10-12 15:18:45 +01003424requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003425run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003426 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003427 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3428 0 \
3429 -C "client hello, adding renegotiation extension" \
3430 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3431 -S "found renegotiation extension" \
3432 -s "server hello, secure renegotiation extension" \
3433 -c "found renegotiation extension" \
3434 -S "record counter limit reached: renegotiate" \
3435 -C "=> renegotiate" \
3436 -S "=> renegotiate" \
3437 -S "write hello request" \
3438 -S "SSL - An unexpected message was received from our peer" \
3439 -S "failed"
3440
Hanno Becker6a243642017-10-12 15:18:45 +01003441requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003442run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003443 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003444 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003445 0 \
3446 -c "client hello, adding renegotiation extension" \
3447 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3448 -s "found renegotiation extension" \
3449 -s "server hello, secure renegotiation extension" \
3450 -c "found renegotiation extension" \
3451 -c "=> renegotiate" \
3452 -s "=> renegotiate" \
3453 -S "write hello request"
3454
Hanno Becker6a243642017-10-12 15:18:45 +01003455requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003456run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003457 "$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 +02003458 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003459 0 \
3460 -c "client hello, adding renegotiation extension" \
3461 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3462 -s "found renegotiation extension" \
3463 -s "server hello, secure renegotiation extension" \
3464 -c "found renegotiation extension" \
3465 -c "=> renegotiate" \
3466 -s "=> renegotiate" \
3467 -s "write hello request"
3468
Hanno Becker6a243642017-10-12 15:18:45 +01003469requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003470run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003471 "$O_SRV -www" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003472 "$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 +02003473 0 \
3474 -c "client hello, adding renegotiation extension" \
3475 -c "found renegotiation extension" \
3476 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003477 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003478 -C "error" \
3479 -c "HTTP/1.0 200 [Oo][Kk]"
3480
Paul Bakker539d9722015-02-08 16:18:35 +01003481requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003482requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003483run_test "Renegotiation: gnutls server strict, client-initiated" \
3484 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003485 "$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 +02003486 0 \
3487 -c "client hello, adding renegotiation extension" \
3488 -c "found renegotiation extension" \
3489 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003490 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003491 -C "error" \
3492 -c "HTTP/1.0 200 [Oo][Kk]"
3493
Paul Bakker539d9722015-02-08 16:18:35 +01003494requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003495requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003496run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3497 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003498 "$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 +01003499 1 \
3500 -c "client hello, adding renegotiation extension" \
3501 -C "found renegotiation extension" \
3502 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003503 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003504 -c "error" \
3505 -C "HTTP/1.0 200 [Oo][Kk]"
3506
Paul Bakker539d9722015-02-08 16:18:35 +01003507requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003508requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003509run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3510 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003511 "$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 +01003512 allow_legacy=0" \
3513 1 \
3514 -c "client hello, adding renegotiation extension" \
3515 -C "found renegotiation extension" \
3516 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003517 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003518 -c "error" \
3519 -C "HTTP/1.0 200 [Oo][Kk]"
3520
Paul Bakker539d9722015-02-08 16:18:35 +01003521requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003522requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003523run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3524 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003525 "$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 +01003526 allow_legacy=1" \
3527 0 \
3528 -c "client hello, adding renegotiation extension" \
3529 -C "found renegotiation extension" \
3530 -c "=> renegotiate" \
3531 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003532 -C "error" \
3533 -c "HTTP/1.0 200 [Oo][Kk]"
3534
Hanno Becker6a243642017-10-12 15:18:45 +01003535requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003536run_test "Renegotiation: DTLS, client-initiated" \
3537 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3538 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3539 0 \
3540 -c "client hello, adding renegotiation extension" \
3541 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3542 -s "found renegotiation extension" \
3543 -s "server hello, secure renegotiation extension" \
3544 -c "found renegotiation extension" \
3545 -c "=> renegotiate" \
3546 -s "=> renegotiate" \
3547 -S "write hello request"
3548
Hanno Becker6a243642017-10-12 15:18:45 +01003549requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003550run_test "Renegotiation: DTLS, server-initiated" \
3551 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003552 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3553 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003554 0 \
3555 -c "client hello, adding renegotiation extension" \
3556 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3557 -s "found renegotiation extension" \
3558 -s "server hello, secure renegotiation extension" \
3559 -c "found renegotiation extension" \
3560 -c "=> renegotiate" \
3561 -s "=> renegotiate" \
3562 -s "write hello request"
3563
Hanno Becker6a243642017-10-12 15:18:45 +01003564requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003565run_test "Renegotiation: DTLS, renego_period overflow" \
3566 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3567 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3568 0 \
3569 -c "client hello, adding renegotiation extension" \
3570 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3571 -s "found renegotiation extension" \
3572 -s "server hello, secure renegotiation extension" \
3573 -s "record counter limit reached: renegotiate" \
3574 -c "=> renegotiate" \
3575 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003576 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003577
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003578requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003579requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003580run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3581 "$G_SRV -u --mtu 4096" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003582 "$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 +02003583 0 \
3584 -c "client hello, adding renegotiation extension" \
3585 -c "found renegotiation extension" \
3586 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003587 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003588 -C "error" \
3589 -s "Extra-header:"
3590
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003591# Test for the "secure renegotation" extension only (no actual renegotiation)
3592
Paul Bakker539d9722015-02-08 16:18:35 +01003593requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003594run_test "Renego ext: gnutls server strict, client default" \
3595 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003596 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003597 0 \
3598 -c "found renegotiation extension" \
3599 -C "error" \
3600 -c "HTTP/1.0 200 [Oo][Kk]"
3601
Paul Bakker539d9722015-02-08 16:18:35 +01003602requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003603run_test "Renego ext: gnutls server unsafe, client default" \
3604 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003605 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003606 0 \
3607 -C "found renegotiation extension" \
3608 -C "error" \
3609 -c "HTTP/1.0 200 [Oo][Kk]"
3610
Paul Bakker539d9722015-02-08 16:18:35 +01003611requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003612run_test "Renego ext: gnutls server unsafe, client break legacy" \
3613 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3614 "$P_CLI debug_level=3 allow_legacy=-1" \
3615 1 \
3616 -C "found renegotiation extension" \
3617 -c "error" \
3618 -C "HTTP/1.0 200 [Oo][Kk]"
3619
Paul Bakker539d9722015-02-08 16:18:35 +01003620requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003621run_test "Renego ext: gnutls client strict, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003622 "$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 +02003623 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003624 0 \
3625 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3626 -s "server hello, secure renegotiation extension"
3627
Paul Bakker539d9722015-02-08 16:18:35 +01003628requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003629run_test "Renego ext: gnutls client unsafe, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003630 "$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 +02003631 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003632 0 \
3633 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3634 -S "server hello, secure renegotiation extension"
3635
Paul Bakker539d9722015-02-08 16:18:35 +01003636requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003637run_test "Renego ext: gnutls client unsafe, server break legacy" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003638 "$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 +02003639 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003640 1 \
3641 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3642 -S "server hello, secure renegotiation extension"
3643
Janos Follath0b242342016-02-17 10:11:21 +00003644# Tests for silently dropping trailing extra bytes in .der certificates
3645
3646requires_gnutls
3647run_test "DER format: no trailing bytes" \
3648 "$P_SRV crt_file=data_files/server5-der0.crt \
3649 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003650 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003651 0 \
3652 -c "Handshake was completed" \
3653
3654requires_gnutls
3655run_test "DER format: with a trailing zero byte" \
3656 "$P_SRV crt_file=data_files/server5-der1a.crt \
3657 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003658 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003659 0 \
3660 -c "Handshake was completed" \
3661
3662requires_gnutls
3663run_test "DER format: with a trailing random byte" \
3664 "$P_SRV crt_file=data_files/server5-der1b.crt \
3665 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003666 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003667 0 \
3668 -c "Handshake was completed" \
3669
3670requires_gnutls
3671run_test "DER format: with 2 trailing random bytes" \
3672 "$P_SRV crt_file=data_files/server5-der2.crt \
3673 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003674 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003675 0 \
3676 -c "Handshake was completed" \
3677
3678requires_gnutls
3679run_test "DER format: with 4 trailing random bytes" \
3680 "$P_SRV crt_file=data_files/server5-der4.crt \
3681 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003682 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003683 0 \
3684 -c "Handshake was completed" \
3685
3686requires_gnutls
3687run_test "DER format: with 8 trailing random bytes" \
3688 "$P_SRV crt_file=data_files/server5-der8.crt \
3689 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003690 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003691 0 \
3692 -c "Handshake was completed" \
3693
3694requires_gnutls
3695run_test "DER format: with 9 trailing random bytes" \
3696 "$P_SRV crt_file=data_files/server5-der9.crt \
3697 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003698 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003699 0 \
3700 -c "Handshake was completed" \
3701
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003702# Tests for auth_mode
3703
Hanno Becker4a156fc2019-06-14 17:07:06 +01003704requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003705requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003706run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003707 "$P_SRV crt_file=data_files/server5-badsign.crt \
3708 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003709 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003710 1 \
3711 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003712 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003713 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003714 -c "X509 - Certificate verification failed"
3715
Hanno Becker4a156fc2019-06-14 17:07:06 +01003716requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003717requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003718run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003719 "$P_SRV crt_file=data_files/server5-badsign.crt \
3720 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003721 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003722 0 \
3723 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003724 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003725 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003726 -C "X509 - Certificate verification failed"
3727
Hanno Becker4a156fc2019-06-14 17:07:06 +01003728requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003729requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003730run_test "Authentication: server goodcert, client optional, no trusted CA" \
3731 "$P_SRV" \
3732 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3733 0 \
3734 -c "x509_verify_cert() returned" \
3735 -c "! The certificate is not correctly signed by the trusted CA" \
3736 -c "! Certificate verification flags"\
3737 -C "! mbedtls_ssl_handshake returned" \
3738 -C "X509 - Certificate verification failed" \
3739 -C "SSL - No CA Chain is set, but required to operate"
3740
Hanno Becker4a156fc2019-06-14 17:07:06 +01003741requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003742requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003743run_test "Authentication: server goodcert, client required, no trusted CA" \
3744 "$P_SRV" \
3745 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3746 1 \
3747 -c "x509_verify_cert() returned" \
3748 -c "! The certificate is not correctly signed by the trusted CA" \
3749 -c "! Certificate verification flags"\
3750 -c "! mbedtls_ssl_handshake returned" \
3751 -c "SSL - No CA Chain is set, but required to operate"
3752
3753# The purpose of the next two tests is to test the client's behaviour when receiving a server
3754# certificate with an unsupported elliptic curve. This should usually not happen because
3755# the client informs the server about the supported curves - it does, though, in the
3756# corner case of a static ECDH suite, because the server doesn't check the curve on that
3757# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3758# different means to have the server ignoring the client's supported curve list.
3759
3760requires_config_enabled MBEDTLS_ECP_C
3761run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3762 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3763 crt_file=data_files/server5.ku-ka.crt" \
3764 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3765 1 \
3766 -c "bad certificate (EC key curve)"\
3767 -c "! Certificate verification flags"\
3768 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3769
3770requires_config_enabled MBEDTLS_ECP_C
3771run_test "Authentication: server ECDH p256v1, client optional, 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=optional 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 only at ECDH params check
3779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003780run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003781 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003782 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003783 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003784 0 \
3785 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003786 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003787 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003788 -C "X509 - Certificate verification failed"
3789
Simon Butcher99000142016-10-13 17:21:01 +01003790run_test "Authentication: client SHA256, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003791 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003792 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3793 key_file=data_files/server6.key \
3794 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3795 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003796 -c "Supported Signature Algorithm found: 5,"
3797
3798run_test "Authentication: client SHA384, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003799 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003800 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3801 key_file=data_files/server6.key \
3802 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3803 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003804 -c "Supported Signature Algorithm found: 5,"
3805
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003806requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3807run_test "Authentication: client has no cert, server required (SSLv3)" \
3808 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3809 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3810 key_file=data_files/server5.key" \
3811 1 \
3812 -S "skip write certificate request" \
3813 -C "skip parse certificate request" \
3814 -c "got a certificate request" \
3815 -c "got no certificate to send" \
3816 -S "x509_verify_cert() returned" \
3817 -s "client has no certificate" \
3818 -s "! mbedtls_ssl_handshake returned" \
3819 -c "! mbedtls_ssl_handshake returned" \
3820 -s "No client certification received from the client, but required by the authentication mode"
3821
3822run_test "Authentication: client has no cert, server required (TLS)" \
3823 "$P_SRV debug_level=3 auth_mode=required" \
3824 "$P_CLI debug_level=3 crt_file=none \
3825 key_file=data_files/server5.key" \
3826 1 \
3827 -S "skip write certificate request" \
3828 -C "skip parse certificate request" \
3829 -c "got a certificate request" \
3830 -c "= write certificate$" \
3831 -C "skip write certificate$" \
3832 -S "x509_verify_cert() returned" \
3833 -s "client has no certificate" \
3834 -s "! mbedtls_ssl_handshake returned" \
3835 -c "! mbedtls_ssl_handshake returned" \
3836 -s "No client certification received from the client, but required by the authentication mode"
3837
Hanno Becker4a156fc2019-06-14 17:07:06 +01003838requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003839requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003840run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003841 "$P_SRV debug_level=3 auth_mode=required" \
3842 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003843 key_file=data_files/server5.key" \
3844 1 \
3845 -S "skip write certificate request" \
3846 -C "skip parse certificate request" \
3847 -c "got a certificate request" \
3848 -C "skip write certificate" \
3849 -C "skip write certificate verify" \
3850 -S "skip parse certificate verify" \
3851 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003852 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003853 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003854 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003855 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003856 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003857# We don't check that the client receives the alert because it might
3858# detect that its write end of the connection is closed and abort
3859# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003860
Hanno Becker4a156fc2019-06-14 17:07:06 +01003861requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003862requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01003863run_test "Authentication: client cert not trusted, server required" \
3864 "$P_SRV debug_level=3 auth_mode=required" \
3865 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3866 key_file=data_files/server5.key" \
3867 1 \
3868 -S "skip write certificate request" \
3869 -C "skip parse certificate request" \
3870 -c "got a certificate request" \
3871 -C "skip write certificate" \
3872 -C "skip write certificate verify" \
3873 -S "skip parse certificate verify" \
3874 -s "x509_verify_cert() returned" \
3875 -s "! The certificate is not correctly signed by the trusted CA" \
3876 -s "! mbedtls_ssl_handshake returned" \
3877 -c "! mbedtls_ssl_handshake returned" \
3878 -s "X509 - Certificate verification failed"
3879
Hanno Becker4a156fc2019-06-14 17:07:06 +01003880requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003881requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003882run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003883 "$P_SRV debug_level=3 auth_mode=optional" \
3884 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003885 key_file=data_files/server5.key" \
3886 0 \
3887 -S "skip write certificate request" \
3888 -C "skip parse certificate request" \
3889 -c "got a certificate request" \
3890 -C "skip write certificate" \
3891 -C "skip write certificate verify" \
3892 -S "skip parse certificate verify" \
3893 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003894 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003895 -S "! mbedtls_ssl_handshake returned" \
3896 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003897 -S "X509 - Certificate verification failed"
3898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003899run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003900 "$P_SRV debug_level=3 auth_mode=none" \
3901 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003902 key_file=data_files/server5.key" \
3903 0 \
3904 -s "skip write certificate request" \
3905 -C "skip parse certificate request" \
3906 -c "got no certificate request" \
3907 -c "skip write certificate" \
3908 -c "skip write certificate verify" \
3909 -s "skip parse certificate verify" \
3910 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003911 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003912 -S "! mbedtls_ssl_handshake returned" \
3913 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003914 -S "X509 - Certificate verification failed"
3915
Hanno Becker4a156fc2019-06-14 17:07:06 +01003916requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003917requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003918run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003919 "$P_SRV debug_level=3 auth_mode=optional" \
3920 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003921 0 \
3922 -S "skip write certificate request" \
3923 -C "skip parse certificate request" \
3924 -c "got a certificate request" \
3925 -C "skip write certificate$" \
3926 -C "got no certificate to send" \
3927 -S "SSLv3 client has no certificate" \
3928 -c "skip write certificate verify" \
3929 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003930 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003931 -S "! mbedtls_ssl_handshake returned" \
3932 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003933 -S "X509 - Certificate verification failed"
3934
Hanno Becker4a156fc2019-06-14 17:07:06 +01003935requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003936requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003937run_test "Authentication: openssl client no cert, server optional" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003938 "$P_SRV debug_level=3 auth_mode=optional ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003939 "$O_CLI" \
3940 0 \
3941 -S "skip write certificate request" \
3942 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003943 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003944 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003945 -S "X509 - Certificate verification failed"
3946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003947run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003948 "$O_SRV -verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003949 "$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 +01003950 0 \
3951 -C "skip parse certificate request" \
3952 -c "got a certificate request" \
3953 -C "skip write certificate$" \
3954 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003955 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003956
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003957run_test "Authentication: client no cert, openssl server required" \
3958 "$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" \
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003960 1 \
3961 -C "skip parse certificate request" \
3962 -c "got a certificate request" \
3963 -C "skip write certificate$" \
3964 -c "skip write certificate verify" \
3965 -c "! mbedtls_ssl_handshake returned"
3966
Janos Follathe2681a42016-03-07 15:57:05 +00003967requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Hanno Beckerb2c63832019-06-17 08:35:16 +01003968requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003969requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003970run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003971 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003972 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003973 0 \
3974 -S "skip write certificate request" \
3975 -C "skip parse certificate request" \
3976 -c "got a certificate request" \
3977 -C "skip write certificate$" \
3978 -c "skip write certificate verify" \
3979 -c "got no certificate to send" \
3980 -s "SSLv3 client has no certificate" \
3981 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003982 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003983 -S "! mbedtls_ssl_handshake returned" \
3984 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003985 -S "X509 - Certificate verification failed"
3986
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02003987# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
3988# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003989
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003990MAX_IM_CA='8'
Arto Kinnunen78213522019-09-26 11:06:39 +03003991MAX_IM_CA_CONFIG="$( get_config_value_or_default MBEDTLS_X509_MAX_INTERMEDIATE_CA )"
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003992
Angus Grattonc4dd0732018-04-11 16:28:39 +10003993requires_full_size_output_buffer
Arto Kinnunenc457ab12019-09-27 12:00:51 +03003994requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003995run_test "Authentication: server max_int chain, client default" \
3996 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
3997 key_file=data_files/dir-maxpath/09.key" \
3998 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
3999 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004000 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004001
Angus Grattonc4dd0732018-04-11 16:28:39 +10004002requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004003requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004004run_test "Authentication: server max_int+1 chain, client default" \
4005 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4006 key_file=data_files/dir-maxpath/10.key" \
4007 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4008 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004009 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004010
Angus Grattonc4dd0732018-04-11 16:28:39 +10004011requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004012requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004013run_test "Authentication: server max_int+1 chain, client optional" \
4014 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4015 key_file=data_files/dir-maxpath/10.key" \
4016 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4017 auth_mode=optional" \
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 none" \
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=none" \
4028 0 \
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
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004032run_test "Authentication: client max_int+1 chain, server default" \
4033 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4034 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4035 key_file=data_files/dir-maxpath/10.key" \
4036 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004037 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004038
Angus Grattonc4dd0732018-04-11 16:28:39 +10004039requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004040run_test "Authentication: client max_int+1 chain, server optional" \
4041 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4042 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4043 key_file=data_files/dir-maxpath/10.key" \
4044 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004045 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004046
Angus Grattonc4dd0732018-04-11 16:28:39 +10004047requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004048run_test "Authentication: client max_int+1 chain, server required" \
4049 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4050 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4051 key_file=data_files/dir-maxpath/10.key" \
4052 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004053 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004054
Angus Grattonc4dd0732018-04-11 16:28:39 +10004055requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004056run_test "Authentication: client max_int chain, server required" \
4057 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4058 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4059 key_file=data_files/dir-maxpath/09.key" \
4060 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004061 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004062
Janos Follath89baba22017-04-10 14:34:35 +01004063# Tests for CA list in CertificateRequest messages
4064
4065run_test "Authentication: send CA list in CertificateRequest (default)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004066 "$P_SRV debug_level=3 auth_mode=required ca_file=data_files/test-ca2.crt" \
Janos Follath89baba22017-04-10 14:34:35 +01004067 "$P_CLI crt_file=data_files/server6.crt \
4068 key_file=data_files/server6.key" \
4069 0 \
4070 -s "requested DN"
4071
4072run_test "Authentication: do not send CA list in CertificateRequest" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004073 "$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 +01004074 "$P_CLI crt_file=data_files/server6.crt \
4075 key_file=data_files/server6.key" \
4076 0 \
4077 -S "requested DN"
4078
Hanno Becker4a156fc2019-06-14 17:07:06 +01004079requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004080requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01004081run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4082 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4083 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4084 key_file=data_files/server5.key" \
4085 1 \
4086 -S "requested DN" \
4087 -s "x509_verify_cert() returned" \
4088 -s "! The certificate is not correctly signed by the trusted CA" \
4089 -s "! mbedtls_ssl_handshake returned" \
4090 -c "! mbedtls_ssl_handshake returned" \
4091 -s "X509 - Certificate verification failed"
4092
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004093# Tests for certificate selection based on SHA verson
4094
Hanno Becker4a156fc2019-06-14 17:07:06 +01004095requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004096requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004097run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4098 "$P_SRV crt_file=data_files/server5.crt \
4099 key_file=data_files/server5.key \
4100 crt_file2=data_files/server5-sha1.crt \
4101 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004102 "$P_CLI force_version=tls1_2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004103 0 \
4104 -c "signed using.*ECDSA with SHA256" \
4105 -C "signed using.*ECDSA with SHA1"
4106
Hanno Becker4a156fc2019-06-14 17:07:06 +01004107requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004108requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004109run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4110 "$P_SRV crt_file=data_files/server5.crt \
4111 key_file=data_files/server5.key \
4112 crt_file2=data_files/server5-sha1.crt \
4113 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004114 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004115 0 \
4116 -C "signed using.*ECDSA with SHA256" \
4117 -c "signed using.*ECDSA with SHA1"
4118
Hanno Becker4a156fc2019-06-14 17:07:06 +01004119requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004120requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004121run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4122 "$P_SRV crt_file=data_files/server5.crt \
4123 key_file=data_files/server5.key \
4124 crt_file2=data_files/server5-sha1.crt \
4125 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004126 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004127 0 \
4128 -C "signed using.*ECDSA with SHA256" \
4129 -c "signed using.*ECDSA with SHA1"
4130
Hanno Becker4a156fc2019-06-14 17:07:06 +01004131requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004132requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004133run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4134 "$P_SRV crt_file=data_files/server5.crt \
4135 key_file=data_files/server5.key \
4136 crt_file2=data_files/server6.crt \
4137 key_file2=data_files/server6.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004138 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004139 0 \
4140 -c "serial number.*09" \
4141 -c "signed using.*ECDSA with SHA256" \
4142 -C "signed using.*ECDSA with SHA1"
4143
Hanno Becker4a156fc2019-06-14 17:07:06 +01004144requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004145requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004146run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4147 "$P_SRV crt_file=data_files/server6.crt \
4148 key_file=data_files/server6.key \
4149 crt_file2=data_files/server5.crt \
4150 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004151 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004152 0 \
4153 -c "serial number.*0A" \
4154 -c "signed using.*ECDSA with SHA256" \
4155 -C "signed using.*ECDSA with SHA1"
4156
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004157# tests for SNI
4158
Hanno Becker4a156fc2019-06-14 17:07:06 +01004159requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004160requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004161run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004162 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004163 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004164 "$P_CLI server_name=localhost ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004165 0 \
4166 -S "parse ServerName extension" \
4167 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4168 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004169
Hanno Becker4a156fc2019-06-14 17:07:06 +01004170requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004171requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004172requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004173run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004174 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004175 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004176 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 +01004177 "$P_CLI server_name=localhost ca_file=data_files/test-ca.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004178 0 \
4179 -s "parse ServerName extension" \
4180 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4181 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004182
Hanno Becker4a156fc2019-06-14 17:07:06 +01004183requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004184requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004185requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004186run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004187 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004188 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004189 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 +02004190 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004191 0 \
4192 -s "parse ServerName extension" \
4193 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4194 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004195
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004196requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004197run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004198 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004199 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004200 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 +02004201 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004202 1 \
4203 -s "parse ServerName extension" \
4204 -s "ssl_sni_wrapper() returned" \
4205 -s "mbedtls_ssl_handshake returned" \
4206 -c "mbedtls_ssl_handshake returned" \
4207 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004208
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004209run_test "SNI: client auth no override: optional" \
4210 "$P_SRV debug_level=3 auth_mode=optional \
4211 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4212 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4213 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004214 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004215 -S "skip write certificate request" \
4216 -C "skip parse certificate request" \
4217 -c "got a certificate request" \
4218 -C "skip write certificate" \
4219 -C "skip write certificate verify" \
4220 -S "skip parse certificate verify"
4221
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004222requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004223run_test "SNI: client auth override: none -> optional" \
4224 "$P_SRV debug_level=3 auth_mode=none \
4225 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4226 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4227 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004228 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004229 -S "skip write certificate request" \
4230 -C "skip parse certificate request" \
4231 -c "got a certificate request" \
4232 -C "skip write certificate" \
4233 -C "skip write certificate verify" \
4234 -S "skip parse certificate verify"
4235
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004236requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004237run_test "SNI: client auth override: optional -> none" \
4238 "$P_SRV debug_level=3 auth_mode=optional \
4239 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4240 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4241 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004242 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004243 -s "skip write certificate request" \
4244 -C "skip parse certificate request" \
4245 -c "got no certificate request" \
4246 -c "skip write certificate" \
4247 -c "skip write certificate verify" \
4248 -s "skip parse certificate verify"
4249
Hanno Becker4a156fc2019-06-14 17:07:06 +01004250requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004251requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004252requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004253run_test "SNI: CA no override" \
4254 "$P_SRV debug_level=3 auth_mode=optional \
4255 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4256 ca_file=data_files/test-ca.crt \
4257 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4258 "$P_CLI debug_level=3 server_name=localhost \
4259 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4260 1 \
4261 -S "skip write certificate request" \
4262 -C "skip parse certificate request" \
4263 -c "got a certificate request" \
4264 -C "skip write certificate" \
4265 -C "skip write certificate verify" \
4266 -S "skip parse certificate verify" \
4267 -s "x509_verify_cert() returned" \
4268 -s "! The certificate is not correctly signed by the trusted CA" \
4269 -S "The certificate has been revoked (is on a CRL)"
4270
Hanno Becker4a156fc2019-06-14 17:07:06 +01004271requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004272requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004273requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004274run_test "SNI: CA override" \
4275 "$P_SRV debug_level=3 auth_mode=optional \
4276 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4277 ca_file=data_files/test-ca.crt \
4278 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4279 "$P_CLI debug_level=3 server_name=localhost \
4280 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4281 0 \
4282 -S "skip write certificate request" \
4283 -C "skip parse certificate request" \
4284 -c "got a certificate request" \
4285 -C "skip write certificate" \
4286 -C "skip write certificate verify" \
4287 -S "skip parse certificate verify" \
4288 -S "x509_verify_cert() returned" \
4289 -S "! The certificate is not correctly signed by the trusted CA" \
4290 -S "The certificate has been revoked (is on a CRL)"
4291
Hanno Becker4a156fc2019-06-14 17:07:06 +01004292requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004293requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004294requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004295run_test "SNI: CA override with CRL" \
4296 "$P_SRV debug_level=3 auth_mode=optional \
4297 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4298 ca_file=data_files/test-ca.crt \
4299 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4300 "$P_CLI debug_level=3 server_name=localhost \
4301 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4302 1 \
4303 -S "skip write certificate request" \
4304 -C "skip parse certificate request" \
4305 -c "got a certificate request" \
4306 -C "skip write certificate" \
4307 -C "skip write certificate verify" \
4308 -S "skip parse certificate verify" \
4309 -s "x509_verify_cert() returned" \
4310 -S "! The certificate is not correctly signed by the trusted CA" \
4311 -s "The certificate has been revoked (is on a CRL)"
4312
Andres AG1a834452016-12-07 10:01:30 +00004313# Tests for SNI and DTLS
4314
Hanno Becker4a156fc2019-06-14 17:07:06 +01004315requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004316requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004317run_test "SNI: DTLS, no SNI callback" \
4318 "$P_SRV debug_level=3 dtls=1 \
4319 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004320 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca2.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004321 0 \
4322 -S "parse ServerName extension" \
4323 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4324 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4325
Hanno Becker4a156fc2019-06-14 17:07:06 +01004326requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004327requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004328requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004329run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004330 "$P_SRV debug_level=3 dtls=1 \
4331 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4332 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 +01004333 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca.crt" \
Andres AG1a834452016-12-07 10:01:30 +00004334 0 \
4335 -s "parse ServerName extension" \
4336 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4337 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4338
Hanno Becker4a156fc2019-06-14 17:07:06 +01004339requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004340requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004341requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004342run_test "SNI: DTLS, matching cert 2" \
4343 "$P_SRV debug_level=3 dtls=1 \
4344 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4345 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 +01004346 "$P_CLI server_name=polarssl.example dtls=1 ca_file=data_files/test-ca.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004347 0 \
4348 -s "parse ServerName extension" \
4349 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4350 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4351
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004352requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004353run_test "SNI: DTLS, no matching cert" \
4354 "$P_SRV debug_level=3 dtls=1 \
4355 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4356 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4357 "$P_CLI server_name=nonesuch.example dtls=1" \
4358 1 \
4359 -s "parse ServerName extension" \
4360 -s "ssl_sni_wrapper() returned" \
4361 -s "mbedtls_ssl_handshake returned" \
4362 -c "mbedtls_ssl_handshake returned" \
4363 -c "SSL - A fatal alert message was received from our peer"
4364
4365run_test "SNI: DTLS, client auth no override: optional" \
4366 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4367 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4368 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4369 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4370 0 \
4371 -S "skip write certificate request" \
4372 -C "skip parse certificate request" \
4373 -c "got a certificate request" \
4374 -C "skip write certificate" \
4375 -C "skip write certificate verify" \
4376 -S "skip parse certificate verify"
4377
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004378requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004379run_test "SNI: DTLS, client auth override: none -> optional" \
4380 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4381 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4382 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4383 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4384 0 \
4385 -S "skip write certificate request" \
4386 -C "skip parse certificate request" \
4387 -c "got a certificate request" \
4388 -C "skip write certificate" \
4389 -C "skip write certificate verify" \
4390 -S "skip parse certificate verify"
4391
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004392requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004393run_test "SNI: DTLS, client auth override: optional -> none" \
4394 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4395 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4396 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4397 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4398 0 \
4399 -s "skip write certificate request" \
4400 -C "skip parse certificate request" \
4401 -c "got no certificate request" \
4402 -c "skip write certificate" \
4403 -c "skip write certificate verify" \
4404 -s "skip parse certificate verify"
4405
Hanno Becker4a156fc2019-06-14 17:07:06 +01004406requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004407requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004408requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004409run_test "SNI: DTLS, CA no override" \
4410 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4411 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4412 ca_file=data_files/test-ca.crt \
4413 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4414 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4415 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4416 1 \
4417 -S "skip write certificate request" \
4418 -C "skip parse certificate request" \
4419 -c "got a certificate request" \
4420 -C "skip write certificate" \
4421 -C "skip write certificate verify" \
4422 -S "skip parse certificate verify" \
4423 -s "x509_verify_cert() returned" \
4424 -s "! The certificate is not correctly signed by the trusted CA" \
4425 -S "The certificate has been revoked (is on a CRL)"
4426
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004427requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004428run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004429 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4430 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4431 ca_file=data_files/test-ca.crt \
4432 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4433 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4434 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4435 0 \
4436 -S "skip write certificate request" \
4437 -C "skip parse certificate request" \
4438 -c "got a certificate request" \
4439 -C "skip write certificate" \
4440 -C "skip write certificate verify" \
4441 -S "skip parse certificate verify" \
4442 -S "x509_verify_cert() returned" \
4443 -S "! The certificate is not correctly signed by the trusted CA" \
4444 -S "The certificate has been revoked (is on a CRL)"
4445
Hanno Becker4a156fc2019-06-14 17:07:06 +01004446requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004447requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004448requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004449run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004450 "$P_SRV debug_level=3 auth_mode=optional \
4451 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4452 ca_file=data_files/test-ca.crt \
4453 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4454 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4455 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4456 1 \
4457 -S "skip write certificate request" \
4458 -C "skip parse certificate request" \
4459 -c "got a certificate request" \
4460 -C "skip write certificate" \
4461 -C "skip write certificate verify" \
4462 -S "skip parse certificate verify" \
4463 -s "x509_verify_cert() returned" \
4464 -S "! The certificate is not correctly signed by the trusted CA" \
4465 -s "The certificate has been revoked (is on a CRL)"
4466
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004467# Tests for non-blocking I/O: exercise a variety of handshake flows
4468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004469run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004470 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4471 "$P_CLI nbio=2 tickets=0" \
4472 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004473 -S "mbedtls_ssl_handshake returned" \
4474 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004475 -c "Read from server: .* bytes read"
4476
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004477run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004478 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4479 "$P_CLI nbio=2 tickets=0" \
4480 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004481 -S "mbedtls_ssl_handshake returned" \
4482 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004483 -c "Read from server: .* bytes read"
4484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004485run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004486 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4487 "$P_CLI nbio=2 tickets=1" \
4488 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004489 -S "mbedtls_ssl_handshake returned" \
4490 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004491 -c "Read from server: .* bytes read"
4492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004493run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004494 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4495 "$P_CLI nbio=2 tickets=1" \
4496 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004497 -S "mbedtls_ssl_handshake returned" \
4498 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004499 -c "Read from server: .* bytes read"
4500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004501run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004502 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4503 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4504 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004505 -S "mbedtls_ssl_handshake returned" \
4506 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004507 -c "Read from server: .* bytes read"
4508
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004509run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004510 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4511 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4512 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004513 -S "mbedtls_ssl_handshake returned" \
4514 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004515 -c "Read from server: .* bytes read"
4516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004517run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004518 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4519 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4520 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004521 -S "mbedtls_ssl_handshake returned" \
4522 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004523 -c "Read from server: .* bytes read"
4524
Hanno Becker00076712017-11-15 16:39:08 +00004525# Tests for event-driven I/O: exercise a variety of handshake flows
4526
4527run_test "Event-driven I/O: basic handshake" \
4528 "$P_SRV event=1 tickets=0 auth_mode=none" \
4529 "$P_CLI event=1 tickets=0" \
4530 0 \
4531 -S "mbedtls_ssl_handshake returned" \
4532 -C "mbedtls_ssl_handshake returned" \
4533 -c "Read from server: .* bytes read"
4534
4535run_test "Event-driven I/O: client auth" \
4536 "$P_SRV event=1 tickets=0 auth_mode=required" \
4537 "$P_CLI event=1 tickets=0" \
4538 0 \
4539 -S "mbedtls_ssl_handshake returned" \
4540 -C "mbedtls_ssl_handshake returned" \
4541 -c "Read from server: .* bytes read"
4542
4543run_test "Event-driven I/O: ticket" \
4544 "$P_SRV event=1 tickets=1 auth_mode=none" \
4545 "$P_CLI event=1 tickets=1" \
4546 0 \
4547 -S "mbedtls_ssl_handshake returned" \
4548 -C "mbedtls_ssl_handshake returned" \
4549 -c "Read from server: .* bytes read"
4550
4551run_test "Event-driven I/O: ticket + client auth" \
4552 "$P_SRV event=1 tickets=1 auth_mode=required" \
4553 "$P_CLI event=1 tickets=1" \
4554 0 \
4555 -S "mbedtls_ssl_handshake returned" \
4556 -C "mbedtls_ssl_handshake returned" \
4557 -c "Read from server: .* bytes read"
4558
4559run_test "Event-driven I/O: ticket + client auth + resume" \
4560 "$P_SRV event=1 tickets=1 auth_mode=required" \
4561 "$P_CLI event=1 tickets=1 reconnect=1" \
4562 0 \
4563 -S "mbedtls_ssl_handshake returned" \
4564 -C "mbedtls_ssl_handshake returned" \
4565 -c "Read from server: .* bytes read"
4566
4567run_test "Event-driven I/O: ticket + resume" \
4568 "$P_SRV event=1 tickets=1 auth_mode=none" \
4569 "$P_CLI event=1 tickets=1 reconnect=1" \
4570 0 \
4571 -S "mbedtls_ssl_handshake returned" \
4572 -C "mbedtls_ssl_handshake returned" \
4573 -c "Read from server: .* bytes read"
4574
4575run_test "Event-driven I/O: session-id resume" \
4576 "$P_SRV event=1 tickets=0 auth_mode=none" \
4577 "$P_CLI event=1 tickets=0 reconnect=1" \
4578 0 \
4579 -S "mbedtls_ssl_handshake returned" \
4580 -C "mbedtls_ssl_handshake returned" \
4581 -c "Read from server: .* bytes read"
4582
Hanno Becker6a33f592018-03-13 11:38:46 +00004583run_test "Event-driven I/O, DTLS: basic handshake" \
4584 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4585 "$P_CLI dtls=1 event=1 tickets=0" \
4586 0 \
4587 -c "Read from server: .* bytes read"
4588
4589run_test "Event-driven I/O, DTLS: client auth" \
4590 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4591 "$P_CLI dtls=1 event=1 tickets=0" \
4592 0 \
4593 -c "Read from server: .* bytes read"
4594
4595run_test "Event-driven I/O, DTLS: ticket" \
4596 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4597 "$P_CLI dtls=1 event=1 tickets=1" \
4598 0 \
4599 -c "Read from server: .* bytes read"
4600
4601run_test "Event-driven I/O, DTLS: ticket + client auth" \
4602 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4603 "$P_CLI dtls=1 event=1 tickets=1" \
4604 0 \
4605 -c "Read from server: .* bytes read"
4606
4607run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4608 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4609 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4610 0 \
4611 -c "Read from server: .* bytes read"
4612
4613run_test "Event-driven I/O, DTLS: ticket + resume" \
4614 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4615 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4616 0 \
4617 -c "Read from server: .* bytes read"
4618
4619run_test "Event-driven I/O, DTLS: session-id resume" \
4620 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4621 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4622 0 \
4623 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004624
4625# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4626# During session resumption, the client will send its ApplicationData record
4627# within the same datagram as the Finished messages. In this situation, the
4628# server MUST NOT idle on the underlying transport after handshake completion,
4629# because the ApplicationData request has already been queued internally.
4630run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004631 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004632 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4633 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4634 0 \
4635 -c "Read from server: .* bytes read"
4636
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004637# Tests for version negotiation
4638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004639run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004640 "$P_SRV" \
4641 "$P_CLI" \
4642 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004643 -S "mbedtls_ssl_handshake returned" \
4644 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004645 -s "Protocol is TLSv1.2" \
4646 -c "Protocol is TLSv1.2"
4647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004648run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004649 "$P_SRV" \
4650 "$P_CLI max_version=tls1_1" \
4651 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004652 -S "mbedtls_ssl_handshake returned" \
4653 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004654 -s "Protocol is TLSv1.1" \
4655 -c "Protocol is TLSv1.1"
4656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004657run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004658 "$P_SRV max_version=tls1_1" \
4659 "$P_CLI" \
4660 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004661 -S "mbedtls_ssl_handshake returned" \
4662 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004663 -s "Protocol is TLSv1.1" \
4664 -c "Protocol is TLSv1.1"
4665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004666run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004667 "$P_SRV max_version=tls1_1" \
4668 "$P_CLI max_version=tls1_1" \
4669 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004670 -S "mbedtls_ssl_handshake returned" \
4671 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004672 -s "Protocol is TLSv1.1" \
4673 -c "Protocol is TLSv1.1"
4674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004675run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004676 "$P_SRV min_version=tls1_1" \
4677 "$P_CLI max_version=tls1_1" \
4678 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004679 -S "mbedtls_ssl_handshake returned" \
4680 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004681 -s "Protocol is TLSv1.1" \
4682 -c "Protocol is TLSv1.1"
4683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004684run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004685 "$P_SRV max_version=tls1_1" \
4686 "$P_CLI min_version=tls1_1" \
4687 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004688 -S "mbedtls_ssl_handshake returned" \
4689 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004690 -s "Protocol is TLSv1.1" \
4691 -c "Protocol is TLSv1.1"
4692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004693run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004694 "$P_SRV max_version=tls1_1" \
4695 "$P_CLI min_version=tls1_2" \
4696 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004697 -s "mbedtls_ssl_handshake returned" \
4698 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004699 -c "SSL - Handshake protocol not within min/max boundaries"
4700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004701run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004702 "$P_SRV min_version=tls1_2" \
4703 "$P_CLI max_version=tls1_1" \
4704 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004705 -s "mbedtls_ssl_handshake returned" \
4706 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004707 -s "SSL - Handshake protocol not within min/max boundaries"
4708
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004709# Tests for ALPN extension
4710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004711run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004712 "$P_SRV debug_level=3" \
4713 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004714 0 \
4715 -C "client hello, adding alpn extension" \
4716 -S "found alpn extension" \
4717 -C "got an alert message, type: \\[2:120]" \
4718 -S "server hello, adding alpn extension" \
4719 -C "found alpn extension " \
4720 -C "Application Layer Protocol is" \
4721 -S "Application Layer Protocol is"
4722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004723run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004724 "$P_SRV debug_level=3" \
4725 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004726 0 \
4727 -c "client hello, adding alpn extension" \
4728 -s "found alpn extension" \
4729 -C "got an alert message, type: \\[2:120]" \
4730 -S "server hello, adding alpn extension" \
4731 -C "found alpn extension " \
4732 -c "Application Layer Protocol is (none)" \
4733 -S "Application Layer Protocol is"
4734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004735run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004736 "$P_SRV debug_level=3 alpn=abc,1234" \
4737 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004738 0 \
4739 -C "client hello, adding alpn extension" \
4740 -S "found alpn extension" \
4741 -C "got an alert message, type: \\[2:120]" \
4742 -S "server hello, adding alpn extension" \
4743 -C "found alpn extension " \
4744 -C "Application Layer Protocol is" \
4745 -s "Application Layer Protocol is (none)"
4746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004747run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004748 "$P_SRV debug_level=3 alpn=abc,1234" \
4749 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004750 0 \
4751 -c "client hello, adding alpn extension" \
4752 -s "found alpn extension" \
4753 -C "got an alert message, type: \\[2:120]" \
4754 -s "server hello, adding alpn extension" \
4755 -c "found alpn extension" \
4756 -c "Application Layer Protocol is abc" \
4757 -s "Application Layer Protocol is abc"
4758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004759run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004760 "$P_SRV debug_level=3 alpn=abc,1234" \
4761 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004762 0 \
4763 -c "client hello, adding alpn extension" \
4764 -s "found alpn extension" \
4765 -C "got an alert message, type: \\[2:120]" \
4766 -s "server hello, adding alpn extension" \
4767 -c "found alpn extension" \
4768 -c "Application Layer Protocol is abc" \
4769 -s "Application Layer Protocol is abc"
4770
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004771run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004772 "$P_SRV debug_level=3 alpn=abc,1234" \
4773 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004774 0 \
4775 -c "client hello, adding alpn extension" \
4776 -s "found alpn extension" \
4777 -C "got an alert message, type: \\[2:120]" \
4778 -s "server hello, adding alpn extension" \
4779 -c "found alpn extension" \
4780 -c "Application Layer Protocol is 1234" \
4781 -s "Application Layer Protocol is 1234"
4782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004783run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004784 "$P_SRV debug_level=3 alpn=abc,123" \
4785 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004786 1 \
4787 -c "client hello, adding alpn extension" \
4788 -s "found alpn extension" \
4789 -c "got an alert message, type: \\[2:120]" \
4790 -S "server hello, adding alpn extension" \
4791 -C "found alpn extension" \
4792 -C "Application Layer Protocol is 1234" \
4793 -S "Application Layer Protocol is 1234"
4794
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02004795
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004796# Tests for keyUsage in leaf certificates, part 1:
4797# server-side certificate/suite selection
4798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004799run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004800 "$P_SRV key_file=data_files/server2.key \
4801 crt_file=data_files/server2.ku-ds.crt" \
4802 "$P_CLI" \
4803 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02004804 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004805
4806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004807run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004808 "$P_SRV key_file=data_files/server2.key \
4809 crt_file=data_files/server2.ku-ke.crt" \
4810 "$P_CLI" \
4811 0 \
4812 -c "Ciphersuite is TLS-RSA-WITH-"
4813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004814run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004815 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004816 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004817 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004818 1 \
4819 -C "Ciphersuite is "
4820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004821run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004822 "$P_SRV key_file=data_files/server5.key \
4823 crt_file=data_files/server5.ku-ds.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004824 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004825 0 \
4826 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
4827
4828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004829run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004830 "$P_SRV key_file=data_files/server5.key \
4831 crt_file=data_files/server5.ku-ka.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004832 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004833 0 \
4834 -c "Ciphersuite is TLS-ECDH-"
4835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004836run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004837 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004838 crt_file=data_files/server5.ku-ke.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004839 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004840 1 \
4841 -C "Ciphersuite is "
4842
4843# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004844# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004846run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004847 "$O_SRV -key data_files/server2.key \
4848 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004849 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004850 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4851 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004852 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004853 -C "Processing of the Certificate handshake message failed" \
4854 -c "Ciphersuite is TLS-"
4855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004856run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004857 "$O_SRV -key data_files/server2.key \
4858 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004859 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004860 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4861 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004862 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004863 -C "Processing of the Certificate handshake message failed" \
4864 -c "Ciphersuite is TLS-"
4865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004866run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004867 "$O_SRV -key data_files/server2.key \
4868 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004869 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004870 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4871 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004872 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004873 -C "Processing of the Certificate handshake message failed" \
4874 -c "Ciphersuite is TLS-"
4875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004876run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004877 "$O_SRV -key data_files/server2.key \
4878 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004879 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004880 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4881 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004882 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004883 -c "Processing of the Certificate handshake message failed" \
4884 -C "Ciphersuite is TLS-"
4885
Hanno Becker4a156fc2019-06-14 17:07:06 +01004886requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004887requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004888run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
4889 "$O_SRV -key data_files/server2.key \
4890 -cert data_files/server2.ku-ke.crt" \
4891 "$P_CLI debug_level=1 auth_mode=optional \
4892 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4893 0 \
4894 -c "bad certificate (usage extensions)" \
4895 -C "Processing of the Certificate handshake message failed" \
4896 -c "Ciphersuite is TLS-" \
4897 -c "! Usage does not match the keyUsage extension"
4898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004899run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004900 "$O_SRV -key data_files/server2.key \
4901 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004902 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004903 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4904 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004905 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004906 -C "Processing of the Certificate handshake message failed" \
4907 -c "Ciphersuite is TLS-"
4908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004909run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004910 "$O_SRV -key data_files/server2.key \
4911 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004912 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004913 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4914 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004915 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004916 -c "Processing of the Certificate handshake message failed" \
4917 -C "Ciphersuite is TLS-"
4918
Hanno Becker4a156fc2019-06-14 17:07:06 +01004919requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004920requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004921run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
4922 "$O_SRV -key data_files/server2.key \
4923 -cert data_files/server2.ku-ds.crt" \
4924 "$P_CLI debug_level=1 auth_mode=optional \
4925 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4926 0 \
4927 -c "bad certificate (usage extensions)" \
4928 -C "Processing of the Certificate handshake message failed" \
4929 -c "Ciphersuite is TLS-" \
4930 -c "! Usage does not match the keyUsage extension"
4931
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004932# Tests for keyUsage in leaf certificates, part 3:
4933# server-side checking of client cert
4934
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004935run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004936 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004937 "$O_CLI -key data_files/server2.key \
4938 -cert data_files/server2.ku-ds.crt" \
4939 0 \
4940 -S "bad certificate (usage extensions)" \
4941 -S "Processing of the Certificate handshake message failed"
4942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004943run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004944 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004945 "$O_CLI -key data_files/server2.key \
4946 -cert data_files/server2.ku-ke.crt" \
4947 0 \
4948 -s "bad certificate (usage extensions)" \
4949 -S "Processing of the Certificate handshake message failed"
4950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004951run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004952 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004953 "$O_CLI -key data_files/server2.key \
4954 -cert data_files/server2.ku-ke.crt" \
4955 1 \
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: ECDSA, DigitalSignature: OK" \
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/server5.key \
4962 -cert data_files/server5.ku-ds.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: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004968 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004969 "$O_CLI -key data_files/server5.key \
4970 -cert data_files/server5.ku-ka.crt" \
4971 0 \
4972 -s "bad certificate (usage extensions)" \
4973 -S "Processing of the Certificate handshake message failed"
4974
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004975# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
4976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004977run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004978 "$P_SRV key_file=data_files/server5.key \
4979 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004980 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004981 0
4982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004983run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004984 "$P_SRV key_file=data_files/server5.key \
4985 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004986 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004987 0
4988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004989run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004990 "$P_SRV key_file=data_files/server5.key \
4991 crt_file=data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004992 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004993 0
4994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004995run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02004996 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004997 crt_file=data_files/server5.eku-cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004998 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004999 1
5000
5001# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005003run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005004 "$O_SRV -key data_files/server5.key \
5005 -cert data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005006 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005007 0 \
5008 -C "bad certificate (usage extensions)" \
5009 -C "Processing of the Certificate handshake message failed" \
5010 -c "Ciphersuite is TLS-"
5011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005012run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005013 "$O_SRV -key data_files/server5.key \
5014 -cert data_files/server5.eku-srv_cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005015 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005016 0 \
5017 -C "bad certificate (usage extensions)" \
5018 -C "Processing of the Certificate handshake message failed" \
5019 -c "Ciphersuite is TLS-"
5020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005021run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005022 "$O_SRV -key data_files/server5.key \
5023 -cert data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005024 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005025 0 \
5026 -C "bad certificate (usage extensions)" \
5027 -C "Processing of the Certificate handshake message failed" \
5028 -c "Ciphersuite is TLS-"
5029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005030run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005031 "$O_SRV -key data_files/server5.key \
5032 -cert data_files/server5.eku-cs.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005033 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005034 1 \
5035 -c "bad certificate (usage extensions)" \
5036 -c "Processing of the Certificate handshake message failed" \
5037 -C "Ciphersuite is TLS-"
5038
5039# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005041run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005042 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005043 "$O_CLI -key data_files/server5.key \
5044 -cert data_files/server5.eku-cli.crt" \
5045 0 \
5046 -S "bad certificate (usage extensions)" \
5047 -S "Processing of the Certificate handshake message failed"
5048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005049run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005050 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005051 "$O_CLI -key data_files/server5.key \
5052 -cert data_files/server5.eku-srv_cli.crt" \
5053 0 \
5054 -S "bad certificate (usage extensions)" \
5055 -S "Processing of the Certificate handshake message failed"
5056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005057run_test "extKeyUsage cli-auth: codeSign,anyEKU -> 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-cs_any.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: codeSign -> fail (soft)" \
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-cs.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 -> fail (hard)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005074 "$P_SRV debug_level=1 auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005075 "$O_CLI -key data_files/server5.key \
5076 -cert data_files/server5.eku-cs.crt" \
5077 1 \
5078 -s "bad certificate (usage extensions)" \
5079 -s "Processing of the Certificate handshake message failed"
5080
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005081# Tests for DHM parameters loading
5082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005083run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005084 "$P_SRV" \
5085 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5086 debug_level=3" \
5087 0 \
5088 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005089 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005090
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005091run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005092 "$P_SRV dhm_file=data_files/dhparams.pem" \
5093 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5094 debug_level=3" \
5095 0 \
5096 -c "value of 'DHM: P ' (1024 bits)" \
5097 -c "value of 'DHM: G ' (2 bits)"
5098
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005099# Tests for DHM client-side size checking
5100
5101run_test "DHM size: server default, client default, OK" \
5102 "$P_SRV" \
5103 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5104 debug_level=1" \
5105 0 \
5106 -C "DHM prime too short:"
5107
5108run_test "DHM size: server default, client 2048, OK" \
5109 "$P_SRV" \
5110 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5111 debug_level=1 dhmlen=2048" \
5112 0 \
5113 -C "DHM prime too short:"
5114
5115run_test "DHM size: server 1024, client default, OK" \
5116 "$P_SRV dhm_file=data_files/dhparams.pem" \
5117 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5118 debug_level=1" \
5119 0 \
5120 -C "DHM prime too short:"
5121
5122run_test "DHM size: server 1000, client default, rejected" \
5123 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5124 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5125 debug_level=1" \
5126 1 \
5127 -c "DHM prime too short:"
5128
5129run_test "DHM size: server default, client 2049, rejected" \
5130 "$P_SRV" \
5131 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5132 debug_level=1 dhmlen=2049" \
5133 1 \
5134 -c "DHM prime too short:"
5135
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005136# Tests for PSK callback
5137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005138run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005139 "$P_SRV psk=abc123 psk_identity=foo" \
5140 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5141 psk_identity=foo psk=abc123" \
5142 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005143 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005144 -S "SSL - Unknown identity received" \
5145 -S "SSL - Verification of the message MAC failed"
5146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005147run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005148 "$P_SRV" \
5149 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5150 psk_identity=foo psk=abc123" \
5151 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005152 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005153 -S "SSL - Unknown identity received" \
5154 -S "SSL - Verification of the message MAC failed"
5155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005156run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005157 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5158 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5159 psk_identity=foo psk=abc123" \
5160 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005161 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005162 -s "SSL - Unknown identity received" \
5163 -S "SSL - Verification of the message MAC failed"
5164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005165run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005166 "$P_SRV psk_list=abc,dead,def,beef" \
5167 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5168 psk_identity=abc psk=dead" \
5169 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005170 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005171 -S "SSL - Unknown identity received" \
5172 -S "SSL - Verification of the message MAC failed"
5173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005174run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005175 "$P_SRV psk_list=abc,dead,def,beef" \
5176 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5177 psk_identity=def psk=beef" \
5178 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005179 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005180 -S "SSL - Unknown identity received" \
5181 -S "SSL - Verification of the message MAC failed"
5182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005183run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005184 "$P_SRV psk_list=abc,dead,def,beef" \
5185 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5186 psk_identity=ghi psk=beef" \
5187 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005188 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005189 -s "SSL - Unknown identity received" \
5190 -S "SSL - Verification of the message MAC failed"
5191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005192run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005193 "$P_SRV psk_list=abc,dead,def,beef" \
5194 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5195 psk_identity=abc psk=beef" \
5196 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005197 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005198 -S "SSL - Unknown identity received" \
5199 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005200
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005201# Tests for EC J-PAKE
5202
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005203requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005204run_test "ECJPAKE: client not configured" \
5205 "$P_SRV debug_level=3" \
5206 "$P_CLI debug_level=3" \
5207 0 \
5208 -C "add ciphersuite: c0ff" \
5209 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005210 -S "found ecjpake kkpp extension" \
5211 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005212 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005213 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005214 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005215 -S "None of the common ciphersuites is usable"
5216
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005217requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005218run_test "ECJPAKE: server not configured" \
5219 "$P_SRV debug_level=3" \
5220 "$P_CLI debug_level=3 ecjpake_pw=bla \
5221 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5222 1 \
5223 -c "add ciphersuite: c0ff" \
5224 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005225 -s "found ecjpake kkpp extension" \
5226 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005227 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005228 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005229 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005230 -s "None of the common ciphersuites is usable"
5231
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005232requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005233run_test "ECJPAKE: working, TLS" \
5234 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5235 "$P_CLI debug_level=3 ecjpake_pw=bla \
5236 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005237 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005238 -c "add ciphersuite: c0ff" \
5239 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005240 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005241 -s "found ecjpake kkpp extension" \
5242 -S "skip ecjpake kkpp extension" \
5243 -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é-Gonnard921f2d02015-09-16 22:52:18 +02005246 -S "None of the common ciphersuites is usable" \
5247 -S "SSL - Verification of the message MAC failed"
5248
Janos Follath74537a62016-09-02 13:45:28 +01005249server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005250requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005251run_test "ECJPAKE: password mismatch, TLS" \
5252 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5253 "$P_CLI debug_level=3 ecjpake_pw=bad \
5254 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5255 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005256 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005257 -s "SSL - Verification of the message MAC failed"
5258
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005259requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005260run_test "ECJPAKE: working, DTLS" \
5261 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5262 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5263 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5264 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005265 -c "re-using cached ecjpake parameters" \
5266 -S "SSL - Verification of the message MAC failed"
5267
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005268requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005269run_test "ECJPAKE: working, DTLS, no cookie" \
5270 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5271 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5272 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5273 0 \
5274 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005275 -S "SSL - Verification of the message MAC failed"
5276
Janos Follath74537a62016-09-02 13:45:28 +01005277server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005278requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005279run_test "ECJPAKE: password mismatch, DTLS" \
5280 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5281 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5282 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5283 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005284 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005285 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005286
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005287# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005288requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005289run_test "ECJPAKE: working, DTLS, nolog" \
5290 "$P_SRV dtls=1 ecjpake_pw=bla" \
5291 "$P_CLI dtls=1 ecjpake_pw=bla \
5292 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5293 0
5294
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005295# Tests for ciphersuites per version
5296
Janos Follathe2681a42016-03-07 15:57:05 +00005297requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005298requires_config_enabled MBEDTLS_CAMELLIA_C
5299requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005300run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005301 "$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 +02005302 "$P_CLI force_version=ssl3" \
5303 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005304 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005305
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005306requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5307requires_config_enabled MBEDTLS_CAMELLIA_C
5308requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005309run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005310 "$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 +01005311 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005312 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005313 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005314
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005315requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5316requires_config_enabled MBEDTLS_CAMELLIA_C
5317requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005318run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005319 "$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 +02005320 "$P_CLI force_version=tls1_1" \
5321 0 \
5322 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5323
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005324requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5325requires_config_enabled MBEDTLS_CAMELLIA_C
5326requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005327run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005328 "$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 +02005329 "$P_CLI force_version=tls1_2" \
5330 0 \
5331 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5332
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005333# Test for ClientHello without extensions
5334
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005335requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005336run_test "ClientHello without extensions, SHA-1 allowed" \
Ron Eldorb76e7652019-01-16 23:14:41 +02005337 "$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 +02005338 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005339 0 \
5340 -s "dumping 'client hello extensions' (0 bytes)"
5341
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005342requires_gnutls
5343run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
5344 "$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 +02005345 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005346 0 \
5347 -s "dumping 'client hello extensions' (0 bytes)"
5348
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005349# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005350
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005351run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005352 "$P_SRV" \
5353 "$P_CLI request_size=100" \
5354 0 \
5355 -s "Read from client: 100 bytes read$"
5356
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005357run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005358 "$P_SRV" \
5359 "$P_CLI request_size=500" \
5360 0 \
5361 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005362
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005363# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005364
Janos Follathe2681a42016-03-07 15:57:05 +00005365requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005366run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005367 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005368 "$P_CLI request_size=1 force_version=ssl3 \
5369 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5370 0 \
5371 -s "Read from client: 1 bytes read"
5372
Janos Follathe2681a42016-03-07 15:57:05 +00005373requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005374run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005375 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005376 "$P_CLI request_size=1 force_version=ssl3 \
5377 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5378 0 \
5379 -s "Read from client: 1 bytes read"
5380
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005381run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005382 "$P_SRV" \
5383 "$P_CLI request_size=1 force_version=tls1 \
5384 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5385 0 \
5386 -s "Read from client: 1 bytes read"
5387
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005388run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005389 "$P_SRV" \
5390 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5391 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5392 0 \
5393 -s "Read from client: 1 bytes read"
5394
Hanno Becker32c55012017-11-10 08:42:54 +00005395requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005396run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005397 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005398 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005399 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005400 0 \
5401 -s "Read from client: 1 bytes read"
5402
Hanno Becker32c55012017-11-10 08:42:54 +00005403requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005404run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005405 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005406 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005407 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005408 0 \
5409 -s "Read from client: 1 bytes read"
5410
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005411run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005412 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005413 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005414 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5415 0 \
5416 -s "Read from client: 1 bytes read"
5417
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005418run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005419 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5420 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005421 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005422 0 \
5423 -s "Read from client: 1 bytes read"
5424
5425requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005426run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005427 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005428 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005429 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005430 0 \
5431 -s "Read from client: 1 bytes read"
5432
Hanno Becker8501f982017-11-10 08:59:04 +00005433requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005434run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005435 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5436 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5437 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005438 0 \
5439 -s "Read from client: 1 bytes read"
5440
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005441run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005442 "$P_SRV" \
5443 "$P_CLI request_size=1 force_version=tls1_1 \
5444 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5445 0 \
5446 -s "Read from client: 1 bytes read"
5447
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005448run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005449 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005450 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005451 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005452 0 \
5453 -s "Read from client: 1 bytes read"
5454
5455requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005456run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005457 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005458 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005459 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005460 0 \
5461 -s "Read from client: 1 bytes read"
5462
5463requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005464run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005465 "$P_SRV trunc_hmac=1" \
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 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005468 0 \
5469 -s "Read from client: 1 bytes read"
5470
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005471run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005472 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005473 "$P_CLI request_size=1 force_version=tls1_1 \
5474 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5475 0 \
5476 -s "Read from client: 1 bytes read"
5477
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005478run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005479 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005480 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005481 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005482 0 \
5483 -s "Read from client: 1 bytes read"
5484
Hanno Becker8501f982017-11-10 08:59:04 +00005485requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005486run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005487 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005488 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005489 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005490 0 \
5491 -s "Read from client: 1 bytes read"
5492
Hanno Becker32c55012017-11-10 08:42:54 +00005493requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005494run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005495 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
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 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005498 0 \
5499 -s "Read from client: 1 bytes read"
5500
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005501run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005502 "$P_SRV" \
5503 "$P_CLI request_size=1 force_version=tls1_2 \
5504 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5505 0 \
5506 -s "Read from client: 1 bytes read"
5507
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005508run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005509 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005510 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005511 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005512 0 \
5513 -s "Read from client: 1 bytes read"
5514
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005515run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005516 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005517 "$P_CLI request_size=1 force_version=tls1_2 \
5518 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005519 0 \
5520 -s "Read from client: 1 bytes read"
5521
Hanno Becker32c55012017-11-10 08:42:54 +00005522requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005523run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005524 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005525 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005526 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005527 0 \
5528 -s "Read from client: 1 bytes read"
5529
Hanno Becker8501f982017-11-10 08:59:04 +00005530requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005531run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005532 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005533 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005534 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005535 0 \
5536 -s "Read from client: 1 bytes read"
5537
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005538run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005539 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005540 "$P_CLI request_size=1 force_version=tls1_2 \
5541 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5542 0 \
5543 -s "Read from client: 1 bytes read"
5544
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005545run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005546 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005547 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005548 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005549 0 \
5550 -s "Read from client: 1 bytes read"
5551
Hanno Becker32c55012017-11-10 08:42:54 +00005552requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005553run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005554 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005555 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005556 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005557 0 \
5558 -s "Read from client: 1 bytes read"
5559
Hanno Becker8501f982017-11-10 08:59:04 +00005560requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005561run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005562 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005563 "$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 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005565 0 \
5566 -s "Read from client: 1 bytes read"
5567
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005568run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005569 "$P_SRV" \
5570 "$P_CLI request_size=1 force_version=tls1_2 \
5571 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5572 0 \
5573 -s "Read from client: 1 bytes read"
5574
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005575run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005576 "$P_SRV" \
5577 "$P_CLI request_size=1 force_version=tls1_2 \
5578 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5579 0 \
5580 -s "Read from client: 1 bytes read"
5581
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005582# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005583
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005584run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005585 "$P_SRV dtls=1 force_version=dtls1" \
5586 "$P_CLI dtls=1 request_size=1 \
5587 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5588 0 \
5589 -s "Read from client: 1 bytes read"
5590
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005591run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00005592 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
5593 "$P_CLI dtls=1 request_size=1 \
5594 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5595 0 \
5596 -s "Read from client: 1 bytes read"
5597
Hanno Beckere2148042017-11-10 08:59:18 +00005598requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005599run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005600 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
5601 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00005602 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5603 0 \
5604 -s "Read from client: 1 bytes read"
5605
Hanno Beckere2148042017-11-10 08:59:18 +00005606requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005607run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005608 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005609 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005610 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005611 0 \
5612 -s "Read from client: 1 bytes read"
5613
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005614run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00005615 "$P_SRV dtls=1 force_version=dtls1_2" \
5616 "$P_CLI dtls=1 request_size=1 \
5617 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5618 0 \
5619 -s "Read from client: 1 bytes read"
5620
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005621run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005622 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005623 "$P_CLI dtls=1 request_size=1 \
5624 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5625 0 \
5626 -s "Read from client: 1 bytes read"
5627
Hanno Beckere2148042017-11-10 08:59:18 +00005628requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005629run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005630 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005631 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005632 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005633 0 \
5634 -s "Read from client: 1 bytes read"
5635
Hanno Beckere2148042017-11-10 08:59:18 +00005636requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005637run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005638 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005639 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005640 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005641 0 \
5642 -s "Read from client: 1 bytes read"
5643
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005644# Tests for small server packets
5645
5646requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5647run_test "Small server packet SSLv3 BlockCipher" \
5648 "$P_SRV response_size=1 min_version=ssl3" \
5649 "$P_CLI force_version=ssl3 \
5650 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5651 0 \
5652 -c "Read from server: 1 bytes read"
5653
5654requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5655run_test "Small server packet SSLv3 StreamCipher" \
5656 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5657 "$P_CLI force_version=ssl3 \
5658 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5659 0 \
5660 -c "Read from server: 1 bytes read"
5661
5662run_test "Small server packet TLS 1.0 BlockCipher" \
5663 "$P_SRV response_size=1" \
5664 "$P_CLI force_version=tls1 \
5665 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5666 0 \
5667 -c "Read from server: 1 bytes read"
5668
5669run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
5670 "$P_SRV response_size=1" \
5671 "$P_CLI force_version=tls1 etm=0 \
5672 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5673 0 \
5674 -c "Read from server: 1 bytes read"
5675
5676requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5677run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
5678 "$P_SRV response_size=1 trunc_hmac=1" \
5679 "$P_CLI force_version=tls1 \
5680 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5681 0 \
5682 -c "Read from server: 1 bytes read"
5683
5684requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5685run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
5686 "$P_SRV response_size=1 trunc_hmac=1" \
5687 "$P_CLI force_version=tls1 \
5688 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5689 0 \
5690 -c "Read from server: 1 bytes read"
5691
5692run_test "Small server packet TLS 1.0 StreamCipher" \
5693 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5694 "$P_CLI force_version=tls1 \
5695 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5696 0 \
5697 -c "Read from server: 1 bytes read"
5698
5699run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
5700 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5701 "$P_CLI force_version=tls1 \
5702 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5703 0 \
5704 -c "Read from server: 1 bytes read"
5705
5706requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5707run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
5708 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5709 "$P_CLI force_version=tls1 \
5710 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5711 0 \
5712 -c "Read from server: 1 bytes read"
5713
5714requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5715run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5716 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5717 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5718 trunc_hmac=1 etm=0" \
5719 0 \
5720 -c "Read from server: 1 bytes read"
5721
5722run_test "Small server packet TLS 1.1 BlockCipher" \
5723 "$P_SRV response_size=1" \
5724 "$P_CLI force_version=tls1_1 \
5725 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5726 0 \
5727 -c "Read from server: 1 bytes read"
5728
5729run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
5730 "$P_SRV response_size=1" \
5731 "$P_CLI force_version=tls1_1 \
5732 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5733 0 \
5734 -c "Read from server: 1 bytes read"
5735
5736requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5737run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
5738 "$P_SRV response_size=1 trunc_hmac=1" \
5739 "$P_CLI force_version=tls1_1 \
5740 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5741 0 \
5742 -c "Read from server: 1 bytes read"
5743
5744requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5745run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5746 "$P_SRV response_size=1 trunc_hmac=1" \
5747 "$P_CLI force_version=tls1_1 \
5748 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5749 0 \
5750 -c "Read from server: 1 bytes read"
5751
5752run_test "Small server packet TLS 1.1 StreamCipher" \
5753 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5754 "$P_CLI force_version=tls1_1 \
5755 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5756 0 \
5757 -c "Read from server: 1 bytes read"
5758
5759run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
5760 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5761 "$P_CLI force_version=tls1_1 \
5762 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5763 0 \
5764 -c "Read from server: 1 bytes read"
5765
5766requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5767run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
5768 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5769 "$P_CLI force_version=tls1_1 \
5770 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5771 0 \
5772 -c "Read from server: 1 bytes read"
5773
5774requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5775run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5776 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5777 "$P_CLI force_version=tls1_1 \
5778 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5779 0 \
5780 -c "Read from server: 1 bytes read"
5781
5782run_test "Small server packet TLS 1.2 BlockCipher" \
5783 "$P_SRV response_size=1" \
5784 "$P_CLI force_version=tls1_2 \
5785 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5786 0 \
5787 -c "Read from server: 1 bytes read"
5788
5789run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5790 "$P_SRV response_size=1" \
5791 "$P_CLI force_version=tls1_2 \
5792 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5793 0 \
5794 -c "Read from server: 1 bytes read"
5795
5796run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5797 "$P_SRV response_size=1" \
5798 "$P_CLI force_version=tls1_2 \
5799 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5800 0 \
5801 -c "Read from server: 1 bytes read"
5802
5803requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5804run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5805 "$P_SRV response_size=1 trunc_hmac=1" \
5806 "$P_CLI force_version=tls1_2 \
5807 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5808 0 \
5809 -c "Read from server: 1 bytes read"
5810
5811requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5812run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5813 "$P_SRV response_size=1 trunc_hmac=1" \
5814 "$P_CLI force_version=tls1_2 \
5815 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5816 0 \
5817 -c "Read from server: 1 bytes read"
5818
5819run_test "Small server packet TLS 1.2 StreamCipher" \
5820 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5821 "$P_CLI force_version=tls1_2 \
5822 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5823 0 \
5824 -c "Read from server: 1 bytes read"
5825
5826run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
5827 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5828 "$P_CLI force_version=tls1_2 \
5829 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5830 0 \
5831 -c "Read from server: 1 bytes read"
5832
5833requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5834run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
5835 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5836 "$P_CLI force_version=tls1_2 \
5837 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5838 0 \
5839 -c "Read from server: 1 bytes read"
5840
5841requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5842run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5843 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5844 "$P_CLI force_version=tls1_2 \
5845 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5846 0 \
5847 -c "Read from server: 1 bytes read"
5848
5849run_test "Small server packet TLS 1.2 AEAD" \
5850 "$P_SRV response_size=1" \
5851 "$P_CLI force_version=tls1_2 \
5852 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5853 0 \
5854 -c "Read from server: 1 bytes read"
5855
5856run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5857 "$P_SRV response_size=1" \
5858 "$P_CLI force_version=tls1_2 \
5859 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5860 0 \
5861 -c "Read from server: 1 bytes read"
5862
5863# Tests for small server packets in DTLS
5864
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005865run_test "Small server packet DTLS 1.0" \
5866 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
5867 "$P_CLI dtls=1 \
5868 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5869 0 \
5870 -c "Read from server: 1 bytes read"
5871
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005872run_test "Small server packet DTLS 1.0, without EtM" \
5873 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
5874 "$P_CLI dtls=1 \
5875 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5876 0 \
5877 -c "Read from server: 1 bytes read"
5878
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005879requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5880run_test "Small server packet DTLS 1.0, truncated hmac" \
5881 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
5882 "$P_CLI dtls=1 trunc_hmac=1 \
5883 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5884 0 \
5885 -c "Read from server: 1 bytes read"
5886
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005887requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5888run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
5889 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
5890 "$P_CLI dtls=1 \
5891 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
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.2" \
5896 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
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 -04005902run_test "Small server packet DTLS 1.2, without EtM" \
5903 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5904 "$P_CLI dtls=1 \
5905 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5906 0 \
5907 -c "Read from server: 1 bytes read"
5908
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005909requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5910run_test "Small server packet DTLS 1.2, truncated hmac" \
5911 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5912 "$P_CLI dtls=1 \
5913 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5914 0 \
5915 -c "Read from server: 1 bytes read"
5916
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005917requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5918run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5919 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5920 "$P_CLI dtls=1 \
5921 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5922 0 \
5923 -c "Read from server: 1 bytes read"
5924
Janos Follath00efff72016-05-06 13:48:23 +01005925# A test for extensions in SSLv3
5926
5927requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5928run_test "SSLv3 with extensions, server side" \
5929 "$P_SRV min_version=ssl3 debug_level=3" \
5930 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
5931 0 \
5932 -S "dumping 'client hello extensions'" \
5933 -S "server hello, total extension length:"
5934
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005935# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005936
Angus Grattonc4dd0732018-04-11 16:28:39 +10005937# How many fragments do we expect to write $1 bytes?
5938fragments_for_write() {
5939 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
5940}
5941
Janos Follathe2681a42016-03-07 15:57:05 +00005942requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005943run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005944 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005945 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005946 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5947 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005948 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5949 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005950
Janos Follathe2681a42016-03-07 15:57:05 +00005951requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005952run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005953 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005954 "$P_CLI request_size=16384 force_version=ssl3 \
5955 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5956 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005957 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5958 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005959
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005960run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005961 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005962 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005963 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5964 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005965 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5966 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005967
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005968run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005969 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005970 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
5971 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5972 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005973 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005974
Hanno Becker32c55012017-11-10 08:42:54 +00005975requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005976run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005977 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005978 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005979 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005980 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005981 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5982 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005983
Hanno Becker32c55012017-11-10 08:42:54 +00005984requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005985run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005986 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005987 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005988 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005989 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005990 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005991
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005992run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005993 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005994 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005995 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5996 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005997 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005998
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005999run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006000 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6001 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006002 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006003 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006004 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006005
6006requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006007run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006008 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006009 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006010 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006011 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006012 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006013
Hanno Becker278fc7a2017-11-10 09:16:28 +00006014requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006015run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006016 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006017 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006018 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006019 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006020 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6021 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006022
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006023run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006024 "$P_SRV" \
6025 "$P_CLI request_size=16384 force_version=tls1_1 \
6026 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6027 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006028 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6029 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006030
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006031run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006032 "$P_SRV" \
6033 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6034 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006035 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006036 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006037
Hanno Becker32c55012017-11-10 08:42:54 +00006038requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006039run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006040 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006041 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006042 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006043 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006044 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006045
Hanno Becker32c55012017-11-10 08:42:54 +00006046requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006047run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006048 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006049 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006050 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006051 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006052 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006053
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006054run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006055 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6056 "$P_CLI request_size=16384 force_version=tls1_1 \
6057 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6058 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006059 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6060 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006061
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006062run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006063 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006064 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006065 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006066 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006067 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6068 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006069
Hanno Becker278fc7a2017-11-10 09:16:28 +00006070requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006071run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006072 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006073 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006074 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006075 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006076 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006077
Hanno Becker278fc7a2017-11-10 09:16:28 +00006078requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006079run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006080 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006081 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006082 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006083 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006084 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6085 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006086
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006087run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006088 "$P_SRV" \
6089 "$P_CLI request_size=16384 force_version=tls1_2 \
6090 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6091 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006092 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6093 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006094
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006095run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006096 "$P_SRV" \
6097 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6098 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6099 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006100 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006101
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006102run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006103 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006104 "$P_CLI request_size=16384 force_version=tls1_2 \
6105 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006106 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006107 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6108 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006109
Hanno Becker32c55012017-11-10 08:42:54 +00006110requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006111run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006112 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006113 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006114 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006115 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006116 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006117
Hanno Becker278fc7a2017-11-10 09:16:28 +00006118requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006119run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006120 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006121 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006122 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006123 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006124 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6125 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006126
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006127run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006128 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006129 "$P_CLI request_size=16384 force_version=tls1_2 \
6130 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6131 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006132 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6133 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006134
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006135run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006136 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006137 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006138 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6139 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006140 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006141
Hanno Becker32c55012017-11-10 08:42:54 +00006142requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006143run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006144 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006145 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006146 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006147 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006148 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006149
Hanno Becker278fc7a2017-11-10 09:16:28 +00006150requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006151run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006152 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006153 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006154 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006155 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006156 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6157 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006158
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006159run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006160 "$P_SRV" \
6161 "$P_CLI request_size=16384 force_version=tls1_2 \
6162 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6163 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006164 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6165 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006166
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006167run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006168 "$P_SRV" \
6169 "$P_CLI request_size=16384 force_version=tls1_2 \
6170 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6171 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006172 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6173 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006174
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006175# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006176requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6177run_test "Large server packet SSLv3 StreamCipher" \
6178 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6179 "$P_CLI force_version=ssl3 \
6180 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6181 0 \
6182 -c "Read from server: 16384 bytes read"
6183
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006184# Checking next 4 tests logs for 1n-1 split against BEAST too
6185requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6186run_test "Large server packet SSLv3 BlockCipher" \
6187 "$P_SRV response_size=16384 min_version=ssl3" \
6188 "$P_CLI force_version=ssl3 recsplit=0 \
6189 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6190 0 \
6191 -c "Read from server: 1 bytes read"\
6192 -c "16383 bytes read"\
6193 -C "Read from server: 16384 bytes read"
6194
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006195run_test "Large server packet TLS 1.0 BlockCipher" \
6196 "$P_SRV response_size=16384" \
6197 "$P_CLI force_version=tls1 recsplit=0 \
6198 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6199 0 \
6200 -c "Read from server: 1 bytes read"\
6201 -c "16383 bytes read"\
6202 -C "Read from server: 16384 bytes read"
6203
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006204run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6205 "$P_SRV response_size=16384" \
6206 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6207 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6208 0 \
6209 -c "Read from server: 1 bytes read"\
6210 -c "16383 bytes read"\
6211 -C "Read from server: 16384 bytes read"
6212
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006213requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6214run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6215 "$P_SRV response_size=16384" \
6216 "$P_CLI force_version=tls1 recsplit=0 \
6217 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6218 trunc_hmac=1" \
6219 0 \
6220 -c "Read from server: 1 bytes read"\
6221 -c "16383 bytes read"\
6222 -C "Read from server: 16384 bytes read"
6223
6224requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6225run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6226 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6227 "$P_CLI force_version=tls1 \
6228 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6229 trunc_hmac=1" \
6230 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006231 -s "16384 bytes written in 1 fragments" \
6232 -c "Read from server: 16384 bytes read"
6233
6234run_test "Large server packet TLS 1.0 StreamCipher" \
6235 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6236 "$P_CLI force_version=tls1 \
6237 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6238 0 \
6239 -s "16384 bytes written in 1 fragments" \
6240 -c "Read from server: 16384 bytes read"
6241
6242run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6243 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6244 "$P_CLI force_version=tls1 \
6245 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6246 0 \
6247 -s "16384 bytes written in 1 fragments" \
6248 -c "Read from server: 16384 bytes read"
6249
6250requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6251run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6252 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6253 "$P_CLI force_version=tls1 \
6254 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6255 0 \
6256 -s "16384 bytes written in 1 fragments" \
6257 -c "Read from server: 16384 bytes read"
6258
6259requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6260run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6261 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6262 "$P_CLI force_version=tls1 \
6263 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6264 0 \
6265 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006266 -c "Read from server: 16384 bytes read"
6267
6268run_test "Large server packet TLS 1.1 BlockCipher" \
6269 "$P_SRV response_size=16384" \
6270 "$P_CLI force_version=tls1_1 \
6271 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6272 0 \
6273 -c "Read from server: 16384 bytes read"
6274
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006275run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6276 "$P_SRV response_size=16384" \
6277 "$P_CLI force_version=tls1_1 etm=0 \
6278 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006279 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006280 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006281 -c "Read from server: 16384 bytes read"
6282
6283requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6284run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6285 "$P_SRV response_size=16384" \
6286 "$P_CLI force_version=tls1_1 \
6287 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6288 trunc_hmac=1" \
6289 0 \
6290 -c "Read from server: 16384 bytes read"
6291
6292requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006293run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6294 "$P_SRV response_size=16384 trunc_hmac=1" \
6295 "$P_CLI force_version=tls1_1 \
6296 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6297 0 \
6298 -s "16384 bytes written in 1 fragments" \
6299 -c "Read from server: 16384 bytes read"
6300
6301run_test "Large server packet TLS 1.1 StreamCipher" \
6302 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6303 "$P_CLI force_version=tls1_1 \
6304 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6305 0 \
6306 -c "Read from server: 16384 bytes read"
6307
6308run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6309 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6310 "$P_CLI force_version=tls1_1 \
6311 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6312 0 \
6313 -s "16384 bytes written in 1 fragments" \
6314 -c "Read from server: 16384 bytes read"
6315
6316requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006317run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6318 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6319 "$P_CLI force_version=tls1_1 \
6320 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6321 trunc_hmac=1" \
6322 0 \
6323 -c "Read from server: 16384 bytes read"
6324
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006325run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6326 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6327 "$P_CLI force_version=tls1_1 \
6328 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6329 0 \
6330 -s "16384 bytes written in 1 fragments" \
6331 -c "Read from server: 16384 bytes read"
6332
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006333run_test "Large server packet TLS 1.2 BlockCipher" \
6334 "$P_SRV response_size=16384" \
6335 "$P_CLI force_version=tls1_2 \
6336 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6337 0 \
6338 -c "Read from server: 16384 bytes read"
6339
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006340run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6341 "$P_SRV response_size=16384" \
6342 "$P_CLI force_version=tls1_2 etm=0 \
6343 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6344 0 \
6345 -s "16384 bytes written in 1 fragments" \
6346 -c "Read from server: 16384 bytes read"
6347
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006348run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6349 "$P_SRV response_size=16384" \
6350 "$P_CLI force_version=tls1_2 \
6351 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6352 0 \
6353 -c "Read from server: 16384 bytes read"
6354
6355requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6356run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6357 "$P_SRV response_size=16384" \
6358 "$P_CLI force_version=tls1_2 \
6359 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6360 trunc_hmac=1" \
6361 0 \
6362 -c "Read from server: 16384 bytes read"
6363
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006364run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6365 "$P_SRV response_size=16384 trunc_hmac=1" \
6366 "$P_CLI force_version=tls1_2 \
6367 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6368 0 \
6369 -s "16384 bytes written in 1 fragments" \
6370 -c "Read from server: 16384 bytes read"
6371
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006372run_test "Large server packet TLS 1.2 StreamCipher" \
6373 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6374 "$P_CLI force_version=tls1_2 \
6375 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6376 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006377 -s "16384 bytes written in 1 fragments" \
6378 -c "Read from server: 16384 bytes read"
6379
6380run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6381 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6382 "$P_CLI force_version=tls1_2 \
6383 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6384 0 \
6385 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006386 -c "Read from server: 16384 bytes read"
6387
6388requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6389run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6390 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6391 "$P_CLI force_version=tls1_2 \
6392 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6393 trunc_hmac=1" \
6394 0 \
6395 -c "Read from server: 16384 bytes read"
6396
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006397requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6398run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6399 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6400 "$P_CLI force_version=tls1_2 \
6401 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6402 0 \
6403 -s "16384 bytes written in 1 fragments" \
6404 -c "Read from server: 16384 bytes read"
6405
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006406run_test "Large server packet TLS 1.2 AEAD" \
6407 "$P_SRV response_size=16384" \
6408 "$P_CLI force_version=tls1_2 \
6409 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6410 0 \
6411 -c "Read from server: 16384 bytes read"
6412
6413run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6414 "$P_SRV response_size=16384" \
6415 "$P_CLI force_version=tls1_2 \
6416 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6417 0 \
6418 -c "Read from server: 16384 bytes read"
6419
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006420# Tests for restartable ECC
6421
6422requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6423run_test "EC restart: TLS, default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006424 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006425 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006426 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006427 debug_level=1" \
6428 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006429 -C "x509_verify_cert.*4b00" \
6430 -C "mbedtls_pk_verify.*4b00" \
6431 -C "mbedtls_ecdh_make_public.*4b00" \
6432 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006433
6434requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6435run_test "EC restart: TLS, max_ops=0" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006436 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006437 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006438 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006439 debug_level=1 ec_max_ops=0" \
6440 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006441 -C "x509_verify_cert.*4b00" \
6442 -C "mbedtls_pk_verify.*4b00" \
6443 -C "mbedtls_ecdh_make_public.*4b00" \
6444 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006445
6446requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6447run_test "EC restart: TLS, max_ops=65535" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006448 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006449 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006450 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006451 debug_level=1 ec_max_ops=65535" \
6452 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006453 -C "x509_verify_cert.*4b00" \
6454 -C "mbedtls_pk_verify.*4b00" \
6455 -C "mbedtls_ecdh_make_public.*4b00" \
6456 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006457
6458requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6459run_test "EC restart: TLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006460 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006461 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006462 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006463 debug_level=1 ec_max_ops=1000" \
6464 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006465 -c "x509_verify_cert.*4b00" \
6466 -c "mbedtls_pk_verify.*4b00" \
6467 -c "mbedtls_ecdh_make_public.*4b00" \
6468 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006469
6470requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Hanno Becker4a156fc2019-06-14 17:07:06 +01006471requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006472run_test "EC restart: TLS, max_ops=1000, badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006473 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006474 crt_file=data_files/server5-badsign.crt \
6475 key_file=data_files/server5.key" \
6476 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker03d77462019-08-27 16:24:56 +01006477 key_file=data_files/server5.key crt_file=data_files/server5.crt ca_file=data_files/test-ca2.crt \
6478 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6479 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006480 -c "x509_verify_cert.*4b00" \
Hanno Becker03d77462019-08-27 16:24:56 +01006481 -c "mbedtls_pk_verify.*4b00" \
6482 -c "mbedtls_ecdh_make_public.*4b00" \
6483 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006484 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006485
Hanno Becker4a156fc2019-06-14 17:07:06 +01006486requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006487requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6488run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006489 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006490 crt_file=data_files/server5-badsign.crt \
6491 key_file=data_files/server5.key" \
6492 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6493 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006494 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006495 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6496 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006497 -c "x509_verify_cert.*4b00" \
6498 -c "mbedtls_pk_verify.*4b00" \
6499 -c "mbedtls_ecdh_make_public.*4b00" \
6500 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006501 -c "! The certificate is not correctly signed by the trusted CA" \
6502 -C "! mbedtls_ssl_handshake returned" \
6503 -C "X509 - Certificate verification failed"
6504
Hanno Becker4a156fc2019-06-14 17:07:06 +01006505requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006506requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006507requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6508run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006509 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006510 crt_file=data_files/server5-badsign.crt \
6511 key_file=data_files/server5.key" \
6512 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006513 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006514 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6515 debug_level=1 ec_max_ops=1000 auth_mode=none" \
6516 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006517 -C "x509_verify_cert.*4b00" \
6518 -c "mbedtls_pk_verify.*4b00" \
6519 -c "mbedtls_ecdh_make_public.*4b00" \
6520 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006521 -C "! The certificate is not correctly signed by the trusted CA" \
6522 -C "! mbedtls_ssl_handshake returned" \
6523 -C "X509 - Certificate verification failed"
6524
6525requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006526run_test "EC restart: DTLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006527 "$P_SRV auth_mode=required dtls=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006528 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006529 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006530 dtls=1 debug_level=1 ec_max_ops=1000" \
6531 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006532 -c "x509_verify_cert.*4b00" \
6533 -c "mbedtls_pk_verify.*4b00" \
6534 -c "mbedtls_ecdh_make_public.*4b00" \
6535 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006536
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006537requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6538run_test "EC restart: TLS, max_ops=1000 no client auth" \
6539 "$P_SRV" \
6540 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6541 debug_level=1 ec_max_ops=1000" \
6542 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006543 -c "x509_verify_cert.*4b00" \
6544 -c "mbedtls_pk_verify.*4b00" \
6545 -c "mbedtls_ecdh_make_public.*4b00" \
6546 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006547
6548requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6549run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6550 "$P_SRV psk=abc123" \
6551 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6552 psk=abc123 debug_level=1 ec_max_ops=1000" \
6553 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006554 -C "x509_verify_cert.*4b00" \
6555 -C "mbedtls_pk_verify.*4b00" \
6556 -C "mbedtls_ecdh_make_public.*4b00" \
6557 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006558
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006559# Tests of asynchronous private key support in SSL
6560
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006561requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006562run_test "SSL async private: sign, delay=0" \
6563 "$P_SRV \
6564 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006565 "$P_CLI" \
6566 0 \
6567 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006568 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006569
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006570requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006571run_test "SSL async private: sign, delay=1" \
6572 "$P_SRV \
6573 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006574 "$P_CLI" \
6575 0 \
6576 -s "Async sign callback: using key slot " \
6577 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006578 -s "Async resume (slot [0-9]): sign done, status=0"
6579
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006580requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6581run_test "SSL async private: sign, delay=2" \
6582 "$P_SRV \
6583 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6584 "$P_CLI" \
6585 0 \
6586 -s "Async sign callback: using key slot " \
6587 -U "Async sign callback: using key slot " \
6588 -s "Async resume (slot [0-9]): call 1 more times." \
6589 -s "Async resume (slot [0-9]): call 0 more times." \
6590 -s "Async resume (slot [0-9]): sign done, status=0"
6591
Gilles Peskined3268832018-04-26 06:23:59 +02006592# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
6593# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
6594requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6595requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6596run_test "SSL async private: sign, RSA, TLS 1.1" \
6597 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
6598 async_operations=s async_private_delay1=0 async_private_delay2=0" \
6599 "$P_CLI force_version=tls1_1" \
6600 0 \
6601 -s "Async sign callback: using key slot " \
6602 -s "Async resume (slot [0-9]): sign done, status=0"
6603
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006604requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerb2c63832019-06-17 08:35:16 +01006605requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03006606requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006607requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskine807d74a2018-04-30 10:30:49 +02006608run_test "SSL async private: sign, SNI" \
6609 "$P_SRV debug_level=3 \
6610 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6611 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6612 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6613 "$P_CLI server_name=polarssl.example" \
6614 0 \
6615 -s "Async sign callback: using key slot " \
6616 -s "Async resume (slot [0-9]): sign done, status=0" \
6617 -s "parse ServerName extension" \
6618 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6619 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6620
6621requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006622run_test "SSL async private: decrypt, delay=0" \
6623 "$P_SRV \
6624 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6625 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6626 0 \
6627 -s "Async decrypt callback: using key slot " \
6628 -s "Async resume (slot [0-9]): decrypt done, status=0"
6629
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006630requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006631run_test "SSL async private: decrypt, delay=1" \
6632 "$P_SRV \
6633 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6634 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6635 0 \
6636 -s "Async decrypt callback: using key slot " \
6637 -s "Async resume (slot [0-9]): call 0 more times." \
6638 -s "Async resume (slot [0-9]): decrypt done, status=0"
6639
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006640requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006641run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6642 "$P_SRV psk=abc123 \
6643 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6644 "$P_CLI psk=abc123 \
6645 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6646 0 \
6647 -s "Async decrypt callback: using key slot " \
6648 -s "Async resume (slot [0-9]): decrypt done, status=0"
6649
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006650requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006651run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6652 "$P_SRV psk=abc123 \
6653 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6654 "$P_CLI psk=abc123 \
6655 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6656 0 \
6657 -s "Async decrypt callback: using key slot " \
6658 -s "Async resume (slot [0-9]): call 0 more times." \
6659 -s "Async resume (slot [0-9]): decrypt done, status=0"
6660
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006661requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006662run_test "SSL async private: sign callback not present" \
6663 "$P_SRV \
6664 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6665 "$P_CLI; [ \$? -eq 1 ] &&
6666 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6667 0 \
6668 -S "Async sign callback" \
6669 -s "! mbedtls_ssl_handshake returned" \
6670 -s "The own private key or pre-shared key is not set, but needed" \
6671 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6672 -s "Successful connection"
6673
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006674requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006675run_test "SSL async private: decrypt callback not present" \
6676 "$P_SRV debug_level=1 \
6677 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6678 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6679 [ \$? -eq 1 ] && $P_CLI" \
6680 0 \
6681 -S "Async decrypt callback" \
6682 -s "! mbedtls_ssl_handshake returned" \
6683 -s "got no RSA private key" \
6684 -s "Async resume (slot [0-9]): sign done, status=0" \
6685 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006686
6687# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006688requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006689run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006690 "$P_SRV \
6691 async_operations=s async_private_delay1=1 \
6692 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6693 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006694 "$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 +01006695 0 \
6696 -s "Async sign callback: using key slot 0," \
6697 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006698 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006699
6700# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006701requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006702run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006703 "$P_SRV \
6704 async_operations=s async_private_delay2=1 \
6705 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6706 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006707 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6708 0 \
6709 -s "Async sign callback: using key slot 0," \
6710 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006711 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006712
6713# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006714requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006715run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006716 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006717 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006718 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6719 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006720 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6721 0 \
6722 -s "Async sign callback: using key slot 1," \
6723 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006724 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006725
6726# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006727requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006728run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006729 "$P_SRV \
6730 async_operations=s async_private_delay1=1 \
6731 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6732 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006733 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6734 0 \
6735 -s "Async sign callback: no key matches this certificate."
6736
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006737requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006738run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006739 "$P_SRV \
6740 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6741 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006742 "$P_CLI" \
6743 1 \
6744 -s "Async sign callback: injected error" \
6745 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006746 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006747 -s "! mbedtls_ssl_handshake returned"
6748
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006749requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006750run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006751 "$P_SRV \
6752 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6753 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006754 "$P_CLI" \
6755 1 \
6756 -s "Async sign callback: using key slot " \
6757 -S "Async resume" \
6758 -s "Async cancel"
6759
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006760requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006761run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006762 "$P_SRV \
6763 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6764 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006765 "$P_CLI" \
6766 1 \
6767 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006768 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006769 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006770 -s "! mbedtls_ssl_handshake returned"
6771
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006772requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006773run_test "SSL async private: decrypt, error in start" \
6774 "$P_SRV \
6775 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6776 async_private_error=1" \
6777 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6778 1 \
6779 -s "Async decrypt callback: injected error" \
6780 -S "Async resume" \
6781 -S "Async cancel" \
6782 -s "! mbedtls_ssl_handshake returned"
6783
6784requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6785run_test "SSL async private: decrypt, cancel after start" \
6786 "$P_SRV \
6787 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6788 async_private_error=2" \
6789 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6790 1 \
6791 -s "Async decrypt callback: using key slot " \
6792 -S "Async resume" \
6793 -s "Async cancel"
6794
6795requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6796run_test "SSL async private: decrypt, error in resume" \
6797 "$P_SRV \
6798 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6799 async_private_error=3" \
6800 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6801 1 \
6802 -s "Async decrypt callback: using key slot " \
6803 -s "Async resume callback: decrypt done but injected error" \
6804 -S "Async cancel" \
6805 -s "! mbedtls_ssl_handshake returned"
6806
6807requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006808run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006809 "$P_SRV \
6810 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6811 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006812 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6813 0 \
6814 -s "Async cancel" \
6815 -s "! mbedtls_ssl_handshake returned" \
6816 -s "Async resume" \
6817 -s "Successful connection"
6818
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006819requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006820run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006821 "$P_SRV \
6822 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6823 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006824 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6825 0 \
6826 -s "! mbedtls_ssl_handshake returned" \
6827 -s "Async resume" \
6828 -s "Successful connection"
6829
6830# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006831requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006832run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006833 "$P_SRV \
6834 async_operations=s async_private_delay1=1 async_private_error=-2 \
6835 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6836 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006837 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6838 [ \$? -eq 1 ] &&
6839 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6840 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006841 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006842 -S "Async resume" \
6843 -s "Async cancel" \
6844 -s "! mbedtls_ssl_handshake returned" \
6845 -s "Async sign callback: no key matches this certificate." \
6846 -s "Successful connection"
6847
6848# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006849requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006850run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006851 "$P_SRV \
6852 async_operations=s async_private_delay1=1 async_private_error=-3 \
6853 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6854 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006855 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6856 [ \$? -eq 1 ] &&
6857 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6858 0 \
6859 -s "Async resume" \
6860 -s "! mbedtls_ssl_handshake returned" \
6861 -s "Async sign callback: no key matches this certificate." \
6862 -s "Successful connection"
6863
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006864requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006865requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006866run_test "SSL async private: renegotiation: client-initiated; sign" \
6867 "$P_SRV \
6868 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006869 exchanges=2 renegotiation=1" \
6870 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6871 0 \
6872 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006873 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006874
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006875requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006876requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006877run_test "SSL async private: renegotiation: server-initiated; sign" \
6878 "$P_SRV \
6879 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006880 exchanges=2 renegotiation=1 renegotiate=1" \
6881 "$P_CLI exchanges=2 renegotiation=1" \
6882 0 \
6883 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006884 -s "Async resume (slot [0-9]): sign done, status=0"
6885
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006886requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006887requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6888run_test "SSL async private: renegotiation: client-initiated; decrypt" \
6889 "$P_SRV \
6890 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6891 exchanges=2 renegotiation=1" \
6892 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6893 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6894 0 \
6895 -s "Async decrypt callback: using key slot " \
6896 -s "Async resume (slot [0-9]): decrypt done, status=0"
6897
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006898requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006899requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6900run_test "SSL async private: renegotiation: server-initiated; decrypt" \
6901 "$P_SRV \
6902 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6903 exchanges=2 renegotiation=1 renegotiate=1" \
6904 "$P_CLI exchanges=2 renegotiation=1 \
6905 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6906 0 \
6907 -s "Async decrypt callback: using key slot " \
6908 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006909
Ron Eldor58093c82018-06-28 13:22:05 +03006910# Tests for ECC extensions (rfc 4492)
6911
Ron Eldor643df7c2018-06-28 16:17:00 +03006912requires_config_enabled MBEDTLS_AES_C
6913requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6914requires_config_enabled MBEDTLS_SHA256_C
6915requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006916run_test "Force a non ECC ciphersuite in the client side" \
6917 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006918 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006919 0 \
6920 -C "client hello, adding supported_elliptic_curves extension" \
6921 -C "client hello, adding supported_point_formats extension" \
6922 -S "found supported elliptic curves extension" \
6923 -S "found supported point formats extension"
6924
Ron Eldor643df7c2018-06-28 16:17:00 +03006925requires_config_enabled MBEDTLS_AES_C
6926requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6927requires_config_enabled MBEDTLS_SHA256_C
6928requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006929run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006930 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006931 "$P_CLI debug_level=3" \
6932 0 \
6933 -C "found supported_point_formats extension" \
6934 -S "server hello, supported_point_formats extension"
6935
Ron Eldor643df7c2018-06-28 16:17:00 +03006936requires_config_enabled MBEDTLS_AES_C
6937requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6938requires_config_enabled MBEDTLS_SHA256_C
6939requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006940run_test "Force an ECC ciphersuite in the client side" \
6941 "$P_SRV debug_level=3" \
6942 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6943 0 \
6944 -c "client hello, adding supported_elliptic_curves extension" \
6945 -c "client hello, adding supported_point_formats extension" \
6946 -s "found supported elliptic curves extension" \
6947 -s "found supported point formats extension"
6948
Ron Eldor643df7c2018-06-28 16:17:00 +03006949requires_config_enabled MBEDTLS_AES_C
6950requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6951requires_config_enabled MBEDTLS_SHA256_C
6952requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006953run_test "Force an ECC ciphersuite in the server side" \
6954 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6955 "$P_CLI debug_level=3" \
6956 0 \
6957 -c "found supported_point_formats extension" \
6958 -s "server hello, supported_point_formats extension"
6959
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006960# Tests for DTLS HelloVerifyRequest
6961
6962run_test "DTLS cookie: enabled" \
6963 "$P_SRV dtls=1 debug_level=2" \
6964 "$P_CLI dtls=1 debug_level=2" \
6965 0 \
6966 -s "cookie verification failed" \
6967 -s "cookie verification passed" \
6968 -S "cookie verification skipped" \
6969 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006970 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006971 -S "SSL - The requested feature is not available"
6972
6973run_test "DTLS cookie: disabled" \
6974 "$P_SRV dtls=1 debug_level=2 cookies=0" \
6975 "$P_CLI dtls=1 debug_level=2" \
6976 0 \
6977 -S "cookie verification failed" \
6978 -S "cookie verification passed" \
6979 -s "cookie verification skipped" \
6980 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006981 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006982 -S "SSL - The requested feature is not available"
6983
Jarno Lamsa33281d52019-10-18 10:54:35 +03006984requires_config_enabled MBEDTLS_ERROR_C
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006985run_test "DTLS cookie: default (failing)" \
6986 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
6987 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
6988 1 \
6989 -s "cookie verification failed" \
6990 -S "cookie verification passed" \
6991 -S "cookie verification skipped" \
6992 -C "received hello verify request" \
6993 -S "hello verification requested" \
6994 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006995
6996requires_ipv6
6997run_test "DTLS cookie: enabled, IPv6" \
6998 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
6999 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
7000 0 \
7001 -s "cookie verification failed" \
7002 -s "cookie verification passed" \
7003 -S "cookie verification skipped" \
7004 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007005 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007006 -S "SSL - The requested feature is not available"
7007
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007008run_test "DTLS cookie: enabled, nbio" \
7009 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7010 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7011 0 \
7012 -s "cookie verification failed" \
7013 -s "cookie verification passed" \
7014 -S "cookie verification skipped" \
7015 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007016 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007017 -S "SSL - The requested feature is not available"
7018
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007019# Tests for client reconnecting from the same port with DTLS
7020
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007021not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007022requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007023run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007024 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7025 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007026 0 \
7027 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007028 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007029 -S "Client initiated reconnection from same port"
7030
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007031not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007032requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007033run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007034 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7035 "$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 +02007036 0 \
7037 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007038 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007039 -s "Client initiated reconnection from same port"
7040
Paul Bakker362689d2016-05-13 10:33:25 +01007041not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
Jarno Lamsa33281d52019-10-18 10:54:35 +03007042requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007043run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007044 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7045 "$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 +02007046 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007047 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007048 -s "Client initiated reconnection from same port"
7049
Paul Bakker362689d2016-05-13 10:33:25 +01007050only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
Jarno Lamsa33281d52019-10-18 10:54:35 +03007051requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007052run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7053 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7054 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7055 0 \
7056 -S "The operation timed out" \
7057 -s "Client initiated reconnection from same port"
7058
Jarno Lamsa33281d52019-10-18 10:54:35 +03007059requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007060run_test "DTLS client reconnect from same port: no cookies" \
7061 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007062 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7063 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007064 -s "The operation timed out" \
7065 -S "Client initiated reconnection from same port"
7066
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007067# Tests for various cases of client authentication with DTLS
7068# (focused on handshake flows and message parsing)
7069
7070run_test "DTLS client auth: required" \
7071 "$P_SRV dtls=1 auth_mode=required" \
7072 "$P_CLI dtls=1" \
7073 0 \
7074 -s "Verifying peer X.509 certificate... ok"
7075
Hanno Becker4a156fc2019-06-14 17:07:06 +01007076requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007077requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007078run_test "DTLS client auth: optional, client has no cert" \
7079 "$P_SRV dtls=1 auth_mode=optional" \
7080 "$P_CLI dtls=1 crt_file=none key_file=none" \
7081 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007082 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007083
Hanno Becker4a156fc2019-06-14 17:07:06 +01007084requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007085requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007086run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007087 "$P_SRV dtls=1 auth_mode=none" \
7088 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7089 0 \
7090 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007091 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007092
Jarno Lamsa33281d52019-10-18 10:54:35 +03007093requires_ciphersuite_enabled TLS-PSK-WITH-AES-128-GCM-SHA256
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007094run_test "DTLS wrong PSK: badmac alert" \
7095 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7096 "$P_CLI dtls=1 psk=abc124" \
7097 1 \
7098 -s "SSL - Verification of the message MAC failed" \
7099 -c "SSL - A fatal alert message was received from our peer"
7100
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007101# Tests for receiving fragmented handshake messages with DTLS
7102
7103requires_gnutls
7104run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7105 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007106 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007107 0 \
7108 -C "found fragmented DTLS handshake message" \
7109 -C "error"
7110
7111requires_gnutls
7112run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7113 "$G_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007114 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007115 0 \
7116 -c "found fragmented DTLS handshake message" \
7117 -C "error"
7118
7119requires_gnutls
7120run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7121 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007122 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007123 0 \
7124 -c "found fragmented DTLS handshake message" \
7125 -C "error"
7126
7127requires_gnutls
7128run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7129 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007130 "$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 +02007131 0 \
7132 -c "found fragmented DTLS handshake message" \
7133 -C "error"
7134
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007135requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007136requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007137run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7138 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007139 "$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 +02007140 0 \
7141 -c "found fragmented DTLS handshake message" \
7142 -c "client hello, adding renegotiation extension" \
7143 -c "found renegotiation extension" \
7144 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007145 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007146 -C "error" \
7147 -s "Extra-header:"
7148
7149requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007150requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007151run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7152 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007153 "$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 +02007154 0 \
7155 -c "found fragmented DTLS handshake message" \
7156 -c "client hello, adding renegotiation extension" \
7157 -c "found renegotiation extension" \
7158 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007159 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007160 -C "error" \
7161 -s "Extra-header:"
7162
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007163run_test "DTLS reassembly: no fragmentation (openssl server)" \
7164 "$O_SRV -dtls1 -mtu 2048" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007165 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007166 0 \
7167 -C "found fragmented DTLS handshake message" \
7168 -C "error"
7169
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007170run_test "DTLS reassembly: some fragmentation (openssl server)" \
7171 "$O_SRV -dtls1 -mtu 768" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007172 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007173 0 \
7174 -c "found fragmented DTLS handshake message" \
7175 -C "error"
7176
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007177run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007178 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007179 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007180 0 \
7181 -c "found fragmented DTLS handshake message" \
7182 -C "error"
7183
7184run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7185 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007186 "$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 +02007187 0 \
7188 -c "found fragmented DTLS handshake message" \
7189 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007190
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007191# Tests for sending fragmented handshake messages with DTLS
7192#
7193# Use client auth when we need the client to send large messages,
7194# and use large cert chains on both sides too (the long chains we have all use
7195# both RSA and ECDSA, but ideally we should have long chains with either).
7196# Sizes reached (UDP payload):
7197# - 2037B for server certificate
7198# - 1542B for client certificate
7199# - 1013B for newsessionticket
7200# - all others below 512B
7201# All those tests assume MAX_CONTENT_LEN is at least 2048
7202
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007203requires_config_enabled MBEDTLS_RSA_C
7204requires_config_enabled MBEDTLS_ECDSA_C
7205requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7206run_test "DTLS fragmenting: none (for reference)" \
7207 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7208 crt_file=data_files/server7_int-ca.crt \
7209 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007210 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007211 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007212 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007213 "$P_CLI dtls=1 debug_level=2 \
7214 crt_file=data_files/server8_int-ca2.crt \
7215 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007216 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007217 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007218 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007219 0 \
7220 -S "found fragmented DTLS handshake message" \
7221 -C "found fragmented DTLS handshake message" \
7222 -C "error"
7223
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007224requires_config_enabled MBEDTLS_RSA_C
7225requires_config_enabled MBEDTLS_ECDSA_C
7226requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007227run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007228 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7229 crt_file=data_files/server7_int-ca.crt \
7230 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007231 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007232 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007233 max_frag_len=1024" \
7234 "$P_CLI dtls=1 debug_level=2 \
7235 crt_file=data_files/server8_int-ca2.crt \
7236 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007237 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007238 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007239 max_frag_len=2048" \
7240 0 \
7241 -S "found fragmented DTLS handshake message" \
7242 -c "found fragmented DTLS handshake message" \
7243 -C "error"
7244
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007245# With the MFL extension, the server has no way of forcing
7246# the client to not exceed a certain MTU; hence, the following
7247# test can't be replicated with an MTU proxy such as the one
7248# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007249requires_config_enabled MBEDTLS_RSA_C
7250requires_config_enabled MBEDTLS_ECDSA_C
7251requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007252run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007253 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7254 crt_file=data_files/server7_int-ca.crt \
7255 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007256 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007257 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007258 max_frag_len=512" \
7259 "$P_CLI dtls=1 debug_level=2 \
7260 crt_file=data_files/server8_int-ca2.crt \
7261 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007262 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007263 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007264 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007265 0 \
7266 -S "found fragmented DTLS handshake message" \
7267 -c "found fragmented DTLS handshake message" \
7268 -C "error"
7269
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007270requires_config_enabled MBEDTLS_RSA_C
7271requires_config_enabled MBEDTLS_ECDSA_C
7272requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007273run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007274 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7275 crt_file=data_files/server7_int-ca.crt \
7276 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007277 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007278 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007279 max_frag_len=2048" \
7280 "$P_CLI dtls=1 debug_level=2 \
7281 crt_file=data_files/server8_int-ca2.crt \
7282 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007283 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007284 hs_timeout=2500-60000 \
7285 max_frag_len=1024" \
7286 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007287 -S "found fragmented DTLS handshake message" \
7288 -c "found fragmented DTLS handshake message" \
7289 -C "error"
7290
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007291# While not required by the standard defining the MFL extension
7292# (according to which it only applies to records, not to datagrams),
7293# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7294# as otherwise there wouldn't be any means to communicate MTU restrictions
7295# to the peer.
7296# The next test checks that no datagrams significantly larger than the
7297# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007298requires_config_enabled MBEDTLS_RSA_C
7299requires_config_enabled MBEDTLS_ECDSA_C
7300requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7301run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007302 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007303 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7304 crt_file=data_files/server7_int-ca.crt \
7305 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007306 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007307 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007308 max_frag_len=2048" \
7309 "$P_CLI dtls=1 debug_level=2 \
7310 crt_file=data_files/server8_int-ca2.crt \
7311 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007312 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007313 hs_timeout=2500-60000 \
7314 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007315 0 \
7316 -S "found fragmented DTLS handshake message" \
7317 -c "found fragmented DTLS handshake message" \
7318 -C "error"
7319
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007320requires_config_enabled MBEDTLS_RSA_C
7321requires_config_enabled MBEDTLS_ECDSA_C
7322requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007323run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007324 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7325 crt_file=data_files/server7_int-ca.crt \
7326 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007327 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007328 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007329 max_frag_len=2048" \
7330 "$P_CLI dtls=1 debug_level=2 \
7331 crt_file=data_files/server8_int-ca2.crt \
7332 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007333 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007334 hs_timeout=2500-60000 \
7335 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007336 0 \
7337 -s "found fragmented DTLS handshake message" \
7338 -c "found fragmented DTLS handshake message" \
7339 -C "error"
7340
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007341# While not required by the standard defining the MFL extension
7342# (according to which it only applies to records, not to datagrams),
7343# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7344# as otherwise there wouldn't be any means to communicate MTU restrictions
7345# to the peer.
7346# The next test checks that no datagrams significantly larger than the
7347# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007348requires_config_enabled MBEDTLS_RSA_C
7349requires_config_enabled MBEDTLS_ECDSA_C
7350requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7351run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007352 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007353 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7354 crt_file=data_files/server7_int-ca.crt \
7355 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007356 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007357 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007358 max_frag_len=2048" \
7359 "$P_CLI dtls=1 debug_level=2 \
7360 crt_file=data_files/server8_int-ca2.crt \
7361 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007362 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007363 hs_timeout=2500-60000 \
7364 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007365 0 \
7366 -s "found fragmented DTLS handshake message" \
7367 -c "found fragmented DTLS handshake message" \
7368 -C "error"
7369
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007370requires_config_enabled MBEDTLS_RSA_C
7371requires_config_enabled MBEDTLS_ECDSA_C
7372run_test "DTLS fragmenting: none (for reference) (MTU)" \
7373 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7374 crt_file=data_files/server7_int-ca.crt \
7375 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007376 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007377 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007378 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007379 "$P_CLI dtls=1 debug_level=2 \
7380 crt_file=data_files/server8_int-ca2.crt \
7381 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007382 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007383 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007384 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007385 0 \
7386 -S "found fragmented DTLS handshake message" \
7387 -C "found fragmented DTLS handshake message" \
7388 -C "error"
7389
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007390requires_config_enabled MBEDTLS_RSA_C
7391requires_config_enabled MBEDTLS_ECDSA_C
7392run_test "DTLS fragmenting: client (MTU)" \
7393 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7394 crt_file=data_files/server7_int-ca.crt \
7395 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007396 ca_file=data_files/test-ca.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007397 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007398 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007399 "$P_CLI dtls=1 debug_level=2 \
7400 crt_file=data_files/server8_int-ca2.crt \
7401 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007402 ca_file=data_files/test-ca2.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007403 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007404 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007405 0 \
7406 -s "found fragmented DTLS handshake message" \
7407 -C "found fragmented DTLS handshake message" \
7408 -C "error"
7409
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007410requires_config_enabled MBEDTLS_RSA_C
7411requires_config_enabled MBEDTLS_ECDSA_C
7412run_test "DTLS fragmenting: server (MTU)" \
7413 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7414 crt_file=data_files/server7_int-ca.crt \
7415 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007416 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007417 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007418 mtu=512" \
7419 "$P_CLI dtls=1 debug_level=2 \
7420 crt_file=data_files/server8_int-ca2.crt \
7421 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007422 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007423 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007424 mtu=2048" \
7425 0 \
7426 -S "found fragmented DTLS handshake message" \
7427 -c "found fragmented DTLS handshake message" \
7428 -C "error"
7429
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007430requires_config_enabled MBEDTLS_RSA_C
7431requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007432run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007433 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007434 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7435 crt_file=data_files/server7_int-ca.crt \
7436 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007437 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007438 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007439 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007440 "$P_CLI dtls=1 debug_level=2 \
7441 crt_file=data_files/server8_int-ca2.crt \
7442 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007443 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007444 hs_timeout=2500-60000 \
7445 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007446 0 \
7447 -s "found fragmented DTLS handshake message" \
7448 -c "found fragmented DTLS handshake message" \
7449 -C "error"
7450
Andrzej Kurek77826052018-10-11 07:34:08 -04007451# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007452requires_config_enabled MBEDTLS_RSA_C
7453requires_config_enabled MBEDTLS_ECDSA_C
7454requires_config_enabled MBEDTLS_SHA256_C
7455requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7456requires_config_enabled MBEDTLS_AES_C
7457requires_config_enabled MBEDTLS_GCM_C
7458run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007459 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007460 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7461 crt_file=data_files/server7_int-ca.crt \
7462 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007463 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007464 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007465 mtu=512" \
7466 "$P_CLI dtls=1 debug_level=2 \
7467 crt_file=data_files/server8_int-ca2.crt \
7468 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007469 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007470 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7471 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007472 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007473 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007474 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007475 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007476 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007477
Andrzej Kurek7311c782018-10-11 06:49:41 -04007478# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007479# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007480# The ratio of max/min timeout should ideally equal 4 to accept two
7481# retransmissions, but in some cases (like both the server and client using
7482# fragmentation and auto-reduction) an extra retransmission might occur,
7483# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007484not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007485requires_config_enabled MBEDTLS_RSA_C
7486requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007487requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7488requires_config_enabled MBEDTLS_AES_C
7489requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007490run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7491 -p "$P_PXY mtu=508" \
7492 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7493 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007494 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007495 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007496 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007497 "$P_CLI dtls=1 debug_level=2 \
7498 crt_file=data_files/server8_int-ca2.crt \
7499 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007500 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007501 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7502 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007503 0 \
7504 -s "found fragmented DTLS handshake message" \
7505 -c "found fragmented DTLS handshake message" \
7506 -C "error"
7507
Andrzej Kurek77826052018-10-11 07:34:08 -04007508# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007509only_with_valgrind
Hanno Becker108992e2018-08-29 17:04:18 +01007510requires_config_enabled MBEDTLS_RSA_C
7511requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007512requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7513requires_config_enabled MBEDTLS_AES_C
7514requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01007515run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7516 -p "$P_PXY mtu=508" \
7517 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7518 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007519 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007520 ca_file=data_files/test-ca.crt \
Hanno Becker108992e2018-08-29 17:04:18 +01007521 hs_timeout=250-10000" \
7522 "$P_CLI dtls=1 debug_level=2 \
7523 crt_file=data_files/server8_int-ca2.crt \
7524 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007525 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007526 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007527 hs_timeout=250-10000" \
7528 0 \
7529 -s "found fragmented DTLS handshake message" \
7530 -c "found fragmented DTLS handshake message" \
7531 -C "error"
7532
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007533# 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 +02007534# OTOH the client might resend if the server is to slow to reset after sending
7535# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007536not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007537requires_config_enabled MBEDTLS_RSA_C
7538requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007539run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007540 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007541 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7542 crt_file=data_files/server7_int-ca.crt \
7543 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007544 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007545 hs_timeout=10000-60000 \
7546 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007547 "$P_CLI dtls=1 debug_level=2 \
7548 crt_file=data_files/server8_int-ca2.crt \
7549 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007550 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007551 hs_timeout=10000-60000 \
7552 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007553 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007554 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007555 -s "found fragmented DTLS handshake message" \
7556 -c "found fragmented DTLS handshake message" \
7557 -C "error"
7558
Andrzej Kurek77826052018-10-11 07:34:08 -04007559# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007560# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7561# OTOH the client might resend if the server is to slow to reset after sending
7562# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007563not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007564requires_config_enabled MBEDTLS_RSA_C
7565requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007566requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7567requires_config_enabled MBEDTLS_AES_C
7568requires_config_enabled MBEDTLS_GCM_C
7569run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007570 -p "$P_PXY mtu=512" \
7571 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7572 crt_file=data_files/server7_int-ca.crt \
7573 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007574 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007575 hs_timeout=10000-60000 \
7576 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007577 "$P_CLI dtls=1 debug_level=2 \
7578 crt_file=data_files/server8_int-ca2.crt \
7579 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007580 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007581 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7582 hs_timeout=10000-60000 \
7583 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007584 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007585 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007586 -s "found fragmented DTLS handshake message" \
7587 -c "found fragmented DTLS handshake message" \
7588 -C "error"
7589
Andrzej Kurek7311c782018-10-11 06:49:41 -04007590not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007591requires_config_enabled MBEDTLS_RSA_C
7592requires_config_enabled MBEDTLS_ECDSA_C
7593run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007594 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007595 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7596 crt_file=data_files/server7_int-ca.crt \
7597 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007598 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007599 hs_timeout=10000-60000 \
7600 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007601 "$P_CLI dtls=1 debug_level=2 \
7602 crt_file=data_files/server8_int-ca2.crt \
7603 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007604 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007605 hs_timeout=10000-60000 \
7606 mtu=1024 nbio=2" \
7607 0 \
7608 -S "autoreduction" \
7609 -s "found fragmented DTLS handshake message" \
7610 -c "found fragmented DTLS handshake message" \
7611 -C "error"
7612
Andrzej Kurek77826052018-10-11 07:34:08 -04007613# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007614not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007615requires_config_enabled MBEDTLS_RSA_C
7616requires_config_enabled MBEDTLS_ECDSA_C
7617requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7618requires_config_enabled MBEDTLS_AES_C
7619requires_config_enabled MBEDTLS_GCM_C
7620run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7621 -p "$P_PXY mtu=512" \
7622 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7623 crt_file=data_files/server7_int-ca.crt \
7624 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007625 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007626 hs_timeout=10000-60000 \
7627 mtu=512 nbio=2" \
7628 "$P_CLI dtls=1 debug_level=2 \
7629 crt_file=data_files/server8_int-ca2.crt \
7630 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007631 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007632 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7633 hs_timeout=10000-60000 \
7634 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007635 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007636 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007637 -s "found fragmented DTLS handshake message" \
7638 -c "found fragmented DTLS handshake message" \
7639 -C "error"
7640
Andrzej Kurek77826052018-10-11 07:34:08 -04007641# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007642# This ensures things still work after session_reset().
7643# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007644# Since we don't support reading fragmented ClientHello yet,
7645# up the MTU to 1450 (larger than ClientHello with session ticket,
7646# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007647# An autoreduction on the client-side might happen if the server is
7648# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007649# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007650# resumed listening, which would result in a spurious autoreduction.
7651not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007652requires_config_enabled MBEDTLS_RSA_C
7653requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007654requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7655requires_config_enabled MBEDTLS_AES_C
7656requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007657run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7658 -p "$P_PXY mtu=1450" \
7659 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7660 crt_file=data_files/server7_int-ca.crt \
7661 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007662 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007663 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007664 mtu=1450" \
7665 "$P_CLI dtls=1 debug_level=2 \
7666 crt_file=data_files/server8_int-ca2.crt \
7667 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007668 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007669 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007670 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007671 mtu=1450 reconnect=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007672 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007673 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007674 -s "found fragmented DTLS handshake message" \
7675 -c "found fragmented DTLS handshake message" \
7676 -C "error"
7677
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007678# An autoreduction on the client-side might happen if the server is
7679# slow to reset, therefore omitting '-C "autoreduction"' below.
7680not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007681requires_config_enabled MBEDTLS_RSA_C
7682requires_config_enabled MBEDTLS_ECDSA_C
7683requires_config_enabled MBEDTLS_SHA256_C
7684requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7685requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7686requires_config_enabled MBEDTLS_CHACHAPOLY_C
7687run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7688 -p "$P_PXY mtu=512" \
7689 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7690 crt_file=data_files/server7_int-ca.crt \
7691 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007692 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007693 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007694 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007695 mtu=512" \
7696 "$P_CLI dtls=1 debug_level=2 \
7697 crt_file=data_files/server8_int-ca2.crt \
7698 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007699 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007700 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007701 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007702 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007703 mtu=512" \
7704 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007705 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007706 -s "found fragmented DTLS handshake message" \
7707 -c "found fragmented DTLS handshake message" \
7708 -C "error"
7709
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007710# An autoreduction on the client-side might happen if the server is
7711# slow to reset, therefore omitting '-C "autoreduction"' below.
7712not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007713requires_config_enabled MBEDTLS_RSA_C
7714requires_config_enabled MBEDTLS_ECDSA_C
7715requires_config_enabled MBEDTLS_SHA256_C
7716requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7717requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7718requires_config_enabled MBEDTLS_AES_C
7719requires_config_enabled MBEDTLS_GCM_C
7720run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7721 -p "$P_PXY mtu=512" \
7722 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7723 crt_file=data_files/server7_int-ca.crt \
7724 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007725 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007726 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007727 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007728 mtu=512" \
7729 "$P_CLI dtls=1 debug_level=2 \
7730 crt_file=data_files/server8_int-ca2.crt \
7731 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007732 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007733 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007734 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007735 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007736 mtu=512" \
7737 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007738 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007739 -s "found fragmented DTLS handshake message" \
7740 -c "found fragmented DTLS handshake message" \
7741 -C "error"
7742
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007743# An autoreduction on the client-side might happen if the server is
7744# slow to reset, therefore omitting '-C "autoreduction"' below.
7745not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007746requires_config_enabled MBEDTLS_RSA_C
7747requires_config_enabled MBEDTLS_ECDSA_C
7748requires_config_enabled MBEDTLS_SHA256_C
7749requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7750requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7751requires_config_enabled MBEDTLS_AES_C
7752requires_config_enabled MBEDTLS_CCM_C
7753run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007754 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007755 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7756 crt_file=data_files/server7_int-ca.crt \
7757 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007758 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007759 exchanges=2 renegotiation=1 \
7760 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007761 hs_timeout=10000-60000 \
7762 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007763 "$P_CLI dtls=1 debug_level=2 \
7764 crt_file=data_files/server8_int-ca2.crt \
7765 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007766 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007767 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007768 hs_timeout=10000-60000 \
7769 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007770 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007771 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007772 -s "found fragmented DTLS handshake message" \
7773 -c "found fragmented DTLS handshake message" \
7774 -C "error"
7775
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007776# An autoreduction on the client-side might happen if the server is
7777# slow to reset, therefore omitting '-C "autoreduction"' below.
7778not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007779requires_config_enabled MBEDTLS_RSA_C
7780requires_config_enabled MBEDTLS_ECDSA_C
7781requires_config_enabled MBEDTLS_SHA256_C
7782requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7783requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7784requires_config_enabled MBEDTLS_AES_C
7785requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7786requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7787run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007788 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007789 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7790 crt_file=data_files/server7_int-ca.crt \
7791 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007792 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007793 exchanges=2 renegotiation=1 \
7794 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007795 hs_timeout=10000-60000 \
7796 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007797 "$P_CLI dtls=1 debug_level=2 \
7798 crt_file=data_files/server8_int-ca2.crt \
7799 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007800 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007801 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007802 hs_timeout=10000-60000 \
7803 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007804 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007805 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007806 -s "found fragmented DTLS handshake message" \
7807 -c "found fragmented DTLS handshake message" \
7808 -C "error"
7809
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007810# An autoreduction on the client-side might happen if the server is
7811# slow to reset, therefore omitting '-C "autoreduction"' below.
7812not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007813requires_config_enabled MBEDTLS_RSA_C
7814requires_config_enabled MBEDTLS_ECDSA_C
7815requires_config_enabled MBEDTLS_SHA256_C
7816requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7817requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7818requires_config_enabled MBEDTLS_AES_C
7819requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7820run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007821 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007822 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7823 crt_file=data_files/server7_int-ca.crt \
7824 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007825 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007826 exchanges=2 renegotiation=1 \
7827 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007828 hs_timeout=10000-60000 \
7829 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007830 "$P_CLI dtls=1 debug_level=2 \
7831 crt_file=data_files/server8_int-ca2.crt \
7832 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007833 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007834 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007835 hs_timeout=10000-60000 \
7836 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007837 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007838 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007839 -s "found fragmented DTLS handshake message" \
7840 -c "found fragmented DTLS handshake message" \
7841 -C "error"
7842
Andrzej Kurek77826052018-10-11 07:34:08 -04007843# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007844requires_config_enabled MBEDTLS_RSA_C
7845requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007846requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7847requires_config_enabled MBEDTLS_AES_C
7848requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007849client_needs_more_time 2
7850run_test "DTLS fragmenting: proxy MTU + 3d" \
7851 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007852 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007853 crt_file=data_files/server7_int-ca.crt \
7854 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007855 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007856 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007857 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007858 crt_file=data_files/server8_int-ca2.crt \
7859 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007860 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007861 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007862 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007863 0 \
7864 -s "found fragmented DTLS handshake message" \
7865 -c "found fragmented DTLS handshake message" \
7866 -C "error"
7867
Andrzej Kurek77826052018-10-11 07:34:08 -04007868# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007869requires_config_enabled MBEDTLS_RSA_C
7870requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007871requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7872requires_config_enabled MBEDTLS_AES_C
7873requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007874client_needs_more_time 2
7875run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7876 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7877 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7878 crt_file=data_files/server7_int-ca.crt \
7879 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007880 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007881 hs_timeout=250-10000 mtu=512 nbio=2" \
7882 "$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 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007886 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007887 hs_timeout=250-10000 mtu=512 nbio=2" \
7888 0 \
7889 -s "found fragmented DTLS handshake message" \
7890 -c "found fragmented DTLS handshake message" \
7891 -C "error"
7892
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007893# interop tests for DTLS fragmentating with reliable connection
7894#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007895# here and below we just want to test that the we fragment in a way that
7896# pleases other implementations, so we don't need the peer to fragment
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007897requires_config_enabled MBEDTLS_RSA_C
7898requires_config_enabled MBEDTLS_ECDSA_C
7899requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007900requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007901run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7902 "$G_SRV -u" \
7903 "$P_CLI dtls=1 debug_level=2 \
7904 crt_file=data_files/server8_int-ca2.crt \
7905 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007906 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007907 mtu=512 force_version=dtls1_2" \
7908 0 \
7909 -c "fragmenting handshake message" \
7910 -C "error"
7911
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007912requires_config_enabled MBEDTLS_RSA_C
7913requires_config_enabled MBEDTLS_ECDSA_C
7914requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007915requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007916run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
7917 "$G_SRV -u" \
7918 "$P_CLI dtls=1 debug_level=2 \
7919 crt_file=data_files/server8_int-ca2.crt \
7920 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007921 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007922 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007923 0 \
7924 -c "fragmenting handshake message" \
7925 -C "error"
7926
Hanno Beckerb9a00862018-08-28 10:20:22 +01007927# We use --insecure for the GnuTLS client because it expects
7928# the hostname / IP it connects to to be the name used in the
7929# certificate obtained from the server. Here, however, it
7930# connects to 127.0.0.1 while our test certificates use 'localhost'
7931# as the server name in the certificate. This will make the
7932# certifiate validation fail, but passing --insecure makes
7933# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007934requires_config_enabled MBEDTLS_RSA_C
7935requires_config_enabled MBEDTLS_ECDSA_C
7936requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007937requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007938requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007939run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007940 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007941 crt_file=data_files/server7_int-ca.crt \
7942 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007943 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007944 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007945 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007946 0 \
7947 -s "fragmenting handshake message"
7948
Hanno Beckerb9a00862018-08-28 10:20:22 +01007949# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007950requires_config_enabled MBEDTLS_RSA_C
7951requires_config_enabled MBEDTLS_ECDSA_C
7952requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007953requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007954requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007955run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007956 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007957 crt_file=data_files/server7_int-ca.crt \
7958 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007959 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007960 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007961 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007962 0 \
7963 -s "fragmenting handshake message"
7964
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007965requires_config_enabled MBEDTLS_RSA_C
7966requires_config_enabled MBEDTLS_ECDSA_C
7967requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7968run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
7969 "$O_SRV -dtls1_2 -verify 10" \
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é-Gonnard1218bc02018-08-17 10:51:26 +02007974 mtu=512 force_version=dtls1_2" \
7975 0 \
7976 -c "fragmenting handshake message" \
7977 -C "error"
7978
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007979requires_config_enabled MBEDTLS_RSA_C
7980requires_config_enabled MBEDTLS_ECDSA_C
7981requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7982run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
7983 "$O_SRV -dtls1 -verify 10" \
7984 "$P_CLI dtls=1 debug_level=2 \
7985 crt_file=data_files/server8_int-ca2.crt \
7986 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007987 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007988 mtu=512 force_version=dtls1" \
7989 0 \
7990 -c "fragmenting handshake message" \
7991 -C "error"
7992
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007993requires_config_enabled MBEDTLS_RSA_C
7994requires_config_enabled MBEDTLS_ECDSA_C
7995requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7996run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
7997 "$P_SRV dtls=1 debug_level=2 \
7998 crt_file=data_files/server7_int-ca.crt \
7999 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008000 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008001 mtu=512 force_version=dtls1_2" \
8002 "$O_CLI -dtls1_2" \
8003 0 \
8004 -s "fragmenting handshake message"
8005
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008006requires_config_enabled MBEDTLS_RSA_C
8007requires_config_enabled MBEDTLS_ECDSA_C
8008requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8009run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8010 "$P_SRV dtls=1 debug_level=2 \
8011 crt_file=data_files/server7_int-ca.crt \
8012 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008013 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008014 mtu=512 force_version=dtls1" \
8015 "$O_CLI -dtls1" \
8016 0 \
8017 -s "fragmenting handshake message"
8018
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008019# interop tests for DTLS fragmentating with unreliable connection
8020#
8021# again we just want to test that the we fragment in a way that
8022# pleases other implementations, so we don't need the peer to fragment
8023requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008024requires_config_enabled MBEDTLS_RSA_C
8025requires_config_enabled MBEDTLS_ECDSA_C
8026requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008027client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008028run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8029 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8030 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008031 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008032 crt_file=data_files/server8_int-ca2.crt \
8033 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008034 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008035 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008036 0 \
8037 -c "fragmenting handshake message" \
8038 -C "error"
8039
8040requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008041requires_config_enabled MBEDTLS_RSA_C
8042requires_config_enabled MBEDTLS_ECDSA_C
8043requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008044client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008045run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8046 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8047 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008048 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008049 crt_file=data_files/server8_int-ca2.crt \
8050 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008051 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008052 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008053 0 \
8054 -c "fragmenting handshake message" \
8055 -C "error"
8056
k-stachowiakabb843e2019-02-18 16:14:03 +01008057requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008058requires_config_enabled MBEDTLS_RSA_C
8059requires_config_enabled MBEDTLS_ECDSA_C
8060requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8061client_needs_more_time 4
8062run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8063 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8064 "$P_SRV dtls=1 debug_level=2 \
8065 crt_file=data_files/server7_int-ca.crt \
8066 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008067 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008068 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008069 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008070 0 \
8071 -s "fragmenting handshake message"
8072
k-stachowiakabb843e2019-02-18 16:14:03 +01008073requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008074requires_config_enabled MBEDTLS_RSA_C
8075requires_config_enabled MBEDTLS_ECDSA_C
8076requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8077client_needs_more_time 4
8078run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8079 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8080 "$P_SRV dtls=1 debug_level=2 \
8081 crt_file=data_files/server7_int-ca.crt \
8082 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008083 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008084 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008085 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008086 0 \
8087 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008088
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008089## Interop test with OpenSSL might trigger a bug in recent versions (including
8090## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008091## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008092## They should be re-enabled once a fixed version of OpenSSL is available
8093## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008094skip_next_test
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008095requires_config_enabled MBEDTLS_RSA_C
8096requires_config_enabled MBEDTLS_ECDSA_C
8097requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8098client_needs_more_time 4
8099run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8100 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8101 "$O_SRV -dtls1_2 -verify 10" \
8102 "$P_CLI dtls=1 debug_level=2 \
8103 crt_file=data_files/server8_int-ca2.crt \
8104 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008105 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008106 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8107 0 \
8108 -c "fragmenting handshake message" \
8109 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008110
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008111skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008112requires_config_enabled MBEDTLS_RSA_C
8113requires_config_enabled MBEDTLS_ECDSA_C
8114requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008115client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008116run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8117 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008118 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008119 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008120 crt_file=data_files/server8_int-ca2.crt \
8121 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008122 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008123 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008124 0 \
8125 -c "fragmenting handshake message" \
8126 -C "error"
8127
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008128skip_next_test
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008129requires_config_enabled MBEDTLS_RSA_C
8130requires_config_enabled MBEDTLS_ECDSA_C
8131requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8132client_needs_more_time 4
8133run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8134 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8135 "$P_SRV dtls=1 debug_level=2 \
8136 crt_file=data_files/server7_int-ca.crt \
8137 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008138 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008139 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8140 "$O_CLI -dtls1_2" \
8141 0 \
8142 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008143
8144# -nbio is added to prevent s_client from blocking in case of duplicated
8145# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008146skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008147requires_config_enabled MBEDTLS_RSA_C
8148requires_config_enabled MBEDTLS_ECDSA_C
8149requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008150client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008151run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8152 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008153 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008154 crt_file=data_files/server7_int-ca.crt \
8155 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008156 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008157 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008158 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008159 0 \
8160 -s "fragmenting handshake message"
8161
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008162# Tests for specific things with "unreliable" UDP connection
8163
8164not_with_valgrind # spurious resend due to timeout
8165run_test "DTLS proxy: reference" \
8166 -p "$P_PXY" \
8167 "$P_SRV dtls=1 debug_level=2" \
8168 "$P_CLI dtls=1 debug_level=2" \
8169 0 \
8170 -C "replayed record" \
8171 -S "replayed record" \
Hanno Beckere03eb7b2019-07-19 15:43:09 +01008172 -C "Buffer record from epoch" \
8173 -S "Buffer record from epoch" \
8174 -C "ssl_buffer_message" \
8175 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008176 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008177 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008178 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008179 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008180 -c "HTTP/1.0 200 OK"
8181
8182not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008183run_test "DTLS proxy: duplicate every packet" \
8184 -p "$P_PXY duplicate=1" \
Hanno Becker7f376f42019-06-12 16:20:48 +01008185 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008186 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008187 0 \
8188 -c "replayed record" \
8189 -s "replayed record" \
8190 -c "record from another epoch" \
8191 -s "record from another epoch" \
8192 -S "resend" \
8193 -s "Extra-header:" \
8194 -c "HTTP/1.0 200 OK"
8195
8196run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8197 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008198 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8199 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008200 0 \
8201 -c "replayed record" \
8202 -S "replayed record" \
8203 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008204 -s "record from another epoch" \
8205 -c "resend" \
8206 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008207 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008208 -c "HTTP/1.0 200 OK"
8209
8210run_test "DTLS proxy: multiple records in same datagram" \
8211 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008212 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8213 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008214 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008215 -c "next record in same datagram" \
8216 -s "next record in same datagram"
8217
8218run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8219 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008220 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8221 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008222 0 \
8223 -c "next record in same datagram" \
8224 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008225
Jarno Lamsa33281d52019-10-18 10:54:35 +03008226requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008227run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8228 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008229 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8230 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008231 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008232 -c "discarding invalid record (mac)" \
8233 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008234 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008235 -c "HTTP/1.0 200 OK" \
8236 -S "too many records with bad MAC" \
8237 -S "Verification of the message MAC failed"
8238
Jarno Lamsa33281d52019-10-18 10:54:35 +03008239requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008240run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8241 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008242 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8243 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008244 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008245 -C "discarding invalid record (mac)" \
8246 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008247 -S "Extra-header:" \
8248 -C "HTTP/1.0 200 OK" \
8249 -s "too many records with bad MAC" \
8250 -s "Verification of the message MAC failed"
8251
Jarno Lamsa33281d52019-10-18 10:54:35 +03008252requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008253run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8254 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008255 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8256 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008257 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008258 -c "discarding invalid record (mac)" \
8259 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008260 -s "Extra-header:" \
8261 -c "HTTP/1.0 200 OK" \
8262 -S "too many records with bad MAC" \
8263 -S "Verification of the message MAC failed"
8264
Jarno Lamsa33281d52019-10-18 10:54:35 +03008265requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008266run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8267 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008268 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8269 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008270 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008271 -c "discarding invalid record (mac)" \
8272 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008273 -s "Extra-header:" \
8274 -c "HTTP/1.0 200 OK" \
8275 -s "too many records with bad MAC" \
8276 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008277
8278run_test "DTLS proxy: delay ChangeCipherSpec" \
8279 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008280 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8281 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008282 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008283 -c "record from another epoch" \
8284 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008285 -s "Extra-header:" \
8286 -c "HTTP/1.0 200 OK"
8287
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008288# Tests for reordering support with DTLS
8289
Hanno Becker56cdfd12018-08-17 13:42:15 +01008290run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8291 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008292 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8293 hs_timeout=2500-60000" \
8294 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8295 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008296 0 \
8297 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008298 -c "Next handshake message has been buffered - load"\
8299 -S "Buffering HS message" \
8300 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008301 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008302 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008303 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008304 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008305
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008306run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8307 -p "$P_PXY delay_srv=ServerHello" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03008308 "$P_SRV mtu=256 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008309 hs_timeout=2500-60000" \
8310 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8311 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008312 0 \
8313 -c "Buffering HS message" \
8314 -c "found fragmented DTLS handshake message"\
8315 -c "Next handshake message 1 not or only partially bufffered" \
8316 -c "Next handshake message has been buffered - load"\
8317 -S "Buffering HS message" \
8318 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008319 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008320 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008321 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008322 -S "Remember CCS message"
8323
Hanno Beckera1adcca2018-08-24 14:41:07 +01008324# The client buffers the ServerKeyExchange before receiving the fragmented
8325# Certificate message; at the time of writing, together these are aroudn 1200b
8326# in size, so that the bound below ensures that the certificate can be reassembled
8327# while keeping the ServerKeyExchange.
8328requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8329run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008330 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008331 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8332 hs_timeout=2500-60000" \
8333 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8334 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008335 0 \
8336 -c "Buffering HS message" \
8337 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008338 -C "attempt to make space by freeing buffered messages" \
8339 -S "Buffering HS message" \
8340 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008341 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008342 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008343 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008344 -S "Remember CCS message"
8345
8346# The size constraints ensure that the delayed certificate message can't
8347# be reassembled while keeping the ServerKeyExchange message, but it can
8348# when dropping it first.
8349requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8350requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8351run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8352 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008353 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8354 hs_timeout=2500-60000" \
8355 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8356 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008357 0 \
8358 -c "Buffering HS message" \
8359 -c "attempt to make space by freeing buffered future messages" \
8360 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008361 -S "Buffering HS message" \
8362 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008363 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008364 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008365 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008366 -S "Remember CCS message"
8367
Hanno Becker56cdfd12018-08-17 13:42:15 +01008368run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8369 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008370 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8371 hs_timeout=2500-60000" \
8372 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8373 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008374 0 \
8375 -C "Buffering HS message" \
8376 -C "Next handshake message has been buffered - load"\
8377 -s "Buffering HS message" \
8378 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008379 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008380 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008381 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008382 -S "Remember CCS message"
8383
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02008384# This needs session tickets; otherwise CCS is the first message in its flight
8385requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008386run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8387 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008388 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8389 hs_timeout=2500-60000" \
8390 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8391 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008392 0 \
8393 -C "Buffering HS message" \
8394 -C "Next handshake message has been buffered - load"\
8395 -S "Buffering HS message" \
8396 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008397 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008398 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008399 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008400 -S "Remember CCS message"
8401
Jarno Lamsa33281d52019-10-18 10:54:35 +03008402# This needs session tickets; otherwise CCS is the first message in its flight
8403requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008404run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8405 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008406 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8407 hs_timeout=2500-60000" \
8408 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8409 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008410 0 \
8411 -C "Buffering HS message" \
8412 -C "Next handshake message has been buffered - load"\
8413 -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 Becker56cdfd12018-08-17 13:42:15 +01008416 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008417 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008418 -s "Remember CCS message"
8419
Hanno Beckera1adcca2018-08-24 14:41:07 +01008420run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008421 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008422 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8423 hs_timeout=2500-60000" \
8424 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8425 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008426 0 \
8427 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008428 -s "Found buffered record from current epoch - load" \
8429 -c "Buffer record from epoch 1" \
8430 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008431
Hanno Beckera1adcca2018-08-24 14:41:07 +01008432# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8433# from the server are delayed, so that the encrypted Finished message
8434# is received and buffered. When the fragmented NewSessionTicket comes
8435# in afterwards, the encrypted Finished message must be freed in order
8436# to make space for the NewSessionTicket to be reassembled.
8437# This works only in very particular circumstances:
8438# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8439# of the NewSessionTicket, but small enough to also allow buffering of
8440# the encrypted Finished message.
8441# - The MTU setting on the server must be so small that the NewSessionTicket
8442# needs to be fragmented.
8443# - All messages sent by the server must be small enough to be either sent
8444# without fragmentation or be reassembled within the bounds of
8445# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8446# handshake, omitting CRTs.
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008447requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8448requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008449run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8450 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008451 "$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 +01008452 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8453 0 \
8454 -s "Buffer record from epoch 1" \
8455 -s "Found buffered record from current epoch - load" \
8456 -c "Buffer record from epoch 1" \
8457 -C "Found buffered record from current epoch - load" \
8458 -c "Enough space available after freeing future epoch record"
8459
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008460# Tests for "randomly unreliable connection": try a variety of flows and peers
8461
8462client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008463run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8464 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008465 "$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 +02008466 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008467 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008468 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8469 0 \
8470 -s "Extra-header:" \
8471 -c "HTTP/1.0 200 OK"
8472
Janos Follath74537a62016-09-02 13:45:28 +01008473client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008474run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8475 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008476 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8477 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008478 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8479 0 \
8480 -s "Extra-header:" \
8481 -c "HTTP/1.0 200 OK"
8482
Janos Follath74537a62016-09-02 13:45:28 +01008483client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008484run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8485 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008486 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8487 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008488 0 \
8489 -s "Extra-header:" \
8490 -c "HTTP/1.0 200 OK"
8491
Janos Follath74537a62016-09-02 13:45:28 +01008492client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008493run_test "DTLS proxy: 3d, FS, client auth" \
8494 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008495 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8496 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008497 0 \
8498 -s "Extra-header:" \
8499 -c "HTTP/1.0 200 OK"
8500
Janos Follath74537a62016-09-02 13:45:28 +01008501client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008502run_test "DTLS proxy: 3d, FS, ticket" \
8503 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008504 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8505 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008506 0 \
8507 -s "Extra-header:" \
8508 -c "HTTP/1.0 200 OK"
8509
Janos Follath74537a62016-09-02 13:45:28 +01008510client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008511run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8512 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008513 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8514 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008515 0 \
8516 -s "Extra-header:" \
8517 -c "HTTP/1.0 200 OK"
8518
Janos Follath74537a62016-09-02 13:45:28 +01008519client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008520run_test "DTLS proxy: 3d, max handshake, nbio" \
8521 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008522 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008523 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008524 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008525 0 \
8526 -s "Extra-header:" \
8527 -c "HTTP/1.0 200 OK"
8528
Janos Follath74537a62016-09-02 13:45:28 +01008529client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008530requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008531requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008532requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008533run_test "DTLS proxy: 3d, min handshake, resumption" \
8534 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008535 "$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 +02008536 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008537 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008538 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8539 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8540 0 \
8541 -s "a session has been resumed" \
8542 -c "a session has been resumed" \
8543 -s "Extra-header:" \
8544 -c "HTTP/1.0 200 OK"
8545
Janos Follath74537a62016-09-02 13:45:28 +01008546client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008547requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008548requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008549requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008550run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8551 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008552 "$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 +02008553 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008554 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008555 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8556 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8557 0 \
8558 -s "a session has been resumed" \
8559 -c "a session has been resumed" \
8560 -s "Extra-header:" \
8561 -c "HTTP/1.0 200 OK"
8562
Janos Follath74537a62016-09-02 13:45:28 +01008563client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008564requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008565run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008566 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008567 "$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 +02008568 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008569 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008570 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008571 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8572 0 \
8573 -c "=> renegotiate" \
8574 -s "=> renegotiate" \
8575 -s "Extra-header:" \
8576 -c "HTTP/1.0 200 OK"
8577
Janos Follath74537a62016-09-02 13:45:28 +01008578client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008579requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008580run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8581 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008582 "$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 +02008583 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008584 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008585 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008586 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8587 0 \
8588 -c "=> renegotiate" \
8589 -s "=> renegotiate" \
8590 -s "Extra-header:" \
8591 -c "HTTP/1.0 200 OK"
8592
Janos Follath74537a62016-09-02 13:45:28 +01008593client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008594requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008595run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008596 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008597 "$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 +02008598 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008599 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008600 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008601 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008602 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8603 0 \
8604 -c "=> renegotiate" \
8605 -s "=> renegotiate" \
8606 -s "Extra-header:" \
8607 -c "HTTP/1.0 200 OK"
8608
Janos Follath74537a62016-09-02 13:45:28 +01008609client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008610requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008611run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008612 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008613 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008614 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008615 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008616 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008617 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008618 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8619 0 \
8620 -c "=> renegotiate" \
8621 -s "=> renegotiate" \
8622 -s "Extra-header:" \
8623 -c "HTTP/1.0 200 OK"
8624
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008625## Interop tests with OpenSSL might trigger a bug in recent versions (including
8626## all versions installed on the CI machines), reported here:
8627## Bug report: https://github.com/openssl/openssl/issues/6902
8628## They should be re-enabled once a fixed version of OpenSSL is available
8629## (this should happen in some 1.1.1_ release according to the ticket).
8630skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008631client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008632not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008633run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008634 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8635 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008636 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008637 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008638 -c "HTTP/1.0 200 OK"
8639
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008640skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008641client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008642not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008643run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8644 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8645 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008646 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008647 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008648 -c "HTTP/1.0 200 OK"
8649
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008650skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008651client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008652not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008653run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8654 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8655 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008656 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008657 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008658 -c "HTTP/1.0 200 OK"
8659
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008660requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008661client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008662not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008663run_test "DTLS proxy: 3d, gnutls server" \
8664 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8665 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008666 "$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 +02008667 0 \
8668 -s "Extra-header:" \
8669 -c "Extra-header:"
8670
k-stachowiakabb843e2019-02-18 16:14:03 +01008671requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008672client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008673not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008674run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8675 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008676 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008677 "$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 +02008678 0 \
8679 -s "Extra-header:" \
8680 -c "Extra-header:"
8681
k-stachowiakabb843e2019-02-18 16:14:03 +01008682requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008683client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008684not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008685run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8686 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008687 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008688 "$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 +02008689 0 \
8690 -s "Extra-header:" \
8691 -c "Extra-header:"
8692
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008693# Final report
8694
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008695echo "------------------------------------------------------------------------"
8696
8697if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008698 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008699else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008700 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008701fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008702PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008703echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008704
8705exit $FAILS