blob: 5c09e18e723ace5d90470d47ed934d95b16bc2a6 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Jaeden Ameroa258ccd2019-07-03 13:51:04 +010024# Limit the size of each log to 10 GiB, in case of failures with this script
25# where it may output seemingly unlimited length error logs.
26ulimit -f 20971520
27
Angus Grattonc4dd0732018-04-11 16:28:39 +100028if cd $( dirname $0 ); then :; else
29 echo "cd $( dirname $0 ) failed" >&2
30 exit 1
31fi
32
Antonin Décimod5f47592019-01-23 15:24:37 +010033# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010034: ${P_SRV:=../programs/ssl/ssl_server2}
35: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020036: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010037: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020038: ${GNUTLS_CLI:=gnutls-cli}
39: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020040: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010041
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020042O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010043O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020044G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010045G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020046TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010047
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020048# alternative versions of OpenSSL and GnuTLS (no default path)
49
50if [ -n "${OPENSSL_LEGACY:-}" ]; then
51 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
52 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
53else
54 O_LEGACY_SRV=false
55 O_LEGACY_CLI=false
56fi
57
Hanno Becker58e9dc32018-08-17 15:53:21 +010058if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020059 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
60else
61 G_NEXT_SRV=false
62fi
63
Hanno Becker58e9dc32018-08-17 15:53:21 +010064if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020065 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
66else
67 G_NEXT_CLI=false
68fi
69
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010070TESTS=0
71FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020072SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010073
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010074MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010075FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020076EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010077
Paul Bakkere20310a2016-05-10 11:18:17 +010078SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010079RUN_TEST_NUMBER=''
80
Paul Bakkeracaac852016-05-10 11:47:13 +010081PRESERVE_LOGS=0
82
Gilles Peskinef93c7d32017-04-14 17:55:28 +020083# Pick a "unique" server port in the range 10000-19999, and a proxy
84# port which is this plus 10000. Each port number may be independently
85# overridden by a command line option.
86SRV_PORT=$(($$ % 10000 + 10000))
87PXY_PORT=$((SRV_PORT + 10000))
88
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010089print_usage() {
90 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010091 printf " -h|--help\tPrint this help.\n"
92 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020093 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
94 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010095 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010096 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010097 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020098 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
99 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100100 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100101}
102
103get_options() {
104 while [ $# -gt 0 ]; do
105 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100106 -f|--filter)
107 shift; FILTER=$1
108 ;;
109 -e|--exclude)
110 shift; EXCLUDE=$1
111 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100112 -m|--memcheck)
113 MEMCHECK=1
114 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100115 -n|--number)
116 shift; RUN_TEST_NUMBER=$1
117 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100118 -s|--show-numbers)
119 SHOW_TEST_NUMBER=1
120 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100121 -p|--preserve-logs)
122 PRESERVE_LOGS=1
123 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200124 --port)
125 shift; SRV_PORT=$1
126 ;;
127 --proxy-port)
128 shift; PXY_PORT=$1
129 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100130 --seed)
131 shift; SEED="$1"
132 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100133 -h|--help)
134 print_usage
135 exit 0
136 ;;
137 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200138 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100139 print_usage
140 exit 1
141 ;;
142 esac
143 shift
144 done
145}
146
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100147# Skip next test; use this macro to skip tests which are legitimate
148# in theory and expected to be re-introduced at some point, but
149# aren't expected to succeed at the moment due to problems outside
150# our control (such as bugs in other TLS implementations).
151skip_next_test() {
152 SKIP_NEXT="YES"
153}
154
Hanno Becker91900362019-07-03 13:22:59 +0100155requires_ciphersuite_enabled() {
156 if [ -z "$($P_CLI --help | grep "$1")" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Hanno Becker7c48dd12018-08-28 16:09:22 +0100161get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100162 # This function uses the query_config command line option to query the
163 # required Mbed TLS compile time configuration from the ssl_server2
164 # program. The command will always return a success value if the
165 # configuration is defined and the value will be printed to stdout.
166 #
167 # Note that if the configuration is not defined or is defined to nothing,
168 # the output of this function will be an empty string.
169 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100170}
171
Hanno Beckerab9a29b2019-09-24 16:14:39 +0100172# skip next test if the flag is enabled in config.h
173requires_config_disabled() {
174 if get_config_value_or_default $1; then
175 SKIP_NEXT="YES"
176 fi
177}
178
179requires_config_enabled() {
180 if ! get_config_value_or_default $1; then
181 SKIP_NEXT="YES"
182 fi
183}
184
Hanno Becker7c48dd12018-08-28 16:09:22 +0100185requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100186 VAL="$( get_config_value_or_default "$1" )"
187 if [ -z "$VAL" ]; then
188 # Should never happen
189 echo "Mbed TLS configuration $1 is not defined"
190 exit 1
191 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100192 SKIP_NEXT="YES"
193 fi
194}
195
196requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100197 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100198 if [ -z "$VAL" ]; then
199 # Should never happen
200 echo "Mbed TLS configuration $1 is not defined"
201 exit 1
202 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100203 SKIP_NEXT="YES"
204 fi
205}
206
Arto Kinnunenc457ab12019-09-27 12:00:51 +0300207requires_config_value_exactly() {
208 VAL=$( get_config_value_or_default "$1" )
209 if [ -z "$VAL" ]; then
210 # Should never happen
211 echo "Mbed TLS configuration $1 is not defined"
212 exit 1
Arto Kinnunen13db25f2019-09-27 13:06:25 +0300213 elif [ "$VAL" -ne "$2" ]; then
Arto Kinnunenc457ab12019-09-27 12:00:51 +0300214 SKIP_NEXT="YES"
215 fi
216}
217
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200218# skip next test if OpenSSL doesn't support FALLBACK_SCSV
219requires_openssl_with_fallback_scsv() {
220 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
221 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
222 then
223 OPENSSL_HAS_FBSCSV="YES"
224 else
225 OPENSSL_HAS_FBSCSV="NO"
226 fi
227 fi
228 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
229 SKIP_NEXT="YES"
230 fi
231}
232
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200233# skip next test if GnuTLS isn't available
234requires_gnutls() {
235 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200236 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200237 GNUTLS_AVAILABLE="YES"
238 else
239 GNUTLS_AVAILABLE="NO"
240 fi
241 fi
242 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
243 SKIP_NEXT="YES"
244 fi
245}
246
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200247# skip next test if GnuTLS-next isn't available
248requires_gnutls_next() {
249 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
250 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
251 GNUTLS_NEXT_AVAILABLE="YES"
252 else
253 GNUTLS_NEXT_AVAILABLE="NO"
254 fi
255 fi
256 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
257 SKIP_NEXT="YES"
258 fi
259}
260
261# skip next test if OpenSSL-legacy isn't available
262requires_openssl_legacy() {
263 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
264 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
265 OPENSSL_LEGACY_AVAILABLE="YES"
266 else
267 OPENSSL_LEGACY_AVAILABLE="NO"
268 fi
269 fi
270 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
271 SKIP_NEXT="YES"
272 fi
273}
274
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200275# skip next test if IPv6 isn't available on this host
276requires_ipv6() {
277 if [ -z "${HAS_IPV6:-}" ]; then
278 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
279 SRV_PID=$!
280 sleep 1
281 kill $SRV_PID >/dev/null 2>&1
282 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
283 HAS_IPV6="NO"
284 else
285 HAS_IPV6="YES"
286 fi
287 rm -r $SRV_OUT
288 fi
289
290 if [ "$HAS_IPV6" = "NO" ]; then
291 SKIP_NEXT="YES"
292 fi
293}
294
Andrzej Kurekb4593462018-10-11 08:43:30 -0400295# skip next test if it's i686 or uname is not available
296requires_not_i686() {
297 if [ -z "${IS_I686:-}" ]; then
298 IS_I686="YES"
299 if which "uname" >/dev/null 2>&1; then
300 if [ -z "$(uname -a | grep i686)" ]; then
301 IS_I686="NO"
302 fi
303 fi
304 fi
305 if [ "$IS_I686" = "YES" ]; then
306 SKIP_NEXT="YES"
307 fi
308}
309
Angus Grattonc4dd0732018-04-11 16:28:39 +1000310# Calculate the input & output maximum content lengths set in the config
Arto Kinnunen78213522019-09-26 11:06:39 +0300311MAX_CONTENT_LEN="$( get_config_value_or_default MBEDTLS_SSL_MAX_CONTENT_LEN )"
312if [ -z "$MAX_CONTENT_LEN" ]; then
313 MAX_CONTENT_LEN=16384
314fi
315
316MAX_IN_LEN="$( get_config_value_or_default MBEDTLS_SSL_IN_CONTENT_LEN )"
317if [ -z "$MAX_IN_LEN" ]; then
318 MAX_IN_LEN=$MAX_CONTENT_LEN
319fi
320
321MAX_OUT_LEN="$( get_config_value_or_default MBEDTLS_SSL_OUT_CONTENT_LEN )"
322if [ -z "$MAX_OUT_LEN" ]; then
323 MAX_OUT_LEN=$MAX_CONTENT_LEN
324fi
Angus Grattonc4dd0732018-04-11 16:28:39 +1000325
326if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
327 MAX_CONTENT_LEN="$MAX_IN_LEN"
328fi
329if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
330 MAX_CONTENT_LEN="$MAX_OUT_LEN"
331fi
332
333# skip the next test if the SSL output buffer is less than 16KB
334requires_full_size_output_buffer() {
335 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
336 SKIP_NEXT="YES"
337 fi
338}
339
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200340# skip the next test if valgrind is in use
341not_with_valgrind() {
342 if [ "$MEMCHECK" -gt 0 ]; then
343 SKIP_NEXT="YES"
344 fi
345}
346
Paul Bakker362689d2016-05-13 10:33:25 +0100347# skip the next test if valgrind is NOT in use
348only_with_valgrind() {
349 if [ "$MEMCHECK" -eq 0 ]; then
350 SKIP_NEXT="YES"
351 fi
352}
353
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200354# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100355client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200356 CLI_DELAY_FACTOR=$1
357}
358
Janos Follath74537a62016-09-02 13:45:28 +0100359# wait for the given seconds after the client finished in the next test
360server_needs_more_time() {
361 SRV_DELAY_SECONDS=$1
362}
363
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100364# print_name <name>
365print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100366 TESTS=$(( $TESTS + 1 ))
367 LINE=""
368
369 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
370 LINE="$TESTS "
371 fi
372
373 LINE="$LINE$1"
374 printf "$LINE "
375 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100376 for i in `seq 1 $LEN`; do printf '.'; done
377 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100378
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100379}
380
381# fail <message>
382fail() {
383 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100384 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100385
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200386 mv $SRV_OUT o-srv-${TESTS}.log
387 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200388 if [ -n "$PXY_CMD" ]; then
389 mv $PXY_OUT o-pxy-${TESTS}.log
390 fi
391 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100392
Azim Khan19d13732018-03-29 11:04:20 +0100393 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot -o "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200394 echo " ! server output:"
395 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200396 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200397 echo " ! client output:"
398 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200399 if [ -n "$PXY_CMD" ]; then
400 echo " ! ========================================================"
401 echo " ! proxy output:"
402 cat o-pxy-${TESTS}.log
403 fi
404 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200405 fi
406
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200407 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100408}
409
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100410# is_polar <cmd_line>
411is_polar() {
412 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
413}
414
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200415# openssl s_server doesn't have -www with DTLS
416check_osrv_dtls() {
417 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
418 NEEDS_INPUT=1
419 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
420 else
421 NEEDS_INPUT=0
422 fi
423}
424
425# provide input to commands that need it
426provide_input() {
427 if [ $NEEDS_INPUT -eq 0 ]; then
428 return
429 fi
430
431 while true; do
432 echo "HTTP/1.0 200 OK"
433 sleep 1
434 done
435}
436
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100437# has_mem_err <log_file_name>
438has_mem_err() {
439 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
440 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
441 then
442 return 1 # false: does not have errors
443 else
444 return 0 # true: has errors
445 fi
446}
447
Unknown43dc0d62019-09-02 10:42:57 -0400448# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100449if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400450 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100451 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200452 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100453 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200454 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100455 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200456 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100457 # Make a tight loop, server normally takes less than 1s to start.
458 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
459 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400460 echo "$3 START TIMEOUT"
461 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100462 break
463 fi
464 # Linux and *BSD support decimal arguments to sleep. On other
465 # OSes this may be a tight loop.
466 sleep 0.1 2>/dev/null || true
467 done
468 }
469else
Unknown43dc0d62019-09-02 10:42:57 -0400470 echo "Warning: lsof not available, wait_app_start = sleep"
471 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200472 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100473 }
474fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200475
Unknown43dc0d62019-09-02 10:42:57 -0400476# Wait for server process $2 to be listening on port $1.
477wait_server_start() {
478 wait_app_start $1 $2 "SERVER" $SRV_OUT
479}
480
481# Wait for proxy process $2 to be listening on port $1.
482wait_proxy_start() {
483 wait_app_start $1 $2 "PROXY" $PXY_OUT
484}
485
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100486# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100487# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100488# acceptable bounds
489check_server_hello_time() {
490 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100491 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100492 # Get the Unix timestamp for now
493 CUR_TIME=$(date +'%s')
494 THRESHOLD_IN_SECS=300
495
496 # Check if the ServerHello time was printed
497 if [ -z "$SERVER_HELLO_TIME" ]; then
498 return 1
499 fi
500
501 # Check the time in ServerHello is within acceptable bounds
502 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
503 # The time in ServerHello is at least 5 minutes before now
504 return 1
505 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100506 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100507 return 1
508 else
509 return 0
510 fi
511}
512
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200513# wait for client to terminate and set CLI_EXIT
514# must be called right after starting the client
515wait_client_done() {
516 CLI_PID=$!
517
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200518 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
519 CLI_DELAY_FACTOR=1
520
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200521 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200522 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200523
524 wait $CLI_PID
525 CLI_EXIT=$?
526
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200527 kill $DOG_PID >/dev/null 2>&1
528 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200529
530 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100531
532 sleep $SRV_DELAY_SECONDS
533 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200534}
535
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200536# check if the given command uses dtls and sets global variable DTLS
537detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200538 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200539 DTLS=1
540 else
541 DTLS=0
542 fi
543}
544
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100545# Strip off a particular parameter from the command line
546# and return its value.
547# Parameter 1: Command line parameter to strip off
548# ENV I/O: CMD command line to search and modify
549extract_cmdline_argument() {
550 __ARG=$(echo "$CMD" | sed -n "s/^.* $1=\([^ ]*\).*$/\1/p")
551 CMD=$(echo "$CMD" | sed "s/$1=\([^ ]*\)//")
552}
553
554# Check compatibility of the ssl_client2/ssl_server2 command-line
555# with a particular compile-time configurable option.
556# Parameter 1: Command-line argument (e.g. extended_ms)
557# Parameter 2: Corresponding compile-time configuration
558# (e.g. MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET)
559# ENV I/O: CMD command line to search and modify
560# SKIP_NEXT set to "YES" on a mismatch
561check_cmdline_param_compat() {
562 __VAL="$( get_config_value_or_default "$2" )"
563 if [ ! -z "$__VAL" ]; then
564 extract_cmdline_argument "$1"
565 if [ ! -z "$__ARG" ] && [ "$__ARG" != "$__VAL" ]; then
566 SKIP_NEXT="YES"
567 fi
568 fi
569}
570
Hanno Beckera43f85c2019-09-05 14:51:20 +0100571check_cmdline_check_tls_dtls() {
Hanno Becker73b72d12019-07-26 12:00:38 +0100572 detect_dtls "$CMD"
573 if [ "$DTLS" = "0" ]; then
574 requires_config_disabled MBEDTLS_SSL_PROTO_NO_TLS
Hanno Beckera43f85c2019-09-05 14:51:20 +0100575 elif [ "$DTLS" = "1" ]; then
576 requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Hanno Becker73b72d12019-07-26 12:00:38 +0100577 fi
578}
579
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100580check_cmdline_authmode_compat() {
581 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_AUTHMODE" )"
582 if [ ! -z "$__VAL" ]; then
583 extract_cmdline_argument "auth_mode"
584 if [ "$__ARG" = "none" ] && [ "$__VAL" != "0" ]; then
585 SKIP_NEXT="YES";
586 elif [ "$__ARG" = "optional" ] && [ "$__VAL" != "1" ]; then
587 SKIP_NEXT="YES"
588 elif [ "$__ARG" = "required" ] && [ "$__VAL" != "2" ]; then
589 SKIP_NEXT="YES"
590 fi
591 fi
592}
593
Hanno Beckerb0b2b672019-06-12 16:58:10 +0100594check_cmdline_legacy_renego_compat() {
595 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_ALLOW_LEGACY_RENEGOTIATION" )"
596 if [ ! -z "$__VAL" ]; then
597 extract_cmdline_argument "allow_legacy"
598 if [ "$__ARG" = "-1" ] && [ "$__VAL" != "2" ]; then
599 SKIP_NEXT="YES";
600 elif [ "$__ARG" = "0" ] && [ "$__VAL" != "0" ]; then
601 SKIP_NEXT="YES"
602 elif [ "$__ARG" = "1" ] && [ "$__VAL" != "1" ]; then
603 SKIP_NEXT="YES"
604 fi
605 fi
606}
607
Hanno Beckerd82a0302019-07-05 11:40:52 +0100608check_cmdline_min_minor_version_compat() {
609 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MIN_MINOR_VER" )"
610 if [ ! -z "$__VAL" ]; then
611 extract_cmdline_argument "min_version"
612 if [ "$__ARG" = "ssl3" ] && [ "$__VAL" != "0" ]; then
613 SKIP_NEXT="YES";
614 elif [ "$__ARG" = "tls1" ] && [ "$__VAL" != "1" ]; then
615 SKIP_NEXT="YES"
616 elif [ "$__ARG" = "tls1_1" ] && [ "$__VAL" != "2" ]; then
617 SKIP_NEXT="YES"
618 elif [ "$__ARG" = "tls1_2" ] && [ "$__VAL" != "3" ]; then
619 SKIP_NEXT="YES"
620 fi
621 fi
622}
623
624check_cmdline_max_minor_version_compat() {
625 __VAL="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MAX_MINOR_VER" )"
626 if [ ! -z "$__VAL" ]; then
627 extract_cmdline_argument "max_version"
628 if [ "$__ARG" = "ssl3" ] && [ "$__VAL" != "0" ]; then
629 SKIP_NEXT="YES";
630 elif [ "$__ARG" = "tls1" ] && [ "$__VAL" != "1" ]; then
631 SKIP_NEXT="YES"
632 elif [ "$__ARG" = "tls1_1" ] && [ "$__VAL" != "2" ]; then
633 SKIP_NEXT="YES"
634 elif [ "$__ARG" = "tls1_2" ] && [ "$__VAL" != "3" ]; then
635 SKIP_NEXT="YES"
636 fi
637 fi
638}
639
640check_cmdline_force_version_compat() {
641 __VAL_MAX="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MAX_MINOR_VER" )"
642 __VAL_MIN="$( get_config_value_or_default "MBEDTLS_SSL_CONF_MIN_MINOR_VER" )"
643 if [ ! -z "$__VAL_MIN" ]; then
644
645 # SSL cli/srv cmd line
646
647 extract_cmdline_argument "force_version"
648 if [ "$__ARG" = "ssl3" ] && \
649 ( [ "$__VAL_MIN" != "0" ] || [ "$__VAL_MAX" != "0" ] ); then
650 SKIP_NEXT="YES";
651 elif [ "$__ARG" = "tls1" ] && \
652 ( [ "$__VAL_MIN" != "1" ] || [ "$__VAL_MAX" != "1" ] ); then
653 SKIP_NEXT="YES"
654 elif ( [ "$__ARG" = "tls1_1" ] || [ "$__ARG" = "dtls1" ] ) && \
655 ( [ "$__VAL_MIN" != "2" ] || [ "$__VAL_MAX" != "2" ] ); then
656 SKIP_NEXT="YES"
657 elif ( [ "$__ARG" = "tls1_2" ] || [ "$__ARG" = "dtls1_2" ] ) && \
658 ( [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ] ); then
Hanno Beckerd82a0302019-07-05 11:40:52 +0100659 SKIP_NEXT="YES"
660 fi
661
662 # OpenSSL cmd line
663
664 if echo "$CMD" | grep -e "-tls1\($\|[^_]\)" > /dev/null; then
665 if [ "$__VAL_MIN" != "1" ] || [ "$__VAL_MAX" != "1" ]; then
666 SKIP_NEXT="YES"
667 fi
668 fi
669
670 if echo "$CMD" | grep -e "-\(dtls1\($\|[^_]\)\|tls1_1\)" > /dev/null; then
671 if [ "$__VAL_MIN" != "2" ] || [ "$__VAL_MAX" != "2" ]; then
672 SKIP_NEXT="YES"
673 fi
674 fi
675
676 if echo "$CMD" | grep -e "-\(dtls1_2\($\|[^_]\)\|tls1_2\)" > /dev/null; then
677 if [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ]; then
678 SKIP_NEXT="YES"
679 fi
680 fi
681
682 fi
683}
684
Hanno Becker69c6cde2019-09-02 14:34:23 +0100685check_cmdline_crt_key_files_compat() {
686
687 # test-ca2.crt
688 if echo "$CMD" | grep -e "test-ca2" > /dev/null; then
689 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
690 fi
691
692 # Variants of server5.key and server5.crt
693 if echo "$CMD" | grep -e "server5" > /dev/null; then
694 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
695 fi
696
697 # Variants of server6.key and server6.crt
698 if echo "$CMD" | grep -e "server6" > /dev/null; then
699 requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
700 fi
701
702}
703
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100704# Go through all options that can be hardcoded at compile-time and
705# detect whether the command line configures them in a conflicting
706# way. If so, skip the test. Otherwise, remove the corresponding
707# entry.
708# Parameter 1: Command line to inspect
709# Output: Modified command line
710# ENV I/O: SKIP_TEST set to 1 on mismatch.
711check_cmdline_compat() {
712 CMD="$1"
713
Hanno Becker69c6cde2019-09-02 14:34:23 +0100714 # Check that if we're specifying particular certificate and/or
715 # ECC key files, the corresponding curve is enabled.
716 check_cmdline_crt_key_files_compat
717
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100718 # ExtendedMasterSecret configuration
719 check_cmdline_param_compat "extended_ms" \
720 "MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET"
721 check_cmdline_param_compat "enforce_extended_master_secret" \
722 "MBEDTLS_SSL_CONF_ENFORCE_EXTENDED_MASTER_SECRET"
Hanno Becker7f376f42019-06-12 16:20:48 +0100723
724 # DTLS anti replay protection configuration
725 check_cmdline_param_compat "anti_replay" \
726 "MBEDTLS_SSL_CONF_ANTI_REPLAY"
727
Hanno Beckerde671542019-06-12 16:30:46 +0100728 # DTLS bad MAC limit
729 check_cmdline_param_compat "badmac_limit" \
730 "MBEDTLS_SSL_CONF_BADMAC_LIMIT"
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100731
Hanno Beckera43f85c2019-09-05 14:51:20 +0100732 # Skip tests relying on TLS/DTLS in configs that disable it.
733 check_cmdline_check_tls_dtls
Hanno Becker73b72d12019-07-26 12:00:38 +0100734
Hanno Beckeracd4fc02019-06-12 16:40:50 +0100735 # Authentication mode
736 check_cmdline_authmode_compat
Hanno Beckerb0b2b672019-06-12 16:58:10 +0100737
738 # Legacy renegotiation
739 check_cmdline_legacy_renego_compat
Hanno Beckerd82a0302019-07-05 11:40:52 +0100740
741 # Version configuration
742 check_cmdline_min_minor_version_compat
743 check_cmdline_max_minor_version_compat
744 check_cmdline_force_version_compat
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100745}
746
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200747# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100748# Options: -s pattern pattern that must be present in server output
749# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100750# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100751# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100752# -S pattern pattern that must be absent in server output
753# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100754# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100755# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100756run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100757 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200758 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100759
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100760 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
761 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200762 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100763 return
764 fi
765
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100766 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100767
Paul Bakkerb7584a52016-05-10 10:50:43 +0100768 # Do we only run numbered tests?
769 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
770 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
771 else
772 SKIP_NEXT="YES"
773 fi
774
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200775 # does this test use a proxy?
776 if [ "X$1" = "X-p" ]; then
777 PXY_CMD="$2"
778 shift 2
779 else
780 PXY_CMD=""
781 fi
782
783 # get commands and client output
784 SRV_CMD="$1"
785 CLI_CMD="$2"
786 CLI_EXPECT="$3"
787 shift 3
788
Hanno Beckeraf5ab912019-06-21 12:59:46 +0100789 check_cmdline_compat "$SRV_CMD"
790 SRV_CMD="$CMD"
791
792 check_cmdline_compat "$CLI_CMD"
793 CLI_CMD="$CMD"
794
Hanno Becker7a11e722019-05-10 14:38:42 +0100795 # Check if test uses files
796 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
797 if [ ! -z "$TEST_USES_FILES" ]; then
798 requires_config_enabled MBEDTLS_FS_IO
799 fi
800
801 # should we skip?
802 if [ "X$SKIP_NEXT" = "XYES" ]; then
803 SKIP_NEXT="NO"
804 echo "SKIP"
805 SKIPS=$(( $SKIPS + 1 ))
806 return
807 fi
808
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200809 # fix client port
810 if [ -n "$PXY_CMD" ]; then
811 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
812 else
813 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
814 fi
815
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200816 # update DTLS variable
817 detect_dtls "$SRV_CMD"
818
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100819 # prepend valgrind to our commands if active
820 if [ "$MEMCHECK" -gt 0 ]; then
821 if is_polar "$SRV_CMD"; then
822 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
823 fi
824 if is_polar "$CLI_CMD"; then
825 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
826 fi
827 fi
828
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200829 TIMES_LEFT=2
830 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200831 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200832
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200833 # run the commands
834 if [ -n "$PXY_CMD" ]; then
835 echo "$PXY_CMD" > $PXY_OUT
836 $PXY_CMD >> $PXY_OUT 2>&1 &
837 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400838 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200839 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200840
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200841 check_osrv_dtls
842 echo "$SRV_CMD" > $SRV_OUT
843 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
844 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100845 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200846
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200847 echo "$CLI_CMD" > $CLI_OUT
848 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
849 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100850
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100851 sleep 0.05
852
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200853 # terminate the server (and the proxy)
854 kill $SRV_PID
855 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100856
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200857 if [ -n "$PXY_CMD" ]; then
858 kill $PXY_PID >/dev/null 2>&1
859 wait $PXY_PID
860 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100861
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200862 # retry only on timeouts
863 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
864 printf "RETRY "
865 else
866 TIMES_LEFT=0
867 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200868 done
869
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100870 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200871 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100872 # expected client exit to incorrectly succeed in case of catastrophic
873 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100874 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200875 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100876 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100877 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100878 return
879 fi
880 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100881 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200882 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100883 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100884 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100885 return
886 fi
887 fi
888
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100889 # check server exit code
890 if [ $? != 0 ]; then
891 fail "server fail"
892 return
893 fi
894
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100895 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100896 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
897 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100898 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200899 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100900 return
901 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100902
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100903 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200904 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100905 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100906 while [ $# -gt 0 ]
907 do
908 case $1 in
909 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100910 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100911 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100912 return
913 fi
914 ;;
915
916 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100917 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100918 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100919 return
920 fi
921 ;;
922
923 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100924 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100925 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100926 return
927 fi
928 ;;
929
930 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100931 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100932 fail "pattern '$2' MUST NOT be present in the Client output"
933 return
934 fi
935 ;;
936
937 # The filtering in the following two options (-u and -U) do the following
938 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100939 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100940 # - keep one of each non-unique line
941 # - count how many lines remain
942 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
943 # if there were no duplicates.
944 "-U")
945 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
946 fail "lines following pattern '$2' must be unique in Server output"
947 return
948 fi
949 ;;
950
951 "-u")
952 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
953 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100954 return
955 fi
956 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100957 "-F")
958 if ! $2 "$SRV_OUT"; then
959 fail "function call to '$2' failed on Server output"
960 return
961 fi
962 ;;
963 "-f")
964 if ! $2 "$CLI_OUT"; then
965 fail "function call to '$2' failed on Client output"
966 return
967 fi
968 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100969
970 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200971 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100972 exit 1
973 esac
974 shift 2
975 done
976
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100977 # check valgrind's results
978 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200979 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100980 fail "Server has memory errors"
981 return
982 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200983 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100984 fail "Client has memory errors"
985 return
986 fi
987 fi
988
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100989 # if we're here, everything is ok
990 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100991 if [ "$PRESERVE_LOGS" -gt 0 ]; then
992 mv $SRV_OUT o-srv-${TESTS}.log
993 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100994 if [ -n "$PXY_CMD" ]; then
995 mv $PXY_OUT o-pxy-${TESTS}.log
996 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100997 fi
998
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200999 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001000}
1001
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001002cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001003 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +02001004 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
1005 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
1006 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
1007 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001008 exit 1
1009}
1010
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +01001011#
1012# MAIN
1013#
1014
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +01001015get_options "$@"
1016
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001017# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +01001018P_SRV_BIN="${P_SRV%%[ ]*}"
1019P_CLI_BIN="${P_CLI%%[ ]*}"
1020P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +01001021if [ ! -x "$P_SRV_BIN" ]; then
1022 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001023 exit 1
1024fi
Hanno Becker17c04932017-10-10 14:44:53 +01001025if [ ! -x "$P_CLI_BIN" ]; then
1026 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001027 exit 1
1028fi
Hanno Becker17c04932017-10-10 14:44:53 +01001029if [ ! -x "$P_PXY_BIN" ]; then
1030 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001031 exit 1
1032fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +01001033if [ "$MEMCHECK" -gt 0 ]; then
1034 if which valgrind >/dev/null 2>&1; then :; else
1035 echo "Memcheck not possible. Valgrind not found"
1036 exit 1
1037 fi
1038fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001039if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1040 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001041 exit 1
1042fi
1043
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001044# used by watchdog
1045MAIN_PID="$$"
1046
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001047# We use somewhat arbitrary delays for tests:
1048# - how long do we wait for the server to start (when lsof not available)?
1049# - how long do we allow for the client to finish?
1050# (not to check performance, just to avoid waiting indefinitely)
1051# Things are slower with valgrind, so give extra time here.
1052#
1053# Note: without lsof, there is a trade-off between the running time of this
1054# script and the risk of spurious errors because we didn't wait long enough.
1055# The watchdog delay on the other hand doesn't affect normal running time of
1056# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001057if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001058 START_DELAY=6
1059 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001060else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001061 START_DELAY=2
1062 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001063fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001064
1065# some particular tests need more time:
1066# - for the client, we multiply the usual watchdog limit by a factor
1067# - for the server, we sleep for a number of seconds after the client exits
1068# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001069CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001070SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001071
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001072# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001073# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001074P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1075P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001076P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +02001077O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001078O_CLI="$O_CLI -connect localhost:+SRV_PORT"
1079G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001080G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001081
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001082if [ -n "${OPENSSL_LEGACY:-}" ]; then
1083 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1084 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1085fi
1086
Hanno Becker58e9dc32018-08-17 15:53:21 +01001087if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001088 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1089fi
1090
Hanno Becker58e9dc32018-08-17 15:53:21 +01001091if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001092 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001093fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001094
Gilles Peskine62469d92017-05-10 10:13:59 +02001095# Allow SHA-1, because many of our test certificates use it
1096P_SRV="$P_SRV allow_sha1=1"
1097P_CLI="$P_CLI allow_sha1=1"
1098
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001099# Also pick a unique name for intermediate files
1100SRV_OUT="srv_out.$$"
1101CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001102PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001103SESSION="session.$$"
1104
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001105SKIP_NEXT="NO"
1106
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001107trap cleanup INT TERM HUP
1108
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001109# Basic test
1110
Hanno Becker91900362019-07-03 13:22:59 +01001111run_test "Default" \
1112 "$P_SRV debug_level=3" \
1113 "$P_CLI" \
1114 0
1115
1116run_test "Default, DTLS" \
1117 "$P_SRV dtls=1" \
1118 "$P_CLI dtls=1" \
1119 0
1120
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001121# Checks that:
1122# - things work with all ciphersuites active (used with config-full in all.sh)
1123# - the expected (highest security) parameters are selected
1124# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Hanno Becker91900362019-07-03 13:22:59 +01001125requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1126requires_config_enabled MBEDTLS_SHA512_C
1127requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1128requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1129run_test "Default, choose highest security suite and hash" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001130 "$P_SRV debug_level=3" \
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03001131 "$P_CLI" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001132 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001133 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001134 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001135 -s "client hello v3, signature_algorithm ext: 6" \
1136 -s "ECDHE curve: secp521r1" \
1137 -S "error" \
1138 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001139
Hanno Becker91900362019-07-03 13:22:59 +01001140requires_ciphersuite_enabled "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
1141requires_config_enabled MBEDTLS_SHA512_C
1142requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
1143requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1144run_test "Default, choose highest security suite and hash, DTLS" \
1145 "$P_SRV debug_level=3 dtls=1" \
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001146 "$P_CLI dtls=1" \
1147 0 \
1148 -s "Protocol is DTLSv1.2" \
Hanno Becker91900362019-07-03 13:22:59 +01001149 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
1150 -s "client hello v3, signature_algorithm ext: 6" \
1151 -s "ECDHE curve: secp521r1"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001152
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001153# Test current time in ServerHello
1154requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001155run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001156 "$P_SRV debug_level=3" \
1157 "$P_CLI debug_level=3" \
1158 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001159 -f "check_server_hello_time" \
1160 -F "check_server_hello_time"
1161
Simon Butcher8e004102016-10-14 00:48:33 +01001162# Test for uniqueness of IVs in AEAD ciphersuites
1163run_test "Unique IV in GCM" \
1164 "$P_SRV exchanges=20 debug_level=4" \
1165 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1166 0 \
1167 -u "IV used" \
1168 -U "IV used"
1169
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001170# Tests for rc4 option
1171
Simon Butchera410af52016-05-19 22:12:18 +01001172requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001173run_test "RC4: server disabled, client enabled" \
1174 "$P_SRV" \
1175 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1176 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001177 -s "SSL - The server has no ciphersuites in common"
1178
Simon Butchera410af52016-05-19 22:12:18 +01001179requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001180run_test "RC4: server half, client enabled" \
1181 "$P_SRV arc4=1" \
1182 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1183 1 \
1184 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001185
1186run_test "RC4: server enabled, client disabled" \
1187 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1188 "$P_CLI" \
1189 1 \
1190 -s "SSL - The server has no ciphersuites in common"
1191
1192run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001193 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001194 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1195 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001196 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001197 -S "SSL - The server has no ciphersuites in common"
1198
Hanno Beckerd26bb202018-08-17 09:54:10 +01001199# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1200
1201requires_gnutls
1202requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1203run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1204 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001205 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001206 0
1207
1208requires_gnutls
1209requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1210run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1211 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001212 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001213 0
1214
Gilles Peskinebc70a182017-05-09 15:59:24 +02001215# Tests for SHA-1 support
1216
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001217requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001218requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001219requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001220run_test "SHA-1 forbidden by default in server certificate" \
1221 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1222 "$P_CLI debug_level=2 allow_sha1=0" \
1223 1 \
1224 -c "The certificate is signed with an unacceptable hash"
1225
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001226requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1227run_test "SHA-1 forbidden by default in server certificate" \
1228 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1229 "$P_CLI debug_level=2 allow_sha1=0" \
1230 0
1231
Gilles Peskinebc70a182017-05-09 15:59:24 +02001232run_test "SHA-1 explicitly allowed in server certificate" \
1233 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1234 "$P_CLI allow_sha1=1" \
1235 0
1236
1237run_test "SHA-256 allowed by default in server certificate" \
1238 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1239 "$P_CLI allow_sha1=0" \
1240 0
1241
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001242requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001243requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001244requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001245run_test "SHA-1 forbidden by default in client certificate" \
1246 "$P_SRV auth_mode=required allow_sha1=0" \
1247 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1248 1 \
1249 -s "The certificate is signed with an unacceptable hash"
1250
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001251requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1252run_test "SHA-1 forbidden by default in client certificate" \
1253 "$P_SRV auth_mode=required allow_sha1=0" \
1254 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1255 0
1256
Gilles Peskinebc70a182017-05-09 15:59:24 +02001257run_test "SHA-1 explicitly allowed in client certificate" \
1258 "$P_SRV auth_mode=required allow_sha1=1" \
1259 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1260 0
1261
1262run_test "SHA-256 allowed by default in client certificate" \
1263 "$P_SRV auth_mode=required allow_sha1=0" \
1264 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1265 0
1266
Hanno Becker7ae8a762018-08-14 15:43:35 +01001267# Tests for datagram packing
1268run_test "DTLS: multiple records in same datagram, client and server" \
1269 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1270 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1271 0 \
1272 -c "next record in same datagram" \
1273 -s "next record in same datagram"
1274
1275run_test "DTLS: multiple records in same datagram, client only" \
1276 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1277 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1278 0 \
1279 -s "next record in same datagram" \
1280 -C "next record in same datagram"
1281
1282run_test "DTLS: multiple records in same datagram, server only" \
1283 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1284 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1285 0 \
1286 -S "next record in same datagram" \
1287 -c "next record in same datagram"
1288
1289run_test "DTLS: multiple records in same datagram, neither client nor server" \
1290 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1291 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1292 0 \
1293 -S "next record in same datagram" \
1294 -C "next record in same datagram"
1295
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001296# Tests for Truncated HMAC extension
1297
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001298run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001299 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001300 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001301 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001302 -s "dumping 'expected mac' (20 bytes)" \
1303 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001304
Hanno Becker32c55012017-11-10 08:42:54 +00001305requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001306run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001307 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001308 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001309 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001310 -s "dumping 'expected mac' (20 bytes)" \
1311 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001312
Hanno Becker32c55012017-11-10 08:42:54 +00001313requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001314run_test "Truncated HMAC: client enabled, server default" \
1315 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001316 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001317 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001318 -s "dumping 'expected mac' (20 bytes)" \
1319 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001320
Hanno Becker32c55012017-11-10 08:42:54 +00001321requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001322run_test "Truncated HMAC: client enabled, server disabled" \
1323 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001324 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001325 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001326 -s "dumping 'expected mac' (20 bytes)" \
1327 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001328
Hanno Becker32c55012017-11-10 08:42:54 +00001329requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001330run_test "Truncated HMAC: client disabled, server enabled" \
1331 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001332 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001333 0 \
1334 -s "dumping 'expected mac' (20 bytes)" \
1335 -S "dumping 'expected mac' (10 bytes)"
1336
1337requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001338run_test "Truncated HMAC: client enabled, server enabled" \
1339 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001340 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001341 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001342 -S "dumping 'expected mac' (20 bytes)" \
1343 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001344
Jarno Lamsa33281d52019-10-18 10:54:35 +03001345requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker4c4f4102017-11-10 09:16:05 +00001346run_test "Truncated HMAC, DTLS: client default, server default" \
1347 "$P_SRV dtls=1 debug_level=4" \
1348 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1349 0 \
1350 -s "dumping 'expected mac' (20 bytes)" \
1351 -S "dumping 'expected mac' (10 bytes)"
1352
1353requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1354run_test "Truncated HMAC, DTLS: client disabled, server default" \
1355 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001356 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001357 0 \
1358 -s "dumping 'expected mac' (20 bytes)" \
1359 -S "dumping 'expected mac' (10 bytes)"
1360
1361requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1362run_test "Truncated HMAC, DTLS: client enabled, server default" \
1363 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001364 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001365 0 \
1366 -s "dumping 'expected mac' (20 bytes)" \
1367 -S "dumping 'expected mac' (10 bytes)"
1368
1369requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1370run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1371 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001372 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001373 0 \
1374 -s "dumping 'expected mac' (20 bytes)" \
1375 -S "dumping 'expected mac' (10 bytes)"
1376
1377requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1378run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1379 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001380 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001381 0 \
1382 -s "dumping 'expected mac' (20 bytes)" \
1383 -S "dumping 'expected mac' (10 bytes)"
1384
1385requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1386run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1387 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001388 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001389 0 \
1390 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001391 -s "dumping 'expected mac' (10 bytes)"
1392
Jarno Lamsafa45e602019-06-04 11:33:23 +03001393# Tests for Context serialization
1394
1395requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001396run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001397 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001398 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001399 0 \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001400 -c "Deserializing connection..." \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001401 -S "Deserializing connection..."
1402
1403requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001404run_test "Context serialization, client serializes, ChaChaPoly" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001405 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001406 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001407 0 \
1408 -c "Deserializing connection..." \
1409 -S "Deserializing connection..."
1410
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001411requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001412run_test "Context serialization, client serializes, GCM" \
1413 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1414 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001415 0 \
1416 -c "Deserializing connection..." \
1417 -S "Deserializing connection..."
Jarno Lamsacc281b82019-06-04 15:21:13 +03001418
Jarno Lamsafa45e602019-06-04 11:33:23 +03001419requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001420requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1421run_test "Context serialization, client serializes, with CID" \
1422 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1423 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1424 0 \
1425 -c "Deserializing connection..." \
1426 -S "Deserializing connection..."
1427
1428requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001429run_test "Context serialization, server serializes, CCM" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001430 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001431 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001432 0 \
1433 -C "Deserializing connection..." \
1434 -s "Deserializing connection..."
1435
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001436requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001437run_test "Context serialization, server serializes, ChaChaPoly" \
1438 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1439 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1440 0 \
1441 -C "Deserializing connection..." \
1442 -s "Deserializing connection..."
1443
1444requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1445run_test "Context serialization, server serializes, GCM" \
1446 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1447 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001448 0 \
1449 -C "Deserializing connection..." \
Jarno Lamsacc281b82019-06-04 15:21:13 +03001450 -s "Deserializing connection..."
Jarno Lamsafa45e602019-06-04 11:33:23 +03001451
1452requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001453requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1454run_test "Context serialization, server serializes, with CID" \
1455 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1456 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1457 0 \
1458 -C "Deserializing connection..." \
1459 -s "Deserializing connection..."
1460
1461requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001462run_test "Context serialization, both serialize, CCM" \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001463 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001464 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1465 0 \
1466 -c "Deserializing connection..." \
1467 -s "Deserializing connection..."
1468
1469requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1470run_test "Context serialization, both serialize, ChaChaPoly" \
1471 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1472 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1473 0 \
1474 -c "Deserializing connection..." \
1475 -s "Deserializing connection..."
1476
1477requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1478run_test "Context serialization, both serialize, GCM" \
1479 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1480 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001481 0 \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001482 -c "Deserializing connection..." \
1483 -s "Deserializing connection..."
1484
1485requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001486requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1487run_test "Context serialization, both serialize, with CID" \
1488 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1489 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1490 0 \
1491 -c "Deserializing connection..." \
1492 -s "Deserializing connection..."
1493
1494requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001495run_test "Context serialization, re-init, client serializes, CCM" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001496 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001497 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1498 0 \
1499 -c "Deserializing connection..." \
1500 -S "Deserializing connection..."
1501
1502requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1503run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1504 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1505 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1506 0 \
1507 -c "Deserializing connection..." \
1508 -S "Deserializing connection..."
1509
1510requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1511run_test "Context serialization, re-init, client serializes, GCM" \
1512 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1513 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001514 0 \
1515 -c "Deserializing connection..." \
1516 -S "Deserializing connection..."
1517
1518requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001519requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1520run_test "Context serialization, re-init, client serializes, with CID" \
1521 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1522 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1523 0 \
1524 -c "Deserializing connection..." \
1525 -S "Deserializing connection..."
1526
1527requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001528run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001529 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001530 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1531 0 \
1532 -C "Deserializing connection..." \
1533 -s "Deserializing connection..."
1534
1535requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1536run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1537 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1538 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1539 0 \
1540 -C "Deserializing connection..." \
1541 -s "Deserializing connection..."
1542
1543requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1544run_test "Context serialization, re-init, server serializes, GCM" \
1545 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1546 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001547 0 \
1548 -C "Deserializing connection..." \
1549 -s "Deserializing connection..."
1550
1551requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001552requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1553run_test "Context serialization, re-init, server serializes, with CID" \
1554 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1555 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1556 0 \
1557 -C "Deserializing connection..." \
1558 -s "Deserializing connection..."
1559
1560requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001561run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001562 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001563 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1564 0 \
1565 -c "Deserializing connection..." \
1566 -s "Deserializing connection..."
1567
1568requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1569run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1570 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1571 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1572 0 \
1573 -c "Deserializing connection..." \
1574 -s "Deserializing connection..."
1575
1576requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1577run_test "Context serialization, re-init, both serialize, GCM" \
1578 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1579 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001580 0 \
1581 -c "Deserializing connection..." \
1582 -s "Deserializing connection..."
1583
Hanno Beckere80c1b02019-08-30 11:18:59 +01001584requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1585requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1586run_test "Context serialization, re-init, both serialize, with CID" \
1587 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1588 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001589 0 \
1590 -c "Deserializing connection..." \
Hanno Becker73455992019-04-25 17:01:43 +01001591 -s "Deserializing connection..."
Hanno Beckerc008cb52019-04-26 14:17:56 +01001592
Hanno Becker4eb05872019-04-26 16:00:29 +01001593# Tests for DTLS Connection ID extension
Hanno Beckercf2a5652019-04-26 16:13:31 +01001594
Hanno Becker5e2cd142019-04-26 16:23:52 +01001595# So far, the CID API isn't implemented, so we can't
1596# grep for output witnessing its use. This needs to be
Hanno Becker6a3ff282019-04-26 17:19:46 +01001597# changed once the CID extension is implemented.
Hanno Beckerad8e2c92019-05-08 13:19:53 +01001598
Hanno Becker2dcdc922019-04-09 18:08:47 +01001599requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckera5a2b082019-05-15 14:03:01 +01001600run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001601 "$P_SRV debug_level=3 dtls=1 cid=0" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03001602 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=dead" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001603 0 \
1604 -s "Disable use of CID extension." \
1605 -s "found CID extension" \
1606 -s "Client sent CID extension, but CID disabled" \
1607 -c "Enable use of CID extension." \
1608 -c "client hello, adding CID extension" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001609 -S "server hello, adding CID extension" \
1610 -C "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001611 -S "Copy CIDs into SSL transform" \
1612 -C "Copy CIDs into SSL transform" \
1613 -c "Use of Connection ID was rejected by the server"
1614
1615requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1616run_test "Connection ID: Cli disabled, Srv enabled" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03001617 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001618 "$P_CLI debug_level=3 dtls=1 cid=0" \
1619 0 \
1620 -c "Disable use of CID extension." \
1621 -C "client hello, adding CID extension" \
1622 -S "found CID extension" \
1623 -s "Enable use of CID extension." \
1624 -S "server hello, adding CID extension" \
1625 -C "found CID extension" \
1626 -S "Copy CIDs into SSL transform" \
1627 -C "Copy CIDs into SSL transform" \
1628 -s "Use of Connection ID was not offered by client"
1629
1630requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb60c85c2019-04-23 12:02:34 +01001631run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001632 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1633 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1634 0 \
1635 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001636 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001637 -c "client hello, adding CID extension" \
1638 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001639 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001640 -s "server hello, adding CID extension" \
1641 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001642 -c "Use of CID extension negotiated" \
1643 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001644 -c "Copy CIDs into SSL transform" \
1645 -c "Peer CID (length 2 Bytes): de ad" \
1646 -s "Peer CID (length 2 Bytes): be ef" \
1647 -s "Use of Connection ID has been negotiated" \
1648 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001649
Hanno Beckera5a2b082019-05-15 14:03:01 +01001650requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001651run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001652 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001653 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1654 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1655 0 \
1656 -c "Enable use of CID extension." \
1657 -s "Enable use of CID extension." \
1658 -c "client hello, adding CID extension" \
1659 -s "found CID extension" \
1660 -s "Use of CID extension negotiated" \
1661 -s "server hello, adding CID extension" \
1662 -c "found CID extension" \
1663 -c "Use of CID extension negotiated" \
1664 -s "Copy CIDs into SSL transform" \
1665 -c "Copy CIDs into SSL transform" \
1666 -c "Peer CID (length 2 Bytes): de ad" \
1667 -s "Peer CID (length 2 Bytes): be ef" \
1668 -s "Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001669 -c "Use of Connection ID has been negotiated" \
1670 -c "ignoring unexpected CID" \
1671 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01001672
Hanno Beckera5a2b082019-05-15 14:03:01 +01001673requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001674run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1675 -p "$P_PXY mtu=800" \
1676 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1677 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1678 0 \
1679 -c "Enable use of CID extension." \
1680 -s "Enable use of CID extension." \
1681 -c "client hello, adding CID extension" \
1682 -s "found CID extension" \
1683 -s "Use of CID extension negotiated" \
1684 -s "server hello, adding CID extension" \
1685 -c "found CID extension" \
1686 -c "Use of CID extension negotiated" \
1687 -s "Copy CIDs into SSL transform" \
1688 -c "Copy CIDs into SSL transform" \
1689 -c "Peer CID (length 2 Bytes): de ad" \
1690 -s "Peer CID (length 2 Bytes): be ef" \
1691 -s "Use of Connection ID has been negotiated" \
1692 -c "Use of Connection ID has been negotiated"
1693
Hanno Beckera5a2b082019-05-15 14:03:01 +01001694requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001695run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001696 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001697 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1698 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1699 0 \
1700 -c "Enable use of CID extension." \
1701 -s "Enable use of CID extension." \
1702 -c "client hello, adding CID extension" \
1703 -s "found CID extension" \
1704 -s "Use of CID extension negotiated" \
1705 -s "server hello, adding CID extension" \
1706 -c "found CID extension" \
1707 -c "Use of CID extension negotiated" \
1708 -s "Copy CIDs into SSL transform" \
1709 -c "Copy CIDs into SSL transform" \
1710 -c "Peer CID (length 2 Bytes): de ad" \
1711 -s "Peer CID (length 2 Bytes): be ef" \
1712 -s "Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001713 -c "Use of Connection ID has been negotiated" \
1714 -c "ignoring unexpected CID" \
1715 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01001716
Hanno Beckera5a2b082019-05-15 14:03:01 +01001717requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001718requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001719run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001720 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1721 "$P_CLI debug_level=3 dtls=1 cid=1" \
1722 0 \
1723 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001724 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001725 -c "client hello, adding CID extension" \
1726 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001727 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001728 -s "server hello, adding CID extension" \
1729 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001730 -c "Use of CID extension negotiated" \
1731 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001732 -c "Copy CIDs into SSL transform" \
1733 -c "Peer CID (length 4 Bytes): de ad be ef" \
1734 -s "Peer CID (length 0 Bytes):" \
1735 -s "Use of Connection ID has been negotiated" \
1736 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001737
Hanno Beckera5a2b082019-05-15 14:03:01 +01001738requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001739requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001740run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001741 "$P_SRV debug_level=3 dtls=1 cid=1" \
1742 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1743 0 \
1744 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001745 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001746 -c "client hello, adding CID extension" \
1747 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001748 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001749 -s "server hello, adding CID extension" \
1750 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001751 -c "Use of CID extension negotiated" \
1752 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001753 -c "Copy CIDs into SSL transform" \
1754 -s "Peer CID (length 4 Bytes): de ad be ef" \
1755 -c "Peer CID (length 0 Bytes):" \
1756 -s "Use of Connection ID has been negotiated" \
1757 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001758
Hanno Beckera5a2b082019-05-15 14:03:01 +01001759requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001760requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001761run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001762 "$P_SRV debug_level=3 dtls=1 cid=1" \
1763 "$P_CLI debug_level=3 dtls=1 cid=1" \
1764 0 \
1765 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001766 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001767 -c "client hello, adding CID extension" \
1768 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001769 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001770 -s "server hello, adding CID extension" \
1771 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001772 -c "Use of CID extension negotiated" \
1773 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001774 -c "Copy CIDs into SSL transform" \
1775 -S "Use of Connection ID has been negotiated" \
1776 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001777
Hanno Beckera5a2b082019-05-15 14:03:01 +01001778requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001779run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001780 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1781 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1782 0 \
1783 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001784 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001785 -c "client hello, adding CID extension" \
1786 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001787 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001788 -s "server hello, adding CID extension" \
1789 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001790 -c "Use of CID extension negotiated" \
1791 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001792 -c "Copy CIDs into SSL transform" \
1793 -c "Peer CID (length 2 Bytes): de ad" \
1794 -s "Peer CID (length 2 Bytes): be ef" \
1795 -s "Use of Connection ID has been negotiated" \
1796 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001797
Hanno Beckera5a2b082019-05-15 14:03:01 +01001798requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001799requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001800run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001801 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1802 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1803 0 \
1804 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001805 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001806 -c "client hello, adding CID extension" \
1807 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001808 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001809 -s "server hello, adding CID extension" \
1810 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001811 -c "Use of CID extension negotiated" \
1812 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001813 -c "Copy CIDs into SSL transform" \
1814 -c "Peer CID (length 4 Bytes): de ad be ef" \
1815 -s "Peer CID (length 0 Bytes):" \
1816 -s "Use of Connection ID has been negotiated" \
1817 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001818
Hanno Beckera5a2b082019-05-15 14:03:01 +01001819requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001820requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001821run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001822 "$P_SRV debug_level=3 dtls=1 cid=1" \
1823 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1824 0 \
1825 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001826 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001827 -c "client hello, adding CID extension" \
1828 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001829 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001830 -s "server hello, adding CID extension" \
1831 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001832 -c "Use of CID extension negotiated" \
1833 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001834 -c "Copy CIDs into SSL transform" \
1835 -s "Peer CID (length 4 Bytes): de ad be ef" \
1836 -c "Peer CID (length 0 Bytes):" \
1837 -s "Use of Connection ID has been negotiated" \
1838 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001839
Hanno Beckera5a2b082019-05-15 14:03:01 +01001840requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001841requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001842run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001843 "$P_SRV debug_level=3 dtls=1 cid=1" \
1844 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1845 0 \
1846 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001847 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001848 -c "client hello, adding CID extension" \
1849 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001850 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001851 -s "server hello, adding CID extension" \
1852 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001853 -c "Use of CID extension negotiated" \
1854 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001855 -c "Copy CIDs into SSL transform" \
1856 -S "Use of Connection ID has been negotiated" \
1857 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001858
Hanno Beckera5a2b082019-05-15 14:03:01 +01001859requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001860requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001861run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001862 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1863 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1864 0 \
1865 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001866 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001867 -c "client hello, adding CID extension" \
1868 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001869 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001870 -s "server hello, adding CID extension" \
1871 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001872 -c "Use of CID extension negotiated" \
1873 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001874 -c "Copy CIDs into SSL transform" \
1875 -c "Peer CID (length 2 Bytes): de ad" \
1876 -s "Peer CID (length 2 Bytes): be ef" \
1877 -s "Use of Connection ID has been negotiated" \
1878 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001879
Hanno Beckera5a2b082019-05-15 14:03:01 +01001880requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001881requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1882requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001883run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001884 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1885 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1886 0 \
1887 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001888 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001889 -c "client hello, adding CID extension" \
1890 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001891 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001892 -s "server hello, adding CID extension" \
1893 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001894 -c "Use of CID extension negotiated" \
1895 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001896 -c "Copy CIDs into SSL transform" \
1897 -c "Peer CID (length 4 Bytes): de ad be ef" \
1898 -s "Peer CID (length 0 Bytes):" \
1899 -s "Use of Connection ID has been negotiated" \
1900 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001901
Hanno Beckera5a2b082019-05-15 14:03:01 +01001902requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001903requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1904requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001905run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001906 "$P_SRV debug_level=3 dtls=1 cid=1" \
1907 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1908 0 \
1909 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001910 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001911 -c "client hello, adding CID extension" \
1912 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001913 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001914 -s "server hello, adding CID extension" \
1915 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001916 -c "Use of CID extension negotiated" \
1917 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001918 -c "Copy CIDs into SSL transform" \
1919 -s "Peer CID (length 4 Bytes): de ad be ef" \
1920 -c "Peer CID (length 0 Bytes):" \
1921 -s "Use of Connection ID has been negotiated" \
1922 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001923
Hanno Beckera5a2b082019-05-15 14:03:01 +01001924requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001925requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1926requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001927run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001928 "$P_SRV debug_level=3 dtls=1 cid=1" \
1929 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1930 0 \
1931 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001932 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001933 -c "client hello, adding CID extension" \
1934 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001935 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001936 -s "server hello, adding CID extension" \
1937 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001938 -c "Use of CID extension negotiated" \
1939 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001940 -c "Copy CIDs into SSL transform" \
1941 -S "Use of Connection ID has been negotiated" \
1942 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001943
Hanno Beckera5a2b082019-05-15 14:03:01 +01001944requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker963cb352019-04-23 11:52:44 +01001945requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001946run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001947 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1948 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1949 0 \
Hanno Becker96870292019-05-03 17:30:59 +01001950 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1951 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1952 -s "(initial handshake) Use of Connection ID has been negotiated" \
1953 -c "(initial handshake) Use of Connection ID has been negotiated" \
1954 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1955 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1956 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1957 -c "(after renegotiation) Use of Connection ID has been negotiated"
1958
Hanno Beckera5a2b082019-05-15 14:03:01 +01001959requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001960requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001961run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Becker96870292019-05-03 17:30:59 +01001962 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
1963 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1964 0 \
1965 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1966 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1967 -s "(initial handshake) Use of Connection ID has been negotiated" \
1968 -c "(initial handshake) Use of Connection ID has been negotiated" \
1969 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1970 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1971 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1972 -c "(after renegotiation) Use of Connection ID has been negotiated"
1973
Hanno Beckera5a2b082019-05-15 14:03:01 +01001974requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001975requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01001976run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
1977 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
1978 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1979 0 \
1980 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1981 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1982 -s "(initial handshake) Use of Connection ID has been negotiated" \
1983 -c "(initial handshake) Use of Connection ID has been negotiated" \
1984 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1985 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1986 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1987 -c "(after renegotiation) Use of Connection ID has been negotiated"
1988
Hanno Beckera5a2b082019-05-15 14:03:01 +01001989requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01001990requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001991run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001992 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001993 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
1994 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1995 0 \
1996 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1997 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1998 -s "(initial handshake) Use of Connection ID has been negotiated" \
1999 -c "(initial handshake) Use of Connection ID has been negotiated" \
2000 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2001 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2002 -s "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002003 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2004 -c "ignoring unexpected CID" \
2005 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002006
Hanno Beckera5a2b082019-05-15 14:03:01 +01002007requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002008requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2009run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Becker96870292019-05-03 17:30:59 +01002010 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2011 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2012 0 \
2013 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2014 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2015 -s "(initial handshake) Use of Connection ID has been negotiated" \
2016 -c "(initial handshake) Use of Connection ID has been negotiated" \
2017 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2018 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2019 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2020 -S "(after renegotiation) Use of Connection ID has been negotiated"
2021
Hanno Beckera5a2b082019-05-15 14:03:01 +01002022requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002023requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01002024run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
2025 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2026 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2027 0 \
2028 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2029 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2030 -s "(initial handshake) Use of Connection ID has been negotiated" \
2031 -c "(initial handshake) Use of Connection ID has been negotiated" \
2032 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2033 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2034 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2035 -S "(after renegotiation) Use of Connection ID has been negotiated"
2036
Hanno Beckera5a2b082019-05-15 14:03:01 +01002037requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01002038requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002039run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002040 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002041 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2042 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2043 0 \
2044 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2045 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2046 -s "(initial handshake) Use of Connection ID has been negotiated" \
2047 -c "(initial handshake) Use of Connection ID has been negotiated" \
2048 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2049 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2050 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002051 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2052 -c "ignoring unexpected CID" \
2053 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002054
Hanno Beckera5a2b082019-05-15 14:03:01 +01002055requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002056requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2057run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002058 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2059 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2060 0 \
2061 -S "(initial handshake) Use of Connection ID has been negotiated" \
2062 -C "(initial handshake) Use of Connection ID has been negotiated" \
2063 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2064 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2065 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2066 -s "(after renegotiation) Use of Connection ID has been negotiated"
2067
Hanno Beckera5a2b082019-05-15 14:03:01 +01002068requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002069requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01002070run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2071 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2072 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2073 0 \
2074 -S "(initial handshake) Use of Connection ID has been negotiated" \
2075 -C "(initial handshake) Use of Connection ID has been negotiated" \
2076 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2077 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2078 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2079 -s "(after renegotiation) Use of Connection ID has been negotiated"
2080
Hanno Beckera5a2b082019-05-15 14:03:01 +01002081requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01002082requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002083run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002084 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002085 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2086 "$P_CLI debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2087 0 \
2088 -S "(initial handshake) Use of Connection ID has been negotiated" \
2089 -C "(initial handshake) Use of Connection ID has been negotiated" \
2090 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2091 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2092 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002093 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2094 -c "ignoring unexpected CID" \
2095 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002096
Hanno Beckera5a2b082019-05-15 14:03:01 +01002097requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002098requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2099run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002100 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2101 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2102 0 \
2103 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2104 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2105 -s "(initial handshake) Use of Connection ID has been negotiated" \
2106 -c "(initial handshake) Use of Connection ID has been negotiated" \
2107 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2108 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2109 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2110 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2111 -s "(after renegotiation) Use of Connection ID was not offered by client"
2112
Hanno Beckera5a2b082019-05-15 14:03:01 +01002113requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002114requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002115run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002116 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002117 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2118 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2119 0 \
2120 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2121 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2122 -s "(initial handshake) Use of Connection ID has been negotiated" \
2123 -c "(initial handshake) Use of Connection ID has been negotiated" \
2124 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2125 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2126 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2127 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002128 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2129 -c "ignoring unexpected CID" \
2130 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002131
Hanno Beckera5a2b082019-05-15 14:03:01 +01002132requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002133requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2134run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2135 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2136 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2137 0 \
2138 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2139 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2140 -s "(initial handshake) Use of Connection ID has been negotiated" \
2141 -c "(initial handshake) Use of Connection ID has been negotiated" \
2142 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2143 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2144 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2145 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2146 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2147
Hanno Beckera5a2b082019-05-15 14:03:01 +01002148requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002149requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2150run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002151 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker96870292019-05-03 17:30:59 +01002152 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2153 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2154 0 \
2155 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2156 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2157 -s "(initial handshake) Use of Connection ID has been negotiated" \
2158 -c "(initial handshake) Use of Connection ID has been negotiated" \
2159 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2160 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2161 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2162 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002163 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2164 -c "ignoring unexpected CID" \
2165 -s "ignoring unexpected CID"
Hanno Becker2dcdc922019-04-09 18:08:47 +01002166
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002167# Tests for Encrypt-then-MAC extension
2168
2169run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002170 "$P_SRV debug_level=3 \
2171 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002172 "$P_CLI debug_level=3" \
2173 0 \
2174 -c "client hello, adding encrypt_then_mac extension" \
2175 -s "found encrypt then mac extension" \
2176 -s "server hello, adding encrypt then mac extension" \
2177 -c "found encrypt_then_mac extension" \
2178 -c "using encrypt then mac" \
2179 -s "using encrypt then mac"
2180
2181run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002182 "$P_SRV debug_level=3 etm=0 \
2183 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002184 "$P_CLI debug_level=3 etm=1" \
2185 0 \
2186 -c "client hello, adding encrypt_then_mac extension" \
2187 -s "found encrypt then mac extension" \
2188 -S "server hello, adding encrypt then mac extension" \
2189 -C "found encrypt_then_mac extension" \
2190 -C "using encrypt then mac" \
2191 -S "using encrypt then mac"
2192
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002193run_test "Encrypt then MAC: client enabled, aead cipher" \
2194 "$P_SRV debug_level=3 etm=1 \
2195 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2196 "$P_CLI debug_level=3 etm=1" \
2197 0 \
2198 -c "client hello, adding encrypt_then_mac extension" \
2199 -s "found encrypt then mac extension" \
2200 -S "server hello, adding encrypt then mac extension" \
2201 -C "found encrypt_then_mac extension" \
2202 -C "using encrypt then mac" \
2203 -S "using encrypt then mac"
2204
2205run_test "Encrypt then MAC: client enabled, stream cipher" \
2206 "$P_SRV debug_level=3 etm=1 \
2207 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002208 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002209 0 \
2210 -c "client hello, adding encrypt_then_mac extension" \
2211 -s "found encrypt then mac extension" \
2212 -S "server hello, adding encrypt then mac extension" \
2213 -C "found encrypt_then_mac extension" \
2214 -C "using encrypt then mac" \
2215 -S "using encrypt then mac"
2216
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002217run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002218 "$P_SRV debug_level=3 etm=1 \
2219 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002220 "$P_CLI debug_level=3 etm=0" \
2221 0 \
2222 -C "client hello, adding encrypt_then_mac extension" \
2223 -S "found encrypt then mac extension" \
2224 -S "server hello, adding encrypt then mac extension" \
2225 -C "found encrypt_then_mac extension" \
2226 -C "using encrypt then mac" \
2227 -S "using encrypt then mac"
2228
Janos Follathe2681a42016-03-07 15:57:05 +00002229requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002230run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002231 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002232 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002233 "$P_CLI debug_level=3 force_version=ssl3" \
2234 0 \
2235 -C "client hello, adding encrypt_then_mac extension" \
2236 -S "found encrypt then mac extension" \
2237 -S "server hello, adding encrypt then mac extension" \
2238 -C "found encrypt_then_mac extension" \
2239 -C "using encrypt then mac" \
2240 -S "using encrypt then mac"
2241
Janos Follathe2681a42016-03-07 15:57:05 +00002242requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002243run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002244 "$P_SRV debug_level=3 force_version=ssl3 \
2245 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002246 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002247 0 \
2248 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002249 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002250 -S "server hello, adding encrypt then mac extension" \
2251 -C "found encrypt_then_mac extension" \
2252 -C "using encrypt then mac" \
2253 -S "using encrypt then mac"
2254
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002255# Tests for Extended Master Secret extension
2256
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002257run_test "Extended Master Secret: default (not enforcing)" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002258 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0 " \
2259 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002260 0 \
2261 -c "client hello, adding extended_master_secret extension" \
2262 -s "found extended master secret extension" \
2263 -s "server hello, adding extended master secret extension" \
2264 -c "found extended_master_secret extension" \
2265 -c "session hash for extended master secret" \
2266 -s "session hash for extended master secret"
2267
2268run_test "Extended Master Secret: both enabled, both enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002269 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2270 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002271 0 \
2272 -c "client hello, adding extended_master_secret extension" \
2273 -s "found extended master secret extension" \
2274 -s "server hello, adding extended master secret extension" \
2275 -c "found extended_master_secret extension" \
2276 -c "session hash for extended master secret" \
2277 -s "session hash for extended master secret"
2278
Jarno Lamsa20095af2019-06-11 17:16:58 +03002279run_test "Extended Master Secret: both enabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002280 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2281 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002282 0 \
2283 -c "client hello, adding extended_master_secret extension" \
2284 -s "found extended master secret extension" \
2285 -s "server hello, adding extended master secret extension" \
2286 -c "found extended_master_secret extension" \
2287 -c "session hash for extended master secret" \
2288 -s "session hash for extended master secret"
2289
2290run_test "Extended Master Secret: both enabled, server enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002291 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2292 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002293 0 \
2294 -c "client hello, adding extended_master_secret extension" \
2295 -s "found extended master secret extension" \
2296 -s "server hello, adding extended master secret extension" \
2297 -c "found extended_master_secret extension" \
2298 -c "session hash for extended master secret" \
2299 -s "session hash for extended master secret"
2300
2301run_test "Extended Master Secret: client enabled, server disabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002302 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002303 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2304 1 \
2305 -c "client hello, adding extended_master_secret extension" \
2306 -s "found extended master secret extension" \
2307 -S "server hello, adding extended master secret extension" \
2308 -C "found extended_master_secret extension" \
2309 -c "Peer not offering extended master secret, while it is enforced"
2310
Jarno Lamsa20095af2019-06-11 17:16:58 +03002311run_test "Extended Master Secret enforced: client disabled, server enabled, server enforcing" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002312 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002313 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002314 1 \
2315 -C "client hello, adding extended_master_secret extension" \
2316 -S "found extended master secret extension" \
2317 -S "server hello, adding extended master secret extension" \
2318 -C "found extended_master_secret extension" \
2319 -s "Peer not offering extended master secret, while it is enforced"
2320
Jarno Lamsa20095af2019-06-11 17:16:58 +03002321run_test "Extended Master Secret: client enabled, server disabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002322 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2323 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002324 0 \
2325 -c "client hello, adding extended_master_secret extension" \
2326 -s "found extended master secret extension" \
2327 -S "server hello, adding extended master secret extension" \
2328 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002329 -C "session hash for extended master secret" \
2330 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002331
Jarno Lamsa20095af2019-06-11 17:16:58 +03002332run_test "Extended Master Secret: client disabled, server enabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002333 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2334 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002335 0 \
2336 -C "client hello, adding extended_master_secret extension" \
2337 -S "found extended master secret extension" \
2338 -S "server hello, adding extended master secret extension" \
2339 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002340 -C "session hash for extended master secret" \
2341 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002342
Jarno Lamsa20095af2019-06-11 17:16:58 +03002343run_test "Extended Master Secret: client disabled, server disabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002344 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2345 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002346 0 \
2347 -C "client hello, adding extended_master_secret extension" \
2348 -S "found extended master secret extension" \
2349 -S "server hello, adding extended master secret extension" \
2350 -C "found extended_master_secret extension" \
2351 -C "session hash for extended master secret" \
2352 -S "session hash for extended master secret"
2353
Janos Follathe2681a42016-03-07 15:57:05 +00002354requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002355run_test "Extended Master Secret: client SSLv3, server enabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002356 "$P_SRV debug_level=3 min_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2357 "$P_CLI debug_level=3 force_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002358 0 \
2359 -C "client hello, adding extended_master_secret extension" \
2360 -S "found extended master secret extension" \
2361 -S "server hello, adding extended master secret extension" \
2362 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002363 -C "session hash for extended master secret" \
2364 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002365
Janos Follathe2681a42016-03-07 15:57:05 +00002366requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002367run_test "Extended Master Secret: client enabled, server SSLv3" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002368 "$P_SRV debug_level=3 force_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2369 "$P_CLI debug_level=3 min_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002370 0 \
2371 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002372 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002373 -S "server hello, adding extended master secret extension" \
2374 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002375 -C "session hash for extended master secret" \
2376 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002377
Jarno Lamsaff434c22019-10-25 12:21:54 +03002378run_test "Extended Master Secret: both enabled, both enforcing, DTLS" \
2379 "$P_SRV dtls=1 debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2380 "$P_CLI dtls=1 debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2381 0 \
2382 -c "client hello, adding extended_master_secret extension" \
2383 -s "found extended master secret extension" \
2384 -s "server hello, adding extended master secret extension" \
2385 -c "found extended_master_secret extension" \
2386 -c "session hash for extended master secret" \
2387 -s "session hash for extended master secret"
2388
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002389# Tests for FALLBACK_SCSV
2390
2391run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002392 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002393 "$P_CLI debug_level=3 force_version=tls1_1" \
2394 0 \
2395 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002396 -S "received FALLBACK_SCSV" \
2397 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002398 -C "is a fatal alert message (msg 86)"
2399
2400run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002401 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002402 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2403 0 \
2404 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002405 -S "received FALLBACK_SCSV" \
2406 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002407 -C "is a fatal alert message (msg 86)"
2408
2409run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002410 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002411 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002412 1 \
2413 -c "adding FALLBACK_SCSV" \
2414 -s "received FALLBACK_SCSV" \
2415 -s "inapropriate fallback" \
2416 -c "is a fatal alert message (msg 86)"
2417
2418run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002419 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002420 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002421 0 \
2422 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002423 -s "received FALLBACK_SCSV" \
2424 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002425 -C "is a fatal alert message (msg 86)"
2426
2427requires_openssl_with_fallback_scsv
2428run_test "Fallback SCSV: default, openssl server" \
2429 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002430 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002431 0 \
2432 -C "adding FALLBACK_SCSV" \
2433 -C "is a fatal alert message (msg 86)"
2434
2435requires_openssl_with_fallback_scsv
2436run_test "Fallback SCSV: enabled, openssl server" \
2437 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002438 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002439 1 \
2440 -c "adding FALLBACK_SCSV" \
2441 -c "is a fatal alert message (msg 86)"
2442
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002443requires_openssl_with_fallback_scsv
2444run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002445 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002446 "$O_CLI -tls1_1" \
2447 0 \
2448 -S "received FALLBACK_SCSV" \
2449 -S "inapropriate fallback"
2450
2451requires_openssl_with_fallback_scsv
2452run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002453 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002454 "$O_CLI -tls1_1 -fallback_scsv" \
2455 1 \
2456 -s "received FALLBACK_SCSV" \
2457 -s "inapropriate fallback"
2458
2459requires_openssl_with_fallback_scsv
2460run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002461 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002462 "$O_CLI -fallback_scsv" \
2463 0 \
2464 -s "received FALLBACK_SCSV" \
2465 -S "inapropriate fallback"
2466
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002467# Test sending and receiving empty application data records
2468
2469run_test "Encrypt then MAC: empty application data record" \
2470 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2471 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2472 0 \
2473 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2474 -s "dumping 'input payload after decrypt' (0 bytes)" \
2475 -c "0 bytes written in 1 fragments"
2476
2477run_test "Default, no Encrypt then MAC: empty application data record" \
2478 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2479 "$P_CLI auth_mode=none etm=0 request_size=0" \
2480 0 \
2481 -s "dumping 'input payload after decrypt' (0 bytes)" \
2482 -c "0 bytes written in 1 fragments"
2483
2484run_test "Encrypt then MAC, DTLS: empty application data record" \
2485 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2486 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2487 0 \
2488 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2489 -s "dumping 'input payload after decrypt' (0 bytes)" \
2490 -c "0 bytes written in 1 fragments"
2491
2492run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
2493 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2494 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2495 0 \
2496 -s "dumping 'input payload after decrypt' (0 bytes)" \
2497 -c "0 bytes written in 1 fragments"
2498
Gilles Peskined50177f2017-05-16 17:53:03 +02002499## ClientHello generated with
2500## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2501## then manually twiddling the ciphersuite list.
2502## The ClientHello content is spelled out below as a hex string as
2503## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2504## The expected response is an inappropriate_fallback alert.
2505requires_openssl_with_fallback_scsv
2506run_test "Fallback SCSV: beginning of list" \
2507 "$P_SRV debug_level=2" \
2508 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2509 0 \
2510 -s "received FALLBACK_SCSV" \
2511 -s "inapropriate fallback"
2512
2513requires_openssl_with_fallback_scsv
2514run_test "Fallback SCSV: end of list" \
2515 "$P_SRV debug_level=2" \
2516 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2517 0 \
2518 -s "received FALLBACK_SCSV" \
2519 -s "inapropriate fallback"
2520
2521## Here the expected response is a valid ServerHello prefix, up to the random.
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02002522## Due to the way the clienthello was generated, this currently needs the
2523## server to have support for session tickets.
2524requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Gilles Peskined50177f2017-05-16 17:53:03 +02002525requires_openssl_with_fallback_scsv
2526run_test "Fallback SCSV: not in list" \
2527 "$P_SRV debug_level=2" \
2528 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2529 0 \
2530 -S "received FALLBACK_SCSV" \
2531 -S "inapropriate fallback"
2532
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002533# Tests for CBC 1/n-1 record splitting
2534
2535run_test "CBC Record splitting: TLS 1.2, no splitting" \
2536 "$P_SRV" \
2537 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2538 request_size=123 force_version=tls1_2" \
2539 0 \
2540 -s "Read from client: 123 bytes read" \
2541 -S "Read from client: 1 bytes read" \
2542 -S "122 bytes read"
2543
2544run_test "CBC Record splitting: TLS 1.1, no splitting" \
2545 "$P_SRV" \
2546 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2547 request_size=123 force_version=tls1_1" \
2548 0 \
2549 -s "Read from client: 123 bytes read" \
2550 -S "Read from client: 1 bytes read" \
2551 -S "122 bytes read"
2552
2553run_test "CBC Record splitting: TLS 1.0, splitting" \
2554 "$P_SRV" \
2555 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2556 request_size=123 force_version=tls1" \
2557 0 \
2558 -S "Read from client: 123 bytes read" \
2559 -s "Read from client: 1 bytes read" \
2560 -s "122 bytes read"
2561
Janos Follathe2681a42016-03-07 15:57:05 +00002562requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002563run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002564 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002565 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2566 request_size=123 force_version=ssl3" \
2567 0 \
2568 -S "Read from client: 123 bytes read" \
2569 -s "Read from client: 1 bytes read" \
2570 -s "122 bytes read"
2571
2572run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002573 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002574 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2575 request_size=123 force_version=tls1" \
2576 0 \
2577 -s "Read from client: 123 bytes read" \
2578 -S "Read from client: 1 bytes read" \
2579 -S "122 bytes read"
2580
2581run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2582 "$P_SRV" \
2583 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2584 request_size=123 force_version=tls1 recsplit=0" \
2585 0 \
2586 -s "Read from client: 123 bytes read" \
2587 -S "Read from client: 1 bytes read" \
2588 -S "122 bytes read"
2589
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002590run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2591 "$P_SRV nbio=2" \
2592 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2593 request_size=123 force_version=tls1" \
2594 0 \
2595 -S "Read from client: 123 bytes read" \
2596 -s "Read from client: 1 bytes read" \
2597 -s "122 bytes read"
2598
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002599# Tests for Session Tickets
2600
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002601requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002602requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002603run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002604 "$P_SRV debug_level=3 tickets=1" \
2605 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002606 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002607 -c "client hello, adding session ticket extension" \
2608 -s "found session ticket extension" \
2609 -s "server hello, adding session ticket extension" \
2610 -c "found session_ticket extension" \
2611 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002612 -S "session successfully restored from cache" \
2613 -s "session successfully restored from ticket" \
2614 -s "a session has been resumed" \
2615 -c "a session has been resumed"
2616
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002617requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002618requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002619run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002620 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2621 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002622 0 \
2623 -c "client hello, adding session ticket extension" \
2624 -s "found session ticket extension" \
2625 -s "server hello, adding session ticket extension" \
2626 -c "found session_ticket extension" \
2627 -c "parse new session ticket" \
2628 -S "session successfully restored from cache" \
2629 -s "session successfully restored from ticket" \
2630 -s "a session has been resumed" \
2631 -c "a session has been resumed"
2632
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002633requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002634requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002635run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002636 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2637 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002638 0 \
2639 -c "client hello, adding session ticket extension" \
2640 -s "found session ticket extension" \
2641 -s "server hello, adding session ticket extension" \
2642 -c "found session_ticket extension" \
2643 -c "parse new session ticket" \
2644 -S "session successfully restored from cache" \
2645 -S "session successfully restored from ticket" \
2646 -S "a session has been resumed" \
2647 -C "a session has been resumed"
2648
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002649requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002650requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002651run_test "Session resume using tickets: session copy" \
2652 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2653 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2654 0 \
2655 -c "client hello, adding session ticket extension" \
2656 -s "found session ticket extension" \
2657 -s "server hello, adding session ticket extension" \
2658 -c "found session_ticket extension" \
2659 -c "parse new session ticket" \
2660 -S "session successfully restored from cache" \
2661 -s "session successfully restored from ticket" \
2662 -s "a session has been resumed" \
2663 -c "a session has been resumed"
2664
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002665requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002666requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002667run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002668 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002669 "$P_CLI debug_level=3 tickets=1 reconnect=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002670 0 \
2671 -c "client hello, adding session ticket extension" \
2672 -c "found session_ticket extension" \
2673 -c "parse new session ticket" \
2674 -c "a session has been resumed"
2675
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002676requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002677requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002678run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002679 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002680 "( $O_CLI -sess_out $SESSION; \
2681 $O_CLI -sess_in $SESSION; \
2682 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002683 0 \
2684 -s "found session ticket extension" \
2685 -s "server hello, adding session ticket extension" \
2686 -S "session successfully restored from cache" \
2687 -s "session successfully restored from ticket" \
2688 -s "a session has been resumed"
2689
Hanno Becker1d739932018-08-21 13:55:22 +01002690# Tests for Session Tickets with DTLS
2691
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002692requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002693requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002694run_test "Session resume using tickets, DTLS: basic" \
2695 "$P_SRV debug_level=3 dtls=1 tickets=1" \
2696 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2697 0 \
2698 -c "client hello, adding session ticket extension" \
2699 -s "found session ticket extension" \
2700 -s "server hello, adding session ticket extension" \
2701 -c "found session_ticket extension" \
2702 -c "parse new session ticket" \
2703 -S "session successfully restored from cache" \
2704 -s "session successfully restored from ticket" \
2705 -s "a session has been resumed" \
2706 -c "a session has been resumed"
2707
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002708requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002709requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002710run_test "Session resume using tickets, DTLS: cache disabled" \
2711 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2712 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2713 0 \
2714 -c "client hello, adding session ticket extension" \
2715 -s "found session ticket extension" \
2716 -s "server hello, adding session ticket extension" \
2717 -c "found session_ticket extension" \
2718 -c "parse new session ticket" \
2719 -S "session successfully restored from cache" \
2720 -s "session successfully restored from ticket" \
2721 -s "a session has been resumed" \
2722 -c "a session has been resumed"
2723
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002724requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002725requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002726run_test "Session resume using tickets, DTLS: timeout" \
2727 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
2728 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \
2729 0 \
2730 -c "client hello, adding session ticket extension" \
2731 -s "found session ticket extension" \
2732 -s "server hello, adding session ticket extension" \
2733 -c "found session_ticket extension" \
2734 -c "parse new session ticket" \
2735 -S "session successfully restored from cache" \
2736 -S "session successfully restored from ticket" \
2737 -S "a session has been resumed" \
2738 -C "a session has been resumed"
2739
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002740requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002741requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002742run_test "Session resume using tickets, DTLS: session copy" \
2743 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2744 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_mode=0" \
2745 0 \
2746 -c "client hello, adding session ticket extension" \
2747 -s "found session ticket extension" \
2748 -s "server hello, adding session ticket extension" \
2749 -c "found session_ticket extension" \
2750 -c "parse new session ticket" \
2751 -S "session successfully restored from cache" \
2752 -s "session successfully restored from ticket" \
2753 -s "a session has been resumed" \
2754 -c "a session has been resumed"
2755
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002756requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002757requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002758run_test "Session resume using tickets, DTLS: openssl server" \
2759 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002760 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 ca_file=data_files/test-ca2.crt" \
Hanno Becker1d739932018-08-21 13:55:22 +01002761 0 \
2762 -c "client hello, adding session ticket extension" \
2763 -c "found session_ticket extension" \
2764 -c "parse new session ticket" \
2765 -c "a session has been resumed"
2766
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002767requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002768requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002769run_test "Session resume using tickets, DTLS: openssl client" \
2770 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2771 "( $O_CLI -dtls1 -sess_out $SESSION; \
2772 $O_CLI -dtls1 -sess_in $SESSION; \
2773 rm -f $SESSION )" \
2774 0 \
2775 -s "found session ticket extension" \
2776 -s "server hello, adding session ticket extension" \
2777 -S "session successfully restored from cache" \
2778 -s "session successfully restored from ticket" \
2779 -s "a session has been resumed"
2780
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002781# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002782
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002783requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002784requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002785requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002786run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002787 "$P_SRV debug_level=3 tickets=0" \
2788 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002789 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002790 -c "client hello, adding session ticket extension" \
2791 -s "found session ticket extension" \
2792 -S "server hello, adding session ticket extension" \
2793 -C "found session_ticket extension" \
2794 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002795 -s "session successfully restored from cache" \
2796 -S "session successfully restored from ticket" \
2797 -s "a session has been resumed" \
2798 -c "a session has been resumed"
2799
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002800requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002801requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002802requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002803run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002804 "$P_SRV debug_level=3 tickets=1" \
2805 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002806 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002807 -C "client hello, adding session ticket extension" \
2808 -S "found session ticket extension" \
2809 -S "server hello, adding session ticket extension" \
2810 -C "found session_ticket extension" \
2811 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002812 -s "session successfully restored from cache" \
2813 -S "session successfully restored from ticket" \
2814 -s "a session has been resumed" \
2815 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002816
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002817requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2818requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002819run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002820 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2821 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002822 0 \
2823 -S "session successfully restored from cache" \
2824 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002825 -S "a session has been resumed" \
2826 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002827
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002828requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2829requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002830run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002831 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2832 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002833 0 \
2834 -s "session successfully restored from cache" \
2835 -S "session successfully restored from ticket" \
2836 -s "a session has been resumed" \
2837 -c "a session has been resumed"
2838
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002839requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2840requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002841run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002842 "$P_SRV debug_level=3 tickets=0" \
2843 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002844 0 \
2845 -s "session successfully restored from cache" \
2846 -S "session successfully restored from ticket" \
2847 -s "a session has been resumed" \
2848 -c "a session has been resumed"
2849
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002850requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2851requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002852run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002853 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2854 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002855 0 \
2856 -S "session successfully restored from cache" \
2857 -S "session successfully restored from ticket" \
2858 -S "a session has been resumed" \
2859 -C "a session has been resumed"
2860
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002861requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2862requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002863run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002864 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2865 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002866 0 \
2867 -s "session successfully restored from cache" \
2868 -S "session successfully restored from ticket" \
2869 -s "a session has been resumed" \
2870 -c "a session has been resumed"
2871
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002872requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2873requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002874run_test "Session resume using cache: session copy" \
2875 "$P_SRV debug_level=3 tickets=0" \
2876 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2877 0 \
2878 -s "session successfully restored from cache" \
2879 -S "session successfully restored from ticket" \
2880 -s "a session has been resumed" \
2881 -c "a session has been resumed"
2882
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002883requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2884requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002885run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002886 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002887 "( $O_CLI -sess_out $SESSION; \
2888 $O_CLI -sess_in $SESSION; \
2889 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002890 0 \
2891 -s "found session ticket extension" \
2892 -S "server hello, adding session ticket extension" \
2893 -s "session successfully restored from cache" \
2894 -S "session successfully restored from ticket" \
2895 -s "a session has been resumed"
2896
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002897requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2898requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002899run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002900 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002901 "$P_CLI debug_level=3 tickets=0 reconnect=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002902 0 \
2903 -C "found session_ticket extension" \
2904 -C "parse new session ticket" \
2905 -c "a session has been resumed"
2906
Hanno Becker1d739932018-08-21 13:55:22 +01002907# Tests for Session Resume based on session-ID and cache, DTLS
2908
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002909requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002910requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002911requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002912run_test "Session resume using cache, DTLS: tickets enabled on client" \
2913 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2914 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2915 0 \
2916 -c "client hello, adding session ticket extension" \
2917 -s "found session ticket extension" \
2918 -S "server hello, adding session ticket extension" \
2919 -C "found session_ticket extension" \
2920 -C "parse new session ticket" \
2921 -s "session successfully restored from cache" \
2922 -S "session successfully restored from ticket" \
2923 -s "a session has been resumed" \
2924 -c "a session has been resumed"
2925
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002926requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002927requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002928requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002929run_test "Session resume using cache, DTLS: tickets enabled on server" \
2930 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2931 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2932 0 \
2933 -C "client hello, adding session ticket extension" \
2934 -S "found session ticket extension" \
2935 -S "server hello, adding session ticket extension" \
2936 -C "found session_ticket extension" \
2937 -C "parse new session ticket" \
2938 -s "session successfully restored from cache" \
2939 -S "session successfully restored from ticket" \
2940 -s "a session has been resumed" \
2941 -c "a session has been resumed"
2942
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002943requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2944requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002945run_test "Session resume using cache, DTLS: cache_max=0" \
2946 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
2947 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2948 0 \
2949 -S "session successfully restored from cache" \
2950 -S "session successfully restored from ticket" \
2951 -S "a session has been resumed" \
2952 -C "a session has been resumed"
2953
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002954requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2955requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002956run_test "Session resume using cache, DTLS: cache_max=1" \
2957 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
2958 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2959 0 \
2960 -s "session successfully restored from cache" \
2961 -S "session successfully restored from ticket" \
2962 -s "a session has been resumed" \
2963 -c "a session has been resumed"
2964
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002965requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2966requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002967run_test "Session resume using cache, DTLS: timeout > delay" \
2968 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2969 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
2970 0 \
2971 -s "session successfully restored from cache" \
2972 -S "session successfully restored from ticket" \
2973 -s "a session has been resumed" \
2974 -c "a session has been resumed"
2975
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002976requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2977requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002978run_test "Session resume using cache, DTLS: timeout < delay" \
2979 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
2980 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2981 0 \
2982 -S "session successfully restored from cache" \
2983 -S "session successfully restored from ticket" \
2984 -S "a session has been resumed" \
2985 -C "a session has been resumed"
2986
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002987requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2988requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002989run_test "Session resume using cache, DTLS: no timeout" \
2990 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
2991 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
2992 0 \
2993 -s "session successfully restored from cache" \
2994 -S "session successfully restored from ticket" \
2995 -s "a session has been resumed" \
2996 -c "a session has been resumed"
2997
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002998requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2999requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02003000run_test "Session resume using cache, DTLS: session copy" \
3001 "$P_SRV dtls=1 debug_level=3 tickets=0" \
3002 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
3003 0 \
3004 -s "session successfully restored from cache" \
3005 -S "session successfully restored from ticket" \
3006 -s "a session has been resumed" \
3007 -c "a session has been resumed"
3008
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03003009requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3010requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01003011run_test "Session resume using cache, DTLS: openssl client" \
3012 "$P_SRV dtls=1 debug_level=3 tickets=0" \
3013 "( $O_CLI -dtls1 -sess_out $SESSION; \
3014 $O_CLI -dtls1 -sess_in $SESSION; \
3015 rm -f $SESSION )" \
3016 0 \
3017 -s "found session ticket extension" \
3018 -S "server hello, adding session ticket extension" \
3019 -s "session successfully restored from cache" \
3020 -S "session successfully restored from ticket" \
3021 -s "a session has been resumed"
3022
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03003023requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3024requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01003025run_test "Session resume using cache, DTLS: openssl server" \
3026 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003027 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 ca_file=data_files/test-ca2.crt" \
Hanno Becker1d739932018-08-21 13:55:22 +01003028 0 \
3029 -C "found session_ticket extension" \
3030 -C "parse new session ticket" \
3031 -c "a session has been resumed"
3032
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003033# Tests for Max Fragment Length extension
3034
Angus Grattonc4dd0732018-04-11 16:28:39 +10003035if [ $MAX_CONTENT_LEN -ne 16384 ]; then
3036 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
3037fi
3038
Hanno Becker4aed27e2017-09-18 15:00:34 +01003039requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003040run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003041 "$P_SRV debug_level=3" \
3042 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003043 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003044 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3045 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003046 -C "client hello, adding max_fragment_length extension" \
3047 -S "found max fragment length extension" \
3048 -S "server hello, max_fragment_length extension" \
3049 -C "found max_fragment_length extension"
3050
Hanno Becker4aed27e2017-09-18 15:00:34 +01003051requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003052run_test "Max fragment length: enabled, default, larger message" \
3053 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003054 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003055 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003056 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3057 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003058 -C "client hello, adding max_fragment_length extension" \
3059 -S "found max fragment length extension" \
3060 -S "server hello, max_fragment_length extension" \
3061 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003062 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3063 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003064 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003065
3066requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003067requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Hanno Beckerc5266962017-09-18 15:01:50 +01003068run_test "Max fragment length, DTLS: enabled, default, larger message" \
3069 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003070 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003071 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003072 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3073 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003074 -C "client hello, adding max_fragment_length extension" \
3075 -S "found max fragment length extension" \
3076 -S "server hello, max_fragment_length extension" \
3077 -C "found max_fragment_length extension" \
3078 -c "fragment larger than.*maximum "
3079
Angus Grattonc4dd0732018-04-11 16:28:39 +10003080# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3081# (session fragment length will be 16384 regardless of mbedtls
3082# content length configuration.)
3083
Hanno Beckerc5266962017-09-18 15:01:50 +01003084requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003085requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 16384
Hanno Beckerc5266962017-09-18 15:01:50 +01003086run_test "Max fragment length: disabled, larger message" \
3087 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003088 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003089 0 \
3090 -C "Maximum fragment length is 16384" \
3091 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003092 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3093 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003094 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003095
3096requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003097requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 16384
Hanno Beckerc5266962017-09-18 15:01:50 +01003098run_test "Max fragment length DTLS: disabled, larger message" \
3099 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003100 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003101 1 \
3102 -C "Maximum fragment length is 16384" \
3103 -S "Maximum fragment length is 16384" \
3104 -c "fragment larger than.*maximum "
3105
3106requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003107requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003108run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003109 "$P_SRV debug_level=3" \
3110 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003111 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003112 -c "Maximum fragment length is 4096" \
3113 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003114 -c "client hello, adding max_fragment_length extension" \
3115 -s "found max fragment length extension" \
3116 -s "server hello, max_fragment_length extension" \
3117 -c "found max_fragment_length extension"
3118
Hanno Becker4aed27e2017-09-18 15:00:34 +01003119requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003120requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003121run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003122 "$P_SRV debug_level=3 max_frag_len=4096" \
3123 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003124 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003125 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003126 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003127 -C "client hello, adding max_fragment_length extension" \
3128 -S "found max fragment length extension" \
3129 -S "server hello, max_fragment_length extension" \
3130 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003131
Hanno Becker4aed27e2017-09-18 15:00:34 +01003132requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003133requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003134requires_gnutls
3135run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003136 "$G_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003137 "$P_CLI debug_level=3 max_frag_len=4096 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003138 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003139 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003140 -c "client hello, adding max_fragment_length extension" \
3141 -c "found max_fragment_length extension"
3142
Hanno Becker4aed27e2017-09-18 15:00:34 +01003143requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003144requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003145run_test "Max fragment length: client, message just fits" \
3146 "$P_SRV debug_level=3" \
3147 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3148 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003149 -c "Maximum fragment length is 2048" \
3150 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003151 -c "client hello, adding max_fragment_length extension" \
3152 -s "found max fragment length extension" \
3153 -s "server hello, max_fragment_length extension" \
3154 -c "found max_fragment_length extension" \
3155 -c "2048 bytes written in 1 fragments" \
3156 -s "2048 bytes read"
3157
Hanno Becker4aed27e2017-09-18 15:00:34 +01003158requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003159requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003160run_test "Max fragment length: client, larger message" \
3161 "$P_SRV debug_level=3" \
3162 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3163 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003164 -c "Maximum fragment length is 2048" \
3165 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003166 -c "client hello, adding max_fragment_length extension" \
3167 -s "found max fragment length extension" \
3168 -s "server hello, max_fragment_length extension" \
3169 -c "found max_fragment_length extension" \
3170 -c "2345 bytes written in 2 fragments" \
3171 -s "2048 bytes read" \
3172 -s "297 bytes read"
3173
Hanno Becker4aed27e2017-09-18 15:00:34 +01003174requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003175requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003176run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003177 "$P_SRV debug_level=3 dtls=1" \
3178 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3179 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003180 -c "Maximum fragment length is 2048" \
3181 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003182 -c "client hello, adding max_fragment_length extension" \
3183 -s "found max fragment length extension" \
3184 -s "server hello, max_fragment_length extension" \
3185 -c "found max_fragment_length extension" \
3186 -c "fragment larger than.*maximum"
3187
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003188# Tests for renegotiation
3189
Hanno Becker6a243642017-10-12 15:18:45 +01003190# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003191run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003192 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003193 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003194 0 \
3195 -C "client hello, adding renegotiation extension" \
3196 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3197 -S "found renegotiation extension" \
3198 -s "server hello, secure renegotiation extension" \
3199 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003200 -C "=> renegotiate" \
3201 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003202 -S "write hello request"
3203
Hanno Becker6a243642017-10-12 15:18:45 +01003204requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003205run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003206 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003207 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003208 0 \
3209 -c "client hello, adding renegotiation extension" \
3210 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3211 -s "found renegotiation extension" \
3212 -s "server hello, secure renegotiation extension" \
3213 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003214 -c "=> renegotiate" \
3215 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003216 -S "write hello request"
3217
Hanno Becker6a243642017-10-12 15:18:45 +01003218requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003219run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003220 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003221 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003222 0 \
3223 -c "client hello, adding renegotiation extension" \
3224 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3225 -s "found renegotiation extension" \
3226 -s "server hello, secure renegotiation extension" \
3227 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003228 -c "=> renegotiate" \
3229 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003230 -s "write hello request"
3231
Janos Follathb0f148c2017-10-05 12:29:42 +01003232# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3233# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3234# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003235requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003236run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3237 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3238 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3239 0 \
3240 -c "client hello, adding renegotiation extension" \
3241 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3242 -s "found renegotiation extension" \
3243 -s "server hello, secure renegotiation extension" \
3244 -c "found renegotiation extension" \
3245 -c "=> renegotiate" \
3246 -s "=> renegotiate" \
3247 -S "write hello request" \
3248 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3249
3250# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3251# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3252# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003253requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003254run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3255 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3256 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3257 0 \
3258 -c "client hello, adding renegotiation extension" \
3259 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3260 -s "found renegotiation extension" \
3261 -s "server hello, secure renegotiation extension" \
3262 -c "found renegotiation extension" \
3263 -c "=> renegotiate" \
3264 -s "=> renegotiate" \
3265 -s "write hello request" \
3266 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3267
Hanno Becker6a243642017-10-12 15:18:45 +01003268requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003269run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003270 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003271 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003272 0 \
3273 -c "client hello, adding renegotiation extension" \
3274 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3275 -s "found renegotiation extension" \
3276 -s "server hello, secure renegotiation extension" \
3277 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003278 -c "=> renegotiate" \
3279 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003280 -s "write hello request"
3281
Hanno Becker6a243642017-10-12 15:18:45 +01003282requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003283run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003284 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003285 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003286 1 \
3287 -c "client hello, adding renegotiation extension" \
3288 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3289 -S "found renegotiation extension" \
3290 -s "server hello, secure renegotiation extension" \
3291 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003292 -c "=> renegotiate" \
3293 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003294 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003295 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003296 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003297
Hanno Becker6a243642017-10-12 15:18:45 +01003298requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003299run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003300 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003301 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003302 0 \
3303 -C "client hello, adding renegotiation extension" \
3304 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3305 -S "found renegotiation extension" \
3306 -s "server hello, secure renegotiation extension" \
3307 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003308 -C "=> renegotiate" \
3309 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003310 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003311 -S "SSL - An unexpected message was received from our peer" \
3312 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003313
Hanno Becker6a243642017-10-12 15:18:45 +01003314requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003315run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003316 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003317 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003318 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003319 0 \
3320 -C "client hello, adding renegotiation extension" \
3321 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3322 -S "found renegotiation extension" \
3323 -s "server hello, secure renegotiation extension" \
3324 -c "found renegotiation extension" \
3325 -C "=> renegotiate" \
3326 -S "=> renegotiate" \
3327 -s "write hello request" \
3328 -S "SSL - An unexpected message was received from our peer" \
3329 -S "failed"
3330
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003331# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003332requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003333run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003334 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003335 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003336 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003337 0 \
3338 -C "client hello, adding renegotiation extension" \
3339 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3340 -S "found renegotiation extension" \
3341 -s "server hello, secure renegotiation extension" \
3342 -c "found renegotiation extension" \
3343 -C "=> renegotiate" \
3344 -S "=> renegotiate" \
3345 -s "write hello request" \
3346 -S "SSL - An unexpected message was received from our peer" \
3347 -S "failed"
3348
Hanno Becker6a243642017-10-12 15:18:45 +01003349requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003350run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003351 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003352 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003353 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003354 0 \
3355 -C "client hello, adding renegotiation extension" \
3356 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3357 -S "found renegotiation extension" \
3358 -s "server hello, secure renegotiation extension" \
3359 -c "found renegotiation extension" \
3360 -C "=> renegotiate" \
3361 -S "=> renegotiate" \
3362 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003363 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003364
Hanno Becker6a243642017-10-12 15:18:45 +01003365requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003366run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003367 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003368 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003369 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003370 0 \
3371 -c "client hello, adding renegotiation extension" \
3372 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3373 -s "found renegotiation extension" \
3374 -s "server hello, secure renegotiation extension" \
3375 -c "found renegotiation extension" \
3376 -c "=> renegotiate" \
3377 -s "=> renegotiate" \
3378 -s "write hello request" \
3379 -S "SSL - An unexpected message was received from our peer" \
3380 -S "failed"
3381
Hanno Becker6a243642017-10-12 15:18:45 +01003382requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003383run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003384 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003385 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3386 0 \
3387 -C "client hello, adding renegotiation extension" \
3388 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3389 -S "found renegotiation extension" \
3390 -s "server hello, secure renegotiation extension" \
3391 -c "found renegotiation extension" \
3392 -S "record counter limit reached: renegotiate" \
3393 -C "=> renegotiate" \
3394 -S "=> renegotiate" \
3395 -S "write hello request" \
3396 -S "SSL - An unexpected message was received from our peer" \
3397 -S "failed"
3398
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003399# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003400requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003401run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003402 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003403 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003404 0 \
3405 -c "client hello, adding renegotiation extension" \
3406 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3407 -s "found renegotiation extension" \
3408 -s "server hello, secure renegotiation extension" \
3409 -c "found renegotiation extension" \
3410 -s "record counter limit reached: renegotiate" \
3411 -c "=> renegotiate" \
3412 -s "=> renegotiate" \
3413 -s "write hello request" \
3414 -S "SSL - An unexpected message was received from our peer" \
3415 -S "failed"
3416
Hanno Becker6a243642017-10-12 15:18:45 +01003417requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003418run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003419 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003420 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003421 0 \
3422 -c "client hello, adding renegotiation extension" \
3423 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3424 -s "found renegotiation extension" \
3425 -s "server hello, secure renegotiation extension" \
3426 -c "found renegotiation extension" \
3427 -s "record counter limit reached: renegotiate" \
3428 -c "=> renegotiate" \
3429 -s "=> renegotiate" \
3430 -s "write hello request" \
3431 -S "SSL - An unexpected message was received from our peer" \
3432 -S "failed"
3433
Hanno Becker6a243642017-10-12 15:18:45 +01003434requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003435run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003436 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003437 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3438 0 \
3439 -C "client hello, adding renegotiation extension" \
3440 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3441 -S "found renegotiation extension" \
3442 -s "server hello, secure renegotiation extension" \
3443 -c "found renegotiation extension" \
3444 -S "record counter limit reached: renegotiate" \
3445 -C "=> renegotiate" \
3446 -S "=> renegotiate" \
3447 -S "write hello request" \
3448 -S "SSL - An unexpected message was received from our peer" \
3449 -S "failed"
3450
Hanno Becker6a243642017-10-12 15:18:45 +01003451requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003452run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003453 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003454 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003455 0 \
3456 -c "client hello, adding renegotiation extension" \
3457 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3458 -s "found renegotiation extension" \
3459 -s "server hello, secure renegotiation extension" \
3460 -c "found renegotiation extension" \
3461 -c "=> renegotiate" \
3462 -s "=> renegotiate" \
3463 -S "write hello request"
3464
Hanno Becker6a243642017-10-12 15:18:45 +01003465requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003466run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003467 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003468 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003469 0 \
3470 -c "client hello, adding renegotiation extension" \
3471 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3472 -s "found renegotiation extension" \
3473 -s "server hello, secure renegotiation extension" \
3474 -c "found renegotiation extension" \
3475 -c "=> renegotiate" \
3476 -s "=> renegotiate" \
3477 -s "write hello request"
3478
Hanno Becker6a243642017-10-12 15:18:45 +01003479requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003480run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003481 "$O_SRV -www" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003482 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003483 0 \
3484 -c "client hello, adding renegotiation extension" \
3485 -c "found renegotiation extension" \
3486 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003487 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003488 -C "error" \
3489 -c "HTTP/1.0 200 [Oo][Kk]"
3490
Paul Bakker539d9722015-02-08 16:18:35 +01003491requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003492requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003493run_test "Renegotiation: gnutls server strict, client-initiated" \
3494 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003495 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003496 0 \
3497 -c "client hello, adding renegotiation extension" \
3498 -c "found renegotiation extension" \
3499 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003500 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003501 -C "error" \
3502 -c "HTTP/1.0 200 [Oo][Kk]"
3503
Paul Bakker539d9722015-02-08 16:18:35 +01003504requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003505requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003506run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3507 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003508 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003509 1 \
3510 -c "client hello, adding renegotiation extension" \
3511 -C "found renegotiation extension" \
3512 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003513 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003514 -c "error" \
3515 -C "HTTP/1.0 200 [Oo][Kk]"
3516
Paul Bakker539d9722015-02-08 16:18:35 +01003517requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003518requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003519run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3520 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003521 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003522 allow_legacy=0" \
3523 1 \
3524 -c "client hello, adding renegotiation extension" \
3525 -C "found renegotiation extension" \
3526 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003527 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003528 -c "error" \
3529 -C "HTTP/1.0 200 [Oo][Kk]"
3530
Paul Bakker539d9722015-02-08 16:18:35 +01003531requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003532requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003533run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3534 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003535 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003536 allow_legacy=1" \
3537 0 \
3538 -c "client hello, adding renegotiation extension" \
3539 -C "found renegotiation extension" \
3540 -c "=> renegotiate" \
3541 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003542 -C "error" \
3543 -c "HTTP/1.0 200 [Oo][Kk]"
3544
Hanno Becker6a243642017-10-12 15:18:45 +01003545requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003546run_test "Renegotiation: DTLS, client-initiated" \
3547 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3548 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3549 0 \
3550 -c "client hello, adding renegotiation extension" \
3551 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3552 -s "found renegotiation extension" \
3553 -s "server hello, secure renegotiation extension" \
3554 -c "found renegotiation extension" \
3555 -c "=> renegotiate" \
3556 -s "=> renegotiate" \
3557 -S "write hello request"
3558
Hanno Becker6a243642017-10-12 15:18:45 +01003559requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003560run_test "Renegotiation: DTLS, server-initiated" \
3561 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003562 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3563 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003564 0 \
3565 -c "client hello, adding renegotiation extension" \
3566 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3567 -s "found renegotiation extension" \
3568 -s "server hello, secure renegotiation extension" \
3569 -c "found renegotiation extension" \
3570 -c "=> renegotiate" \
3571 -s "=> renegotiate" \
3572 -s "write hello request"
3573
Hanno Becker6a243642017-10-12 15:18:45 +01003574requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003575run_test "Renegotiation: DTLS, renego_period overflow" \
3576 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3577 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3578 0 \
3579 -c "client hello, adding renegotiation extension" \
3580 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3581 -s "found renegotiation extension" \
3582 -s "server hello, secure renegotiation extension" \
3583 -s "record counter limit reached: renegotiate" \
3584 -c "=> renegotiate" \
3585 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003586 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003587
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003588requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003589requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003590run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3591 "$G_SRV -u --mtu 4096" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003592 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003593 0 \
3594 -c "client hello, adding renegotiation extension" \
3595 -c "found renegotiation extension" \
3596 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003597 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003598 -C "error" \
3599 -s "Extra-header:"
3600
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003601# Test for the "secure renegotation" extension only (no actual renegotiation)
3602
Paul Bakker539d9722015-02-08 16:18:35 +01003603requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003604run_test "Renego ext: gnutls server strict, client default" \
3605 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003606 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003607 0 \
3608 -c "found renegotiation extension" \
3609 -C "error" \
3610 -c "HTTP/1.0 200 [Oo][Kk]"
3611
Paul Bakker539d9722015-02-08 16:18:35 +01003612requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003613run_test "Renego ext: gnutls server unsafe, client default" \
3614 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003615 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003616 0 \
3617 -C "found renegotiation extension" \
3618 -C "error" \
3619 -c "HTTP/1.0 200 [Oo][Kk]"
3620
Paul Bakker539d9722015-02-08 16:18:35 +01003621requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003622run_test "Renego ext: gnutls server unsafe, client break legacy" \
3623 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3624 "$P_CLI debug_level=3 allow_legacy=-1" \
3625 1 \
3626 -C "found renegotiation extension" \
3627 -c "error" \
3628 -C "HTTP/1.0 200 [Oo][Kk]"
3629
Paul Bakker539d9722015-02-08 16:18:35 +01003630requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003631run_test "Renego ext: gnutls client strict, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003632 "$P_SRV debug_level=3 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003633 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003634 0 \
3635 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3636 -s "server hello, secure renegotiation extension"
3637
Paul Bakker539d9722015-02-08 16:18:35 +01003638requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003639run_test "Renego ext: gnutls client unsafe, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003640 "$P_SRV debug_level=3 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003641 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003642 0 \
3643 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3644 -S "server hello, secure renegotiation extension"
3645
Paul Bakker539d9722015-02-08 16:18:35 +01003646requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003647run_test "Renego ext: gnutls client unsafe, server break legacy" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003648 "$P_SRV debug_level=3 allow_legacy=-1 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003649 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003650 1 \
3651 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3652 -S "server hello, secure renegotiation extension"
3653
Janos Follath0b242342016-02-17 10:11:21 +00003654# Tests for silently dropping trailing extra bytes in .der certificates
3655
3656requires_gnutls
3657run_test "DER format: no trailing bytes" \
3658 "$P_SRV crt_file=data_files/server5-der0.crt \
3659 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003660 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003661 0 \
3662 -c "Handshake was completed" \
3663
3664requires_gnutls
3665run_test "DER format: with a trailing zero byte" \
3666 "$P_SRV crt_file=data_files/server5-der1a.crt \
3667 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003668 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003669 0 \
3670 -c "Handshake was completed" \
3671
3672requires_gnutls
3673run_test "DER format: with a trailing random byte" \
3674 "$P_SRV crt_file=data_files/server5-der1b.crt \
3675 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003676 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003677 0 \
3678 -c "Handshake was completed" \
3679
3680requires_gnutls
3681run_test "DER format: with 2 trailing random bytes" \
3682 "$P_SRV crt_file=data_files/server5-der2.crt \
3683 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003684 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003685 0 \
3686 -c "Handshake was completed" \
3687
3688requires_gnutls
3689run_test "DER format: with 4 trailing random bytes" \
3690 "$P_SRV crt_file=data_files/server5-der4.crt \
3691 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003692 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003693 0 \
3694 -c "Handshake was completed" \
3695
3696requires_gnutls
3697run_test "DER format: with 8 trailing random bytes" \
3698 "$P_SRV crt_file=data_files/server5-der8.crt \
3699 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003700 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003701 0 \
3702 -c "Handshake was completed" \
3703
3704requires_gnutls
3705run_test "DER format: with 9 trailing random bytes" \
3706 "$P_SRV crt_file=data_files/server5-der9.crt \
3707 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003708 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003709 0 \
3710 -c "Handshake was completed" \
3711
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003712# Tests for auth_mode
3713
Hanno Becker4a156fc2019-06-14 17:07:06 +01003714requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003715requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003716run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003717 "$P_SRV crt_file=data_files/server5-badsign.crt \
3718 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003719 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003720 1 \
3721 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003722 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003723 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003724 -c "X509 - Certificate verification failed"
3725
Hanno Becker4a156fc2019-06-14 17:07:06 +01003726requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003727requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003728run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003729 "$P_SRV crt_file=data_files/server5-badsign.crt \
3730 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003731 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003732 0 \
3733 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003734 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003735 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003736 -C "X509 - Certificate verification failed"
3737
Hanno Becker4a156fc2019-06-14 17:07:06 +01003738requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003739requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003740run_test "Authentication: server goodcert, client optional, no trusted CA" \
3741 "$P_SRV" \
3742 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3743 0 \
3744 -c "x509_verify_cert() returned" \
3745 -c "! The certificate is not correctly signed by the trusted CA" \
3746 -c "! Certificate verification flags"\
3747 -C "! mbedtls_ssl_handshake returned" \
3748 -C "X509 - Certificate verification failed" \
3749 -C "SSL - No CA Chain is set, but required to operate"
3750
Hanno Becker4a156fc2019-06-14 17:07:06 +01003751requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003752requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003753run_test "Authentication: server goodcert, client required, no trusted CA" \
3754 "$P_SRV" \
3755 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3756 1 \
3757 -c "x509_verify_cert() returned" \
3758 -c "! The certificate is not correctly signed by the trusted CA" \
3759 -c "! Certificate verification flags"\
3760 -c "! mbedtls_ssl_handshake returned" \
3761 -c "SSL - No CA Chain is set, but required to operate"
3762
3763# The purpose of the next two tests is to test the client's behaviour when receiving a server
3764# certificate with an unsupported elliptic curve. This should usually not happen because
3765# the client informs the server about the supported curves - it does, though, in the
3766# corner case of a static ECDH suite, because the server doesn't check the curve on that
3767# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3768# different means to have the server ignoring the client's supported curve list.
3769
3770requires_config_enabled MBEDTLS_ECP_C
3771run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3772 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3773 crt_file=data_files/server5.ku-ka.crt" \
3774 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3775 1 \
3776 -c "bad certificate (EC key curve)"\
3777 -c "! Certificate verification flags"\
3778 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3779
3780requires_config_enabled MBEDTLS_ECP_C
3781run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3782 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3783 crt_file=data_files/server5.ku-ka.crt" \
3784 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3785 1 \
3786 -c "bad certificate (EC key curve)"\
3787 -c "! Certificate verification flags"\
3788 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003790run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003791 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003792 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003793 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003794 0 \
3795 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003796 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003797 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003798 -C "X509 - Certificate verification failed"
3799
Simon Butcher99000142016-10-13 17:21:01 +01003800run_test "Authentication: client SHA256, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003801 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003802 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3803 key_file=data_files/server6.key \
3804 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3805 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003806 -c "Supported Signature Algorithm found: 5,"
3807
3808run_test "Authentication: client SHA384, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003809 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003810 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3811 key_file=data_files/server6.key \
3812 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3813 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003814 -c "Supported Signature Algorithm found: 5,"
3815
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003816requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3817run_test "Authentication: client has no cert, server required (SSLv3)" \
3818 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3819 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3820 key_file=data_files/server5.key" \
3821 1 \
3822 -S "skip write certificate request" \
3823 -C "skip parse certificate request" \
3824 -c "got a certificate request" \
3825 -c "got no certificate to send" \
3826 -S "x509_verify_cert() returned" \
3827 -s "client has no certificate" \
3828 -s "! mbedtls_ssl_handshake returned" \
3829 -c "! mbedtls_ssl_handshake returned" \
3830 -s "No client certification received from the client, but required by the authentication mode"
3831
3832run_test "Authentication: client has no cert, server required (TLS)" \
3833 "$P_SRV debug_level=3 auth_mode=required" \
3834 "$P_CLI debug_level=3 crt_file=none \
3835 key_file=data_files/server5.key" \
3836 1 \
3837 -S "skip write certificate request" \
3838 -C "skip parse certificate request" \
3839 -c "got a certificate request" \
3840 -c "= write certificate$" \
3841 -C "skip write certificate$" \
3842 -S "x509_verify_cert() returned" \
3843 -s "client has no certificate" \
3844 -s "! mbedtls_ssl_handshake returned" \
3845 -c "! mbedtls_ssl_handshake returned" \
3846 -s "No client certification received from the client, but required by the authentication mode"
3847
Hanno Becker4a156fc2019-06-14 17:07:06 +01003848requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003849requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003850run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003851 "$P_SRV debug_level=3 auth_mode=required" \
3852 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003853 key_file=data_files/server5.key" \
3854 1 \
3855 -S "skip write certificate request" \
3856 -C "skip parse certificate request" \
3857 -c "got a certificate request" \
3858 -C "skip write certificate" \
3859 -C "skip write certificate verify" \
3860 -S "skip parse certificate verify" \
3861 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003862 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003863 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003864 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003865 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003866 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003867# We don't check that the client receives the alert because it might
3868# detect that its write end of the connection is closed and abort
3869# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003870
Hanno Becker4a156fc2019-06-14 17:07:06 +01003871requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003872requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01003873run_test "Authentication: client cert not trusted, server required" \
3874 "$P_SRV debug_level=3 auth_mode=required" \
3875 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3876 key_file=data_files/server5.key" \
3877 1 \
3878 -S "skip write certificate request" \
3879 -C "skip parse certificate request" \
3880 -c "got a certificate request" \
3881 -C "skip write certificate" \
3882 -C "skip write certificate verify" \
3883 -S "skip parse certificate verify" \
3884 -s "x509_verify_cert() returned" \
3885 -s "! The certificate is not correctly signed by the trusted CA" \
3886 -s "! mbedtls_ssl_handshake returned" \
3887 -c "! mbedtls_ssl_handshake returned" \
3888 -s "X509 - Certificate verification failed"
3889
Hanno Becker4a156fc2019-06-14 17:07:06 +01003890requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003891requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003892run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003893 "$P_SRV debug_level=3 auth_mode=optional" \
3894 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003895 key_file=data_files/server5.key" \
3896 0 \
3897 -S "skip write certificate request" \
3898 -C "skip parse certificate request" \
3899 -c "got a certificate request" \
3900 -C "skip write certificate" \
3901 -C "skip write certificate verify" \
3902 -S "skip parse certificate verify" \
3903 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003904 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003905 -S "! mbedtls_ssl_handshake returned" \
3906 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003907 -S "X509 - Certificate verification failed"
3908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003909run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003910 "$P_SRV debug_level=3 auth_mode=none" \
3911 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003912 key_file=data_files/server5.key" \
3913 0 \
3914 -s "skip write certificate request" \
3915 -C "skip parse certificate request" \
3916 -c "got no certificate request" \
3917 -c "skip write certificate" \
3918 -c "skip write certificate verify" \
3919 -s "skip parse certificate verify" \
3920 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003921 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003922 -S "! mbedtls_ssl_handshake returned" \
3923 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003924 -S "X509 - Certificate verification failed"
3925
Hanno Becker4a156fc2019-06-14 17:07:06 +01003926requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003927requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003928run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003929 "$P_SRV debug_level=3 auth_mode=optional" \
3930 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003931 0 \
3932 -S "skip write certificate request" \
3933 -C "skip parse certificate request" \
3934 -c "got a certificate request" \
3935 -C "skip write certificate$" \
3936 -C "got no certificate to send" \
3937 -S "SSLv3 client has no certificate" \
3938 -c "skip write certificate verify" \
3939 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003940 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003941 -S "! mbedtls_ssl_handshake returned" \
3942 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003943 -S "X509 - Certificate verification failed"
3944
Hanno Becker4a156fc2019-06-14 17:07:06 +01003945requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003946requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003947run_test "Authentication: openssl client no cert, server optional" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003948 "$P_SRV debug_level=3 auth_mode=optional ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003949 "$O_CLI" \
3950 0 \
3951 -S "skip write certificate request" \
3952 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003953 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003954 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003955 -S "X509 - Certificate verification failed"
3956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003957run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003958 "$O_SRV -verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003959 "$P_CLI debug_level=3 crt_file=none key_file=none ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003960 0 \
3961 -C "skip parse certificate request" \
3962 -c "got a certificate request" \
3963 -C "skip write certificate$" \
3964 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003965 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003966
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003967run_test "Authentication: client no cert, openssl server required" \
3968 "$O_SRV -Verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003969 "$P_CLI debug_level=3 crt_file=none key_file=none ca_file=data_files/test-ca2.crt" \
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003970 1 \
3971 -C "skip parse certificate request" \
3972 -c "got a certificate request" \
3973 -C "skip write certificate$" \
3974 -c "skip write certificate verify" \
3975 -c "! mbedtls_ssl_handshake returned"
3976
Janos Follathe2681a42016-03-07 15:57:05 +00003977requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Hanno Beckerb2c63832019-06-17 08:35:16 +01003978requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003979requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003980run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003981 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003982 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003983 0 \
3984 -S "skip write certificate request" \
3985 -C "skip parse certificate request" \
3986 -c "got a certificate request" \
3987 -C "skip write certificate$" \
3988 -c "skip write certificate verify" \
3989 -c "got no certificate to send" \
3990 -s "SSLv3 client has no certificate" \
3991 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003992 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003993 -S "! mbedtls_ssl_handshake returned" \
3994 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003995 -S "X509 - Certificate verification failed"
3996
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02003997# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
3998# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003999
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004000MAX_IM_CA='8'
Arto Kinnunen78213522019-09-26 11:06:39 +03004001MAX_IM_CA_CONFIG="$( get_config_value_or_default MBEDTLS_X509_MAX_INTERMEDIATE_CA )"
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004002
Angus Grattonc4dd0732018-04-11 16:28:39 +10004003requires_full_size_output_buffer
Arto Kinnunenc457ab12019-09-27 12:00:51 +03004004requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004005run_test "Authentication: server max_int chain, client default" \
4006 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4007 key_file=data_files/dir-maxpath/09.key" \
4008 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4009 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004010 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004011
Angus Grattonc4dd0732018-04-11 16:28:39 +10004012requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004013requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004014run_test "Authentication: server max_int+1 chain, client default" \
4015 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4016 key_file=data_files/dir-maxpath/10.key" \
4017 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4018 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004019 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004020
Angus Grattonc4dd0732018-04-11 16:28:39 +10004021requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004022requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004023run_test "Authentication: server max_int+1 chain, client optional" \
4024 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4025 key_file=data_files/dir-maxpath/10.key" \
4026 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4027 auth_mode=optional" \
4028 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004029 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004030
Angus Grattonc4dd0732018-04-11 16:28:39 +10004031requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004032requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004033run_test "Authentication: server max_int+1 chain, client none" \
4034 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4035 key_file=data_files/dir-maxpath/10.key" \
4036 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4037 auth_mode=none" \
4038 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004039 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004040
Angus Grattonc4dd0732018-04-11 16:28:39 +10004041requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004042run_test "Authentication: client max_int+1 chain, server default" \
4043 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4044 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4045 key_file=data_files/dir-maxpath/10.key" \
4046 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004047 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004048
Angus Grattonc4dd0732018-04-11 16:28:39 +10004049requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004050run_test "Authentication: client max_int+1 chain, server optional" \
4051 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4052 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4053 key_file=data_files/dir-maxpath/10.key" \
4054 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004055 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004056
Angus Grattonc4dd0732018-04-11 16:28:39 +10004057requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004058run_test "Authentication: client max_int+1 chain, server required" \
4059 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4060 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4061 key_file=data_files/dir-maxpath/10.key" \
4062 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004063 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004064
Angus Grattonc4dd0732018-04-11 16:28:39 +10004065requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004066run_test "Authentication: client max_int chain, server required" \
4067 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4068 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4069 key_file=data_files/dir-maxpath/09.key" \
4070 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004071 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004072
Janos Follath89baba22017-04-10 14:34:35 +01004073# Tests for CA list in CertificateRequest messages
4074
4075run_test "Authentication: send CA list in CertificateRequest (default)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004076 "$P_SRV debug_level=3 auth_mode=required ca_file=data_files/test-ca2.crt" \
Janos Follath89baba22017-04-10 14:34:35 +01004077 "$P_CLI crt_file=data_files/server6.crt \
4078 key_file=data_files/server6.key" \
4079 0 \
4080 -s "requested DN"
4081
4082run_test "Authentication: do not send CA list in CertificateRequest" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004083 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0 ca_file=data_files/test-ca2.crt" \
Janos Follath89baba22017-04-10 14:34:35 +01004084 "$P_CLI crt_file=data_files/server6.crt \
4085 key_file=data_files/server6.key" \
4086 0 \
4087 -S "requested DN"
4088
Hanno Becker4a156fc2019-06-14 17:07:06 +01004089requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004090requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01004091run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4092 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4093 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4094 key_file=data_files/server5.key" \
4095 1 \
4096 -S "requested DN" \
4097 -s "x509_verify_cert() returned" \
4098 -s "! The certificate is not correctly signed by the trusted CA" \
4099 -s "! mbedtls_ssl_handshake returned" \
4100 -c "! mbedtls_ssl_handshake returned" \
4101 -s "X509 - Certificate verification failed"
4102
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004103# Tests for certificate selection based on SHA verson
4104
Hanno Becker4a156fc2019-06-14 17:07:06 +01004105requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004106requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004107run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4108 "$P_SRV crt_file=data_files/server5.crt \
4109 key_file=data_files/server5.key \
4110 crt_file2=data_files/server5-sha1.crt \
4111 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004112 "$P_CLI force_version=tls1_2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004113 0 \
4114 -c "signed using.*ECDSA with SHA256" \
4115 -C "signed using.*ECDSA with SHA1"
4116
Hanno Becker4a156fc2019-06-14 17:07:06 +01004117requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004118requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004119run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4120 "$P_SRV crt_file=data_files/server5.crt \
4121 key_file=data_files/server5.key \
4122 crt_file2=data_files/server5-sha1.crt \
4123 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004124 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004125 0 \
4126 -C "signed using.*ECDSA with SHA256" \
4127 -c "signed using.*ECDSA with SHA1"
4128
Hanno Becker4a156fc2019-06-14 17:07:06 +01004129requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004130requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004131run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4132 "$P_SRV crt_file=data_files/server5.crt \
4133 key_file=data_files/server5.key \
4134 crt_file2=data_files/server5-sha1.crt \
4135 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004136 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004137 0 \
4138 -C "signed using.*ECDSA with SHA256" \
4139 -c "signed using.*ECDSA with SHA1"
4140
Hanno Becker4a156fc2019-06-14 17:07:06 +01004141requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004142requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004143run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4144 "$P_SRV crt_file=data_files/server5.crt \
4145 key_file=data_files/server5.key \
4146 crt_file2=data_files/server6.crt \
4147 key_file2=data_files/server6.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004148 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004149 0 \
4150 -c "serial number.*09" \
4151 -c "signed using.*ECDSA with SHA256" \
4152 -C "signed using.*ECDSA with SHA1"
4153
Hanno Becker4a156fc2019-06-14 17:07:06 +01004154requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004155requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004156run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4157 "$P_SRV crt_file=data_files/server6.crt \
4158 key_file=data_files/server6.key \
4159 crt_file2=data_files/server5.crt \
4160 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004161 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004162 0 \
4163 -c "serial number.*0A" \
4164 -c "signed using.*ECDSA with SHA256" \
4165 -C "signed using.*ECDSA with SHA1"
4166
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004167# tests for SNI
4168
Hanno Becker4a156fc2019-06-14 17:07:06 +01004169requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004170requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004171run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004172 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004173 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004174 "$P_CLI server_name=localhost ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004175 0 \
4176 -S "parse ServerName extension" \
4177 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4178 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004179
Hanno Becker4a156fc2019-06-14 17:07:06 +01004180requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004181requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004182requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004183run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004184 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004185 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004186 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004187 "$P_CLI server_name=localhost ca_file=data_files/test-ca.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004188 0 \
4189 -s "parse ServerName extension" \
4190 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4191 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004192
Hanno Becker4a156fc2019-06-14 17:07:06 +01004193requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004194requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004195requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004196run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004197 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004198 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004199 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004200 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004201 0 \
4202 -s "parse ServerName extension" \
4203 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4204 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004205
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004206requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004207run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004208 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004209 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004210 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004211 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004212 1 \
4213 -s "parse ServerName extension" \
4214 -s "ssl_sni_wrapper() returned" \
4215 -s "mbedtls_ssl_handshake returned" \
4216 -c "mbedtls_ssl_handshake returned" \
4217 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004218
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004219run_test "SNI: client auth no override: optional" \
4220 "$P_SRV debug_level=3 auth_mode=optional \
4221 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4222 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4223 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004224 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004225 -S "skip write certificate request" \
4226 -C "skip parse certificate request" \
4227 -c "got a certificate request" \
4228 -C "skip write certificate" \
4229 -C "skip write certificate verify" \
4230 -S "skip parse certificate verify"
4231
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004232requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004233run_test "SNI: client auth override: none -> optional" \
4234 "$P_SRV debug_level=3 auth_mode=none \
4235 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4236 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4237 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004238 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004239 -S "skip write certificate request" \
4240 -C "skip parse certificate request" \
4241 -c "got a certificate request" \
4242 -C "skip write certificate" \
4243 -C "skip write certificate verify" \
4244 -S "skip parse certificate verify"
4245
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004246requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004247run_test "SNI: client auth override: optional -> none" \
4248 "$P_SRV debug_level=3 auth_mode=optional \
4249 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4250 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4251 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004252 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004253 -s "skip write certificate request" \
4254 -C "skip parse certificate request" \
4255 -c "got no certificate request" \
4256 -c "skip write certificate" \
4257 -c "skip write certificate verify" \
4258 -s "skip parse certificate verify"
4259
Hanno Becker4a156fc2019-06-14 17:07:06 +01004260requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004261requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004262requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004263run_test "SNI: CA no override" \
4264 "$P_SRV debug_level=3 auth_mode=optional \
4265 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4266 ca_file=data_files/test-ca.crt \
4267 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4268 "$P_CLI debug_level=3 server_name=localhost \
4269 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4270 1 \
4271 -S "skip write certificate request" \
4272 -C "skip parse certificate request" \
4273 -c "got a certificate request" \
4274 -C "skip write certificate" \
4275 -C "skip write certificate verify" \
4276 -S "skip parse certificate verify" \
4277 -s "x509_verify_cert() returned" \
4278 -s "! The certificate is not correctly signed by the trusted CA" \
4279 -S "The certificate has been revoked (is on a CRL)"
4280
Hanno Becker4a156fc2019-06-14 17:07:06 +01004281requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004282requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004283requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004284run_test "SNI: CA override" \
4285 "$P_SRV debug_level=3 auth_mode=optional \
4286 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4287 ca_file=data_files/test-ca.crt \
4288 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4289 "$P_CLI debug_level=3 server_name=localhost \
4290 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4291 0 \
4292 -S "skip write certificate request" \
4293 -C "skip parse certificate request" \
4294 -c "got a certificate request" \
4295 -C "skip write certificate" \
4296 -C "skip write certificate verify" \
4297 -S "skip parse certificate verify" \
4298 -S "x509_verify_cert() returned" \
4299 -S "! The certificate is not correctly signed by the trusted CA" \
4300 -S "The certificate has been revoked (is on a CRL)"
4301
Hanno Becker4a156fc2019-06-14 17:07:06 +01004302requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004303requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004304requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004305run_test "SNI: CA override with CRL" \
4306 "$P_SRV debug_level=3 auth_mode=optional \
4307 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4308 ca_file=data_files/test-ca.crt \
4309 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4310 "$P_CLI debug_level=3 server_name=localhost \
4311 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4312 1 \
4313 -S "skip write certificate request" \
4314 -C "skip parse certificate request" \
4315 -c "got a certificate request" \
4316 -C "skip write certificate" \
4317 -C "skip write certificate verify" \
4318 -S "skip parse certificate verify" \
4319 -s "x509_verify_cert() returned" \
4320 -S "! The certificate is not correctly signed by the trusted CA" \
4321 -s "The certificate has been revoked (is on a CRL)"
4322
Andres AG1a834452016-12-07 10:01:30 +00004323# Tests for SNI and DTLS
4324
Hanno Becker4a156fc2019-06-14 17:07:06 +01004325requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004326requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004327run_test "SNI: DTLS, no SNI callback" \
4328 "$P_SRV debug_level=3 dtls=1 \
4329 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004330 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca2.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004331 0 \
4332 -S "parse ServerName extension" \
4333 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4334 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4335
Hanno Becker4a156fc2019-06-14 17:07:06 +01004336requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004337requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004338requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004339run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004340 "$P_SRV debug_level=3 dtls=1 \
4341 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4342 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004343 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca.crt" \
Andres AG1a834452016-12-07 10:01:30 +00004344 0 \
4345 -s "parse ServerName extension" \
4346 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4347 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4348
Hanno Becker4a156fc2019-06-14 17:07:06 +01004349requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004350requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004351requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004352run_test "SNI: DTLS, matching cert 2" \
4353 "$P_SRV debug_level=3 dtls=1 \
4354 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4355 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004356 "$P_CLI server_name=polarssl.example dtls=1 ca_file=data_files/test-ca.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004357 0 \
4358 -s "parse ServerName extension" \
4359 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4360 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4361
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004362requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004363run_test "SNI: DTLS, no matching cert" \
4364 "$P_SRV debug_level=3 dtls=1 \
4365 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4366 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4367 "$P_CLI server_name=nonesuch.example dtls=1" \
4368 1 \
4369 -s "parse ServerName extension" \
4370 -s "ssl_sni_wrapper() returned" \
4371 -s "mbedtls_ssl_handshake returned" \
4372 -c "mbedtls_ssl_handshake returned" \
4373 -c "SSL - A fatal alert message was received from our peer"
4374
4375run_test "SNI: DTLS, client auth no override: optional" \
4376 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4377 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4378 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4379 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4380 0 \
4381 -S "skip write certificate request" \
4382 -C "skip parse certificate request" \
4383 -c "got a certificate request" \
4384 -C "skip write certificate" \
4385 -C "skip write certificate verify" \
4386 -S "skip parse certificate verify"
4387
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004388requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004389run_test "SNI: DTLS, client auth override: none -> optional" \
4390 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4391 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4392 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4393 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4394 0 \
4395 -S "skip write certificate request" \
4396 -C "skip parse certificate request" \
4397 -c "got a certificate request" \
4398 -C "skip write certificate" \
4399 -C "skip write certificate verify" \
4400 -S "skip parse certificate verify"
4401
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004402requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004403run_test "SNI: DTLS, client auth override: optional -> none" \
4404 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4405 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4406 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4407 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4408 0 \
4409 -s "skip write certificate request" \
4410 -C "skip parse certificate request" \
4411 -c "got no certificate request" \
4412 -c "skip write certificate" \
4413 -c "skip write certificate verify" \
4414 -s "skip parse certificate verify"
4415
Hanno Becker4a156fc2019-06-14 17:07:06 +01004416requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004417requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004418requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004419run_test "SNI: DTLS, CA no override" \
4420 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4421 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4422 ca_file=data_files/test-ca.crt \
4423 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4424 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4425 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4426 1 \
4427 -S "skip write certificate request" \
4428 -C "skip parse certificate request" \
4429 -c "got a certificate request" \
4430 -C "skip write certificate" \
4431 -C "skip write certificate verify" \
4432 -S "skip parse certificate verify" \
4433 -s "x509_verify_cert() returned" \
4434 -s "! The certificate is not correctly signed by the trusted CA" \
4435 -S "The certificate has been revoked (is on a CRL)"
4436
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004437requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004438run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004439 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4440 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4441 ca_file=data_files/test-ca.crt \
4442 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4443 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4444 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4445 0 \
4446 -S "skip write certificate request" \
4447 -C "skip parse certificate request" \
4448 -c "got a certificate request" \
4449 -C "skip write certificate" \
4450 -C "skip write certificate verify" \
4451 -S "skip parse certificate verify" \
4452 -S "x509_verify_cert() returned" \
4453 -S "! The certificate is not correctly signed by the trusted CA" \
4454 -S "The certificate has been revoked (is on a CRL)"
4455
Hanno Becker4a156fc2019-06-14 17:07:06 +01004456requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004457requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004458requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004459run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004460 "$P_SRV debug_level=3 auth_mode=optional \
4461 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4462 ca_file=data_files/test-ca.crt \
4463 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4464 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4465 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4466 1 \
4467 -S "skip write certificate request" \
4468 -C "skip parse certificate request" \
4469 -c "got a certificate request" \
4470 -C "skip write certificate" \
4471 -C "skip write certificate verify" \
4472 -S "skip parse certificate verify" \
4473 -s "x509_verify_cert() returned" \
4474 -S "! The certificate is not correctly signed by the trusted CA" \
4475 -s "The certificate has been revoked (is on a CRL)"
4476
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004477# Tests for non-blocking I/O: exercise a variety of handshake flows
4478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004479run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004480 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4481 "$P_CLI nbio=2 tickets=0" \
4482 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004483 -S "mbedtls_ssl_handshake returned" \
4484 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004485 -c "Read from server: .* bytes read"
4486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004487run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004488 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4489 "$P_CLI nbio=2 tickets=0" \
4490 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004491 -S "mbedtls_ssl_handshake returned" \
4492 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004493 -c "Read from server: .* bytes read"
4494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004495run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004496 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4497 "$P_CLI nbio=2 tickets=1" \
4498 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004499 -S "mbedtls_ssl_handshake returned" \
4500 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004501 -c "Read from server: .* bytes read"
4502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004503run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004504 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4505 "$P_CLI nbio=2 tickets=1" \
4506 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004507 -S "mbedtls_ssl_handshake returned" \
4508 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004509 -c "Read from server: .* bytes read"
4510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004511run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004512 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4513 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4514 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004515 -S "mbedtls_ssl_handshake returned" \
4516 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004517 -c "Read from server: .* bytes read"
4518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004519run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004520 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4521 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4522 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004523 -S "mbedtls_ssl_handshake returned" \
4524 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004525 -c "Read from server: .* bytes read"
4526
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004527run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004528 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4529 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4530 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004531 -S "mbedtls_ssl_handshake returned" \
4532 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004533 -c "Read from server: .* bytes read"
4534
Hanno Becker00076712017-11-15 16:39:08 +00004535# Tests for event-driven I/O: exercise a variety of handshake flows
4536
4537run_test "Event-driven I/O: basic handshake" \
4538 "$P_SRV event=1 tickets=0 auth_mode=none" \
4539 "$P_CLI event=1 tickets=0" \
4540 0 \
4541 -S "mbedtls_ssl_handshake returned" \
4542 -C "mbedtls_ssl_handshake returned" \
4543 -c "Read from server: .* bytes read"
4544
4545run_test "Event-driven I/O: client auth" \
4546 "$P_SRV event=1 tickets=0 auth_mode=required" \
4547 "$P_CLI event=1 tickets=0" \
4548 0 \
4549 -S "mbedtls_ssl_handshake returned" \
4550 -C "mbedtls_ssl_handshake returned" \
4551 -c "Read from server: .* bytes read"
4552
4553run_test "Event-driven I/O: ticket" \
4554 "$P_SRV event=1 tickets=1 auth_mode=none" \
4555 "$P_CLI event=1 tickets=1" \
4556 0 \
4557 -S "mbedtls_ssl_handshake returned" \
4558 -C "mbedtls_ssl_handshake returned" \
4559 -c "Read from server: .* bytes read"
4560
4561run_test "Event-driven I/O: ticket + client auth" \
4562 "$P_SRV event=1 tickets=1 auth_mode=required" \
4563 "$P_CLI event=1 tickets=1" \
4564 0 \
4565 -S "mbedtls_ssl_handshake returned" \
4566 -C "mbedtls_ssl_handshake returned" \
4567 -c "Read from server: .* bytes read"
4568
4569run_test "Event-driven I/O: ticket + client auth + resume" \
4570 "$P_SRV event=1 tickets=1 auth_mode=required" \
4571 "$P_CLI event=1 tickets=1 reconnect=1" \
4572 0 \
4573 -S "mbedtls_ssl_handshake returned" \
4574 -C "mbedtls_ssl_handshake returned" \
4575 -c "Read from server: .* bytes read"
4576
4577run_test "Event-driven I/O: ticket + resume" \
4578 "$P_SRV event=1 tickets=1 auth_mode=none" \
4579 "$P_CLI event=1 tickets=1 reconnect=1" \
4580 0 \
4581 -S "mbedtls_ssl_handshake returned" \
4582 -C "mbedtls_ssl_handshake returned" \
4583 -c "Read from server: .* bytes read"
4584
4585run_test "Event-driven I/O: session-id resume" \
4586 "$P_SRV event=1 tickets=0 auth_mode=none" \
4587 "$P_CLI event=1 tickets=0 reconnect=1" \
4588 0 \
4589 -S "mbedtls_ssl_handshake returned" \
4590 -C "mbedtls_ssl_handshake returned" \
4591 -c "Read from server: .* bytes read"
4592
Hanno Becker6a33f592018-03-13 11:38:46 +00004593run_test "Event-driven I/O, DTLS: basic handshake" \
4594 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4595 "$P_CLI dtls=1 event=1 tickets=0" \
4596 0 \
4597 -c "Read from server: .* bytes read"
4598
4599run_test "Event-driven I/O, DTLS: client auth" \
4600 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4601 "$P_CLI dtls=1 event=1 tickets=0" \
4602 0 \
4603 -c "Read from server: .* bytes read"
4604
4605run_test "Event-driven I/O, DTLS: ticket" \
4606 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4607 "$P_CLI dtls=1 event=1 tickets=1" \
4608 0 \
4609 -c "Read from server: .* bytes read"
4610
4611run_test "Event-driven I/O, DTLS: ticket + client auth" \
4612 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4613 "$P_CLI dtls=1 event=1 tickets=1" \
4614 0 \
4615 -c "Read from server: .* bytes read"
4616
4617run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4618 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4619 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4620 0 \
4621 -c "Read from server: .* bytes read"
4622
4623run_test "Event-driven I/O, DTLS: ticket + resume" \
4624 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4625 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4626 0 \
4627 -c "Read from server: .* bytes read"
4628
4629run_test "Event-driven I/O, DTLS: session-id resume" \
4630 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4631 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4632 0 \
4633 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004634
4635# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4636# During session resumption, the client will send its ApplicationData record
4637# within the same datagram as the Finished messages. In this situation, the
4638# server MUST NOT idle on the underlying transport after handshake completion,
4639# because the ApplicationData request has already been queued internally.
4640run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004641 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004642 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4643 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4644 0 \
4645 -c "Read from server: .* bytes read"
4646
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004647# Tests for version negotiation
4648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004649run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004650 "$P_SRV" \
4651 "$P_CLI" \
4652 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004653 -S "mbedtls_ssl_handshake returned" \
4654 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004655 -s "Protocol is TLSv1.2" \
4656 -c "Protocol is TLSv1.2"
4657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004658run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004659 "$P_SRV" \
4660 "$P_CLI max_version=tls1_1" \
4661 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004662 -S "mbedtls_ssl_handshake returned" \
4663 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004664 -s "Protocol is TLSv1.1" \
4665 -c "Protocol is TLSv1.1"
4666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004667run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004668 "$P_SRV max_version=tls1_1" \
4669 "$P_CLI" \
4670 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004671 -S "mbedtls_ssl_handshake returned" \
4672 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004673 -s "Protocol is TLSv1.1" \
4674 -c "Protocol is TLSv1.1"
4675
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004676run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004677 "$P_SRV max_version=tls1_1" \
4678 "$P_CLI max_version=tls1_1" \
4679 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004680 -S "mbedtls_ssl_handshake returned" \
4681 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004682 -s "Protocol is TLSv1.1" \
4683 -c "Protocol is TLSv1.1"
4684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004685run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004686 "$P_SRV min_version=tls1_1" \
4687 "$P_CLI max_version=tls1_1" \
4688 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004689 -S "mbedtls_ssl_handshake returned" \
4690 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004691 -s "Protocol is TLSv1.1" \
4692 -c "Protocol is TLSv1.1"
4693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004694run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004695 "$P_SRV max_version=tls1_1" \
4696 "$P_CLI min_version=tls1_1" \
4697 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004698 -S "mbedtls_ssl_handshake returned" \
4699 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004700 -s "Protocol is TLSv1.1" \
4701 -c "Protocol is TLSv1.1"
4702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004703run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004704 "$P_SRV max_version=tls1_1" \
4705 "$P_CLI min_version=tls1_2" \
4706 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004707 -s "mbedtls_ssl_handshake returned" \
4708 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004709 -c "SSL - Handshake protocol not within min/max boundaries"
4710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004711run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004712 "$P_SRV min_version=tls1_2" \
4713 "$P_CLI max_version=tls1_1" \
4714 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004715 -s "mbedtls_ssl_handshake returned" \
4716 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004717 -s "SSL - Handshake protocol not within min/max boundaries"
4718
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004719# Tests for ALPN extension
4720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004721run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004722 "$P_SRV debug_level=3" \
4723 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004724 0 \
4725 -C "client hello, adding alpn extension" \
4726 -S "found alpn extension" \
4727 -C "got an alert message, type: \\[2:120]" \
4728 -S "server hello, adding alpn extension" \
4729 -C "found alpn extension " \
4730 -C "Application Layer Protocol is" \
4731 -S "Application Layer Protocol is"
4732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004733run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004734 "$P_SRV debug_level=3" \
4735 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004736 0 \
4737 -c "client hello, adding alpn extension" \
4738 -s "found alpn extension" \
4739 -C "got an alert message, type: \\[2:120]" \
4740 -S "server hello, adding alpn extension" \
4741 -C "found alpn extension " \
4742 -c "Application Layer Protocol is (none)" \
4743 -S "Application Layer Protocol is"
4744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004745run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004746 "$P_SRV debug_level=3 alpn=abc,1234" \
4747 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004748 0 \
4749 -C "client hello, adding alpn extension" \
4750 -S "found alpn extension" \
4751 -C "got an alert message, type: \\[2:120]" \
4752 -S "server hello, adding alpn extension" \
4753 -C "found alpn extension " \
4754 -C "Application Layer Protocol is" \
4755 -s "Application Layer Protocol is (none)"
4756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004757run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004758 "$P_SRV debug_level=3 alpn=abc,1234" \
4759 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004760 0 \
4761 -c "client hello, adding alpn extension" \
4762 -s "found alpn extension" \
4763 -C "got an alert message, type: \\[2:120]" \
4764 -s "server hello, adding alpn extension" \
4765 -c "found alpn extension" \
4766 -c "Application Layer Protocol is abc" \
4767 -s "Application Layer Protocol is abc"
4768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004769run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004770 "$P_SRV debug_level=3 alpn=abc,1234" \
4771 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004772 0 \
4773 -c "client hello, adding alpn extension" \
4774 -s "found alpn extension" \
4775 -C "got an alert message, type: \\[2:120]" \
4776 -s "server hello, adding alpn extension" \
4777 -c "found alpn extension" \
4778 -c "Application Layer Protocol is abc" \
4779 -s "Application Layer Protocol is abc"
4780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004781run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004782 "$P_SRV debug_level=3 alpn=abc,1234" \
4783 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004784 0 \
4785 -c "client hello, adding alpn extension" \
4786 -s "found alpn extension" \
4787 -C "got an alert message, type: \\[2:120]" \
4788 -s "server hello, adding alpn extension" \
4789 -c "found alpn extension" \
4790 -c "Application Layer Protocol is 1234" \
4791 -s "Application Layer Protocol is 1234"
4792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004793run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004794 "$P_SRV debug_level=3 alpn=abc,123" \
4795 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004796 1 \
4797 -c "client hello, adding alpn extension" \
4798 -s "found alpn extension" \
4799 -c "got an alert message, type: \\[2:120]" \
4800 -S "server hello, adding alpn extension" \
4801 -C "found alpn extension" \
4802 -C "Application Layer Protocol is 1234" \
4803 -S "Application Layer Protocol is 1234"
4804
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02004805
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004806# Tests for keyUsage in leaf certificates, part 1:
4807# server-side certificate/suite selection
4808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004809run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004810 "$P_SRV key_file=data_files/server2.key \
4811 crt_file=data_files/server2.ku-ds.crt" \
4812 "$P_CLI" \
4813 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02004814 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004815
4816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004817run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004818 "$P_SRV key_file=data_files/server2.key \
4819 crt_file=data_files/server2.ku-ke.crt" \
4820 "$P_CLI" \
4821 0 \
4822 -c "Ciphersuite is TLS-RSA-WITH-"
4823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004824run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004825 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004826 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004827 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004828 1 \
4829 -C "Ciphersuite is "
4830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004831run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004832 "$P_SRV key_file=data_files/server5.key \
4833 crt_file=data_files/server5.ku-ds.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004834 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004835 0 \
4836 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
4837
4838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004839run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004840 "$P_SRV key_file=data_files/server5.key \
4841 crt_file=data_files/server5.ku-ka.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004842 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004843 0 \
4844 -c "Ciphersuite is TLS-ECDH-"
4845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004846run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004847 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004848 crt_file=data_files/server5.ku-ke.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004849 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004850 1 \
4851 -C "Ciphersuite is "
4852
4853# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004854# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004856run_test "keyUsage cli: DigitalSignature+KeyEncipherment, 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-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: DigitalSignature+KeyEncipherment, DHE-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-ds_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-DHE-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, RSA: OK" \
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-RSA-WITH-AES-128-CBC-SHA" \
4881 0 \
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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004886run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004887 "$O_SRV -key data_files/server2.key \
4888 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004889 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004890 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4891 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004892 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004893 -c "Processing of the Certificate handshake message failed" \
4894 -C "Ciphersuite is TLS-"
4895
Hanno Becker4a156fc2019-06-14 17:07:06 +01004896requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004897requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004898run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
4899 "$O_SRV -key data_files/server2.key \
4900 -cert data_files/server2.ku-ke.crt" \
4901 "$P_CLI debug_level=1 auth_mode=optional \
4902 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4903 0 \
4904 -c "bad certificate (usage extensions)" \
4905 -C "Processing of the Certificate handshake message failed" \
4906 -c "Ciphersuite is TLS-" \
4907 -c "! Usage does not match the keyUsage extension"
4908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004909run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
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-DHE-RSA-WITH-AES-128-CBC-SHA" \
4914 0 \
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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004919run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004920 "$O_SRV -key data_files/server2.key \
4921 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004922 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004923 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4924 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004925 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004926 -c "Processing of the Certificate handshake message failed" \
4927 -C "Ciphersuite is TLS-"
4928
Hanno Becker4a156fc2019-06-14 17:07:06 +01004929requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004930requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004931run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
4932 "$O_SRV -key data_files/server2.key \
4933 -cert data_files/server2.ku-ds.crt" \
4934 "$P_CLI debug_level=1 auth_mode=optional \
4935 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4936 0 \
4937 -c "bad certificate (usage extensions)" \
4938 -C "Processing of the Certificate handshake message failed" \
4939 -c "Ciphersuite is TLS-" \
4940 -c "! Usage does not match the keyUsage extension"
4941
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004942# Tests for keyUsage in leaf certificates, part 3:
4943# server-side checking of client cert
4944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004945run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004946 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004947 "$O_CLI -key data_files/server2.key \
4948 -cert data_files/server2.ku-ds.crt" \
4949 0 \
4950 -S "bad certificate (usage extensions)" \
4951 -S "Processing of the Certificate handshake message failed"
4952
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004953run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004954 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004955 "$O_CLI -key data_files/server2.key \
4956 -cert data_files/server2.ku-ke.crt" \
4957 0 \
4958 -s "bad certificate (usage extensions)" \
4959 -S "Processing of the Certificate handshake message failed"
4960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004961run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004962 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004963 "$O_CLI -key data_files/server2.key \
4964 -cert data_files/server2.ku-ke.crt" \
4965 1 \
4966 -s "bad certificate (usage extensions)" \
4967 -s "Processing of the Certificate handshake message failed"
4968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004969run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004970 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004971 "$O_CLI -key data_files/server5.key \
4972 -cert data_files/server5.ku-ds.crt" \
4973 0 \
4974 -S "bad certificate (usage extensions)" \
4975 -S "Processing of the Certificate handshake message failed"
4976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004977run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004978 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004979 "$O_CLI -key data_files/server5.key \
4980 -cert data_files/server5.ku-ka.crt" \
4981 0 \
4982 -s "bad certificate (usage extensions)" \
4983 -S "Processing of the Certificate handshake message failed"
4984
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004985# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
4986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004987run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004988 "$P_SRV key_file=data_files/server5.key \
4989 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004990 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004991 0
4992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004993run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004994 "$P_SRV key_file=data_files/server5.key \
4995 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004996 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004997 0
4998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004999run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005000 "$P_SRV key_file=data_files/server5.key \
5001 crt_file=data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005002 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005003 0
5004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005005run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005006 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005007 crt_file=data_files/server5.eku-cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005008 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005009 1
5010
5011# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5012
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005013run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005014 "$O_SRV -key data_files/server5.key \
5015 -cert data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005016 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005017 0 \
5018 -C "bad certificate (usage extensions)" \
5019 -C "Processing of the Certificate handshake message failed" \
5020 -c "Ciphersuite is TLS-"
5021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005022run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005023 "$O_SRV -key data_files/server5.key \
5024 -cert data_files/server5.eku-srv_cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005025 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005026 0 \
5027 -C "bad certificate (usage extensions)" \
5028 -C "Processing of the Certificate handshake message failed" \
5029 -c "Ciphersuite is TLS-"
5030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005031run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005032 "$O_SRV -key data_files/server5.key \
5033 -cert data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005034 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005035 0 \
5036 -C "bad certificate (usage extensions)" \
5037 -C "Processing of the Certificate handshake message failed" \
5038 -c "Ciphersuite is TLS-"
5039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005040run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005041 "$O_SRV -key data_files/server5.key \
5042 -cert data_files/server5.eku-cs.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005043 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005044 1 \
5045 -c "bad certificate (usage extensions)" \
5046 -c "Processing of the Certificate handshake message failed" \
5047 -C "Ciphersuite is TLS-"
5048
5049# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005051run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005052 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005053 "$O_CLI -key data_files/server5.key \
5054 -cert data_files/server5.eku-cli.crt" \
5055 0 \
5056 -S "bad certificate (usage extensions)" \
5057 -S "Processing of the Certificate handshake message failed"
5058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005059run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005060 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005061 "$O_CLI -key data_files/server5.key \
5062 -cert data_files/server5.eku-srv_cli.crt" \
5063 0 \
5064 -S "bad certificate (usage extensions)" \
5065 -S "Processing of the Certificate handshake message failed"
5066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005067run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005068 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005069 "$O_CLI -key data_files/server5.key \
5070 -cert data_files/server5.eku-cs_any.crt" \
5071 0 \
5072 -S "bad certificate (usage extensions)" \
5073 -S "Processing of the Certificate handshake message failed"
5074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005075run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005076 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005077 "$O_CLI -key data_files/server5.key \
5078 -cert data_files/server5.eku-cs.crt" \
5079 0 \
5080 -s "bad certificate (usage extensions)" \
5081 -S "Processing of the Certificate handshake message failed"
5082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005083run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005084 "$P_SRV debug_level=1 auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005085 "$O_CLI -key data_files/server5.key \
5086 -cert data_files/server5.eku-cs.crt" \
5087 1 \
5088 -s "bad certificate (usage extensions)" \
5089 -s "Processing of the Certificate handshake message failed"
5090
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005091# Tests for DHM parameters loading
5092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005093run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005094 "$P_SRV" \
5095 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5096 debug_level=3" \
5097 0 \
5098 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005099 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005101run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005102 "$P_SRV dhm_file=data_files/dhparams.pem" \
5103 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5104 debug_level=3" \
5105 0 \
5106 -c "value of 'DHM: P ' (1024 bits)" \
5107 -c "value of 'DHM: G ' (2 bits)"
5108
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005109# Tests for DHM client-side size checking
5110
5111run_test "DHM size: server default, client default, OK" \
5112 "$P_SRV" \
5113 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5114 debug_level=1" \
5115 0 \
5116 -C "DHM prime too short:"
5117
5118run_test "DHM size: server default, client 2048, OK" \
5119 "$P_SRV" \
5120 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5121 debug_level=1 dhmlen=2048" \
5122 0 \
5123 -C "DHM prime too short:"
5124
5125run_test "DHM size: server 1024, client default, OK" \
5126 "$P_SRV dhm_file=data_files/dhparams.pem" \
5127 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5128 debug_level=1" \
5129 0 \
5130 -C "DHM prime too short:"
5131
5132run_test "DHM size: server 1000, client default, rejected" \
5133 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5134 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5135 debug_level=1" \
5136 1 \
5137 -c "DHM prime too short:"
5138
5139run_test "DHM size: server default, client 2049, rejected" \
5140 "$P_SRV" \
5141 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5142 debug_level=1 dhmlen=2049" \
5143 1 \
5144 -c "DHM prime too short:"
5145
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005146# Tests for PSK callback
5147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005148run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005149 "$P_SRV psk=abc123 psk_identity=foo" \
5150 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5151 psk_identity=foo psk=abc123" \
5152 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005153 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005154 -S "SSL - Unknown identity received" \
5155 -S "SSL - Verification of the message MAC failed"
5156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005157run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005158 "$P_SRV" \
5159 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5160 psk_identity=foo psk=abc123" \
5161 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005162 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005163 -S "SSL - Unknown identity received" \
5164 -S "SSL - Verification of the message MAC failed"
5165
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005166run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005167 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5168 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5169 psk_identity=foo psk=abc123" \
5170 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005171 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005172 -s "SSL - Unknown identity received" \
5173 -S "SSL - Verification of the message MAC failed"
5174
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005175run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005176 "$P_SRV psk_list=abc,dead,def,beef" \
5177 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5178 psk_identity=abc psk=dead" \
5179 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005180 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005181 -S "SSL - Unknown identity received" \
5182 -S "SSL - Verification of the message MAC failed"
5183
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005184run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005185 "$P_SRV psk_list=abc,dead,def,beef" \
5186 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5187 psk_identity=def psk=beef" \
5188 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005189 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005190 -S "SSL - Unknown identity received" \
5191 -S "SSL - Verification of the message MAC failed"
5192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005193run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005194 "$P_SRV psk_list=abc,dead,def,beef" \
5195 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5196 psk_identity=ghi psk=beef" \
5197 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005198 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005199 -s "SSL - Unknown identity received" \
5200 -S "SSL - Verification of the message MAC failed"
5201
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005202run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005203 "$P_SRV psk_list=abc,dead,def,beef" \
5204 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5205 psk_identity=abc psk=beef" \
5206 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005207 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005208 -S "SSL - Unknown identity received" \
5209 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005210
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005211# Tests for EC J-PAKE
5212
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005213requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005214run_test "ECJPAKE: client not configured" \
5215 "$P_SRV debug_level=3" \
5216 "$P_CLI debug_level=3" \
5217 0 \
5218 -C "add ciphersuite: c0ff" \
5219 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005220 -S "found ecjpake kkpp extension" \
5221 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005222 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005223 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005224 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005225 -S "None of the common ciphersuites is usable"
5226
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005227requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005228run_test "ECJPAKE: server not configured" \
5229 "$P_SRV debug_level=3" \
5230 "$P_CLI debug_level=3 ecjpake_pw=bla \
5231 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5232 1 \
5233 -c "add ciphersuite: c0ff" \
5234 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005235 -s "found ecjpake kkpp extension" \
5236 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005237 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005238 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005239 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005240 -s "None of the common ciphersuites is usable"
5241
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005242requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005243run_test "ECJPAKE: working, TLS" \
5244 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5245 "$P_CLI debug_level=3 ecjpake_pw=bla \
5246 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005247 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005248 -c "add ciphersuite: c0ff" \
5249 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005250 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005251 -s "found ecjpake kkpp extension" \
5252 -S "skip ecjpake kkpp extension" \
5253 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005254 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005255 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005256 -S "None of the common ciphersuites is usable" \
5257 -S "SSL - Verification of the message MAC failed"
5258
Janos Follath74537a62016-09-02 13:45:28 +01005259server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005260requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005261run_test "ECJPAKE: password mismatch, TLS" \
5262 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5263 "$P_CLI debug_level=3 ecjpake_pw=bad \
5264 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5265 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005266 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005267 -s "SSL - Verification of the message MAC failed"
5268
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005269requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005270run_test "ECJPAKE: working, DTLS" \
5271 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5272 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5273 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5274 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005275 -c "re-using cached ecjpake parameters" \
5276 -S "SSL - Verification of the message MAC failed"
5277
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005278requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005279run_test "ECJPAKE: working, DTLS, no cookie" \
5280 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5281 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5282 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5283 0 \
5284 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005285 -S "SSL - Verification of the message MAC failed"
5286
Janos Follath74537a62016-09-02 13:45:28 +01005287server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005288requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005289run_test "ECJPAKE: password mismatch, DTLS" \
5290 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5291 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5292 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5293 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005294 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005295 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005296
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005297# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005298requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005299run_test "ECJPAKE: working, DTLS, nolog" \
5300 "$P_SRV dtls=1 ecjpake_pw=bla" \
5301 "$P_CLI dtls=1 ecjpake_pw=bla \
5302 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5303 0
5304
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005305# Tests for ciphersuites per version
5306
Janos Follathe2681a42016-03-07 15:57:05 +00005307requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005308requires_config_enabled MBEDTLS_CAMELLIA_C
5309requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005310run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005311 "$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 +02005312 "$P_CLI force_version=ssl3" \
5313 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005314 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005315
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005316requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5317requires_config_enabled MBEDTLS_CAMELLIA_C
5318requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005319run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005320 "$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 +01005321 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005322 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005323 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005324
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005325requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5326requires_config_enabled MBEDTLS_CAMELLIA_C
5327requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005328run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005329 "$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 +02005330 "$P_CLI force_version=tls1_1" \
5331 0 \
5332 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5333
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005334requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5335requires_config_enabled MBEDTLS_CAMELLIA_C
5336requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005337run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005338 "$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 +02005339 "$P_CLI force_version=tls1_2" \
5340 0 \
5341 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5342
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005343# Test for ClientHello without extensions
5344
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005345requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005346run_test "ClientHello without extensions, SHA-1 allowed" \
Ron Eldorb76e7652019-01-16 23:14:41 +02005347 "$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 +02005348 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005349 0 \
5350 -s "dumping 'client hello extensions' (0 bytes)"
5351
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005352requires_gnutls
5353run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
5354 "$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 +02005355 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005356 0 \
5357 -s "dumping 'client hello extensions' (0 bytes)"
5358
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005359# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005360
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005361run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005362 "$P_SRV" \
5363 "$P_CLI request_size=100" \
5364 0 \
5365 -s "Read from client: 100 bytes read$"
5366
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005367run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005368 "$P_SRV" \
5369 "$P_CLI request_size=500" \
5370 0 \
5371 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005372
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005373# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005374
Janos Follathe2681a42016-03-07 15:57:05 +00005375requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005376run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005377 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005378 "$P_CLI request_size=1 force_version=ssl3 \
5379 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5380 0 \
5381 -s "Read from client: 1 bytes read"
5382
Janos Follathe2681a42016-03-07 15:57:05 +00005383requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005384run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005385 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005386 "$P_CLI request_size=1 force_version=ssl3 \
5387 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5388 0 \
5389 -s "Read from client: 1 bytes read"
5390
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005391run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005392 "$P_SRV" \
5393 "$P_CLI request_size=1 force_version=tls1 \
5394 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5395 0 \
5396 -s "Read from client: 1 bytes read"
5397
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005398run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005399 "$P_SRV" \
5400 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5401 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5402 0 \
5403 -s "Read from client: 1 bytes read"
5404
Hanno Becker32c55012017-11-10 08:42:54 +00005405requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005406run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005407 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005408 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005409 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005410 0 \
5411 -s "Read from client: 1 bytes read"
5412
Hanno Becker32c55012017-11-10 08:42:54 +00005413requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005414run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005415 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005416 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005417 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005418 0 \
5419 -s "Read from client: 1 bytes read"
5420
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005421run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005422 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005423 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005424 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5425 0 \
5426 -s "Read from client: 1 bytes read"
5427
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005428run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005429 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5430 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005431 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005432 0 \
5433 -s "Read from client: 1 bytes read"
5434
5435requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005436run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005437 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005438 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005439 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005440 0 \
5441 -s "Read from client: 1 bytes read"
5442
Hanno Becker8501f982017-11-10 08:59:04 +00005443requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005444run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005445 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5446 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5447 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005448 0 \
5449 -s "Read from client: 1 bytes read"
5450
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005451run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005452 "$P_SRV" \
5453 "$P_CLI request_size=1 force_version=tls1_1 \
5454 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5455 0 \
5456 -s "Read from client: 1 bytes read"
5457
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005458run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005459 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005460 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005461 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005462 0 \
5463 -s "Read from client: 1 bytes read"
5464
5465requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005466run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005467 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005468 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005469 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005470 0 \
5471 -s "Read from client: 1 bytes read"
5472
5473requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005474run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005475 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005476 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005477 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005478 0 \
5479 -s "Read from client: 1 bytes read"
5480
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005481run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005482 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005483 "$P_CLI request_size=1 force_version=tls1_1 \
5484 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5485 0 \
5486 -s "Read from client: 1 bytes read"
5487
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005488run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005489 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005490 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005491 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005492 0 \
5493 -s "Read from client: 1 bytes read"
5494
Hanno Becker8501f982017-11-10 08:59:04 +00005495requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005496run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005497 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005498 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005499 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005500 0 \
5501 -s "Read from client: 1 bytes read"
5502
Hanno Becker32c55012017-11-10 08:42:54 +00005503requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005504run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005505 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005506 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005507 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005508 0 \
5509 -s "Read from client: 1 bytes read"
5510
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005511run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005512 "$P_SRV" \
5513 "$P_CLI request_size=1 force_version=tls1_2 \
5514 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5515 0 \
5516 -s "Read from client: 1 bytes read"
5517
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005518run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005519 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005520 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005521 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005522 0 \
5523 -s "Read from client: 1 bytes read"
5524
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005525run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005526 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005527 "$P_CLI request_size=1 force_version=tls1_2 \
5528 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005529 0 \
5530 -s "Read from client: 1 bytes read"
5531
Hanno Becker32c55012017-11-10 08:42:54 +00005532requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005533run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005534 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005535 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005536 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005537 0 \
5538 -s "Read from client: 1 bytes read"
5539
Hanno Becker8501f982017-11-10 08:59:04 +00005540requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005541run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005542 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005543 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005544 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005545 0 \
5546 -s "Read from client: 1 bytes read"
5547
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005548run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005549 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005550 "$P_CLI request_size=1 force_version=tls1_2 \
5551 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5552 0 \
5553 -s "Read from client: 1 bytes read"
5554
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005555run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005556 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005557 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005558 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005559 0 \
5560 -s "Read from client: 1 bytes read"
5561
Hanno Becker32c55012017-11-10 08:42:54 +00005562requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005563run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005564 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005565 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005566 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005567 0 \
5568 -s "Read from client: 1 bytes read"
5569
Hanno Becker8501f982017-11-10 08:59:04 +00005570requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005571run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005572 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005573 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005574 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005575 0 \
5576 -s "Read from client: 1 bytes read"
5577
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005578run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005579 "$P_SRV" \
5580 "$P_CLI request_size=1 force_version=tls1_2 \
5581 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5582 0 \
5583 -s "Read from client: 1 bytes read"
5584
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005585run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005586 "$P_SRV" \
5587 "$P_CLI request_size=1 force_version=tls1_2 \
5588 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5589 0 \
5590 -s "Read from client: 1 bytes read"
5591
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005592# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005593
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005594run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005595 "$P_SRV dtls=1 force_version=dtls1" \
5596 "$P_CLI dtls=1 request_size=1 \
5597 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5598 0 \
5599 -s "Read from client: 1 bytes read"
5600
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005601run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00005602 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
5603 "$P_CLI dtls=1 request_size=1 \
5604 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5605 0 \
5606 -s "Read from client: 1 bytes read"
5607
Hanno Beckere2148042017-11-10 08:59:18 +00005608requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005609run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005610 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
5611 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00005612 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5613 0 \
5614 -s "Read from client: 1 bytes read"
5615
Hanno Beckere2148042017-11-10 08:59:18 +00005616requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005617run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005618 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005619 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005620 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005621 0 \
5622 -s "Read from client: 1 bytes read"
5623
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005624run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00005625 "$P_SRV dtls=1 force_version=dtls1_2" \
5626 "$P_CLI dtls=1 request_size=1 \
5627 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5628 0 \
5629 -s "Read from client: 1 bytes read"
5630
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005631run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005632 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005633 "$P_CLI dtls=1 request_size=1 \
5634 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5635 0 \
5636 -s "Read from client: 1 bytes read"
5637
Hanno Beckere2148042017-11-10 08:59:18 +00005638requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005639run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005640 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005641 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005642 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005643 0 \
5644 -s "Read from client: 1 bytes read"
5645
Hanno Beckere2148042017-11-10 08:59:18 +00005646requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005647run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005648 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005649 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005650 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005651 0 \
5652 -s "Read from client: 1 bytes read"
5653
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005654# Tests for small server packets
5655
5656requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5657run_test "Small server packet SSLv3 BlockCipher" \
5658 "$P_SRV response_size=1 min_version=ssl3" \
5659 "$P_CLI force_version=ssl3 \
5660 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5661 0 \
5662 -c "Read from server: 1 bytes read"
5663
5664requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5665run_test "Small server packet SSLv3 StreamCipher" \
5666 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5667 "$P_CLI force_version=ssl3 \
5668 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5669 0 \
5670 -c "Read from server: 1 bytes read"
5671
5672run_test "Small server packet TLS 1.0 BlockCipher" \
5673 "$P_SRV response_size=1" \
5674 "$P_CLI force_version=tls1 \
5675 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5676 0 \
5677 -c "Read from server: 1 bytes read"
5678
5679run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
5680 "$P_SRV response_size=1" \
5681 "$P_CLI force_version=tls1 etm=0 \
5682 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5683 0 \
5684 -c "Read from server: 1 bytes read"
5685
5686requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5687run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
5688 "$P_SRV response_size=1 trunc_hmac=1" \
5689 "$P_CLI force_version=tls1 \
5690 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5691 0 \
5692 -c "Read from server: 1 bytes read"
5693
5694requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5695run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
5696 "$P_SRV response_size=1 trunc_hmac=1" \
5697 "$P_CLI force_version=tls1 \
5698 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5699 0 \
5700 -c "Read from server: 1 bytes read"
5701
5702run_test "Small server packet TLS 1.0 StreamCipher" \
5703 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5704 "$P_CLI force_version=tls1 \
5705 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5706 0 \
5707 -c "Read from server: 1 bytes read"
5708
5709run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
5710 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5711 "$P_CLI force_version=tls1 \
5712 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5713 0 \
5714 -c "Read from server: 1 bytes read"
5715
5716requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5717run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
5718 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5719 "$P_CLI force_version=tls1 \
5720 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5721 0 \
5722 -c "Read from server: 1 bytes read"
5723
5724requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5725run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5726 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5727 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5728 trunc_hmac=1 etm=0" \
5729 0 \
5730 -c "Read from server: 1 bytes read"
5731
5732run_test "Small server packet TLS 1.1 BlockCipher" \
5733 "$P_SRV response_size=1" \
5734 "$P_CLI force_version=tls1_1 \
5735 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5736 0 \
5737 -c "Read from server: 1 bytes read"
5738
5739run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
5740 "$P_SRV response_size=1" \
5741 "$P_CLI force_version=tls1_1 \
5742 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5743 0 \
5744 -c "Read from server: 1 bytes read"
5745
5746requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5747run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
5748 "$P_SRV response_size=1 trunc_hmac=1" \
5749 "$P_CLI force_version=tls1_1 \
5750 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5751 0 \
5752 -c "Read from server: 1 bytes read"
5753
5754requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5755run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5756 "$P_SRV response_size=1 trunc_hmac=1" \
5757 "$P_CLI force_version=tls1_1 \
5758 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5759 0 \
5760 -c "Read from server: 1 bytes read"
5761
5762run_test "Small server packet TLS 1.1 StreamCipher" \
5763 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5764 "$P_CLI force_version=tls1_1 \
5765 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5766 0 \
5767 -c "Read from server: 1 bytes read"
5768
5769run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
5770 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5771 "$P_CLI force_version=tls1_1 \
5772 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5773 0 \
5774 -c "Read from server: 1 bytes read"
5775
5776requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5777run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
5778 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5779 "$P_CLI force_version=tls1_1 \
5780 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5781 0 \
5782 -c "Read from server: 1 bytes read"
5783
5784requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5785run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5786 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5787 "$P_CLI force_version=tls1_1 \
5788 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5789 0 \
5790 -c "Read from server: 1 bytes read"
5791
5792run_test "Small server packet TLS 1.2 BlockCipher" \
5793 "$P_SRV response_size=1" \
5794 "$P_CLI force_version=tls1_2 \
5795 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5796 0 \
5797 -c "Read from server: 1 bytes read"
5798
5799run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5800 "$P_SRV response_size=1" \
5801 "$P_CLI force_version=tls1_2 \
5802 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5803 0 \
5804 -c "Read from server: 1 bytes read"
5805
5806run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5807 "$P_SRV response_size=1" \
5808 "$P_CLI force_version=tls1_2 \
5809 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5810 0 \
5811 -c "Read from server: 1 bytes read"
5812
5813requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5814run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5815 "$P_SRV response_size=1 trunc_hmac=1" \
5816 "$P_CLI force_version=tls1_2 \
5817 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5818 0 \
5819 -c "Read from server: 1 bytes read"
5820
5821requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5822run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5823 "$P_SRV response_size=1 trunc_hmac=1" \
5824 "$P_CLI force_version=tls1_2 \
5825 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5826 0 \
5827 -c "Read from server: 1 bytes read"
5828
5829run_test "Small server packet TLS 1.2 StreamCipher" \
5830 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5831 "$P_CLI force_version=tls1_2 \
5832 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5833 0 \
5834 -c "Read from server: 1 bytes read"
5835
5836run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
5837 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5838 "$P_CLI force_version=tls1_2 \
5839 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5840 0 \
5841 -c "Read from server: 1 bytes read"
5842
5843requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5844run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
5845 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5846 "$P_CLI force_version=tls1_2 \
5847 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5848 0 \
5849 -c "Read from server: 1 bytes read"
5850
5851requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5852run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5853 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5854 "$P_CLI force_version=tls1_2 \
5855 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5856 0 \
5857 -c "Read from server: 1 bytes read"
5858
5859run_test "Small server packet TLS 1.2 AEAD" \
5860 "$P_SRV response_size=1" \
5861 "$P_CLI force_version=tls1_2 \
5862 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5863 0 \
5864 -c "Read from server: 1 bytes read"
5865
5866run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5867 "$P_SRV response_size=1" \
5868 "$P_CLI force_version=tls1_2 \
5869 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5870 0 \
5871 -c "Read from server: 1 bytes read"
5872
5873# Tests for small server packets in DTLS
5874
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005875run_test "Small server packet DTLS 1.0" \
5876 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
5877 "$P_CLI dtls=1 \
5878 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5879 0 \
5880 -c "Read from server: 1 bytes read"
5881
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005882run_test "Small server packet DTLS 1.0, without EtM" \
5883 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
5884 "$P_CLI dtls=1 \
5885 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5886 0 \
5887 -c "Read from server: 1 bytes read"
5888
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005889requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5890run_test "Small server packet DTLS 1.0, truncated hmac" \
5891 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
5892 "$P_CLI dtls=1 trunc_hmac=1 \
5893 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5894 0 \
5895 -c "Read from server: 1 bytes read"
5896
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005897requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5898run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
5899 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
5900 "$P_CLI dtls=1 \
5901 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5902 0 \
5903 -c "Read from server: 1 bytes read"
5904
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005905run_test "Small server packet DTLS 1.2" \
5906 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
5907 "$P_CLI dtls=1 \
5908 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5909 0 \
5910 -c "Read from server: 1 bytes read"
5911
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005912run_test "Small server packet DTLS 1.2, without EtM" \
5913 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5914 "$P_CLI dtls=1 \
5915 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5916 0 \
5917 -c "Read from server: 1 bytes read"
5918
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005919requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5920run_test "Small server packet DTLS 1.2, truncated hmac" \
5921 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5922 "$P_CLI dtls=1 \
5923 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5924 0 \
5925 -c "Read from server: 1 bytes read"
5926
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005927requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5928run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5929 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5930 "$P_CLI dtls=1 \
5931 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5932 0 \
5933 -c "Read from server: 1 bytes read"
5934
Janos Follath00efff72016-05-06 13:48:23 +01005935# A test for extensions in SSLv3
5936
5937requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5938run_test "SSLv3 with extensions, server side" \
5939 "$P_SRV min_version=ssl3 debug_level=3" \
5940 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
5941 0 \
5942 -S "dumping 'client hello extensions'" \
5943 -S "server hello, total extension length:"
5944
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005945# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005946
Angus Grattonc4dd0732018-04-11 16:28:39 +10005947# How many fragments do we expect to write $1 bytes?
5948fragments_for_write() {
5949 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
5950}
5951
Janos Follathe2681a42016-03-07 15:57:05 +00005952requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005953run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005954 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005955 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005956 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5957 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005958 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5959 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005960
Janos Follathe2681a42016-03-07 15:57:05 +00005961requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005962run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005963 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005964 "$P_CLI request_size=16384 force_version=ssl3 \
5965 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5966 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005967 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5968 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005969
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005970run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005971 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005972 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005973 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5974 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005975 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5976 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005977
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005978run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005979 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005980 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
5981 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5982 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005983 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005984
Hanno Becker32c55012017-11-10 08:42:54 +00005985requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005986run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005987 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005988 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005989 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005990 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005991 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5992 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005993
Hanno Becker32c55012017-11-10 08:42:54 +00005994requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005995run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005996 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005997 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005998 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005999 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006000 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006001
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006002run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006003 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006004 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006005 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6006 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006007 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006008
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006009run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006010 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6011 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006012 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006013 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006014 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006015
6016requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006017run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006018 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006019 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006020 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006021 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006022 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006023
Hanno Becker278fc7a2017-11-10 09:16:28 +00006024requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006025run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006026 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006027 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006028 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006029 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006030 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6031 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006032
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006033run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006034 "$P_SRV" \
6035 "$P_CLI request_size=16384 force_version=tls1_1 \
6036 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6037 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006038 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6039 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006040
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006041run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006042 "$P_SRV" \
6043 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6044 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006045 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006046 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006047
Hanno Becker32c55012017-11-10 08:42:54 +00006048requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006049run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006050 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006051 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006052 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006053 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006054 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006055
Hanno Becker32c55012017-11-10 08:42:54 +00006056requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006057run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006058 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006059 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006060 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006061 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006062 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006063
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006064run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006065 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6066 "$P_CLI request_size=16384 force_version=tls1_1 \
6067 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6068 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006069 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6070 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006071
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006072run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006073 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006074 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006075 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006076 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006077 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6078 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006079
Hanno Becker278fc7a2017-11-10 09:16:28 +00006080requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006081run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006082 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006083 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006084 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006085 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006086 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006087
Hanno Becker278fc7a2017-11-10 09:16:28 +00006088requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006089run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006090 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006091 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006092 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006093 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006094 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6095 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006096
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006097run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006098 "$P_SRV" \
6099 "$P_CLI request_size=16384 force_version=tls1_2 \
6100 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6101 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006102 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6103 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006104
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006105run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006106 "$P_SRV" \
6107 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6108 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6109 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006110 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006111
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006112run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006113 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006114 "$P_CLI request_size=16384 force_version=tls1_2 \
6115 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006116 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006117 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6118 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006119
Hanno Becker32c55012017-11-10 08:42:54 +00006120requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006121run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006122 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006123 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006124 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006125 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006126 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006127
Hanno Becker278fc7a2017-11-10 09:16:28 +00006128requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006129run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006130 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006131 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006132 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006133 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006134 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6135 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006136
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006137run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006138 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006139 "$P_CLI request_size=16384 force_version=tls1_2 \
6140 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6141 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006142 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6143 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006144
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006145run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006146 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006147 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006148 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6149 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006150 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006151
Hanno Becker32c55012017-11-10 08:42:54 +00006152requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006153run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006154 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006155 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006156 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006157 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006158 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006159
Hanno Becker278fc7a2017-11-10 09:16:28 +00006160requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006161run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006162 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006163 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006164 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006165 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006166 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6167 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006168
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006169run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006170 "$P_SRV" \
6171 "$P_CLI request_size=16384 force_version=tls1_2 \
6172 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6173 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006174 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6175 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006176
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006177run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006178 "$P_SRV" \
6179 "$P_CLI request_size=16384 force_version=tls1_2 \
6180 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6181 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006182 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6183 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006184
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006185# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006186requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6187run_test "Large server packet SSLv3 StreamCipher" \
6188 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6189 "$P_CLI force_version=ssl3 \
6190 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6191 0 \
6192 -c "Read from server: 16384 bytes read"
6193
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006194# Checking next 4 tests logs for 1n-1 split against BEAST too
6195requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6196run_test "Large server packet SSLv3 BlockCipher" \
6197 "$P_SRV response_size=16384 min_version=ssl3" \
6198 "$P_CLI force_version=ssl3 recsplit=0 \
6199 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6200 0 \
6201 -c "Read from server: 1 bytes read"\
6202 -c "16383 bytes read"\
6203 -C "Read from server: 16384 bytes read"
6204
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006205run_test "Large server packet TLS 1.0 BlockCipher" \
6206 "$P_SRV response_size=16384" \
6207 "$P_CLI force_version=tls1 recsplit=0 \
6208 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6209 0 \
6210 -c "Read from server: 1 bytes read"\
6211 -c "16383 bytes read"\
6212 -C "Read from server: 16384 bytes read"
6213
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006214run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6215 "$P_SRV response_size=16384" \
6216 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6217 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6218 0 \
6219 -c "Read from server: 1 bytes read"\
6220 -c "16383 bytes read"\
6221 -C "Read from server: 16384 bytes read"
6222
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006223requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6224run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6225 "$P_SRV response_size=16384" \
6226 "$P_CLI force_version=tls1 recsplit=0 \
6227 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6228 trunc_hmac=1" \
6229 0 \
6230 -c "Read from server: 1 bytes read"\
6231 -c "16383 bytes read"\
6232 -C "Read from server: 16384 bytes read"
6233
6234requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6235run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6236 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6237 "$P_CLI force_version=tls1 \
6238 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6239 trunc_hmac=1" \
6240 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006241 -s "16384 bytes written in 1 fragments" \
6242 -c "Read from server: 16384 bytes read"
6243
6244run_test "Large server packet TLS 1.0 StreamCipher" \
6245 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6246 "$P_CLI force_version=tls1 \
6247 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6248 0 \
6249 -s "16384 bytes written in 1 fragments" \
6250 -c "Read from server: 16384 bytes read"
6251
6252run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6253 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6254 "$P_CLI force_version=tls1 \
6255 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6256 0 \
6257 -s "16384 bytes written in 1 fragments" \
6258 -c "Read from server: 16384 bytes read"
6259
6260requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6261run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6262 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6263 "$P_CLI force_version=tls1 \
6264 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6265 0 \
6266 -s "16384 bytes written in 1 fragments" \
6267 -c "Read from server: 16384 bytes read"
6268
6269requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6270run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6271 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6272 "$P_CLI force_version=tls1 \
6273 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6274 0 \
6275 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006276 -c "Read from server: 16384 bytes read"
6277
6278run_test "Large server packet TLS 1.1 BlockCipher" \
6279 "$P_SRV response_size=16384" \
6280 "$P_CLI force_version=tls1_1 \
6281 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6282 0 \
6283 -c "Read from server: 16384 bytes read"
6284
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006285run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6286 "$P_SRV response_size=16384" \
6287 "$P_CLI force_version=tls1_1 etm=0 \
6288 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006289 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006290 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006291 -c "Read from server: 16384 bytes read"
6292
6293requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6294run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6295 "$P_SRV response_size=16384" \
6296 "$P_CLI force_version=tls1_1 \
6297 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6298 trunc_hmac=1" \
6299 0 \
6300 -c "Read from server: 16384 bytes read"
6301
6302requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006303run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6304 "$P_SRV response_size=16384 trunc_hmac=1" \
6305 "$P_CLI force_version=tls1_1 \
6306 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6307 0 \
6308 -s "16384 bytes written in 1 fragments" \
6309 -c "Read from server: 16384 bytes read"
6310
6311run_test "Large server packet TLS 1.1 StreamCipher" \
6312 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6313 "$P_CLI force_version=tls1_1 \
6314 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6315 0 \
6316 -c "Read from server: 16384 bytes read"
6317
6318run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6319 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6320 "$P_CLI force_version=tls1_1 \
6321 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6322 0 \
6323 -s "16384 bytes written in 1 fragments" \
6324 -c "Read from server: 16384 bytes read"
6325
6326requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006327run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6328 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6329 "$P_CLI force_version=tls1_1 \
6330 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6331 trunc_hmac=1" \
6332 0 \
6333 -c "Read from server: 16384 bytes read"
6334
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006335run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6336 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6337 "$P_CLI force_version=tls1_1 \
6338 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6339 0 \
6340 -s "16384 bytes written in 1 fragments" \
6341 -c "Read from server: 16384 bytes read"
6342
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006343run_test "Large server packet TLS 1.2 BlockCipher" \
6344 "$P_SRV response_size=16384" \
6345 "$P_CLI force_version=tls1_2 \
6346 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6347 0 \
6348 -c "Read from server: 16384 bytes read"
6349
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006350run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6351 "$P_SRV response_size=16384" \
6352 "$P_CLI force_version=tls1_2 etm=0 \
6353 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6354 0 \
6355 -s "16384 bytes written in 1 fragments" \
6356 -c "Read from server: 16384 bytes read"
6357
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006358run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6359 "$P_SRV response_size=16384" \
6360 "$P_CLI force_version=tls1_2 \
6361 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6362 0 \
6363 -c "Read from server: 16384 bytes read"
6364
6365requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6366run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6367 "$P_SRV response_size=16384" \
6368 "$P_CLI force_version=tls1_2 \
6369 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6370 trunc_hmac=1" \
6371 0 \
6372 -c "Read from server: 16384 bytes read"
6373
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006374run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6375 "$P_SRV response_size=16384 trunc_hmac=1" \
6376 "$P_CLI force_version=tls1_2 \
6377 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6378 0 \
6379 -s "16384 bytes written in 1 fragments" \
6380 -c "Read from server: 16384 bytes read"
6381
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006382run_test "Large server packet TLS 1.2 StreamCipher" \
6383 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6384 "$P_CLI force_version=tls1_2 \
6385 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6386 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006387 -s "16384 bytes written in 1 fragments" \
6388 -c "Read from server: 16384 bytes read"
6389
6390run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6391 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6392 "$P_CLI force_version=tls1_2 \
6393 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6394 0 \
6395 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006396 -c "Read from server: 16384 bytes read"
6397
6398requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6399run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6400 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6401 "$P_CLI force_version=tls1_2 \
6402 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6403 trunc_hmac=1" \
6404 0 \
6405 -c "Read from server: 16384 bytes read"
6406
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006407requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6408run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6409 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6410 "$P_CLI force_version=tls1_2 \
6411 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6412 0 \
6413 -s "16384 bytes written in 1 fragments" \
6414 -c "Read from server: 16384 bytes read"
6415
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006416run_test "Large server packet TLS 1.2 AEAD" \
6417 "$P_SRV response_size=16384" \
6418 "$P_CLI force_version=tls1_2 \
6419 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6420 0 \
6421 -c "Read from server: 16384 bytes read"
6422
6423run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6424 "$P_SRV response_size=16384" \
6425 "$P_CLI force_version=tls1_2 \
6426 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6427 0 \
6428 -c "Read from server: 16384 bytes read"
6429
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006430# Tests for restartable ECC
6431
6432requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6433run_test "EC restart: TLS, default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006434 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006435 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006436 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006437 debug_level=1" \
6438 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006439 -C "x509_verify_cert.*4b00" \
6440 -C "mbedtls_pk_verify.*4b00" \
6441 -C "mbedtls_ecdh_make_public.*4b00" \
6442 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006443
6444requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6445run_test "EC restart: TLS, max_ops=0" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006446 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006447 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006448 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006449 debug_level=1 ec_max_ops=0" \
6450 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006451 -C "x509_verify_cert.*4b00" \
6452 -C "mbedtls_pk_verify.*4b00" \
6453 -C "mbedtls_ecdh_make_public.*4b00" \
6454 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006455
6456requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6457run_test "EC restart: TLS, max_ops=65535" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006458 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006459 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006460 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006461 debug_level=1 ec_max_ops=65535" \
6462 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006463 -C "x509_verify_cert.*4b00" \
6464 -C "mbedtls_pk_verify.*4b00" \
6465 -C "mbedtls_ecdh_make_public.*4b00" \
6466 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006467
6468requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6469run_test "EC restart: TLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006470 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006471 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006472 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006473 debug_level=1 ec_max_ops=1000" \
6474 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006475 -c "x509_verify_cert.*4b00" \
6476 -c "mbedtls_pk_verify.*4b00" \
6477 -c "mbedtls_ecdh_make_public.*4b00" \
6478 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006479
6480requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Hanno Becker4a156fc2019-06-14 17:07:06 +01006481requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006482run_test "EC restart: TLS, max_ops=1000, badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006483 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006484 crt_file=data_files/server5-badsign.crt \
6485 key_file=data_files/server5.key" \
6486 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker03d77462019-08-27 16:24:56 +01006487 key_file=data_files/server5.key crt_file=data_files/server5.crt ca_file=data_files/test-ca2.crt \
6488 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6489 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006490 -c "x509_verify_cert.*4b00" \
Hanno Becker03d77462019-08-27 16:24:56 +01006491 -c "mbedtls_pk_verify.*4b00" \
6492 -c "mbedtls_ecdh_make_public.*4b00" \
6493 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006494 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006495
Hanno Becker4a156fc2019-06-14 17:07:06 +01006496requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006497requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6498run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006499 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006500 crt_file=data_files/server5-badsign.crt \
6501 key_file=data_files/server5.key" \
6502 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6503 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006504 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006505 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6506 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006507 -c "x509_verify_cert.*4b00" \
6508 -c "mbedtls_pk_verify.*4b00" \
6509 -c "mbedtls_ecdh_make_public.*4b00" \
6510 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006511 -c "! The certificate is not correctly signed by the trusted CA" \
6512 -C "! mbedtls_ssl_handshake returned" \
6513 -C "X509 - Certificate verification failed"
6514
Hanno Becker4a156fc2019-06-14 17:07:06 +01006515requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006516requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006517requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6518run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006519 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006520 crt_file=data_files/server5-badsign.crt \
6521 key_file=data_files/server5.key" \
6522 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006523 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006524 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6525 debug_level=1 ec_max_ops=1000 auth_mode=none" \
6526 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006527 -C "x509_verify_cert.*4b00" \
6528 -c "mbedtls_pk_verify.*4b00" \
6529 -c "mbedtls_ecdh_make_public.*4b00" \
6530 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006531 -C "! The certificate is not correctly signed by the trusted CA" \
6532 -C "! mbedtls_ssl_handshake returned" \
6533 -C "X509 - Certificate verification failed"
6534
6535requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006536run_test "EC restart: DTLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006537 "$P_SRV auth_mode=required dtls=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006538 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006539 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006540 dtls=1 debug_level=1 ec_max_ops=1000" \
6541 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006542 -c "x509_verify_cert.*4b00" \
6543 -c "mbedtls_pk_verify.*4b00" \
6544 -c "mbedtls_ecdh_make_public.*4b00" \
6545 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006546
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006547requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6548run_test "EC restart: TLS, max_ops=1000 no client auth" \
6549 "$P_SRV" \
6550 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6551 debug_level=1 ec_max_ops=1000" \
6552 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006553 -c "x509_verify_cert.*4b00" \
6554 -c "mbedtls_pk_verify.*4b00" \
6555 -c "mbedtls_ecdh_make_public.*4b00" \
6556 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006557
6558requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6559run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6560 "$P_SRV psk=abc123" \
6561 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6562 psk=abc123 debug_level=1 ec_max_ops=1000" \
6563 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006564 -C "x509_verify_cert.*4b00" \
6565 -C "mbedtls_pk_verify.*4b00" \
6566 -C "mbedtls_ecdh_make_public.*4b00" \
6567 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006568
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006569# Tests of asynchronous private key support in SSL
6570
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006571requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006572run_test "SSL async private: sign, delay=0" \
6573 "$P_SRV \
6574 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006575 "$P_CLI" \
6576 0 \
6577 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006578 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006579
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006580requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006581run_test "SSL async private: sign, delay=1" \
6582 "$P_SRV \
6583 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006584 "$P_CLI" \
6585 0 \
6586 -s "Async sign callback: using key slot " \
6587 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006588 -s "Async resume (slot [0-9]): sign done, status=0"
6589
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006590requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6591run_test "SSL async private: sign, delay=2" \
6592 "$P_SRV \
6593 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6594 "$P_CLI" \
6595 0 \
6596 -s "Async sign callback: using key slot " \
6597 -U "Async sign callback: using key slot " \
6598 -s "Async resume (slot [0-9]): call 1 more times." \
6599 -s "Async resume (slot [0-9]): call 0 more times." \
6600 -s "Async resume (slot [0-9]): sign done, status=0"
6601
Gilles Peskined3268832018-04-26 06:23:59 +02006602# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
6603# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
6604requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6605requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6606run_test "SSL async private: sign, RSA, TLS 1.1" \
6607 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
6608 async_operations=s async_private_delay1=0 async_private_delay2=0" \
6609 "$P_CLI force_version=tls1_1" \
6610 0 \
6611 -s "Async sign callback: using key slot " \
6612 -s "Async resume (slot [0-9]): sign done, status=0"
6613
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006614requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerb2c63832019-06-17 08:35:16 +01006615requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03006616requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006617requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskine807d74a2018-04-30 10:30:49 +02006618run_test "SSL async private: sign, SNI" \
6619 "$P_SRV debug_level=3 \
6620 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6621 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6622 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6623 "$P_CLI server_name=polarssl.example" \
6624 0 \
6625 -s "Async sign callback: using key slot " \
6626 -s "Async resume (slot [0-9]): sign done, status=0" \
6627 -s "parse ServerName extension" \
6628 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6629 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6630
6631requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006632run_test "SSL async private: decrypt, delay=0" \
6633 "$P_SRV \
6634 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6635 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6636 0 \
6637 -s "Async decrypt callback: using key slot " \
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, delay=1" \
6642 "$P_SRV \
6643 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6644 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6645 0 \
6646 -s "Async decrypt callback: using key slot " \
6647 -s "Async resume (slot [0-9]): call 0 more times." \
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=0" \
6652 "$P_SRV psk=abc123 \
6653 async_operations=d async_private_delay1=0 async_private_delay2=0" \
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]): decrypt done, status=0"
6659
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006660requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006661run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6662 "$P_SRV psk=abc123 \
6663 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6664 "$P_CLI psk=abc123 \
6665 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6666 0 \
6667 -s "Async decrypt callback: using key slot " \
6668 -s "Async resume (slot [0-9]): call 0 more times." \
6669 -s "Async resume (slot [0-9]): decrypt done, status=0"
6670
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006671requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006672run_test "SSL async private: sign callback not present" \
6673 "$P_SRV \
6674 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6675 "$P_CLI; [ \$? -eq 1 ] &&
6676 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6677 0 \
6678 -S "Async sign callback" \
6679 -s "! mbedtls_ssl_handshake returned" \
6680 -s "The own private key or pre-shared key is not set, but needed" \
6681 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6682 -s "Successful connection"
6683
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006684requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006685run_test "SSL async private: decrypt callback not present" \
6686 "$P_SRV debug_level=1 \
6687 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6688 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6689 [ \$? -eq 1 ] && $P_CLI" \
6690 0 \
6691 -S "Async decrypt callback" \
6692 -s "! mbedtls_ssl_handshake returned" \
6693 -s "got no RSA private key" \
6694 -s "Async resume (slot [0-9]): sign done, status=0" \
6695 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006696
6697# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006698requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006699run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006700 "$P_SRV \
6701 async_operations=s async_private_delay1=1 \
6702 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6703 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006704 "$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 +01006705 0 \
6706 -s "Async sign callback: using key slot 0," \
6707 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006708 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006709
6710# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006711requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006712run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006713 "$P_SRV \
6714 async_operations=s async_private_delay2=1 \
6715 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6716 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006717 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6718 0 \
6719 -s "Async sign callback: using key slot 0," \
6720 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006721 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006722
6723# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006724requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006725run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006726 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006727 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006728 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6729 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006730 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6731 0 \
6732 -s "Async sign callback: using key slot 1," \
6733 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006734 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006735
6736# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006737requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006738run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006739 "$P_SRV \
6740 async_operations=s async_private_delay1=1 \
6741 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6742 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006743 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6744 0 \
6745 -s "Async sign callback: no key matches this certificate."
6746
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006747requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006748run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006749 "$P_SRV \
6750 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6751 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006752 "$P_CLI" \
6753 1 \
6754 -s "Async sign callback: injected error" \
6755 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006756 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006757 -s "! mbedtls_ssl_handshake returned"
6758
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006759requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006760run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006761 "$P_SRV \
6762 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6763 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006764 "$P_CLI" \
6765 1 \
6766 -s "Async sign callback: using key slot " \
6767 -S "Async resume" \
6768 -s "Async cancel"
6769
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006770requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006771run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006772 "$P_SRV \
6773 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6774 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006775 "$P_CLI" \
6776 1 \
6777 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006778 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006779 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006780 -s "! mbedtls_ssl_handshake returned"
6781
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006782requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006783run_test "SSL async private: decrypt, error in start" \
6784 "$P_SRV \
6785 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6786 async_private_error=1" \
6787 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6788 1 \
6789 -s "Async decrypt callback: injected error" \
6790 -S "Async resume" \
6791 -S "Async cancel" \
6792 -s "! mbedtls_ssl_handshake returned"
6793
6794requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6795run_test "SSL async private: decrypt, cancel after start" \
6796 "$P_SRV \
6797 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6798 async_private_error=2" \
6799 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6800 1 \
6801 -s "Async decrypt callback: using key slot " \
6802 -S "Async resume" \
6803 -s "Async cancel"
6804
6805requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6806run_test "SSL async private: decrypt, error in resume" \
6807 "$P_SRV \
6808 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6809 async_private_error=3" \
6810 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6811 1 \
6812 -s "Async decrypt callback: using key slot " \
6813 -s "Async resume callback: decrypt done but injected error" \
6814 -S "Async cancel" \
6815 -s "! mbedtls_ssl_handshake returned"
6816
6817requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006818run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006819 "$P_SRV \
6820 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6821 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006822 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6823 0 \
6824 -s "Async cancel" \
6825 -s "! mbedtls_ssl_handshake returned" \
6826 -s "Async resume" \
6827 -s "Successful connection"
6828
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006829requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006830run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006831 "$P_SRV \
6832 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6833 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006834 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6835 0 \
6836 -s "! mbedtls_ssl_handshake returned" \
6837 -s "Async resume" \
6838 -s "Successful connection"
6839
6840# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006841requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006842run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006843 "$P_SRV \
6844 async_operations=s async_private_delay1=1 async_private_error=-2 \
6845 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6846 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006847 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6848 [ \$? -eq 1 ] &&
6849 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6850 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006851 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006852 -S "Async resume" \
6853 -s "Async cancel" \
6854 -s "! mbedtls_ssl_handshake returned" \
6855 -s "Async sign callback: no key matches this certificate." \
6856 -s "Successful connection"
6857
6858# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006859requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006860run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006861 "$P_SRV \
6862 async_operations=s async_private_delay1=1 async_private_error=-3 \
6863 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6864 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006865 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6866 [ \$? -eq 1 ] &&
6867 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6868 0 \
6869 -s "Async resume" \
6870 -s "! mbedtls_ssl_handshake returned" \
6871 -s "Async sign callback: no key matches this certificate." \
6872 -s "Successful connection"
6873
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006874requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006875requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006876run_test "SSL async private: renegotiation: client-initiated; sign" \
6877 "$P_SRV \
6878 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006879 exchanges=2 renegotiation=1" \
6880 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6881 0 \
6882 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006883 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006884
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006885requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006886requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006887run_test "SSL async private: renegotiation: server-initiated; sign" \
6888 "$P_SRV \
6889 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006890 exchanges=2 renegotiation=1 renegotiate=1" \
6891 "$P_CLI exchanges=2 renegotiation=1" \
6892 0 \
6893 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006894 -s "Async resume (slot [0-9]): sign done, status=0"
6895
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006896requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006897requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6898run_test "SSL async private: renegotiation: client-initiated; decrypt" \
6899 "$P_SRV \
6900 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6901 exchanges=2 renegotiation=1" \
6902 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6903 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6904 0 \
6905 -s "Async decrypt callback: using key slot " \
6906 -s "Async resume (slot [0-9]): decrypt done, status=0"
6907
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006908requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006909requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6910run_test "SSL async private: renegotiation: server-initiated; decrypt" \
6911 "$P_SRV \
6912 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6913 exchanges=2 renegotiation=1 renegotiate=1" \
6914 "$P_CLI exchanges=2 renegotiation=1 \
6915 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6916 0 \
6917 -s "Async decrypt callback: using key slot " \
6918 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006919
Ron Eldor58093c82018-06-28 13:22:05 +03006920# Tests for ECC extensions (rfc 4492)
6921
Ron Eldor643df7c2018-06-28 16:17:00 +03006922requires_config_enabled MBEDTLS_AES_C
6923requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6924requires_config_enabled MBEDTLS_SHA256_C
6925requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006926run_test "Force a non ECC ciphersuite in the client side" \
6927 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006928 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006929 0 \
6930 -C "client hello, adding supported_elliptic_curves extension" \
6931 -C "client hello, adding supported_point_formats extension" \
6932 -S "found supported elliptic curves extension" \
6933 -S "found supported point formats extension"
6934
Ron Eldor643df7c2018-06-28 16:17:00 +03006935requires_config_enabled MBEDTLS_AES_C
6936requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6937requires_config_enabled MBEDTLS_SHA256_C
6938requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006939run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006940 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006941 "$P_CLI debug_level=3" \
6942 0 \
6943 -C "found supported_point_formats extension" \
6944 -S "server hello, supported_point_formats extension"
6945
Ron Eldor643df7c2018-06-28 16:17:00 +03006946requires_config_enabled MBEDTLS_AES_C
6947requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6948requires_config_enabled MBEDTLS_SHA256_C
6949requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006950run_test "Force an ECC ciphersuite in the client side" \
6951 "$P_SRV debug_level=3" \
6952 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6953 0 \
6954 -c "client hello, adding supported_elliptic_curves extension" \
6955 -c "client hello, adding supported_point_formats extension" \
6956 -s "found supported elliptic curves extension" \
6957 -s "found supported point formats extension"
6958
Ron Eldor643df7c2018-06-28 16:17:00 +03006959requires_config_enabled MBEDTLS_AES_C
6960requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6961requires_config_enabled MBEDTLS_SHA256_C
6962requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006963run_test "Force an ECC ciphersuite in the server side" \
6964 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6965 "$P_CLI debug_level=3" \
6966 0 \
6967 -c "found supported_point_formats extension" \
6968 -s "server hello, supported_point_formats extension"
6969
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006970# Tests for DTLS HelloVerifyRequest
6971
6972run_test "DTLS cookie: enabled" \
6973 "$P_SRV dtls=1 debug_level=2" \
6974 "$P_CLI dtls=1 debug_level=2" \
6975 0 \
6976 -s "cookie verification failed" \
6977 -s "cookie verification passed" \
6978 -S "cookie verification skipped" \
6979 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006980 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006981 -S "SSL - The requested feature is not available"
6982
6983run_test "DTLS cookie: disabled" \
6984 "$P_SRV dtls=1 debug_level=2 cookies=0" \
6985 "$P_CLI dtls=1 debug_level=2" \
6986 0 \
6987 -S "cookie verification failed" \
6988 -S "cookie verification passed" \
6989 -s "cookie verification skipped" \
6990 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006991 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006992 -S "SSL - The requested feature is not available"
6993
Jarno Lamsa33281d52019-10-18 10:54:35 +03006994requires_config_enabled MBEDTLS_ERROR_C
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006995run_test "DTLS cookie: default (failing)" \
6996 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
6997 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
6998 1 \
6999 -s "cookie verification failed" \
7000 -S "cookie verification passed" \
7001 -S "cookie verification skipped" \
7002 -C "received hello verify request" \
7003 -S "hello verification requested" \
7004 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007005
7006requires_ipv6
7007run_test "DTLS cookie: enabled, IPv6" \
7008 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
7009 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
7010 0 \
7011 -s "cookie verification failed" \
7012 -s "cookie verification passed" \
7013 -S "cookie verification skipped" \
7014 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007015 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007016 -S "SSL - The requested feature is not available"
7017
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007018run_test "DTLS cookie: enabled, nbio" \
7019 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7020 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7021 0 \
7022 -s "cookie verification failed" \
7023 -s "cookie verification passed" \
7024 -S "cookie verification skipped" \
7025 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007026 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007027 -S "SSL - The requested feature is not available"
7028
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007029# Tests for client reconnecting from the same port with DTLS
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: reference" \
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" \
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
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007041not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007042requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007043run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007044 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
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 \
7047 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007048 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007049 -s "Client initiated reconnection from same port"
7050
Paul Bakker362689d2016-05-13 10:33:25 +01007051not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
Jarno Lamsa33281d52019-10-18 10:54:35 +03007052requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007053run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007054 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7055 "$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 +02007056 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007057 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007058 -s "Client initiated reconnection from same port"
7059
Paul Bakker362689d2016-05-13 10:33:25 +01007060only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
Jarno Lamsa33281d52019-10-18 10:54:35 +03007061requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007062run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7063 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7064 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7065 0 \
7066 -S "The operation timed out" \
7067 -s "Client initiated reconnection from same port"
7068
Jarno Lamsa33281d52019-10-18 10:54:35 +03007069requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007070run_test "DTLS client reconnect from same port: no cookies" \
7071 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007072 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7073 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007074 -s "The operation timed out" \
7075 -S "Client initiated reconnection from same port"
7076
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007077# Tests for various cases of client authentication with DTLS
7078# (focused on handshake flows and message parsing)
7079
7080run_test "DTLS client auth: required" \
7081 "$P_SRV dtls=1 auth_mode=required" \
7082 "$P_CLI dtls=1" \
7083 0 \
7084 -s "Verifying peer X.509 certificate... ok"
7085
Hanno Becker4a156fc2019-06-14 17:07:06 +01007086requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007087requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007088run_test "DTLS client auth: optional, client has no cert" \
7089 "$P_SRV dtls=1 auth_mode=optional" \
7090 "$P_CLI dtls=1 crt_file=none key_file=none" \
7091 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007092 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007093
Hanno Becker4a156fc2019-06-14 17:07:06 +01007094requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007095requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007096run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007097 "$P_SRV dtls=1 auth_mode=none" \
7098 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7099 0 \
7100 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007101 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007102
Jarno Lamsa33281d52019-10-18 10:54:35 +03007103requires_ciphersuite_enabled TLS-PSK-WITH-AES-128-GCM-SHA256
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007104run_test "DTLS wrong PSK: badmac alert" \
7105 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7106 "$P_CLI dtls=1 psk=abc124" \
7107 1 \
7108 -s "SSL - Verification of the message MAC failed" \
7109 -c "SSL - A fatal alert message was received from our peer"
7110
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007111# Tests for receiving fragmented handshake messages with DTLS
7112
7113requires_gnutls
7114run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7115 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007116 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007117 0 \
7118 -C "found fragmented DTLS handshake message" \
7119 -C "error"
7120
7121requires_gnutls
7122run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7123 "$G_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007124 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007125 0 \
7126 -c "found fragmented DTLS handshake message" \
7127 -C "error"
7128
7129requires_gnutls
7130run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7131 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007132 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007133 0 \
7134 -c "found fragmented DTLS handshake message" \
7135 -C "error"
7136
7137requires_gnutls
7138run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7139 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007140 "$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 +02007141 0 \
7142 -c "found fragmented DTLS handshake message" \
7143 -C "error"
7144
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007145requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007146requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007147run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7148 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007149 "$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 +02007150 0 \
7151 -c "found fragmented DTLS handshake message" \
7152 -c "client hello, adding renegotiation extension" \
7153 -c "found renegotiation extension" \
7154 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007155 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007156 -C "error" \
7157 -s "Extra-header:"
7158
7159requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007160requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007161run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7162 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007163 "$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 +02007164 0 \
7165 -c "found fragmented DTLS handshake message" \
7166 -c "client hello, adding renegotiation extension" \
7167 -c "found renegotiation extension" \
7168 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007169 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007170 -C "error" \
7171 -s "Extra-header:"
7172
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007173run_test "DTLS reassembly: no fragmentation (openssl server)" \
7174 "$O_SRV -dtls1 -mtu 2048" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007175 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007176 0 \
7177 -C "found fragmented DTLS handshake message" \
7178 -C "error"
7179
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007180run_test "DTLS reassembly: some fragmentation (openssl server)" \
7181 "$O_SRV -dtls1 -mtu 768" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007182 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007183 0 \
7184 -c "found fragmented DTLS handshake message" \
7185 -C "error"
7186
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007187run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007188 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007189 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007190 0 \
7191 -c "found fragmented DTLS handshake message" \
7192 -C "error"
7193
7194run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7195 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007196 "$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 +02007197 0 \
7198 -c "found fragmented DTLS handshake message" \
7199 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007200
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007201# Tests for sending fragmented handshake messages with DTLS
7202#
7203# Use client auth when we need the client to send large messages,
7204# and use large cert chains on both sides too (the long chains we have all use
7205# both RSA and ECDSA, but ideally we should have long chains with either).
7206# Sizes reached (UDP payload):
7207# - 2037B for server certificate
7208# - 1542B for client certificate
7209# - 1013B for newsessionticket
7210# - all others below 512B
7211# All those tests assume MAX_CONTENT_LEN is at least 2048
7212
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007213requires_config_enabled MBEDTLS_RSA_C
7214requires_config_enabled MBEDTLS_ECDSA_C
7215requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7216run_test "DTLS fragmenting: none (for reference)" \
7217 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7218 crt_file=data_files/server7_int-ca.crt \
7219 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007220 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007221 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007222 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007223 "$P_CLI dtls=1 debug_level=2 \
7224 crt_file=data_files/server8_int-ca2.crt \
7225 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007226 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007227 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007228 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007229 0 \
7230 -S "found fragmented DTLS handshake message" \
7231 -C "found fragmented DTLS handshake message" \
7232 -C "error"
7233
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007234requires_config_enabled MBEDTLS_RSA_C
7235requires_config_enabled MBEDTLS_ECDSA_C
7236requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007237run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007238 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7239 crt_file=data_files/server7_int-ca.crt \
7240 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007241 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007242 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007243 max_frag_len=1024" \
7244 "$P_CLI dtls=1 debug_level=2 \
7245 crt_file=data_files/server8_int-ca2.crt \
7246 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007247 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007248 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007249 max_frag_len=2048" \
7250 0 \
7251 -S "found fragmented DTLS handshake message" \
7252 -c "found fragmented DTLS handshake message" \
7253 -C "error"
7254
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007255# With the MFL extension, the server has no way of forcing
7256# the client to not exceed a certain MTU; hence, the following
7257# test can't be replicated with an MTU proxy such as the one
7258# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007259requires_config_enabled MBEDTLS_RSA_C
7260requires_config_enabled MBEDTLS_ECDSA_C
7261requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007262run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007263 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7264 crt_file=data_files/server7_int-ca.crt \
7265 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007266 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007267 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007268 max_frag_len=512" \
7269 "$P_CLI dtls=1 debug_level=2 \
7270 crt_file=data_files/server8_int-ca2.crt \
7271 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007272 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007273 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007274 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007275 0 \
7276 -S "found fragmented DTLS handshake message" \
7277 -c "found fragmented DTLS handshake message" \
7278 -C "error"
7279
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007280requires_config_enabled MBEDTLS_RSA_C
7281requires_config_enabled MBEDTLS_ECDSA_C
7282requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007283run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007284 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7285 crt_file=data_files/server7_int-ca.crt \
7286 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007287 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007288 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007289 max_frag_len=2048" \
7290 "$P_CLI dtls=1 debug_level=2 \
7291 crt_file=data_files/server8_int-ca2.crt \
7292 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007293 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007294 hs_timeout=2500-60000 \
7295 max_frag_len=1024" \
7296 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007297 -S "found fragmented DTLS handshake message" \
7298 -c "found fragmented DTLS handshake message" \
7299 -C "error"
7300
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007301# While not required by the standard defining the MFL extension
7302# (according to which it only applies to records, not to datagrams),
7303# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7304# as otherwise there wouldn't be any means to communicate MTU restrictions
7305# to the peer.
7306# The next test checks that no datagrams significantly larger than the
7307# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007308requires_config_enabled MBEDTLS_RSA_C
7309requires_config_enabled MBEDTLS_ECDSA_C
7310requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7311run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007312 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007313 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7314 crt_file=data_files/server7_int-ca.crt \
7315 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007316 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007317 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007318 max_frag_len=2048" \
7319 "$P_CLI dtls=1 debug_level=2 \
7320 crt_file=data_files/server8_int-ca2.crt \
7321 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007322 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007323 hs_timeout=2500-60000 \
7324 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007325 0 \
7326 -S "found fragmented DTLS handshake message" \
7327 -c "found fragmented DTLS handshake message" \
7328 -C "error"
7329
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007330requires_config_enabled MBEDTLS_RSA_C
7331requires_config_enabled MBEDTLS_ECDSA_C
7332requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007333run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007334 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7335 crt_file=data_files/server7_int-ca.crt \
7336 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007337 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007338 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007339 max_frag_len=2048" \
7340 "$P_CLI dtls=1 debug_level=2 \
7341 crt_file=data_files/server8_int-ca2.crt \
7342 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007343 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007344 hs_timeout=2500-60000 \
7345 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007346 0 \
7347 -s "found fragmented DTLS handshake message" \
7348 -c "found fragmented DTLS handshake message" \
7349 -C "error"
7350
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007351# While not required by the standard defining the MFL extension
7352# (according to which it only applies to records, not to datagrams),
7353# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7354# as otherwise there wouldn't be any means to communicate MTU restrictions
7355# to the peer.
7356# The next test checks that no datagrams significantly larger than the
7357# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007358requires_config_enabled MBEDTLS_RSA_C
7359requires_config_enabled MBEDTLS_ECDSA_C
7360requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7361run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007362 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007363 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7364 crt_file=data_files/server7_int-ca.crt \
7365 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007366 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007367 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007368 max_frag_len=2048" \
7369 "$P_CLI dtls=1 debug_level=2 \
7370 crt_file=data_files/server8_int-ca2.crt \
7371 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007372 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007373 hs_timeout=2500-60000 \
7374 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007375 0 \
7376 -s "found fragmented DTLS handshake message" \
7377 -c "found fragmented DTLS handshake message" \
7378 -C "error"
7379
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007380requires_config_enabled MBEDTLS_RSA_C
7381requires_config_enabled MBEDTLS_ECDSA_C
7382run_test "DTLS fragmenting: none (for reference) (MTU)" \
7383 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7384 crt_file=data_files/server7_int-ca.crt \
7385 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007386 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007387 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007388 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007389 "$P_CLI dtls=1 debug_level=2 \
7390 crt_file=data_files/server8_int-ca2.crt \
7391 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007392 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007393 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007394 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007395 0 \
7396 -S "found fragmented DTLS handshake message" \
7397 -C "found fragmented DTLS handshake message" \
7398 -C "error"
7399
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007400requires_config_enabled MBEDTLS_RSA_C
7401requires_config_enabled MBEDTLS_ECDSA_C
7402run_test "DTLS fragmenting: client (MTU)" \
7403 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7404 crt_file=data_files/server7_int-ca.crt \
7405 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007406 ca_file=data_files/test-ca.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007407 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007408 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007409 "$P_CLI dtls=1 debug_level=2 \
7410 crt_file=data_files/server8_int-ca2.crt \
7411 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007412 ca_file=data_files/test-ca2.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007413 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007414 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007415 0 \
7416 -s "found fragmented DTLS handshake message" \
7417 -C "found fragmented DTLS handshake message" \
7418 -C "error"
7419
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007420requires_config_enabled MBEDTLS_RSA_C
7421requires_config_enabled MBEDTLS_ECDSA_C
7422run_test "DTLS fragmenting: server (MTU)" \
7423 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7424 crt_file=data_files/server7_int-ca.crt \
7425 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007426 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007427 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007428 mtu=512" \
7429 "$P_CLI dtls=1 debug_level=2 \
7430 crt_file=data_files/server8_int-ca2.crt \
7431 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007432 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007433 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007434 mtu=2048" \
7435 0 \
7436 -S "found fragmented DTLS handshake message" \
7437 -c "found fragmented DTLS handshake message" \
7438 -C "error"
7439
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007440requires_config_enabled MBEDTLS_RSA_C
7441requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007442run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007443 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007444 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7445 crt_file=data_files/server7_int-ca.crt \
7446 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007447 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007448 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007449 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007450 "$P_CLI dtls=1 debug_level=2 \
7451 crt_file=data_files/server8_int-ca2.crt \
7452 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007453 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007454 hs_timeout=2500-60000 \
7455 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007456 0 \
7457 -s "found fragmented DTLS handshake message" \
7458 -c "found fragmented DTLS handshake message" \
7459 -C "error"
7460
Andrzej Kurek77826052018-10-11 07:34:08 -04007461# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007462requires_config_enabled MBEDTLS_RSA_C
7463requires_config_enabled MBEDTLS_ECDSA_C
7464requires_config_enabled MBEDTLS_SHA256_C
7465requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7466requires_config_enabled MBEDTLS_AES_C
7467requires_config_enabled MBEDTLS_GCM_C
7468run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007469 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007470 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7471 crt_file=data_files/server7_int-ca.crt \
7472 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007473 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007474 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007475 mtu=512" \
7476 "$P_CLI dtls=1 debug_level=2 \
7477 crt_file=data_files/server8_int-ca2.crt \
7478 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007479 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007480 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7481 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007482 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007483 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007484 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007485 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007486 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007487
Andrzej Kurek7311c782018-10-11 06:49:41 -04007488# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007489# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007490# The ratio of max/min timeout should ideally equal 4 to accept two
7491# retransmissions, but in some cases (like both the server and client using
7492# fragmentation and auto-reduction) an extra retransmission might occur,
7493# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007494not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007495requires_config_enabled MBEDTLS_RSA_C
7496requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007497requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7498requires_config_enabled MBEDTLS_AES_C
7499requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007500run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7501 -p "$P_PXY mtu=508" \
7502 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7503 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007504 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007505 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007506 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007507 "$P_CLI dtls=1 debug_level=2 \
7508 crt_file=data_files/server8_int-ca2.crt \
7509 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007510 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007511 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7512 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007513 0 \
7514 -s "found fragmented DTLS handshake message" \
7515 -c "found fragmented DTLS handshake message" \
7516 -C "error"
7517
Andrzej Kurek77826052018-10-11 07:34:08 -04007518# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007519only_with_valgrind
Hanno Becker108992e2018-08-29 17:04:18 +01007520requires_config_enabled MBEDTLS_RSA_C
7521requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007522requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7523requires_config_enabled MBEDTLS_AES_C
7524requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01007525run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7526 -p "$P_PXY mtu=508" \
7527 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7528 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007529 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007530 ca_file=data_files/test-ca.crt \
Hanno Becker108992e2018-08-29 17:04:18 +01007531 hs_timeout=250-10000" \
7532 "$P_CLI dtls=1 debug_level=2 \
7533 crt_file=data_files/server8_int-ca2.crt \
7534 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007535 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007536 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007537 hs_timeout=250-10000" \
7538 0 \
7539 -s "found fragmented DTLS handshake message" \
7540 -c "found fragmented DTLS handshake message" \
7541 -C "error"
7542
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007543# 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 +02007544# OTOH the client might resend if the server is to slow to reset after sending
7545# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007546not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007547requires_config_enabled MBEDTLS_RSA_C
7548requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007549run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007550 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007551 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7552 crt_file=data_files/server7_int-ca.crt \
7553 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007554 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007555 hs_timeout=10000-60000 \
7556 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007557 "$P_CLI dtls=1 debug_level=2 \
7558 crt_file=data_files/server8_int-ca2.crt \
7559 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007560 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007561 hs_timeout=10000-60000 \
7562 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007563 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007564 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007565 -s "found fragmented DTLS handshake message" \
7566 -c "found fragmented DTLS handshake message" \
7567 -C "error"
7568
Andrzej Kurek77826052018-10-11 07:34:08 -04007569# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007570# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7571# OTOH the client might resend if the server is to slow to reset after sending
7572# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007573not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007574requires_config_enabled MBEDTLS_RSA_C
7575requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007576requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7577requires_config_enabled MBEDTLS_AES_C
7578requires_config_enabled MBEDTLS_GCM_C
7579run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007580 -p "$P_PXY mtu=512" \
7581 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7582 crt_file=data_files/server7_int-ca.crt \
7583 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007584 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007585 hs_timeout=10000-60000 \
7586 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007587 "$P_CLI dtls=1 debug_level=2 \
7588 crt_file=data_files/server8_int-ca2.crt \
7589 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007590 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007591 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7592 hs_timeout=10000-60000 \
7593 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007594 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007595 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007596 -s "found fragmented DTLS handshake message" \
7597 -c "found fragmented DTLS handshake message" \
7598 -C "error"
7599
Andrzej Kurek7311c782018-10-11 06:49:41 -04007600not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007601requires_config_enabled MBEDTLS_RSA_C
7602requires_config_enabled MBEDTLS_ECDSA_C
7603run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007604 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007605 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7606 crt_file=data_files/server7_int-ca.crt \
7607 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007608 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007609 hs_timeout=10000-60000 \
7610 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007611 "$P_CLI dtls=1 debug_level=2 \
7612 crt_file=data_files/server8_int-ca2.crt \
7613 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007614 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007615 hs_timeout=10000-60000 \
7616 mtu=1024 nbio=2" \
7617 0 \
7618 -S "autoreduction" \
7619 -s "found fragmented DTLS handshake message" \
7620 -c "found fragmented DTLS handshake message" \
7621 -C "error"
7622
Andrzej Kurek77826052018-10-11 07:34:08 -04007623# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007624not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007625requires_config_enabled MBEDTLS_RSA_C
7626requires_config_enabled MBEDTLS_ECDSA_C
7627requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7628requires_config_enabled MBEDTLS_AES_C
7629requires_config_enabled MBEDTLS_GCM_C
7630run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7631 -p "$P_PXY mtu=512" \
7632 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7633 crt_file=data_files/server7_int-ca.crt \
7634 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007635 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007636 hs_timeout=10000-60000 \
7637 mtu=512 nbio=2" \
7638 "$P_CLI dtls=1 debug_level=2 \
7639 crt_file=data_files/server8_int-ca2.crt \
7640 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007641 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007642 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7643 hs_timeout=10000-60000 \
7644 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007645 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007646 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007647 -s "found fragmented DTLS handshake message" \
7648 -c "found fragmented DTLS handshake message" \
7649 -C "error"
7650
Andrzej Kurek77826052018-10-11 07:34:08 -04007651# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007652# This ensures things still work after session_reset().
7653# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007654# Since we don't support reading fragmented ClientHello yet,
7655# up the MTU to 1450 (larger than ClientHello with session ticket,
7656# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007657# An autoreduction on the client-side might happen if the server is
7658# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007659# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007660# resumed listening, which would result in a spurious autoreduction.
7661not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007662requires_config_enabled MBEDTLS_RSA_C
7663requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007664requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7665requires_config_enabled MBEDTLS_AES_C
7666requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007667run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7668 -p "$P_PXY mtu=1450" \
7669 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7670 crt_file=data_files/server7_int-ca.crt \
7671 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007672 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007673 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007674 mtu=1450" \
7675 "$P_CLI dtls=1 debug_level=2 \
7676 crt_file=data_files/server8_int-ca2.crt \
7677 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007678 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007679 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007680 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007681 mtu=1450 reconnect=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007682 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007683 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007684 -s "found fragmented DTLS handshake message" \
7685 -c "found fragmented DTLS handshake message" \
7686 -C "error"
7687
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007688# An autoreduction on the client-side might happen if the server is
7689# slow to reset, therefore omitting '-C "autoreduction"' below.
7690not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007691requires_config_enabled MBEDTLS_RSA_C
7692requires_config_enabled MBEDTLS_ECDSA_C
7693requires_config_enabled MBEDTLS_SHA256_C
7694requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7695requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7696requires_config_enabled MBEDTLS_CHACHAPOLY_C
7697run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7698 -p "$P_PXY mtu=512" \
7699 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7700 crt_file=data_files/server7_int-ca.crt \
7701 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007702 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007703 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007704 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007705 mtu=512" \
7706 "$P_CLI dtls=1 debug_level=2 \
7707 crt_file=data_files/server8_int-ca2.crt \
7708 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007709 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007710 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007711 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007712 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007713 mtu=512" \
7714 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007715 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007716 -s "found fragmented DTLS handshake message" \
7717 -c "found fragmented DTLS handshake message" \
7718 -C "error"
7719
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007720# An autoreduction on the client-side might happen if the server is
7721# slow to reset, therefore omitting '-C "autoreduction"' below.
7722not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007723requires_config_enabled MBEDTLS_RSA_C
7724requires_config_enabled MBEDTLS_ECDSA_C
7725requires_config_enabled MBEDTLS_SHA256_C
7726requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7727requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7728requires_config_enabled MBEDTLS_AES_C
7729requires_config_enabled MBEDTLS_GCM_C
7730run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7731 -p "$P_PXY mtu=512" \
7732 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7733 crt_file=data_files/server7_int-ca.crt \
7734 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007735 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007736 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007737 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007738 mtu=512" \
7739 "$P_CLI dtls=1 debug_level=2 \
7740 crt_file=data_files/server8_int-ca2.crt \
7741 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007742 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007743 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007744 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007745 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007746 mtu=512" \
7747 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007748 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007749 -s "found fragmented DTLS handshake message" \
7750 -c "found fragmented DTLS handshake message" \
7751 -C "error"
7752
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007753# An autoreduction on the client-side might happen if the server is
7754# slow to reset, therefore omitting '-C "autoreduction"' below.
7755not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007756requires_config_enabled MBEDTLS_RSA_C
7757requires_config_enabled MBEDTLS_ECDSA_C
7758requires_config_enabled MBEDTLS_SHA256_C
7759requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7760requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7761requires_config_enabled MBEDTLS_AES_C
7762requires_config_enabled MBEDTLS_CCM_C
7763run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007764 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007765 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7766 crt_file=data_files/server7_int-ca.crt \
7767 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007768 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007769 exchanges=2 renegotiation=1 \
7770 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007771 hs_timeout=10000-60000 \
7772 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007773 "$P_CLI dtls=1 debug_level=2 \
7774 crt_file=data_files/server8_int-ca2.crt \
7775 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007776 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007777 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007778 hs_timeout=10000-60000 \
7779 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007780 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007781 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007782 -s "found fragmented DTLS handshake message" \
7783 -c "found fragmented DTLS handshake message" \
7784 -C "error"
7785
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007786# An autoreduction on the client-side might happen if the server is
7787# slow to reset, therefore omitting '-C "autoreduction"' below.
7788not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007789requires_config_enabled MBEDTLS_RSA_C
7790requires_config_enabled MBEDTLS_ECDSA_C
7791requires_config_enabled MBEDTLS_SHA256_C
7792requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7793requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7794requires_config_enabled MBEDTLS_AES_C
7795requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7796requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7797run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007798 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007799 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7800 crt_file=data_files/server7_int-ca.crt \
7801 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007802 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007803 exchanges=2 renegotiation=1 \
7804 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007805 hs_timeout=10000-60000 \
7806 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007807 "$P_CLI dtls=1 debug_level=2 \
7808 crt_file=data_files/server8_int-ca2.crt \
7809 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007810 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007811 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007812 hs_timeout=10000-60000 \
7813 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007814 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007815 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007816 -s "found fragmented DTLS handshake message" \
7817 -c "found fragmented DTLS handshake message" \
7818 -C "error"
7819
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007820# An autoreduction on the client-side might happen if the server is
7821# slow to reset, therefore omitting '-C "autoreduction"' below.
7822not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007823requires_config_enabled MBEDTLS_RSA_C
7824requires_config_enabled MBEDTLS_ECDSA_C
7825requires_config_enabled MBEDTLS_SHA256_C
7826requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7827requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7828requires_config_enabled MBEDTLS_AES_C
7829requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7830run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007831 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007832 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7833 crt_file=data_files/server7_int-ca.crt \
7834 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007835 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007836 exchanges=2 renegotiation=1 \
7837 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007838 hs_timeout=10000-60000 \
7839 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007840 "$P_CLI dtls=1 debug_level=2 \
7841 crt_file=data_files/server8_int-ca2.crt \
7842 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007843 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007844 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007845 hs_timeout=10000-60000 \
7846 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007847 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007848 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007849 -s "found fragmented DTLS handshake message" \
7850 -c "found fragmented DTLS handshake message" \
7851 -C "error"
7852
Andrzej Kurek77826052018-10-11 07:34:08 -04007853# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007854requires_config_enabled MBEDTLS_RSA_C
7855requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007856requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7857requires_config_enabled MBEDTLS_AES_C
7858requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007859client_needs_more_time 2
7860run_test "DTLS fragmenting: proxy MTU + 3d" \
7861 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007862 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007863 crt_file=data_files/server7_int-ca.crt \
7864 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007865 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007866 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007867 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007868 crt_file=data_files/server8_int-ca2.crt \
7869 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007870 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007871 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007872 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007873 0 \
7874 -s "found fragmented DTLS handshake message" \
7875 -c "found fragmented DTLS handshake message" \
7876 -C "error"
7877
Andrzej Kurek77826052018-10-11 07:34:08 -04007878# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007879requires_config_enabled MBEDTLS_RSA_C
7880requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007881requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7882requires_config_enabled MBEDTLS_AES_C
7883requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007884client_needs_more_time 2
7885run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7886 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7887 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7888 crt_file=data_files/server7_int-ca.crt \
7889 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007890 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007891 hs_timeout=250-10000 mtu=512 nbio=2" \
7892 "$P_CLI dtls=1 debug_level=2 \
7893 crt_file=data_files/server8_int-ca2.crt \
7894 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007895 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007896 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007897 hs_timeout=250-10000 mtu=512 nbio=2" \
7898 0 \
7899 -s "found fragmented DTLS handshake message" \
7900 -c "found fragmented DTLS handshake message" \
7901 -C "error"
7902
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007903# interop tests for DTLS fragmentating with reliable connection
7904#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007905# here and below we just want to test that the we fragment in a way that
7906# pleases other implementations, so we don't need the peer to fragment
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007907requires_config_enabled MBEDTLS_RSA_C
7908requires_config_enabled MBEDTLS_ECDSA_C
7909requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007910requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007911run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7912 "$G_SRV -u" \
7913 "$P_CLI dtls=1 debug_level=2 \
7914 crt_file=data_files/server8_int-ca2.crt \
7915 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007916 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007917 mtu=512 force_version=dtls1_2" \
7918 0 \
7919 -c "fragmenting handshake message" \
7920 -C "error"
7921
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007922requires_config_enabled MBEDTLS_RSA_C
7923requires_config_enabled MBEDTLS_ECDSA_C
7924requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007925requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007926run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
7927 "$G_SRV -u" \
7928 "$P_CLI dtls=1 debug_level=2 \
7929 crt_file=data_files/server8_int-ca2.crt \
7930 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007931 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007932 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007933 0 \
7934 -c "fragmenting handshake message" \
7935 -C "error"
7936
Hanno Beckerb9a00862018-08-28 10:20:22 +01007937# We use --insecure for the GnuTLS client because it expects
7938# the hostname / IP it connects to to be the name used in the
7939# certificate obtained from the server. Here, however, it
7940# connects to 127.0.0.1 while our test certificates use 'localhost'
7941# as the server name in the certificate. This will make the
7942# certifiate validation fail, but passing --insecure makes
7943# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007944requires_config_enabled MBEDTLS_RSA_C
7945requires_config_enabled MBEDTLS_ECDSA_C
7946requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007947requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007948requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007949run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007950 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007951 crt_file=data_files/server7_int-ca.crt \
7952 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007953 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007954 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007955 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007956 0 \
7957 -s "fragmenting handshake message"
7958
Hanno Beckerb9a00862018-08-28 10:20:22 +01007959# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007960requires_config_enabled MBEDTLS_RSA_C
7961requires_config_enabled MBEDTLS_ECDSA_C
7962requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007963requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007964requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007965run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007966 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007967 crt_file=data_files/server7_int-ca.crt \
7968 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007969 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007970 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007971 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007972 0 \
7973 -s "fragmenting handshake message"
7974
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007975requires_config_enabled MBEDTLS_RSA_C
7976requires_config_enabled MBEDTLS_ECDSA_C
7977requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7978run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
7979 "$O_SRV -dtls1_2 -verify 10" \
7980 "$P_CLI dtls=1 debug_level=2 \
7981 crt_file=data_files/server8_int-ca2.crt \
7982 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007983 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007984 mtu=512 force_version=dtls1_2" \
7985 0 \
7986 -c "fragmenting handshake message" \
7987 -C "error"
7988
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007989requires_config_enabled MBEDTLS_RSA_C
7990requires_config_enabled MBEDTLS_ECDSA_C
7991requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7992run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
7993 "$O_SRV -dtls1 -verify 10" \
7994 "$P_CLI dtls=1 debug_level=2 \
7995 crt_file=data_files/server8_int-ca2.crt \
7996 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007997 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007998 mtu=512 force_version=dtls1" \
7999 0 \
8000 -c "fragmenting handshake message" \
8001 -C "error"
8002
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008003requires_config_enabled MBEDTLS_RSA_C
8004requires_config_enabled MBEDTLS_ECDSA_C
8005requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8006run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
8007 "$P_SRV dtls=1 debug_level=2 \
8008 crt_file=data_files/server7_int-ca.crt \
8009 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008010 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008011 mtu=512 force_version=dtls1_2" \
8012 "$O_CLI -dtls1_2" \
8013 0 \
8014 -s "fragmenting handshake message"
8015
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008016requires_config_enabled MBEDTLS_RSA_C
8017requires_config_enabled MBEDTLS_ECDSA_C
8018requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8019run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8020 "$P_SRV dtls=1 debug_level=2 \
8021 crt_file=data_files/server7_int-ca.crt \
8022 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008023 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008024 mtu=512 force_version=dtls1" \
8025 "$O_CLI -dtls1" \
8026 0 \
8027 -s "fragmenting handshake message"
8028
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008029# interop tests for DTLS fragmentating with unreliable connection
8030#
8031# again we just want to test that the we fragment in a way that
8032# pleases other implementations, so we don't need the peer to fragment
8033requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008034requires_config_enabled MBEDTLS_RSA_C
8035requires_config_enabled MBEDTLS_ECDSA_C
8036requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008037client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008038run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8039 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8040 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008041 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008042 crt_file=data_files/server8_int-ca2.crt \
8043 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008044 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008045 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008046 0 \
8047 -c "fragmenting handshake message" \
8048 -C "error"
8049
8050requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008051requires_config_enabled MBEDTLS_RSA_C
8052requires_config_enabled MBEDTLS_ECDSA_C
8053requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008054client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008055run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8056 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8057 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008058 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008059 crt_file=data_files/server8_int-ca2.crt \
8060 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008061 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008062 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008063 0 \
8064 -c "fragmenting handshake message" \
8065 -C "error"
8066
k-stachowiakabb843e2019-02-18 16:14:03 +01008067requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008068requires_config_enabled MBEDTLS_RSA_C
8069requires_config_enabled MBEDTLS_ECDSA_C
8070requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8071client_needs_more_time 4
8072run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8073 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8074 "$P_SRV dtls=1 debug_level=2 \
8075 crt_file=data_files/server7_int-ca.crt \
8076 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008077 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008078 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008079 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008080 0 \
8081 -s "fragmenting handshake message"
8082
k-stachowiakabb843e2019-02-18 16:14:03 +01008083requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008084requires_config_enabled MBEDTLS_RSA_C
8085requires_config_enabled MBEDTLS_ECDSA_C
8086requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8087client_needs_more_time 4
8088run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8089 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8090 "$P_SRV dtls=1 debug_level=2 \
8091 crt_file=data_files/server7_int-ca.crt \
8092 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008093 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008094 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008095 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008096 0 \
8097 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008098
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008099## Interop test with OpenSSL might trigger a bug in recent versions (including
8100## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008101## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008102## They should be re-enabled once a fixed version of OpenSSL is available
8103## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008104skip_next_test
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008105requires_config_enabled MBEDTLS_RSA_C
8106requires_config_enabled MBEDTLS_ECDSA_C
8107requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8108client_needs_more_time 4
8109run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8110 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8111 "$O_SRV -dtls1_2 -verify 10" \
8112 "$P_CLI dtls=1 debug_level=2 \
8113 crt_file=data_files/server8_int-ca2.crt \
8114 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008115 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008116 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8117 0 \
8118 -c "fragmenting handshake message" \
8119 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008120
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008121skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008122requires_config_enabled MBEDTLS_RSA_C
8123requires_config_enabled MBEDTLS_ECDSA_C
8124requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008125client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008126run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8127 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008128 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008129 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008130 crt_file=data_files/server8_int-ca2.crt \
8131 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008132 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008133 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008134 0 \
8135 -c "fragmenting handshake message" \
8136 -C "error"
8137
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008138skip_next_test
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008139requires_config_enabled MBEDTLS_RSA_C
8140requires_config_enabled MBEDTLS_ECDSA_C
8141requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8142client_needs_more_time 4
8143run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8144 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8145 "$P_SRV dtls=1 debug_level=2 \
8146 crt_file=data_files/server7_int-ca.crt \
8147 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008148 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008149 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8150 "$O_CLI -dtls1_2" \
8151 0 \
8152 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008153
8154# -nbio is added to prevent s_client from blocking in case of duplicated
8155# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008156skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008157requires_config_enabled MBEDTLS_RSA_C
8158requires_config_enabled MBEDTLS_ECDSA_C
8159requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008160client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008161run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8162 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008163 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008164 crt_file=data_files/server7_int-ca.crt \
8165 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008166 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008167 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008168 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008169 0 \
8170 -s "fragmenting handshake message"
8171
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008172# Tests for specific things with "unreliable" UDP connection
8173
8174not_with_valgrind # spurious resend due to timeout
8175run_test "DTLS proxy: reference" \
8176 -p "$P_PXY" \
8177 "$P_SRV dtls=1 debug_level=2" \
8178 "$P_CLI dtls=1 debug_level=2" \
8179 0 \
8180 -C "replayed record" \
8181 -S "replayed record" \
Hanno Beckere03eb7b2019-07-19 15:43:09 +01008182 -C "Buffer record from epoch" \
8183 -S "Buffer record from epoch" \
8184 -C "ssl_buffer_message" \
8185 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008186 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008187 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008188 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008189 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008190 -c "HTTP/1.0 200 OK"
8191
8192not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008193run_test "DTLS proxy: duplicate every packet" \
8194 -p "$P_PXY duplicate=1" \
Hanno Becker7f376f42019-06-12 16:20:48 +01008195 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008196 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008197 0 \
8198 -c "replayed record" \
8199 -s "replayed record" \
8200 -c "record from another epoch" \
8201 -s "record from another epoch" \
8202 -S "resend" \
8203 -s "Extra-header:" \
8204 -c "HTTP/1.0 200 OK"
8205
8206run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8207 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008208 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8209 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008210 0 \
8211 -c "replayed record" \
8212 -S "replayed record" \
8213 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008214 -s "record from another epoch" \
8215 -c "resend" \
8216 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008217 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008218 -c "HTTP/1.0 200 OK"
8219
8220run_test "DTLS proxy: multiple records in same datagram" \
8221 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008222 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8223 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008224 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008225 -c "next record in same datagram" \
8226 -s "next record in same datagram"
8227
8228run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8229 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008230 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8231 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008232 0 \
8233 -c "next record in same datagram" \
8234 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008235
Jarno Lamsa33281d52019-10-18 10:54:35 +03008236requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008237run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8238 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008239 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8240 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008241 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008242 -c "discarding invalid record (mac)" \
8243 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008244 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008245 -c "HTTP/1.0 200 OK" \
8246 -S "too many records with bad MAC" \
8247 -S "Verification of the message MAC failed"
8248
Jarno Lamsa33281d52019-10-18 10:54:35 +03008249requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008250run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8251 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008252 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8253 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008254 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008255 -C "discarding invalid record (mac)" \
8256 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008257 -S "Extra-header:" \
8258 -C "HTTP/1.0 200 OK" \
8259 -s "too many records with bad MAC" \
8260 -s "Verification of the message MAC failed"
8261
Jarno Lamsa33281d52019-10-18 10:54:35 +03008262requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008263run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8264 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008265 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8266 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008267 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008268 -c "discarding invalid record (mac)" \
8269 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008270 -s "Extra-header:" \
8271 -c "HTTP/1.0 200 OK" \
8272 -S "too many records with bad MAC" \
8273 -S "Verification of the message MAC failed"
8274
Jarno Lamsa33281d52019-10-18 10:54:35 +03008275requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008276run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8277 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008278 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8279 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008280 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008281 -c "discarding invalid record (mac)" \
8282 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008283 -s "Extra-header:" \
8284 -c "HTTP/1.0 200 OK" \
8285 -s "too many records with bad MAC" \
8286 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008287
8288run_test "DTLS proxy: delay ChangeCipherSpec" \
8289 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008290 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8291 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008292 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008293 -c "record from another epoch" \
8294 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008295 -s "Extra-header:" \
8296 -c "HTTP/1.0 200 OK"
8297
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008298# Tests for reordering support with DTLS
8299
Hanno Becker56cdfd12018-08-17 13:42:15 +01008300run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8301 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008302 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8303 hs_timeout=2500-60000" \
8304 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8305 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008306 0 \
8307 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008308 -c "Next handshake message has been buffered - load"\
8309 -S "Buffering HS message" \
8310 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008311 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008312 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008313 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008314 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008315
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008316run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8317 -p "$P_PXY delay_srv=ServerHello" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03008318 "$P_SRV mtu=256 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008319 hs_timeout=2500-60000" \
8320 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8321 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008322 0 \
8323 -c "Buffering HS message" \
8324 -c "found fragmented DTLS handshake message"\
8325 -c "Next handshake message 1 not or only partially bufffered" \
8326 -c "Next handshake message has been buffered - load"\
8327 -S "Buffering HS message" \
8328 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008329 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008330 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008331 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008332 -S "Remember CCS message"
8333
Hanno Beckera1adcca2018-08-24 14:41:07 +01008334# The client buffers the ServerKeyExchange before receiving the fragmented
8335# Certificate message; at the time of writing, together these are aroudn 1200b
8336# in size, so that the bound below ensures that the certificate can be reassembled
8337# while keeping the ServerKeyExchange.
8338requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8339run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008340 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008341 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8342 hs_timeout=2500-60000" \
8343 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8344 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008345 0 \
8346 -c "Buffering HS message" \
8347 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008348 -C "attempt to make space by freeing buffered messages" \
8349 -S "Buffering HS message" \
8350 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008351 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008352 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008353 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008354 -S "Remember CCS message"
8355
8356# The size constraints ensure that the delayed certificate message can't
8357# be reassembled while keeping the ServerKeyExchange message, but it can
8358# when dropping it first.
8359requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8360requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8361run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8362 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008363 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8364 hs_timeout=2500-60000" \
8365 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8366 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008367 0 \
8368 -c "Buffering HS message" \
8369 -c "attempt to make space by freeing buffered future messages" \
8370 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008371 -S "Buffering HS message" \
8372 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008373 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008374 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008375 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008376 -S "Remember CCS message"
8377
Hanno Becker56cdfd12018-08-17 13:42:15 +01008378run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8379 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008380 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8381 hs_timeout=2500-60000" \
8382 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8383 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008384 0 \
8385 -C "Buffering HS message" \
8386 -C "Next handshake message has been buffered - load"\
8387 -s "Buffering HS message" \
8388 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008389 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008390 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008391 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008392 -S "Remember CCS message"
8393
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02008394# This needs session tickets; otherwise CCS is the first message in its flight
8395requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008396run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8397 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008398 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8399 hs_timeout=2500-60000" \
8400 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8401 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008402 0 \
8403 -C "Buffering HS message" \
8404 -C "Next handshake message has been buffered - load"\
8405 -S "Buffering HS message" \
8406 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008407 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008408 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008409 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008410 -S "Remember CCS message"
8411
Jarno Lamsa33281d52019-10-18 10:54:35 +03008412# This needs session tickets; otherwise CCS is the first message in its flight
8413requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008414run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8415 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008416 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8417 hs_timeout=2500-60000" \
8418 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8419 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008420 0 \
8421 -C "Buffering HS message" \
8422 -C "Next handshake message has been buffered - load"\
8423 -S "Buffering HS message" \
8424 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008425 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008426 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008427 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008428 -s "Remember CCS message"
8429
Hanno Beckera1adcca2018-08-24 14:41:07 +01008430run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008431 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008432 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8433 hs_timeout=2500-60000" \
8434 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8435 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008436 0 \
8437 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008438 -s "Found buffered record from current epoch - load" \
8439 -c "Buffer record from epoch 1" \
8440 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008441
Hanno Beckera1adcca2018-08-24 14:41:07 +01008442# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8443# from the server are delayed, so that the encrypted Finished message
8444# is received and buffered. When the fragmented NewSessionTicket comes
8445# in afterwards, the encrypted Finished message must be freed in order
8446# to make space for the NewSessionTicket to be reassembled.
8447# This works only in very particular circumstances:
8448# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8449# of the NewSessionTicket, but small enough to also allow buffering of
8450# the encrypted Finished message.
8451# - The MTU setting on the server must be so small that the NewSessionTicket
8452# needs to be fragmented.
8453# - All messages sent by the server must be small enough to be either sent
8454# without fragmentation or be reassembled within the bounds of
8455# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8456# handshake, omitting CRTs.
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008457requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8458requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008459run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8460 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008461 "$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 +01008462 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8463 0 \
8464 -s "Buffer record from epoch 1" \
8465 -s "Found buffered record from current epoch - load" \
8466 -c "Buffer record from epoch 1" \
8467 -C "Found buffered record from current epoch - load" \
8468 -c "Enough space available after freeing future epoch record"
8469
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008470# Tests for "randomly unreliable connection": try a variety of flows and peers
8471
8472client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008473run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8474 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008475 "$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 +02008476 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008477 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008478 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
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\" RSA 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 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8489 0 \
8490 -s "Extra-header:" \
8491 -c "HTTP/1.0 200 OK"
8492
Janos Follath74537a62016-09-02 13:45:28 +01008493client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008494run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8495 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008496 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8497 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008498 0 \
8499 -s "Extra-header:" \
8500 -c "HTTP/1.0 200 OK"
8501
Janos Follath74537a62016-09-02 13:45:28 +01008502client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008503run_test "DTLS proxy: 3d, FS, client auth" \
8504 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008505 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8506 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008507 0 \
8508 -s "Extra-header:" \
8509 -c "HTTP/1.0 200 OK"
8510
Janos Follath74537a62016-09-02 13:45:28 +01008511client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008512run_test "DTLS proxy: 3d, FS, ticket" \
8513 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008514 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8515 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008516 0 \
8517 -s "Extra-header:" \
8518 -c "HTTP/1.0 200 OK"
8519
Janos Follath74537a62016-09-02 13:45:28 +01008520client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008521run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8522 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008523 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8524 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +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 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008530run_test "DTLS proxy: 3d, max handshake, nbio" \
8531 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008532 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008533 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008534 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008535 0 \
8536 -s "Extra-header:" \
8537 -c "HTTP/1.0 200 OK"
8538
Janos Follath74537a62016-09-02 13:45:28 +01008539client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008540requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008541requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008542requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008543run_test "DTLS proxy: 3d, min handshake, resumption" \
8544 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008545 "$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 +02008546 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008547 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008548 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8549 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8550 0 \
8551 -s "a session has been resumed" \
8552 -c "a session has been resumed" \
8553 -s "Extra-header:" \
8554 -c "HTTP/1.0 200 OK"
8555
Janos Follath74537a62016-09-02 13:45:28 +01008556client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008557requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008558requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008559requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008560run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8561 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008562 "$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 +02008563 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008564 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008565 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8566 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8567 0 \
8568 -s "a session has been resumed" \
8569 -c "a session has been resumed" \
8570 -s "Extra-header:" \
8571 -c "HTTP/1.0 200 OK"
8572
Janos Follath74537a62016-09-02 13:45:28 +01008573client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008574requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008575run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008576 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008577 "$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 +02008578 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008579 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008580 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008581 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8582 0 \
8583 -c "=> renegotiate" \
8584 -s "=> renegotiate" \
8585 -s "Extra-header:" \
8586 -c "HTTP/1.0 200 OK"
8587
Janos Follath74537a62016-09-02 13:45:28 +01008588client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008589requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008590run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8591 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008592 "$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 +02008593 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008594 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008595 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008596 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8597 0 \
8598 -c "=> renegotiate" \
8599 -s "=> renegotiate" \
8600 -s "Extra-header:" \
8601 -c "HTTP/1.0 200 OK"
8602
Janos Follath74537a62016-09-02 13:45:28 +01008603client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008604requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008605run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008606 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008607 "$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 +02008608 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008609 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008610 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008611 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008612 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8613 0 \
8614 -c "=> renegotiate" \
8615 -s "=> renegotiate" \
8616 -s "Extra-header:" \
8617 -c "HTTP/1.0 200 OK"
8618
Janos Follath74537a62016-09-02 13:45:28 +01008619client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008620requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008621run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008622 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008623 "$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 +02008624 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008625 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008626 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008627 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008628 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8629 0 \
8630 -c "=> renegotiate" \
8631 -s "=> renegotiate" \
8632 -s "Extra-header:" \
8633 -c "HTTP/1.0 200 OK"
8634
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008635## Interop tests with OpenSSL might trigger a bug in recent versions (including
8636## all versions installed on the CI machines), reported here:
8637## Bug report: https://github.com/openssl/openssl/issues/6902
8638## They should be re-enabled once a fixed version of OpenSSL is available
8639## (this should happen in some 1.1.1_ release according to the ticket).
8640skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008641client_needs_more_time 6
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" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008644 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8645 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008646 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008647 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +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é-Gonnard9590e0a2014-09-26 16:27:59 +02008653run_test "DTLS proxy: 3d, openssl server, fragmentation" \
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 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008657 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008658 -c "HTTP/1.0 200 OK"
8659
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008660skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008661client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008662not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008663run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8664 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8665 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008666 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008667 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008668 -c "HTTP/1.0 200 OK"
8669
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008670requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008671client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008672not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008673run_test "DTLS proxy: 3d, gnutls server" \
8674 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8675 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008676 "$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 +02008677 0 \
8678 -s "Extra-header:" \
8679 -c "Extra-header:"
8680
k-stachowiakabb843e2019-02-18 16:14:03 +01008681requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008682client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008683not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008684run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8685 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008686 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008687 "$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 +02008688 0 \
8689 -s "Extra-header:" \
8690 -c "Extra-header:"
8691
k-stachowiakabb843e2019-02-18 16:14:03 +01008692requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008693client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008694not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008695run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8696 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008697 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008698 "$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 +02008699 0 \
8700 -s "Extra-header:" \
8701 -c "Extra-header:"
8702
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008703# Final report
8704
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008705echo "------------------------------------------------------------------------"
8706
8707if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008708 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008709else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008710 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008711fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008712PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008713echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008714
8715exit $FAILS