blob: b18d64c672c84c190d4a63fefbebc2a95579731f [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
Jarno Lamsa6ba32ca2019-10-29 15:16:40 +02003790requires_config_enabled MBEDTLS_USE_TINYCRYPT
3791run_test "Authentication: DTLS server ECDH p256v1, client required, server goodcert" \
3792 "$P_SRV dtls=1 debug_level=1 key_file=data_files/server11.key.der \
3793 crt_file=data_files/server11.crt.der" \
3794 "$P_CLI dtls=1 debug_level=3 auth_mode=required" \
3795 0 \
3796 -C "bad certificate (EC key curve)"\
3797 -C "! Certificate verification flags"\
3798 -C "! mbedtls_ssl_handshake returned"
3799
3800requires_config_enabled MBEDTLS_USE_TINYCRYPT
3801run_test "Authentication: DTLS server ECDH p256v1, client required, server badcert" \
3802 "$P_SRV dtls=1 debug_level=1 key_file=data_files/server11.key.der \
3803 crt_file=data_files/server11-bad.crt.der" \
3804 "$P_CLI dtls=1 debug_level=3 auth_mode=required" \
3805 1 \
3806 -c "! Certificate verification flags"\
3807 -c "! mbedtls_ssl_handshake returned"
3808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003809run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003810 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003811 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003812 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003813 0 \
3814 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003815 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003816 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003817 -C "X509 - Certificate verification failed"
3818
Simon Butcher99000142016-10-13 17:21:01 +01003819run_test "Authentication: client SHA256, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003820 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003821 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3822 key_file=data_files/server6.key \
3823 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3824 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003825 -c "Supported Signature Algorithm found: 5,"
3826
3827run_test "Authentication: client SHA384, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003828 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003829 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3830 key_file=data_files/server6.key \
3831 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3832 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003833 -c "Supported Signature Algorithm found: 5,"
3834
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003835requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3836run_test "Authentication: client has no cert, server required (SSLv3)" \
3837 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3838 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3839 key_file=data_files/server5.key" \
3840 1 \
3841 -S "skip write certificate request" \
3842 -C "skip parse certificate request" \
3843 -c "got a certificate request" \
3844 -c "got no certificate to send" \
3845 -S "x509_verify_cert() returned" \
3846 -s "client has no certificate" \
3847 -s "! mbedtls_ssl_handshake returned" \
3848 -c "! mbedtls_ssl_handshake returned" \
3849 -s "No client certification received from the client, but required by the authentication mode"
3850
3851run_test "Authentication: client has no cert, server required (TLS)" \
3852 "$P_SRV debug_level=3 auth_mode=required" \
3853 "$P_CLI debug_level=3 crt_file=none \
3854 key_file=data_files/server5.key" \
3855 1 \
3856 -S "skip write certificate request" \
3857 -C "skip parse certificate request" \
3858 -c "got a certificate request" \
3859 -c "= write certificate$" \
3860 -C "skip write certificate$" \
3861 -S "x509_verify_cert() returned" \
3862 -s "client has no certificate" \
3863 -s "! mbedtls_ssl_handshake returned" \
3864 -c "! mbedtls_ssl_handshake returned" \
3865 -s "No client certification received from the client, but required by the authentication mode"
3866
Hanno Becker4a156fc2019-06-14 17:07:06 +01003867requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003868requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003869run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003870 "$P_SRV debug_level=3 auth_mode=required" \
3871 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003872 key_file=data_files/server5.key" \
3873 1 \
3874 -S "skip write certificate request" \
3875 -C "skip parse certificate request" \
3876 -c "got a certificate request" \
3877 -C "skip write certificate" \
3878 -C "skip write certificate verify" \
3879 -S "skip parse certificate verify" \
3880 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003881 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003882 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003883 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003884 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003885 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003886# We don't check that the client receives the alert because it might
3887# detect that its write end of the connection is closed and abort
3888# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003889
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
Janos Follath89baba22017-04-10 14:34:35 +01003892run_test "Authentication: client cert not trusted, server required" \
3893 "$P_SRV debug_level=3 auth_mode=required" \
3894 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3895 key_file=data_files/server5.key" \
3896 1 \
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" \
3904 -s "! The certificate is not correctly signed by the trusted CA" \
3905 -s "! mbedtls_ssl_handshake returned" \
3906 -c "! mbedtls_ssl_handshake returned" \
3907 -s "X509 - Certificate verification failed"
3908
Hanno Becker4a156fc2019-06-14 17:07:06 +01003909requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003910requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003911run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003912 "$P_SRV debug_level=3 auth_mode=optional" \
3913 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003914 key_file=data_files/server5.key" \
3915 0 \
3916 -S "skip write certificate request" \
3917 -C "skip parse certificate request" \
3918 -c "got a certificate request" \
3919 -C "skip write certificate" \
3920 -C "skip write certificate verify" \
3921 -S "skip parse certificate verify" \
3922 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003923 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003924 -S "! mbedtls_ssl_handshake returned" \
3925 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003926 -S "X509 - Certificate verification failed"
3927
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003928run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003929 "$P_SRV debug_level=3 auth_mode=none" \
3930 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003931 key_file=data_files/server5.key" \
3932 0 \
3933 -s "skip write certificate request" \
3934 -C "skip parse certificate request" \
3935 -c "got no certificate request" \
3936 -c "skip write certificate" \
3937 -c "skip write certificate verify" \
3938 -s "skip parse certificate verify" \
3939 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003940 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003941 -S "! mbedtls_ssl_handshake returned" \
3942 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +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: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003948 "$P_SRV debug_level=3 auth_mode=optional" \
3949 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003950 0 \
3951 -S "skip write certificate request" \
3952 -C "skip parse certificate request" \
3953 -c "got a certificate request" \
3954 -C "skip write certificate$" \
3955 -C "got no certificate to send" \
3956 -S "SSLv3 client has no certificate" \
3957 -c "skip write certificate verify" \
3958 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003959 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003960 -S "! mbedtls_ssl_handshake returned" \
3961 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003962 -S "X509 - Certificate verification failed"
3963
Hanno Becker4a156fc2019-06-14 17:07:06 +01003964requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003965requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003966run_test "Authentication: openssl client no cert, server optional" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003967 "$P_SRV debug_level=3 auth_mode=optional ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003968 "$O_CLI" \
3969 0 \
3970 -S "skip write certificate request" \
3971 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003972 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003973 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003974 -S "X509 - Certificate verification failed"
3975
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003976run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003977 "$O_SRV -verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003978 "$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 +01003979 0 \
3980 -C "skip parse certificate request" \
3981 -c "got a certificate request" \
3982 -C "skip write certificate$" \
3983 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003984 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003985
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003986run_test "Authentication: client no cert, openssl server required" \
3987 "$O_SRV -Verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003988 "$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 +02003989 1 \
3990 -C "skip parse certificate request" \
3991 -c "got a certificate request" \
3992 -C "skip write certificate$" \
3993 -c "skip write certificate verify" \
3994 -c "! mbedtls_ssl_handshake returned"
3995
Janos Follathe2681a42016-03-07 15:57:05 +00003996requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Hanno Beckerb2c63832019-06-17 08:35:16 +01003997requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003998requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003999run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004000 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004001 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004002 0 \
4003 -S "skip write certificate request" \
4004 -C "skip parse certificate request" \
4005 -c "got a certificate request" \
4006 -C "skip write certificate$" \
4007 -c "skip write certificate verify" \
4008 -c "got no certificate to send" \
4009 -s "SSLv3 client has no certificate" \
4010 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004011 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004012 -S "! mbedtls_ssl_handshake returned" \
4013 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004014 -S "X509 - Certificate verification failed"
4015
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02004016# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
4017# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004018
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004019MAX_IM_CA='8'
Arto Kinnunen78213522019-09-26 11:06:39 +03004020MAX_IM_CA_CONFIG="$( get_config_value_or_default MBEDTLS_X509_MAX_INTERMEDIATE_CA )"
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004021
Angus Grattonc4dd0732018-04-11 16:28:39 +10004022requires_full_size_output_buffer
Arto Kinnunenc457ab12019-09-27 12:00:51 +03004023requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004024run_test "Authentication: server max_int chain, client default" \
4025 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4026 key_file=data_files/dir-maxpath/09.key" \
4027 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4028 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004029 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004030
Angus Grattonc4dd0732018-04-11 16:28:39 +10004031requires_full_size_output_buffer
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 default" \
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 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004038 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004039
Angus Grattonc4dd0732018-04-11 16:28:39 +10004040requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004041requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004042run_test "Authentication: server max_int+1 chain, client optional" \
4043 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4044 key_file=data_files/dir-maxpath/10.key" \
4045 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4046 auth_mode=optional" \
4047 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004048 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004049
Angus Grattonc4dd0732018-04-11 16:28:39 +10004050requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004051requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004052run_test "Authentication: server max_int+1 chain, client none" \
4053 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4054 key_file=data_files/dir-maxpath/10.key" \
4055 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4056 auth_mode=none" \
4057 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004058 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004059
Angus Grattonc4dd0732018-04-11 16:28:39 +10004060requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004061run_test "Authentication: client max_int+1 chain, server default" \
4062 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4063 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4064 key_file=data_files/dir-maxpath/10.key" \
4065 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004066 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004067
Angus Grattonc4dd0732018-04-11 16:28:39 +10004068requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004069run_test "Authentication: client max_int+1 chain, server optional" \
4070 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4071 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4072 key_file=data_files/dir-maxpath/10.key" \
4073 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004074 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004075
Angus Grattonc4dd0732018-04-11 16:28:39 +10004076requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004077run_test "Authentication: client max_int+1 chain, server required" \
4078 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4079 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4080 key_file=data_files/dir-maxpath/10.key" \
4081 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004082 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004083
Angus Grattonc4dd0732018-04-11 16:28:39 +10004084requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004085run_test "Authentication: client max_int chain, server required" \
4086 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4087 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4088 key_file=data_files/dir-maxpath/09.key" \
4089 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004090 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004091
Janos Follath89baba22017-04-10 14:34:35 +01004092# Tests for CA list in CertificateRequest messages
4093
4094run_test "Authentication: send CA list in CertificateRequest (default)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004095 "$P_SRV debug_level=3 auth_mode=required ca_file=data_files/test-ca2.crt" \
Janos Follath89baba22017-04-10 14:34:35 +01004096 "$P_CLI crt_file=data_files/server6.crt \
4097 key_file=data_files/server6.key" \
4098 0 \
4099 -s "requested DN"
4100
4101run_test "Authentication: do not send CA list in CertificateRequest" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004102 "$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 +01004103 "$P_CLI crt_file=data_files/server6.crt \
4104 key_file=data_files/server6.key" \
4105 0 \
4106 -S "requested DN"
4107
Hanno Becker4a156fc2019-06-14 17:07:06 +01004108requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004109requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01004110run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4111 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4112 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4113 key_file=data_files/server5.key" \
4114 1 \
4115 -S "requested DN" \
4116 -s "x509_verify_cert() returned" \
4117 -s "! The certificate is not correctly signed by the trusted CA" \
4118 -s "! mbedtls_ssl_handshake returned" \
4119 -c "! mbedtls_ssl_handshake returned" \
4120 -s "X509 - Certificate verification failed"
4121
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004122# Tests for certificate selection based on SHA verson
4123
Hanno Becker4a156fc2019-06-14 17:07:06 +01004124requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004125requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004126run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4127 "$P_SRV crt_file=data_files/server5.crt \
4128 key_file=data_files/server5.key \
4129 crt_file2=data_files/server5-sha1.crt \
4130 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004131 "$P_CLI force_version=tls1_2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004132 0 \
4133 -c "signed using.*ECDSA with SHA256" \
4134 -C "signed using.*ECDSA with SHA1"
4135
Hanno Becker4a156fc2019-06-14 17:07:06 +01004136requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004137requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004138run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4139 "$P_SRV crt_file=data_files/server5.crt \
4140 key_file=data_files/server5.key \
4141 crt_file2=data_files/server5-sha1.crt \
4142 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004143 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004144 0 \
4145 -C "signed using.*ECDSA with SHA256" \
4146 -c "signed using.*ECDSA with SHA1"
4147
Hanno Becker4a156fc2019-06-14 17:07:06 +01004148requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004149requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004150run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4151 "$P_SRV crt_file=data_files/server5.crt \
4152 key_file=data_files/server5.key \
4153 crt_file2=data_files/server5-sha1.crt \
4154 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004155 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004156 0 \
4157 -C "signed using.*ECDSA with SHA256" \
4158 -c "signed using.*ECDSA with SHA1"
4159
Hanno Becker4a156fc2019-06-14 17:07:06 +01004160requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004161requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004162run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4163 "$P_SRV crt_file=data_files/server5.crt \
4164 key_file=data_files/server5.key \
4165 crt_file2=data_files/server6.crt \
4166 key_file2=data_files/server6.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004167 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004168 0 \
4169 -c "serial number.*09" \
4170 -c "signed using.*ECDSA with SHA256" \
4171 -C "signed using.*ECDSA with SHA1"
4172
Hanno Becker4a156fc2019-06-14 17:07:06 +01004173requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004174requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004175run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4176 "$P_SRV crt_file=data_files/server6.crt \
4177 key_file=data_files/server6.key \
4178 crt_file2=data_files/server5.crt \
4179 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004180 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004181 0 \
4182 -c "serial number.*0A" \
4183 -c "signed using.*ECDSA with SHA256" \
4184 -C "signed using.*ECDSA with SHA1"
4185
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004186# tests for SNI
4187
Hanno Becker4a156fc2019-06-14 17:07:06 +01004188requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004189requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004190run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004191 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004192 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004193 "$P_CLI server_name=localhost ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004194 0 \
4195 -S "parse ServerName extension" \
4196 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4197 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004198
Hanno Becker4a156fc2019-06-14 17:07:06 +01004199requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004200requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004201requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004202run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004203 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004204 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004205 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 +01004206 "$P_CLI server_name=localhost ca_file=data_files/test-ca.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004207 0 \
4208 -s "parse ServerName extension" \
4209 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4210 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004211
Hanno Becker4a156fc2019-06-14 17:07:06 +01004212requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004213requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004214requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004215run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004216 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004217 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004218 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 +02004219 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004220 0 \
4221 -s "parse ServerName extension" \
4222 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4223 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004224
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004225requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004226run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004227 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004228 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004229 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 +02004230 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004231 1 \
4232 -s "parse ServerName extension" \
4233 -s "ssl_sni_wrapper() returned" \
4234 -s "mbedtls_ssl_handshake returned" \
4235 -c "mbedtls_ssl_handshake returned" \
4236 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004237
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004238run_test "SNI: client auth no override: optional" \
4239 "$P_SRV debug_level=3 auth_mode=optional \
4240 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4241 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4242 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004243 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004244 -S "skip write certificate request" \
4245 -C "skip parse certificate request" \
4246 -c "got a certificate request" \
4247 -C "skip write certificate" \
4248 -C "skip write certificate verify" \
4249 -S "skip parse certificate verify"
4250
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004251requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004252run_test "SNI: client auth override: none -> optional" \
4253 "$P_SRV debug_level=3 auth_mode=none \
4254 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4255 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4256 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004257 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004258 -S "skip write certificate request" \
4259 -C "skip parse certificate request" \
4260 -c "got a certificate request" \
4261 -C "skip write certificate" \
4262 -C "skip write certificate verify" \
4263 -S "skip parse certificate verify"
4264
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004265requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004266run_test "SNI: client auth override: optional -> none" \
4267 "$P_SRV debug_level=3 auth_mode=optional \
4268 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4269 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4270 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004271 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004272 -s "skip write certificate request" \
4273 -C "skip parse certificate request" \
4274 -c "got no certificate request" \
4275 -c "skip write certificate" \
4276 -c "skip write certificate verify" \
4277 -s "skip parse certificate verify"
4278
Hanno Becker4a156fc2019-06-14 17:07:06 +01004279requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004280requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004281requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004282run_test "SNI: CA no override" \
4283 "$P_SRV debug_level=3 auth_mode=optional \
4284 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4285 ca_file=data_files/test-ca.crt \
4286 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4287 "$P_CLI debug_level=3 server_name=localhost \
4288 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4289 1 \
4290 -S "skip write certificate request" \
4291 -C "skip parse certificate request" \
4292 -c "got a certificate request" \
4293 -C "skip write certificate" \
4294 -C "skip write certificate verify" \
4295 -S "skip parse certificate verify" \
4296 -s "x509_verify_cert() returned" \
4297 -s "! The certificate is not correctly signed by the trusted CA" \
4298 -S "The certificate has been revoked (is on a CRL)"
4299
Hanno Becker4a156fc2019-06-14 17:07:06 +01004300requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004301requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004302requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004303run_test "SNI: CA override" \
4304 "$P_SRV debug_level=3 auth_mode=optional \
4305 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4306 ca_file=data_files/test-ca.crt \
4307 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4308 "$P_CLI debug_level=3 server_name=localhost \
4309 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4310 0 \
4311 -S "skip write certificate request" \
4312 -C "skip parse certificate request" \
4313 -c "got a certificate request" \
4314 -C "skip write certificate" \
4315 -C "skip write certificate verify" \
4316 -S "skip parse certificate verify" \
4317 -S "x509_verify_cert() returned" \
4318 -S "! The certificate is not correctly signed by the trusted CA" \
4319 -S "The certificate has been revoked (is on a CRL)"
4320
Hanno Becker4a156fc2019-06-14 17:07:06 +01004321requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004322requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004323requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004324run_test "SNI: CA override with CRL" \
4325 "$P_SRV debug_level=3 auth_mode=optional \
4326 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4327 ca_file=data_files/test-ca.crt \
4328 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4329 "$P_CLI debug_level=3 server_name=localhost \
4330 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4331 1 \
4332 -S "skip write certificate request" \
4333 -C "skip parse certificate request" \
4334 -c "got a certificate request" \
4335 -C "skip write certificate" \
4336 -C "skip write certificate verify" \
4337 -S "skip parse certificate verify" \
4338 -s "x509_verify_cert() returned" \
4339 -S "! The certificate is not correctly signed by the trusted CA" \
4340 -s "The certificate has been revoked (is on a CRL)"
4341
Andres AG1a834452016-12-07 10:01:30 +00004342# Tests for SNI and DTLS
4343
Hanno Becker4a156fc2019-06-14 17:07:06 +01004344requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004345requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004346run_test "SNI: DTLS, no SNI callback" \
4347 "$P_SRV debug_level=3 dtls=1 \
4348 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004349 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca2.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004350 0 \
4351 -S "parse ServerName extension" \
4352 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4353 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4354
Hanno Becker4a156fc2019-06-14 17:07:06 +01004355requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004356requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004357requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004358run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004359 "$P_SRV debug_level=3 dtls=1 \
4360 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4361 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004362 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca.crt" \
Andres AG1a834452016-12-07 10:01:30 +00004363 0 \
4364 -s "parse ServerName extension" \
4365 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4366 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4367
Hanno Becker4a156fc2019-06-14 17:07:06 +01004368requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004369requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004370requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004371run_test "SNI: DTLS, matching cert 2" \
4372 "$P_SRV debug_level=3 dtls=1 \
4373 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4374 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 +01004375 "$P_CLI server_name=polarssl.example dtls=1 ca_file=data_files/test-ca.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004376 0 \
4377 -s "parse ServerName extension" \
4378 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4379 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4380
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004381requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004382run_test "SNI: DTLS, no matching cert" \
4383 "$P_SRV debug_level=3 dtls=1 \
4384 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4385 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4386 "$P_CLI server_name=nonesuch.example dtls=1" \
4387 1 \
4388 -s "parse ServerName extension" \
4389 -s "ssl_sni_wrapper() returned" \
4390 -s "mbedtls_ssl_handshake returned" \
4391 -c "mbedtls_ssl_handshake returned" \
4392 -c "SSL - A fatal alert message was received from our peer"
4393
4394run_test "SNI: DTLS, client auth no override: optional" \
4395 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4396 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4397 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4398 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4399 0 \
4400 -S "skip write certificate request" \
4401 -C "skip parse certificate request" \
4402 -c "got a certificate request" \
4403 -C "skip write certificate" \
4404 -C "skip write certificate verify" \
4405 -S "skip parse certificate verify"
4406
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004407requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004408run_test "SNI: DTLS, client auth override: none -> optional" \
4409 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4410 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4411 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4412 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4413 0 \
4414 -S "skip write certificate request" \
4415 -C "skip parse certificate request" \
4416 -c "got a certificate request" \
4417 -C "skip write certificate" \
4418 -C "skip write certificate verify" \
4419 -S "skip parse certificate verify"
4420
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004421requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004422run_test "SNI: DTLS, client auth override: optional -> none" \
4423 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4424 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4425 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4426 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4427 0 \
4428 -s "skip write certificate request" \
4429 -C "skip parse certificate request" \
4430 -c "got no certificate request" \
4431 -c "skip write certificate" \
4432 -c "skip write certificate verify" \
4433 -s "skip parse certificate verify"
4434
Hanno Becker4a156fc2019-06-14 17:07:06 +01004435requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004436requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004437requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004438run_test "SNI: DTLS, CA no override" \
4439 "$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,-,-,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 1 \
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
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004456requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004457run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004458 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4459 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4460 ca_file=data_files/test-ca.crt \
4461 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4462 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4463 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4464 0 \
4465 -S "skip write certificate request" \
4466 -C "skip parse certificate request" \
4467 -c "got a certificate request" \
4468 -C "skip write certificate" \
4469 -C "skip write certificate verify" \
4470 -S "skip parse certificate verify" \
4471 -S "x509_verify_cert() returned" \
4472 -S "! The certificate is not correctly signed by the trusted CA" \
4473 -S "The certificate has been revoked (is on a CRL)"
4474
Hanno Becker4a156fc2019-06-14 17:07:06 +01004475requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004476requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004477requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004478run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004479 "$P_SRV debug_level=3 auth_mode=optional \
4480 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4481 ca_file=data_files/test-ca.crt \
4482 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4483 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4484 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4485 1 \
4486 -S "skip write certificate request" \
4487 -C "skip parse certificate request" \
4488 -c "got a certificate request" \
4489 -C "skip write certificate" \
4490 -C "skip write certificate verify" \
4491 -S "skip parse certificate verify" \
4492 -s "x509_verify_cert() returned" \
4493 -S "! The certificate is not correctly signed by the trusted CA" \
4494 -s "The certificate has been revoked (is on a CRL)"
4495
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004496# Tests for non-blocking I/O: exercise a variety of handshake flows
4497
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004498run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004499 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4500 "$P_CLI nbio=2 tickets=0" \
4501 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004502 -S "mbedtls_ssl_handshake returned" \
4503 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004504 -c "Read from server: .* bytes read"
4505
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004506run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004507 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4508 "$P_CLI nbio=2 tickets=0" \
4509 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004510 -S "mbedtls_ssl_handshake returned" \
4511 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004512 -c "Read from server: .* bytes read"
4513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004514run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004515 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4516 "$P_CLI nbio=2 tickets=1" \
4517 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004518 -S "mbedtls_ssl_handshake returned" \
4519 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004520 -c "Read from server: .* bytes read"
4521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004522run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004523 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4524 "$P_CLI nbio=2 tickets=1" \
4525 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004526 -S "mbedtls_ssl_handshake returned" \
4527 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004528 -c "Read from server: .* bytes read"
4529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004530run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004531 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4532 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4533 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004534 -S "mbedtls_ssl_handshake returned" \
4535 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004536 -c "Read from server: .* bytes read"
4537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004538run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004539 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4540 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4541 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004542 -S "mbedtls_ssl_handshake returned" \
4543 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004544 -c "Read from server: .* bytes read"
4545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004546run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004547 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4548 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4549 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004550 -S "mbedtls_ssl_handshake returned" \
4551 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004552 -c "Read from server: .* bytes read"
4553
Hanno Becker00076712017-11-15 16:39:08 +00004554# Tests for event-driven I/O: exercise a variety of handshake flows
4555
4556run_test "Event-driven I/O: basic handshake" \
4557 "$P_SRV event=1 tickets=0 auth_mode=none" \
4558 "$P_CLI event=1 tickets=0" \
4559 0 \
4560 -S "mbedtls_ssl_handshake returned" \
4561 -C "mbedtls_ssl_handshake returned" \
4562 -c "Read from server: .* bytes read"
4563
4564run_test "Event-driven I/O: client auth" \
4565 "$P_SRV event=1 tickets=0 auth_mode=required" \
4566 "$P_CLI event=1 tickets=0" \
4567 0 \
4568 -S "mbedtls_ssl_handshake returned" \
4569 -C "mbedtls_ssl_handshake returned" \
4570 -c "Read from server: .* bytes read"
4571
4572run_test "Event-driven I/O: ticket" \
4573 "$P_SRV event=1 tickets=1 auth_mode=none" \
4574 "$P_CLI event=1 tickets=1" \
4575 0 \
4576 -S "mbedtls_ssl_handshake returned" \
4577 -C "mbedtls_ssl_handshake returned" \
4578 -c "Read from server: .* bytes read"
4579
4580run_test "Event-driven I/O: ticket + client auth" \
4581 "$P_SRV event=1 tickets=1 auth_mode=required" \
4582 "$P_CLI event=1 tickets=1" \
4583 0 \
4584 -S "mbedtls_ssl_handshake returned" \
4585 -C "mbedtls_ssl_handshake returned" \
4586 -c "Read from server: .* bytes read"
4587
4588run_test "Event-driven I/O: ticket + client auth + resume" \
4589 "$P_SRV event=1 tickets=1 auth_mode=required" \
4590 "$P_CLI event=1 tickets=1 reconnect=1" \
4591 0 \
4592 -S "mbedtls_ssl_handshake returned" \
4593 -C "mbedtls_ssl_handshake returned" \
4594 -c "Read from server: .* bytes read"
4595
4596run_test "Event-driven I/O: ticket + resume" \
4597 "$P_SRV event=1 tickets=1 auth_mode=none" \
4598 "$P_CLI event=1 tickets=1 reconnect=1" \
4599 0 \
4600 -S "mbedtls_ssl_handshake returned" \
4601 -C "mbedtls_ssl_handshake returned" \
4602 -c "Read from server: .* bytes read"
4603
4604run_test "Event-driven I/O: session-id resume" \
4605 "$P_SRV event=1 tickets=0 auth_mode=none" \
4606 "$P_CLI event=1 tickets=0 reconnect=1" \
4607 0 \
4608 -S "mbedtls_ssl_handshake returned" \
4609 -C "mbedtls_ssl_handshake returned" \
4610 -c "Read from server: .* bytes read"
4611
Hanno Becker6a33f592018-03-13 11:38:46 +00004612run_test "Event-driven I/O, DTLS: basic handshake" \
4613 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4614 "$P_CLI dtls=1 event=1 tickets=0" \
4615 0 \
4616 -c "Read from server: .* bytes read"
4617
4618run_test "Event-driven I/O, DTLS: client auth" \
4619 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4620 "$P_CLI dtls=1 event=1 tickets=0" \
4621 0 \
4622 -c "Read from server: .* bytes read"
4623
4624run_test "Event-driven I/O, DTLS: ticket" \
4625 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4626 "$P_CLI dtls=1 event=1 tickets=1" \
4627 0 \
4628 -c "Read from server: .* bytes read"
4629
4630run_test "Event-driven I/O, DTLS: ticket + client auth" \
4631 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4632 "$P_CLI dtls=1 event=1 tickets=1" \
4633 0 \
4634 -c "Read from server: .* bytes read"
4635
4636run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4637 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4638 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4639 0 \
4640 -c "Read from server: .* bytes read"
4641
4642run_test "Event-driven I/O, DTLS: ticket + resume" \
4643 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4644 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4645 0 \
4646 -c "Read from server: .* bytes read"
4647
4648run_test "Event-driven I/O, DTLS: session-id resume" \
4649 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4650 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4651 0 \
4652 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004653
4654# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4655# During session resumption, the client will send its ApplicationData record
4656# within the same datagram as the Finished messages. In this situation, the
4657# server MUST NOT idle on the underlying transport after handshake completion,
4658# because the ApplicationData request has already been queued internally.
4659run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004660 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004661 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4662 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4663 0 \
4664 -c "Read from server: .* bytes read"
4665
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004666# Tests for version negotiation
4667
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004668run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004669 "$P_SRV" \
4670 "$P_CLI" \
4671 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004672 -S "mbedtls_ssl_handshake returned" \
4673 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004674 -s "Protocol is TLSv1.2" \
4675 -c "Protocol is TLSv1.2"
4676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004677run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004678 "$P_SRV" \
4679 "$P_CLI max_version=tls1_1" \
4680 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004681 -S "mbedtls_ssl_handshake returned" \
4682 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004683 -s "Protocol is TLSv1.1" \
4684 -c "Protocol is TLSv1.1"
4685
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004686run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004687 "$P_SRV max_version=tls1_1" \
4688 "$P_CLI" \
4689 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004690 -S "mbedtls_ssl_handshake returned" \
4691 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004692 -s "Protocol is TLSv1.1" \
4693 -c "Protocol is TLSv1.1"
4694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004695run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004696 "$P_SRV max_version=tls1_1" \
4697 "$P_CLI max_version=tls1_1" \
4698 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004699 -S "mbedtls_ssl_handshake returned" \
4700 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004701 -s "Protocol is TLSv1.1" \
4702 -c "Protocol is TLSv1.1"
4703
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004704run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004705 "$P_SRV min_version=tls1_1" \
4706 "$P_CLI max_version=tls1_1" \
4707 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004708 -S "mbedtls_ssl_handshake returned" \
4709 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004710 -s "Protocol is TLSv1.1" \
4711 -c "Protocol is TLSv1.1"
4712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004713run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004714 "$P_SRV max_version=tls1_1" \
4715 "$P_CLI min_version=tls1_1" \
4716 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004717 -S "mbedtls_ssl_handshake returned" \
4718 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004719 -s "Protocol is TLSv1.1" \
4720 -c "Protocol is TLSv1.1"
4721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004722run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004723 "$P_SRV max_version=tls1_1" \
4724 "$P_CLI min_version=tls1_2" \
4725 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004726 -s "mbedtls_ssl_handshake returned" \
4727 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004728 -c "SSL - Handshake protocol not within min/max boundaries"
4729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004730run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004731 "$P_SRV min_version=tls1_2" \
4732 "$P_CLI max_version=tls1_1" \
4733 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004734 -s "mbedtls_ssl_handshake returned" \
4735 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004736 -s "SSL - Handshake protocol not within min/max boundaries"
4737
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004738# Tests for ALPN extension
4739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004740run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004741 "$P_SRV debug_level=3" \
4742 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004743 0 \
4744 -C "client hello, adding alpn extension" \
4745 -S "found alpn extension" \
4746 -C "got an alert message, type: \\[2:120]" \
4747 -S "server hello, adding alpn extension" \
4748 -C "found alpn extension " \
4749 -C "Application Layer Protocol is" \
4750 -S "Application Layer Protocol is"
4751
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004752run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004753 "$P_SRV debug_level=3" \
4754 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004755 0 \
4756 -c "client hello, adding alpn extension" \
4757 -s "found alpn extension" \
4758 -C "got an alert message, type: \\[2:120]" \
4759 -S "server hello, adding alpn extension" \
4760 -C "found alpn extension " \
4761 -c "Application Layer Protocol is (none)" \
4762 -S "Application Layer Protocol is"
4763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004764run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004765 "$P_SRV debug_level=3 alpn=abc,1234" \
4766 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004767 0 \
4768 -C "client hello, adding alpn extension" \
4769 -S "found alpn extension" \
4770 -C "got an alert message, type: \\[2:120]" \
4771 -S "server hello, adding alpn extension" \
4772 -C "found alpn extension " \
4773 -C "Application Layer Protocol is" \
4774 -s "Application Layer Protocol is (none)"
4775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004776run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004777 "$P_SRV debug_level=3 alpn=abc,1234" \
4778 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004779 0 \
4780 -c "client hello, adding alpn extension" \
4781 -s "found alpn extension" \
4782 -C "got an alert message, type: \\[2:120]" \
4783 -s "server hello, adding alpn extension" \
4784 -c "found alpn extension" \
4785 -c "Application Layer Protocol is abc" \
4786 -s "Application Layer Protocol is abc"
4787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004788run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004789 "$P_SRV debug_level=3 alpn=abc,1234" \
4790 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004791 0 \
4792 -c "client hello, adding alpn extension" \
4793 -s "found alpn extension" \
4794 -C "got an alert message, type: \\[2:120]" \
4795 -s "server hello, adding alpn extension" \
4796 -c "found alpn extension" \
4797 -c "Application Layer Protocol is abc" \
4798 -s "Application Layer Protocol is abc"
4799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004800run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004801 "$P_SRV debug_level=3 alpn=abc,1234" \
4802 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004803 0 \
4804 -c "client hello, adding alpn extension" \
4805 -s "found alpn extension" \
4806 -C "got an alert message, type: \\[2:120]" \
4807 -s "server hello, adding alpn extension" \
4808 -c "found alpn extension" \
4809 -c "Application Layer Protocol is 1234" \
4810 -s "Application Layer Protocol is 1234"
4811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004812run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004813 "$P_SRV debug_level=3 alpn=abc,123" \
4814 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004815 1 \
4816 -c "client hello, adding alpn extension" \
4817 -s "found alpn extension" \
4818 -c "got an alert message, type: \\[2:120]" \
4819 -S "server hello, adding alpn extension" \
4820 -C "found alpn extension" \
4821 -C "Application Layer Protocol is 1234" \
4822 -S "Application Layer Protocol is 1234"
4823
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02004824
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004825# Tests for keyUsage in leaf certificates, part 1:
4826# server-side certificate/suite selection
4827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004828run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004829 "$P_SRV key_file=data_files/server2.key \
4830 crt_file=data_files/server2.ku-ds.crt" \
4831 "$P_CLI" \
4832 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02004833 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004834
4835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004836run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004837 "$P_SRV key_file=data_files/server2.key \
4838 crt_file=data_files/server2.ku-ke.crt" \
4839 "$P_CLI" \
4840 0 \
4841 -c "Ciphersuite is TLS-RSA-WITH-"
4842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004843run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004844 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004845 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004846 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004847 1 \
4848 -C "Ciphersuite is "
4849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004850run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004851 "$P_SRV key_file=data_files/server5.key \
4852 crt_file=data_files/server5.ku-ds.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004853 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004854 0 \
4855 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
4856
Jarno Lamsac5118b72019-10-28 10:30:58 +02004857run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA p256" \
4858 "$P_SRV dtls=1 key_file=data_files/server11.key.der \
4859 crt_file=data_files/server11.crt.der" \
4860 "$P_CLI dtls=1 ca_file=data_files/test-ca3.crt.der" \
4861 0 \
4862 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004864run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004865 "$P_SRV key_file=data_files/server5.key \
4866 crt_file=data_files/server5.ku-ka.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004867 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004868 0 \
4869 -c "Ciphersuite is TLS-ECDH-"
4870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004871run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004872 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004873 crt_file=data_files/server5.ku-ke.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004874 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004875 1 \
4876 -C "Ciphersuite is "
4877
4878# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004879# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004880
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004881run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004882 "$O_SRV -key data_files/server2.key \
4883 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004884 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004885 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4886 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004887 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004888 -C "Processing of the Certificate handshake message failed" \
4889 -c "Ciphersuite is TLS-"
4890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004891run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004892 "$O_SRV -key data_files/server2.key \
4893 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004894 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004895 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4896 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004897 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004898 -C "Processing of the Certificate handshake message failed" \
4899 -c "Ciphersuite is TLS-"
4900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004901run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004902 "$O_SRV -key data_files/server2.key \
4903 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004904 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004905 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4906 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004907 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004908 -C "Processing of the Certificate handshake message failed" \
4909 -c "Ciphersuite is TLS-"
4910
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004911run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004912 "$O_SRV -key data_files/server2.key \
4913 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004914 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004915 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4916 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004917 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004918 -c "Processing of the Certificate handshake message failed" \
4919 -C "Ciphersuite is TLS-"
4920
Hanno Becker4a156fc2019-06-14 17:07:06 +01004921requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004922requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004923run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
4924 "$O_SRV -key data_files/server2.key \
4925 -cert data_files/server2.ku-ke.crt" \
4926 "$P_CLI debug_level=1 auth_mode=optional \
4927 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4928 0 \
4929 -c "bad certificate (usage extensions)" \
4930 -C "Processing of the Certificate handshake message failed" \
4931 -c "Ciphersuite is TLS-" \
4932 -c "! Usage does not match the keyUsage extension"
4933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004934run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004935 "$O_SRV -key data_files/server2.key \
4936 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004937 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004938 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4939 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004940 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004941 -C "Processing of the Certificate handshake message failed" \
4942 -c "Ciphersuite is TLS-"
4943
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004944run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004945 "$O_SRV -key data_files/server2.key \
4946 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004947 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004948 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4949 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004950 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004951 -c "Processing of the Certificate handshake message failed" \
4952 -C "Ciphersuite is TLS-"
4953
Hanno Becker4a156fc2019-06-14 17:07:06 +01004954requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004955requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004956run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
4957 "$O_SRV -key data_files/server2.key \
4958 -cert data_files/server2.ku-ds.crt" \
4959 "$P_CLI debug_level=1 auth_mode=optional \
4960 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4961 0 \
4962 -c "bad certificate (usage extensions)" \
4963 -C "Processing of the Certificate handshake message failed" \
4964 -c "Ciphersuite is TLS-" \
4965 -c "! Usage does not match the keyUsage extension"
4966
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004967# Tests for keyUsage in leaf certificates, part 3:
4968# server-side checking of client cert
4969
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004970run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004971 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004972 "$O_CLI -key data_files/server2.key \
4973 -cert data_files/server2.ku-ds.crt" \
4974 0 \
4975 -S "bad certificate (usage extensions)" \
4976 -S "Processing of the Certificate handshake message failed"
4977
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004978run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004979 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004980 "$O_CLI -key data_files/server2.key \
4981 -cert data_files/server2.ku-ke.crt" \
4982 0 \
4983 -s "bad certificate (usage extensions)" \
4984 -S "Processing of the Certificate handshake message failed"
4985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004986run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004987 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004988 "$O_CLI -key data_files/server2.key \
4989 -cert data_files/server2.ku-ke.crt" \
4990 1 \
4991 -s "bad certificate (usage extensions)" \
4992 -s "Processing of the Certificate handshake message failed"
4993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004994run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004995 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004996 "$O_CLI -key data_files/server5.key \
4997 -cert data_files/server5.ku-ds.crt" \
4998 0 \
4999 -S "bad certificate (usage extensions)" \
5000 -S "Processing of the Certificate handshake message failed"
5001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005002run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005003 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005004 "$O_CLI -key data_files/server5.key \
5005 -cert data_files/server5.ku-ka.crt" \
5006 0 \
5007 -s "bad certificate (usage extensions)" \
5008 -S "Processing of the Certificate handshake message failed"
5009
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005010# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
5011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005012run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005013 "$P_SRV key_file=data_files/server5.key \
5014 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005015 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005016 0
5017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005018run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005019 "$P_SRV key_file=data_files/server5.key \
5020 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005021 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005022 0
5023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005024run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005025 "$P_SRV key_file=data_files/server5.key \
5026 crt_file=data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005027 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005028 0
5029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005030run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005031 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005032 crt_file=data_files/server5.eku-cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005033 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005034 1
5035
5036# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005038run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005039 "$O_SRV -key data_files/server5.key \
5040 -cert data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005041 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005042 0 \
5043 -C "bad certificate (usage extensions)" \
5044 -C "Processing of the Certificate handshake message failed" \
5045 -c "Ciphersuite is TLS-"
5046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005047run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005048 "$O_SRV -key data_files/server5.key \
5049 -cert data_files/server5.eku-srv_cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005050 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005051 0 \
5052 -C "bad certificate (usage extensions)" \
5053 -C "Processing of the Certificate handshake message failed" \
5054 -c "Ciphersuite is TLS-"
5055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005056run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005057 "$O_SRV -key data_files/server5.key \
5058 -cert data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005059 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005060 0 \
5061 -C "bad certificate (usage extensions)" \
5062 -C "Processing of the Certificate handshake message failed" \
5063 -c "Ciphersuite is TLS-"
5064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005065run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005066 "$O_SRV -key data_files/server5.key \
5067 -cert data_files/server5.eku-cs.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005068 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005069 1 \
5070 -c "bad certificate (usage extensions)" \
5071 -c "Processing of the Certificate handshake message failed" \
5072 -C "Ciphersuite is TLS-"
5073
5074# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005076run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005077 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005078 "$O_CLI -key data_files/server5.key \
5079 -cert data_files/server5.eku-cli.crt" \
5080 0 \
5081 -S "bad certificate (usage extensions)" \
5082 -S "Processing of the Certificate handshake message failed"
5083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005084run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005085 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005086 "$O_CLI -key data_files/server5.key \
5087 -cert data_files/server5.eku-srv_cli.crt" \
5088 0 \
5089 -S "bad certificate (usage extensions)" \
5090 -S "Processing of the Certificate handshake message failed"
5091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005092run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005093 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005094 "$O_CLI -key data_files/server5.key \
5095 -cert data_files/server5.eku-cs_any.crt" \
5096 0 \
5097 -S "bad certificate (usage extensions)" \
5098 -S "Processing of the Certificate handshake message failed"
5099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005100run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005101 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005102 "$O_CLI -key data_files/server5.key \
5103 -cert data_files/server5.eku-cs.crt" \
5104 0 \
5105 -s "bad certificate (usage extensions)" \
5106 -S "Processing of the Certificate handshake message failed"
5107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005108run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005109 "$P_SRV debug_level=1 auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005110 "$O_CLI -key data_files/server5.key \
5111 -cert data_files/server5.eku-cs.crt" \
5112 1 \
5113 -s "bad certificate (usage extensions)" \
5114 -s "Processing of the Certificate handshake message failed"
5115
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005116# Tests for DHM parameters loading
5117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005118run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005119 "$P_SRV" \
5120 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5121 debug_level=3" \
5122 0 \
5123 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005124 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005126run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005127 "$P_SRV dhm_file=data_files/dhparams.pem" \
5128 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5129 debug_level=3" \
5130 0 \
5131 -c "value of 'DHM: P ' (1024 bits)" \
5132 -c "value of 'DHM: G ' (2 bits)"
5133
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005134# Tests for DHM client-side size checking
5135
5136run_test "DHM size: server default, client default, OK" \
5137 "$P_SRV" \
5138 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5139 debug_level=1" \
5140 0 \
5141 -C "DHM prime too short:"
5142
5143run_test "DHM size: server default, client 2048, OK" \
5144 "$P_SRV" \
5145 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5146 debug_level=1 dhmlen=2048" \
5147 0 \
5148 -C "DHM prime too short:"
5149
5150run_test "DHM size: server 1024, client default, OK" \
5151 "$P_SRV dhm_file=data_files/dhparams.pem" \
5152 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5153 debug_level=1" \
5154 0 \
5155 -C "DHM prime too short:"
5156
5157run_test "DHM size: server 1000, client default, rejected" \
5158 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5159 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5160 debug_level=1" \
5161 1 \
5162 -c "DHM prime too short:"
5163
5164run_test "DHM size: server default, client 2049, rejected" \
5165 "$P_SRV" \
5166 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5167 debug_level=1 dhmlen=2049" \
5168 1 \
5169 -c "DHM prime too short:"
5170
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005171# Tests for PSK callback
5172
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005173run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005174 "$P_SRV psk=abc123 psk_identity=foo" \
5175 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5176 psk_identity=foo psk=abc123" \
5177 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005178 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005179 -S "SSL - Unknown identity received" \
5180 -S "SSL - Verification of the message MAC failed"
5181
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005182run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005183 "$P_SRV" \
5184 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5185 psk_identity=foo psk=abc123" \
5186 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005187 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005188 -S "SSL - Unknown identity received" \
5189 -S "SSL - Verification of the message MAC failed"
5190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005191run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005192 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5193 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5194 psk_identity=foo psk=abc123" \
5195 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005196 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005197 -s "SSL - Unknown identity received" \
5198 -S "SSL - Verification of the message MAC failed"
5199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005200run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005201 "$P_SRV psk_list=abc,dead,def,beef" \
5202 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5203 psk_identity=abc psk=dead" \
5204 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005205 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005206 -S "SSL - Unknown identity received" \
5207 -S "SSL - Verification of the message MAC failed"
5208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005209run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005210 "$P_SRV psk_list=abc,dead,def,beef" \
5211 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5212 psk_identity=def psk=beef" \
5213 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005214 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005215 -S "SSL - Unknown identity received" \
5216 -S "SSL - Verification of the message MAC failed"
5217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005218run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005219 "$P_SRV psk_list=abc,dead,def,beef" \
5220 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5221 psk_identity=ghi psk=beef" \
5222 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005223 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005224 -s "SSL - Unknown identity received" \
5225 -S "SSL - Verification of the message MAC failed"
5226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005227run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005228 "$P_SRV psk_list=abc,dead,def,beef" \
5229 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5230 psk_identity=abc psk=beef" \
5231 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005232 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005233 -S "SSL - Unknown identity received" \
5234 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005235
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005236# Tests for EC J-PAKE
5237
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005238requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005239run_test "ECJPAKE: client not configured" \
5240 "$P_SRV debug_level=3" \
5241 "$P_CLI debug_level=3" \
5242 0 \
5243 -C "add ciphersuite: c0ff" \
5244 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005245 -S "found ecjpake kkpp extension" \
5246 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005247 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005248 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005249 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005250 -S "None of the common ciphersuites is usable"
5251
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005252requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005253run_test "ECJPAKE: server not configured" \
5254 "$P_SRV debug_level=3" \
5255 "$P_CLI debug_level=3 ecjpake_pw=bla \
5256 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5257 1 \
5258 -c "add ciphersuite: c0ff" \
5259 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005260 -s "found ecjpake kkpp extension" \
5261 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005262 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005263 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005264 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005265 -s "None of the common ciphersuites is usable"
5266
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005267requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005268run_test "ECJPAKE: working, TLS" \
5269 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5270 "$P_CLI debug_level=3 ecjpake_pw=bla \
5271 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005272 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005273 -c "add ciphersuite: c0ff" \
5274 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005275 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005276 -s "found ecjpake kkpp extension" \
5277 -S "skip ecjpake kkpp extension" \
5278 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005279 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005280 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005281 -S "None of the common ciphersuites is usable" \
5282 -S "SSL - Verification of the message MAC failed"
5283
Janos Follath74537a62016-09-02 13:45:28 +01005284server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005285requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005286run_test "ECJPAKE: password mismatch, TLS" \
5287 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5288 "$P_CLI debug_level=3 ecjpake_pw=bad \
5289 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5290 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005291 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005292 -s "SSL - Verification of the message MAC failed"
5293
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005294requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005295run_test "ECJPAKE: working, DTLS" \
5296 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5297 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5298 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5299 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005300 -c "re-using cached ecjpake parameters" \
5301 -S "SSL - Verification of the message MAC failed"
5302
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005303requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005304run_test "ECJPAKE: working, DTLS, no cookie" \
5305 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5306 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5307 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5308 0 \
5309 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005310 -S "SSL - Verification of the message MAC failed"
5311
Janos Follath74537a62016-09-02 13:45:28 +01005312server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005313requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005314run_test "ECJPAKE: password mismatch, DTLS" \
5315 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5316 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5317 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5318 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005319 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005320 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005321
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005322# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005323requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005324run_test "ECJPAKE: working, DTLS, nolog" \
5325 "$P_SRV dtls=1 ecjpake_pw=bla" \
5326 "$P_CLI dtls=1 ecjpake_pw=bla \
5327 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5328 0
5329
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005330# Tests for ciphersuites per version
5331
Janos Follathe2681a42016-03-07 15:57:05 +00005332requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005333requires_config_enabled MBEDTLS_CAMELLIA_C
5334requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005335run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005336 "$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 +02005337 "$P_CLI force_version=ssl3" \
5338 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005339 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005340
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005341requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5342requires_config_enabled MBEDTLS_CAMELLIA_C
5343requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005344run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005345 "$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 +01005346 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005347 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005348 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005349
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005350requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5351requires_config_enabled MBEDTLS_CAMELLIA_C
5352requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005353run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005354 "$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 +02005355 "$P_CLI force_version=tls1_1" \
5356 0 \
5357 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5358
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005359requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5360requires_config_enabled MBEDTLS_CAMELLIA_C
5361requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005362run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005363 "$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 +02005364 "$P_CLI force_version=tls1_2" \
5365 0 \
5366 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5367
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005368# Test for ClientHello without extensions
5369
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005370requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005371run_test "ClientHello without extensions, SHA-1 allowed" \
Ron Eldorb76e7652019-01-16 23:14:41 +02005372 "$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 +02005373 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005374 0 \
5375 -s "dumping 'client hello extensions' (0 bytes)"
5376
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005377requires_gnutls
5378run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
5379 "$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 +02005380 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005381 0 \
5382 -s "dumping 'client hello extensions' (0 bytes)"
5383
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005384# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005385
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005386run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005387 "$P_SRV" \
5388 "$P_CLI request_size=100" \
5389 0 \
5390 -s "Read from client: 100 bytes read$"
5391
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005392run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005393 "$P_SRV" \
5394 "$P_CLI request_size=500" \
5395 0 \
5396 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005397
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005398# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005399
Janos Follathe2681a42016-03-07 15:57:05 +00005400requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005401run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005402 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005403 "$P_CLI request_size=1 force_version=ssl3 \
5404 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5405 0 \
5406 -s "Read from client: 1 bytes read"
5407
Janos Follathe2681a42016-03-07 15:57:05 +00005408requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005409run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005410 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005411 "$P_CLI request_size=1 force_version=ssl3 \
5412 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5413 0 \
5414 -s "Read from client: 1 bytes read"
5415
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005416run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005417 "$P_SRV" \
5418 "$P_CLI request_size=1 force_version=tls1 \
5419 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5420 0 \
5421 -s "Read from client: 1 bytes read"
5422
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005423run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005424 "$P_SRV" \
5425 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5426 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5427 0 \
5428 -s "Read from client: 1 bytes read"
5429
Hanno Becker32c55012017-11-10 08:42:54 +00005430requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005431run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005432 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005433 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005434 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005435 0 \
5436 -s "Read from client: 1 bytes read"
5437
Hanno Becker32c55012017-11-10 08:42:54 +00005438requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005439run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005440 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005441 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005442 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005443 0 \
5444 -s "Read from client: 1 bytes read"
5445
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005446run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005447 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005448 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005449 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5450 0 \
5451 -s "Read from client: 1 bytes read"
5452
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005453run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005454 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5455 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005456 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005457 0 \
5458 -s "Read from client: 1 bytes read"
5459
5460requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005461run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005462 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005463 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005464 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005465 0 \
5466 -s "Read from client: 1 bytes read"
5467
Hanno Becker8501f982017-11-10 08:59:04 +00005468requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005469run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005470 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5471 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5472 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005473 0 \
5474 -s "Read from client: 1 bytes read"
5475
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005476run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005477 "$P_SRV" \
5478 "$P_CLI request_size=1 force_version=tls1_1 \
5479 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5480 0 \
5481 -s "Read from client: 1 bytes read"
5482
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005483run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005484 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005485 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005486 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005487 0 \
5488 -s "Read from client: 1 bytes read"
5489
5490requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005491run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005492 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005493 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005494 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005495 0 \
5496 -s "Read from client: 1 bytes read"
5497
5498requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005499run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005500 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005501 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005502 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005503 0 \
5504 -s "Read from client: 1 bytes read"
5505
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005506run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005507 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005508 "$P_CLI request_size=1 force_version=tls1_1 \
5509 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5510 0 \
5511 -s "Read from client: 1 bytes read"
5512
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005513run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005514 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005515 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005516 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005517 0 \
5518 -s "Read from client: 1 bytes read"
5519
Hanno Becker8501f982017-11-10 08:59:04 +00005520requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005521run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005522 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005523 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005524 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005525 0 \
5526 -s "Read from client: 1 bytes read"
5527
Hanno Becker32c55012017-11-10 08:42:54 +00005528requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005529run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005530 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005531 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005532 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005533 0 \
5534 -s "Read from client: 1 bytes read"
5535
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005536run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005537 "$P_SRV" \
5538 "$P_CLI request_size=1 force_version=tls1_2 \
5539 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5540 0 \
5541 -s "Read from client: 1 bytes read"
5542
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005543run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005544 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005545 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005546 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005547 0 \
5548 -s "Read from client: 1 bytes read"
5549
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005550run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005551 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005552 "$P_CLI request_size=1 force_version=tls1_2 \
5553 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005554 0 \
5555 -s "Read from client: 1 bytes read"
5556
Hanno Becker32c55012017-11-10 08:42:54 +00005557requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005558run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005559 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005560 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005561 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005562 0 \
5563 -s "Read from client: 1 bytes read"
5564
Hanno Becker8501f982017-11-10 08:59:04 +00005565requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005566run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005567 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005568 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005569 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005570 0 \
5571 -s "Read from client: 1 bytes read"
5572
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005573run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005574 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005575 "$P_CLI request_size=1 force_version=tls1_2 \
5576 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5577 0 \
5578 -s "Read from client: 1 bytes read"
5579
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005580run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005581 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005582 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005583 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005584 0 \
5585 -s "Read from client: 1 bytes read"
5586
Hanno Becker32c55012017-11-10 08:42:54 +00005587requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005588run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005589 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005590 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005591 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005592 0 \
5593 -s "Read from client: 1 bytes read"
5594
Hanno Becker8501f982017-11-10 08:59:04 +00005595requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005596run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005597 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005598 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005599 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005600 0 \
5601 -s "Read from client: 1 bytes read"
5602
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005603run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005604 "$P_SRV" \
5605 "$P_CLI request_size=1 force_version=tls1_2 \
5606 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5607 0 \
5608 -s "Read from client: 1 bytes read"
5609
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005610run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005611 "$P_SRV" \
5612 "$P_CLI request_size=1 force_version=tls1_2 \
5613 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5614 0 \
5615 -s "Read from client: 1 bytes read"
5616
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005617# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005618
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005619run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005620 "$P_SRV dtls=1 force_version=dtls1" \
5621 "$P_CLI dtls=1 request_size=1 \
5622 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5623 0 \
5624 -s "Read from client: 1 bytes read"
5625
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005626run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00005627 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
5628 "$P_CLI dtls=1 request_size=1 \
5629 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5630 0 \
5631 -s "Read from client: 1 bytes read"
5632
Hanno Beckere2148042017-11-10 08:59:18 +00005633requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005634run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005635 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
5636 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00005637 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5638 0 \
5639 -s "Read from client: 1 bytes read"
5640
Hanno Beckere2148042017-11-10 08:59:18 +00005641requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005642run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005643 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005644 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005645 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005646 0 \
5647 -s "Read from client: 1 bytes read"
5648
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005649run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00005650 "$P_SRV dtls=1 force_version=dtls1_2" \
5651 "$P_CLI dtls=1 request_size=1 \
5652 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5653 0 \
5654 -s "Read from client: 1 bytes read"
5655
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005656run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005657 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005658 "$P_CLI dtls=1 request_size=1 \
5659 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5660 0 \
5661 -s "Read from client: 1 bytes read"
5662
Hanno Beckere2148042017-11-10 08:59:18 +00005663requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005664run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005665 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005666 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005667 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005668 0 \
5669 -s "Read from client: 1 bytes read"
5670
Hanno Beckere2148042017-11-10 08:59:18 +00005671requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005672run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005673 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005674 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005675 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005676 0 \
5677 -s "Read from client: 1 bytes read"
5678
Jarno Lamsa0ed68082019-10-28 14:10:59 +02005679run_test "Small client packet DTLS, ECDHE-ECDSA" \
5680 "$P_SRV dtls=1" \
5681 "$P_CLI dtls=1 request_size=1 \
5682 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
5683 0 \
5684 -s "Read from client: 1 bytes read"
5685
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005686# Tests for small server packets
5687
5688requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5689run_test "Small server packet SSLv3 BlockCipher" \
5690 "$P_SRV response_size=1 min_version=ssl3" \
5691 "$P_CLI force_version=ssl3 \
5692 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5693 0 \
5694 -c "Read from server: 1 bytes read"
5695
5696requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5697run_test "Small server packet SSLv3 StreamCipher" \
5698 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5699 "$P_CLI force_version=ssl3 \
5700 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5701 0 \
5702 -c "Read from server: 1 bytes read"
5703
5704run_test "Small server packet TLS 1.0 BlockCipher" \
5705 "$P_SRV response_size=1" \
5706 "$P_CLI force_version=tls1 \
5707 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5708 0 \
5709 -c "Read from server: 1 bytes read"
5710
5711run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
5712 "$P_SRV response_size=1" \
5713 "$P_CLI force_version=tls1 etm=0 \
5714 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5715 0 \
5716 -c "Read from server: 1 bytes read"
5717
5718requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5719run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
5720 "$P_SRV response_size=1 trunc_hmac=1" \
5721 "$P_CLI force_version=tls1 \
5722 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5723 0 \
5724 -c "Read from server: 1 bytes read"
5725
5726requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5727run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
5728 "$P_SRV response_size=1 trunc_hmac=1" \
5729 "$P_CLI force_version=tls1 \
5730 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5731 0 \
5732 -c "Read from server: 1 bytes read"
5733
5734run_test "Small server packet TLS 1.0 StreamCipher" \
5735 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5736 "$P_CLI force_version=tls1 \
5737 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5738 0 \
5739 -c "Read from server: 1 bytes read"
5740
5741run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
5742 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5743 "$P_CLI force_version=tls1 \
5744 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5745 0 \
5746 -c "Read from server: 1 bytes read"
5747
5748requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5749run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
5750 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5751 "$P_CLI force_version=tls1 \
5752 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5753 0 \
5754 -c "Read from server: 1 bytes read"
5755
5756requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5757run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5758 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5759 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5760 trunc_hmac=1 etm=0" \
5761 0 \
5762 -c "Read from server: 1 bytes read"
5763
5764run_test "Small server packet TLS 1.1 BlockCipher" \
5765 "$P_SRV response_size=1" \
5766 "$P_CLI force_version=tls1_1 \
5767 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5768 0 \
5769 -c "Read from server: 1 bytes read"
5770
5771run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
5772 "$P_SRV response_size=1" \
5773 "$P_CLI force_version=tls1_1 \
5774 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5775 0 \
5776 -c "Read from server: 1 bytes read"
5777
5778requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5779run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
5780 "$P_SRV response_size=1 trunc_hmac=1" \
5781 "$P_CLI force_version=tls1_1 \
5782 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5783 0 \
5784 -c "Read from server: 1 bytes read"
5785
5786requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5787run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5788 "$P_SRV response_size=1 trunc_hmac=1" \
5789 "$P_CLI force_version=tls1_1 \
5790 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5791 0 \
5792 -c "Read from server: 1 bytes read"
5793
5794run_test "Small server packet TLS 1.1 StreamCipher" \
5795 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5796 "$P_CLI force_version=tls1_1 \
5797 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5798 0 \
5799 -c "Read from server: 1 bytes read"
5800
5801run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
5802 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5803 "$P_CLI force_version=tls1_1 \
5804 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5805 0 \
5806 -c "Read from server: 1 bytes read"
5807
5808requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5809run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
5810 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5811 "$P_CLI force_version=tls1_1 \
5812 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5813 0 \
5814 -c "Read from server: 1 bytes read"
5815
5816requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5817run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5818 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5819 "$P_CLI force_version=tls1_1 \
5820 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5821 0 \
5822 -c "Read from server: 1 bytes read"
5823
5824run_test "Small server packet TLS 1.2 BlockCipher" \
5825 "$P_SRV response_size=1" \
5826 "$P_CLI force_version=tls1_2 \
5827 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5828 0 \
5829 -c "Read from server: 1 bytes read"
5830
5831run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5832 "$P_SRV response_size=1" \
5833 "$P_CLI force_version=tls1_2 \
5834 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5835 0 \
5836 -c "Read from server: 1 bytes read"
5837
5838run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5839 "$P_SRV response_size=1" \
5840 "$P_CLI force_version=tls1_2 \
5841 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5842 0 \
5843 -c "Read from server: 1 bytes read"
5844
5845requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5846run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5847 "$P_SRV response_size=1 trunc_hmac=1" \
5848 "$P_CLI force_version=tls1_2 \
5849 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5850 0 \
5851 -c "Read from server: 1 bytes read"
5852
5853requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5854run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5855 "$P_SRV response_size=1 trunc_hmac=1" \
5856 "$P_CLI force_version=tls1_2 \
5857 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5858 0 \
5859 -c "Read from server: 1 bytes read"
5860
5861run_test "Small server packet TLS 1.2 StreamCipher" \
5862 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5863 "$P_CLI force_version=tls1_2 \
5864 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5865 0 \
5866 -c "Read from server: 1 bytes read"
5867
5868run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
5869 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5870 "$P_CLI force_version=tls1_2 \
5871 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5872 0 \
5873 -c "Read from server: 1 bytes read"
5874
5875requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5876run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
5877 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5878 "$P_CLI force_version=tls1_2 \
5879 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5880 0 \
5881 -c "Read from server: 1 bytes read"
5882
5883requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5884run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5885 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5886 "$P_CLI force_version=tls1_2 \
5887 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5888 0 \
5889 -c "Read from server: 1 bytes read"
5890
5891run_test "Small server packet TLS 1.2 AEAD" \
5892 "$P_SRV response_size=1" \
5893 "$P_CLI force_version=tls1_2 \
5894 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5895 0 \
5896 -c "Read from server: 1 bytes read"
5897
5898run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5899 "$P_SRV response_size=1" \
5900 "$P_CLI force_version=tls1_2 \
5901 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5902 0 \
5903 -c "Read from server: 1 bytes read"
5904
5905# Tests for small server packets in DTLS
5906
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005907run_test "Small server packet DTLS 1.0" \
5908 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
5909 "$P_CLI dtls=1 \
5910 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5911 0 \
5912 -c "Read from server: 1 bytes read"
5913
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005914run_test "Small server packet DTLS 1.0, without EtM" \
5915 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
5916 "$P_CLI dtls=1 \
5917 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5918 0 \
5919 -c "Read from server: 1 bytes read"
5920
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005921requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5922run_test "Small server packet DTLS 1.0, truncated hmac" \
5923 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
5924 "$P_CLI dtls=1 trunc_hmac=1 \
5925 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5926 0 \
5927 -c "Read from server: 1 bytes read"
5928
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005929requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5930run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
5931 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
5932 "$P_CLI dtls=1 \
5933 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5934 0 \
5935 -c "Read from server: 1 bytes read"
5936
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005937run_test "Small server packet DTLS 1.2" \
5938 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
5939 "$P_CLI dtls=1 \
5940 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5941 0 \
5942 -c "Read from server: 1 bytes read"
5943
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005944run_test "Small server packet DTLS 1.2, without EtM" \
5945 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5946 "$P_CLI dtls=1 \
5947 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5948 0 \
5949 -c "Read from server: 1 bytes read"
5950
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005951requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5952run_test "Small server packet DTLS 1.2, truncated hmac" \
5953 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5954 "$P_CLI dtls=1 \
5955 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5956 0 \
5957 -c "Read from server: 1 bytes read"
5958
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005959requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5960run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5961 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5962 "$P_CLI dtls=1 \
5963 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5964 0 \
5965 -c "Read from server: 1 bytes read"
5966
Jarno Lamsac40184b2019-10-28 14:16:12 +02005967run_test "Small server packet DTLS, ECDHE-ECDSA" \
5968 "$P_SRV dtls=1 response_size=1" \
5969 "$P_CLI dtls=1 \
5970 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
5971 0 \
5972 -c "Read from server: 1 bytes read"
5973
Janos Follath00efff72016-05-06 13:48:23 +01005974# A test for extensions in SSLv3
5975
5976requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5977run_test "SSLv3 with extensions, server side" \
5978 "$P_SRV min_version=ssl3 debug_level=3" \
5979 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
5980 0 \
5981 -S "dumping 'client hello extensions'" \
5982 -S "server hello, total extension length:"
5983
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005984# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005985
Angus Grattonc4dd0732018-04-11 16:28:39 +10005986# How many fragments do we expect to write $1 bytes?
5987fragments_for_write() {
5988 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
5989}
5990
Janos Follathe2681a42016-03-07 15:57:05 +00005991requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005992run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005993 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005994 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005995 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5996 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005997 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5998 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005999
Janos Follathe2681a42016-03-07 15:57:05 +00006000requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006001run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006002 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006003 "$P_CLI request_size=16384 force_version=ssl3 \
6004 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6005 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006006 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6007 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006008
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006009run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006010 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006011 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006012 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6013 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006014 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6015 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006016
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006017run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006018 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006019 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
6020 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6021 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006022 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006023
Hanno Becker32c55012017-11-10 08:42:54 +00006024requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006025run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006026 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006027 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006028 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
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
Hanno Becker32c55012017-11-10 08:42:54 +00006033requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006034run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006035 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006036 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006037 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006038 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006039 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006040
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006041run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006042 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006043 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006044 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6045 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006046 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006047
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006048run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006049 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6050 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006051 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006052 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006053 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006054
6055requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006056run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006057 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006058 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006059 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006060 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006061 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006062
Hanno Becker278fc7a2017-11-10 09:16:28 +00006063requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006064run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006065 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006066 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006067 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006068 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 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006073 "$P_SRV" \
6074 "$P_CLI request_size=16384 force_version=tls1_1 \
6075 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6076 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
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006080run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006081 "$P_SRV" \
6082 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6083 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006084 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006085 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006086
Hanno Becker32c55012017-11-10 08:42:54 +00006087requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006088run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006089 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006090 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006091 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006092 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006093 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006094
Hanno Becker32c55012017-11-10 08:42:54 +00006095requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006096run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006097 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006098 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006099 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006100 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006101 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006102
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006103run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006104 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6105 "$P_CLI request_size=16384 force_version=tls1_1 \
6106 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6107 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006108 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6109 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006110
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006111run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006112 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006113 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006114 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006115 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006116 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6117 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006118
Hanno Becker278fc7a2017-11-10 09:16:28 +00006119requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006120run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006121 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006122 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006123 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006124 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006125 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006126
Hanno Becker278fc7a2017-11-10 09:16:28 +00006127requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006128run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006129 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006130 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006131 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006132 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006133 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6134 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006135
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006136run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006137 "$P_SRV" \
6138 "$P_CLI request_size=16384 force_version=tls1_2 \
6139 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6140 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006141 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6142 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006143
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006144run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006145 "$P_SRV" \
6146 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6147 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6148 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006149 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006150
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006151run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006152 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006153 "$P_CLI request_size=16384 force_version=tls1_2 \
6154 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006155 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006156 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6157 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006158
Hanno Becker32c55012017-11-10 08:42:54 +00006159requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006160run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006161 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006162 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006163 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006164 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006165 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006166
Hanno Becker278fc7a2017-11-10 09:16:28 +00006167requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006168run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006169 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006170 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006171 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006172 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006173 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6174 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006175
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006176run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006177 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006178 "$P_CLI request_size=16384 force_version=tls1_2 \
6179 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6180 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006181 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6182 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006183
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006184run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006185 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006186 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006187 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6188 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006189 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006190
Hanno Becker32c55012017-11-10 08:42:54 +00006191requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006192run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006193 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006194 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006195 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006196 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006197 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006198
Hanno Becker278fc7a2017-11-10 09:16:28 +00006199requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006200run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006201 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006202 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006203 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006204 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006205 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6206 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006207
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006208run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006209 "$P_SRV" \
6210 "$P_CLI request_size=16384 force_version=tls1_2 \
6211 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6212 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006213 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6214 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006215
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006216run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006217 "$P_SRV" \
6218 "$P_CLI request_size=16384 force_version=tls1_2 \
6219 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6220 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006221 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6222 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006223
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006224# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006225requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6226run_test "Large server packet SSLv3 StreamCipher" \
6227 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6228 "$P_CLI force_version=ssl3 \
6229 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6230 0 \
6231 -c "Read from server: 16384 bytes read"
6232
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006233# Checking next 4 tests logs for 1n-1 split against BEAST too
6234requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6235run_test "Large server packet SSLv3 BlockCipher" \
6236 "$P_SRV response_size=16384 min_version=ssl3" \
6237 "$P_CLI force_version=ssl3 recsplit=0 \
6238 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6239 0 \
6240 -c "Read from server: 1 bytes read"\
6241 -c "16383 bytes read"\
6242 -C "Read from server: 16384 bytes read"
6243
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006244run_test "Large server packet TLS 1.0 BlockCipher" \
6245 "$P_SRV response_size=16384" \
6246 "$P_CLI force_version=tls1 recsplit=0 \
6247 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6248 0 \
6249 -c "Read from server: 1 bytes read"\
6250 -c "16383 bytes read"\
6251 -C "Read from server: 16384 bytes read"
6252
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006253run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6254 "$P_SRV response_size=16384" \
6255 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6256 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6257 0 \
6258 -c "Read from server: 1 bytes read"\
6259 -c "16383 bytes read"\
6260 -C "Read from server: 16384 bytes read"
6261
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006262requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6263run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6264 "$P_SRV response_size=16384" \
6265 "$P_CLI force_version=tls1 recsplit=0 \
6266 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6267 trunc_hmac=1" \
6268 0 \
6269 -c "Read from server: 1 bytes read"\
6270 -c "16383 bytes read"\
6271 -C "Read from server: 16384 bytes read"
6272
6273requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6274run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6275 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6276 "$P_CLI force_version=tls1 \
6277 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6278 trunc_hmac=1" \
6279 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006280 -s "16384 bytes written in 1 fragments" \
6281 -c "Read from server: 16384 bytes read"
6282
6283run_test "Large server packet TLS 1.0 StreamCipher" \
6284 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6285 "$P_CLI force_version=tls1 \
6286 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6287 0 \
6288 -s "16384 bytes written in 1 fragments" \
6289 -c "Read from server: 16384 bytes read"
6290
6291run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6292 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6293 "$P_CLI force_version=tls1 \
6294 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6295 0 \
6296 -s "16384 bytes written in 1 fragments" \
6297 -c "Read from server: 16384 bytes read"
6298
6299requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6300run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6301 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6302 "$P_CLI force_version=tls1 \
6303 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6304 0 \
6305 -s "16384 bytes written in 1 fragments" \
6306 -c "Read from server: 16384 bytes read"
6307
6308requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6309run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6310 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6311 "$P_CLI force_version=tls1 \
6312 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6313 0 \
6314 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006315 -c "Read from server: 16384 bytes read"
6316
6317run_test "Large server packet TLS 1.1 BlockCipher" \
6318 "$P_SRV response_size=16384" \
6319 "$P_CLI force_version=tls1_1 \
6320 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6321 0 \
6322 -c "Read from server: 16384 bytes read"
6323
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006324run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6325 "$P_SRV response_size=16384" \
6326 "$P_CLI force_version=tls1_1 etm=0 \
6327 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006328 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006329 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006330 -c "Read from server: 16384 bytes read"
6331
6332requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6333run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6334 "$P_SRV response_size=16384" \
6335 "$P_CLI force_version=tls1_1 \
6336 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6337 trunc_hmac=1" \
6338 0 \
6339 -c "Read from server: 16384 bytes read"
6340
6341requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006342run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6343 "$P_SRV response_size=16384 trunc_hmac=1" \
6344 "$P_CLI force_version=tls1_1 \
6345 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6346 0 \
6347 -s "16384 bytes written in 1 fragments" \
6348 -c "Read from server: 16384 bytes read"
6349
6350run_test "Large server packet TLS 1.1 StreamCipher" \
6351 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6352 "$P_CLI force_version=tls1_1 \
6353 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6354 0 \
6355 -c "Read from server: 16384 bytes read"
6356
6357run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6358 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6359 "$P_CLI force_version=tls1_1 \
6360 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6361 0 \
6362 -s "16384 bytes written in 1 fragments" \
6363 -c "Read from server: 16384 bytes read"
6364
6365requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006366run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6367 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6368 "$P_CLI force_version=tls1_1 \
6369 force_ciphersuite=TLS-RSA-WITH-RC4-128-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.1 StreamCipher, without EtM, truncated MAC" \
6375 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6376 "$P_CLI force_version=tls1_1 \
6377 force_ciphersuite=TLS-RSA-WITH-RC4-128-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 BlockCipher" \
6383 "$P_SRV response_size=16384" \
6384 "$P_CLI force_version=tls1_2 \
6385 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6386 0 \
6387 -c "Read from server: 16384 bytes read"
6388
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006389run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6390 "$P_SRV response_size=16384" \
6391 "$P_CLI force_version=tls1_2 etm=0 \
6392 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6393 0 \
6394 -s "16384 bytes written in 1 fragments" \
6395 -c "Read from server: 16384 bytes read"
6396
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006397run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6398 "$P_SRV response_size=16384" \
6399 "$P_CLI force_version=tls1_2 \
6400 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6401 0 \
6402 -c "Read from server: 16384 bytes read"
6403
6404requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6405run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6406 "$P_SRV response_size=16384" \
6407 "$P_CLI force_version=tls1_2 \
6408 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6409 trunc_hmac=1" \
6410 0 \
6411 -c "Read from server: 16384 bytes read"
6412
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006413run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6414 "$P_SRV response_size=16384 trunc_hmac=1" \
6415 "$P_CLI force_version=tls1_2 \
6416 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6417 0 \
6418 -s "16384 bytes written in 1 fragments" \
6419 -c "Read from server: 16384 bytes read"
6420
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006421run_test "Large server packet TLS 1.2 StreamCipher" \
6422 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6423 "$P_CLI force_version=tls1_2 \
6424 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6425 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006426 -s "16384 bytes written in 1 fragments" \
6427 -c "Read from server: 16384 bytes read"
6428
6429run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6430 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6431 "$P_CLI force_version=tls1_2 \
6432 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6433 0 \
6434 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006435 -c "Read from server: 16384 bytes read"
6436
6437requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6438run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6439 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6440 "$P_CLI force_version=tls1_2 \
6441 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6442 trunc_hmac=1" \
6443 0 \
6444 -c "Read from server: 16384 bytes read"
6445
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006446requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6447run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6448 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6449 "$P_CLI force_version=tls1_2 \
6450 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6451 0 \
6452 -s "16384 bytes written in 1 fragments" \
6453 -c "Read from server: 16384 bytes read"
6454
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006455run_test "Large server packet TLS 1.2 AEAD" \
6456 "$P_SRV response_size=16384" \
6457 "$P_CLI force_version=tls1_2 \
6458 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6459 0 \
6460 -c "Read from server: 16384 bytes read"
6461
6462run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6463 "$P_SRV response_size=16384" \
6464 "$P_CLI force_version=tls1_2 \
6465 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6466 0 \
6467 -c "Read from server: 16384 bytes read"
6468
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006469# Tests for restartable ECC
6470
6471requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6472run_test "EC restart: TLS, default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006473 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006474 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006475 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006476 debug_level=1" \
6477 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006478 -C "x509_verify_cert.*4b00" \
6479 -C "mbedtls_pk_verify.*4b00" \
6480 -C "mbedtls_ecdh_make_public.*4b00" \
6481 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006482
6483requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6484run_test "EC restart: TLS, max_ops=0" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006485 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006486 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006487 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006488 debug_level=1 ec_max_ops=0" \
6489 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006490 -C "x509_verify_cert.*4b00" \
6491 -C "mbedtls_pk_verify.*4b00" \
6492 -C "mbedtls_ecdh_make_public.*4b00" \
6493 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006494
6495requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6496run_test "EC restart: TLS, max_ops=65535" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006497 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006498 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006499 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006500 debug_level=1 ec_max_ops=65535" \
6501 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006502 -C "x509_verify_cert.*4b00" \
6503 -C "mbedtls_pk_verify.*4b00" \
6504 -C "mbedtls_ecdh_make_public.*4b00" \
6505 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006506
6507requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6508run_test "EC restart: TLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006509 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006510 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006511 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006512 debug_level=1 ec_max_ops=1000" \
6513 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006514 -c "x509_verify_cert.*4b00" \
6515 -c "mbedtls_pk_verify.*4b00" \
6516 -c "mbedtls_ecdh_make_public.*4b00" \
6517 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006518
6519requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Hanno Becker4a156fc2019-06-14 17:07:06 +01006520requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006521run_test "EC restart: TLS, max_ops=1000, badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006522 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006523 crt_file=data_files/server5-badsign.crt \
6524 key_file=data_files/server5.key" \
6525 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker03d77462019-08-27 16:24:56 +01006526 key_file=data_files/server5.key crt_file=data_files/server5.crt ca_file=data_files/test-ca2.crt \
6527 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6528 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006529 -c "x509_verify_cert.*4b00" \
Hanno Becker03d77462019-08-27 16:24:56 +01006530 -c "mbedtls_pk_verify.*4b00" \
6531 -c "mbedtls_ecdh_make_public.*4b00" \
6532 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006533 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006534
Hanno Becker4a156fc2019-06-14 17:07:06 +01006535requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006536requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6537run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006538 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006539 crt_file=data_files/server5-badsign.crt \
6540 key_file=data_files/server5.key" \
6541 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6542 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006543 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006544 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6545 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006546 -c "x509_verify_cert.*4b00" \
6547 -c "mbedtls_pk_verify.*4b00" \
6548 -c "mbedtls_ecdh_make_public.*4b00" \
6549 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006550 -c "! The certificate is not correctly signed by the trusted CA" \
6551 -C "! mbedtls_ssl_handshake returned" \
6552 -C "X509 - Certificate verification failed"
6553
Hanno Becker4a156fc2019-06-14 17:07:06 +01006554requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006555requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006556requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6557run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006558 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006559 crt_file=data_files/server5-badsign.crt \
6560 key_file=data_files/server5.key" \
6561 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006562 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006563 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6564 debug_level=1 ec_max_ops=1000 auth_mode=none" \
6565 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006566 -C "x509_verify_cert.*4b00" \
6567 -c "mbedtls_pk_verify.*4b00" \
6568 -c "mbedtls_ecdh_make_public.*4b00" \
6569 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006570 -C "! The certificate is not correctly signed by the trusted CA" \
6571 -C "! mbedtls_ssl_handshake returned" \
6572 -C "X509 - Certificate verification failed"
6573
6574requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006575run_test "EC restart: DTLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006576 "$P_SRV auth_mode=required dtls=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006577 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006578 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006579 dtls=1 debug_level=1 ec_max_ops=1000" \
6580 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006581 -c "x509_verify_cert.*4b00" \
6582 -c "mbedtls_pk_verify.*4b00" \
6583 -c "mbedtls_ecdh_make_public.*4b00" \
6584 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006585
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006586requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6587run_test "EC restart: TLS, max_ops=1000 no client auth" \
6588 "$P_SRV" \
6589 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6590 debug_level=1 ec_max_ops=1000" \
6591 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006592 -c "x509_verify_cert.*4b00" \
6593 -c "mbedtls_pk_verify.*4b00" \
6594 -c "mbedtls_ecdh_make_public.*4b00" \
6595 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006596
6597requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6598run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6599 "$P_SRV psk=abc123" \
6600 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6601 psk=abc123 debug_level=1 ec_max_ops=1000" \
6602 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006603 -C "x509_verify_cert.*4b00" \
6604 -C "mbedtls_pk_verify.*4b00" \
6605 -C "mbedtls_ecdh_make_public.*4b00" \
6606 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006607
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006608# Tests of asynchronous private key support in SSL
6609
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006610requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006611run_test "SSL async private: sign, delay=0" \
6612 "$P_SRV \
6613 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006614 "$P_CLI" \
6615 0 \
6616 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006617 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006618
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006619requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006620run_test "SSL async private: sign, delay=1" \
6621 "$P_SRV \
6622 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006623 "$P_CLI" \
6624 0 \
6625 -s "Async sign callback: using key slot " \
6626 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006627 -s "Async resume (slot [0-9]): sign done, status=0"
6628
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006629requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6630run_test "SSL async private: sign, delay=2" \
6631 "$P_SRV \
6632 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6633 "$P_CLI" \
6634 0 \
6635 -s "Async sign callback: using key slot " \
6636 -U "Async sign callback: using key slot " \
6637 -s "Async resume (slot [0-9]): call 1 more times." \
6638 -s "Async resume (slot [0-9]): call 0 more times." \
6639 -s "Async resume (slot [0-9]): sign done, status=0"
6640
Gilles Peskined3268832018-04-26 06:23:59 +02006641# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
6642# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
6643requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6644requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6645run_test "SSL async private: sign, RSA, TLS 1.1" \
6646 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
6647 async_operations=s async_private_delay1=0 async_private_delay2=0" \
6648 "$P_CLI force_version=tls1_1" \
6649 0 \
6650 -s "Async sign callback: using key slot " \
6651 -s "Async resume (slot [0-9]): sign done, status=0"
6652
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006653requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerb2c63832019-06-17 08:35:16 +01006654requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03006655requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006656requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskine807d74a2018-04-30 10:30:49 +02006657run_test "SSL async private: sign, SNI" \
6658 "$P_SRV debug_level=3 \
6659 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6660 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6661 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6662 "$P_CLI server_name=polarssl.example" \
6663 0 \
6664 -s "Async sign callback: using key slot " \
6665 -s "Async resume (slot [0-9]): sign done, status=0" \
6666 -s "parse ServerName extension" \
6667 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6668 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6669
6670requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006671run_test "SSL async private: decrypt, delay=0" \
6672 "$P_SRV \
6673 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6674 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6675 0 \
6676 -s "Async decrypt callback: using key slot " \
6677 -s "Async resume (slot [0-9]): decrypt done, status=0"
6678
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006679requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006680run_test "SSL async private: decrypt, delay=1" \
6681 "$P_SRV \
6682 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6683 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6684 0 \
6685 -s "Async decrypt callback: using key slot " \
6686 -s "Async resume (slot [0-9]): call 0 more times." \
6687 -s "Async resume (slot [0-9]): decrypt done, status=0"
6688
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006689requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006690run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6691 "$P_SRV psk=abc123 \
6692 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6693 "$P_CLI psk=abc123 \
6694 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6695 0 \
6696 -s "Async decrypt callback: using key slot " \
6697 -s "Async resume (slot [0-9]): decrypt done, status=0"
6698
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006699requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006700run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6701 "$P_SRV psk=abc123 \
6702 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6703 "$P_CLI psk=abc123 \
6704 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6705 0 \
6706 -s "Async decrypt callback: using key slot " \
6707 -s "Async resume (slot [0-9]): call 0 more times." \
6708 -s "Async resume (slot [0-9]): decrypt done, status=0"
6709
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006710requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006711run_test "SSL async private: sign callback not present" \
6712 "$P_SRV \
6713 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6714 "$P_CLI; [ \$? -eq 1 ] &&
6715 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6716 0 \
6717 -S "Async sign callback" \
6718 -s "! mbedtls_ssl_handshake returned" \
6719 -s "The own private key or pre-shared key is not set, but needed" \
6720 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6721 -s "Successful connection"
6722
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006723requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006724run_test "SSL async private: decrypt callback not present" \
6725 "$P_SRV debug_level=1 \
6726 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6727 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6728 [ \$? -eq 1 ] && $P_CLI" \
6729 0 \
6730 -S "Async decrypt callback" \
6731 -s "! mbedtls_ssl_handshake returned" \
6732 -s "got no RSA private key" \
6733 -s "Async resume (slot [0-9]): sign done, status=0" \
6734 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006735
6736# key1: ECDSA, key2: RSA; use key1 from slot 0
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: slot 0 used with key1" \
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" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006743 "$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 +01006744 0 \
6745 -s "Async sign callback: using key slot 0," \
6746 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006747 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006748
6749# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006750requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006751run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006752 "$P_SRV \
6753 async_operations=s async_private_delay2=1 \
6754 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6755 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006756 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6757 0 \
6758 -s "Async sign callback: using key slot 0," \
6759 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006760 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006761
6762# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006763requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006764run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006765 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006766 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006767 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6768 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006769 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6770 0 \
6771 -s "Async sign callback: using key slot 1," \
6772 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006773 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006774
6775# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006776requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006777run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006778 "$P_SRV \
6779 async_operations=s async_private_delay1=1 \
6780 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6781 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006782 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6783 0 \
6784 -s "Async sign callback: no key matches this certificate."
6785
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006786requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006787run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006788 "$P_SRV \
6789 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6790 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006791 "$P_CLI" \
6792 1 \
6793 -s "Async sign callback: injected error" \
6794 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006795 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006796 -s "! mbedtls_ssl_handshake returned"
6797
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006798requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006799run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006800 "$P_SRV \
6801 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6802 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006803 "$P_CLI" \
6804 1 \
6805 -s "Async sign callback: using key slot " \
6806 -S "Async resume" \
6807 -s "Async cancel"
6808
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006809requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006810run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006811 "$P_SRV \
6812 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6813 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006814 "$P_CLI" \
6815 1 \
6816 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006817 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006818 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006819 -s "! mbedtls_ssl_handshake returned"
6820
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006821requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006822run_test "SSL async private: decrypt, error in start" \
6823 "$P_SRV \
6824 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6825 async_private_error=1" \
6826 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6827 1 \
6828 -s "Async decrypt callback: injected error" \
6829 -S "Async resume" \
6830 -S "Async cancel" \
6831 -s "! mbedtls_ssl_handshake returned"
6832
6833requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6834run_test "SSL async private: decrypt, cancel after start" \
6835 "$P_SRV \
6836 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6837 async_private_error=2" \
6838 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6839 1 \
6840 -s "Async decrypt callback: using key slot " \
6841 -S "Async resume" \
6842 -s "Async cancel"
6843
6844requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6845run_test "SSL async private: decrypt, error in resume" \
6846 "$P_SRV \
6847 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6848 async_private_error=3" \
6849 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6850 1 \
6851 -s "Async decrypt callback: using key slot " \
6852 -s "Async resume callback: decrypt done but injected error" \
6853 -S "Async cancel" \
6854 -s "! mbedtls_ssl_handshake returned"
6855
6856requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006857run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006858 "$P_SRV \
6859 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6860 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006861 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6862 0 \
6863 -s "Async cancel" \
6864 -s "! mbedtls_ssl_handshake returned" \
6865 -s "Async resume" \
6866 -s "Successful connection"
6867
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006868requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006869run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006870 "$P_SRV \
6871 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6872 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006873 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6874 0 \
6875 -s "! mbedtls_ssl_handshake returned" \
6876 -s "Async resume" \
6877 -s "Successful connection"
6878
6879# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006880requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006881run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006882 "$P_SRV \
6883 async_operations=s async_private_delay1=1 async_private_error=-2 \
6884 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6885 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006886 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6887 [ \$? -eq 1 ] &&
6888 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6889 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006890 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006891 -S "Async resume" \
6892 -s "Async cancel" \
6893 -s "! mbedtls_ssl_handshake returned" \
6894 -s "Async sign callback: no key matches this certificate." \
6895 -s "Successful connection"
6896
6897# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006898requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006899run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006900 "$P_SRV \
6901 async_operations=s async_private_delay1=1 async_private_error=-3 \
6902 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6903 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006904 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6905 [ \$? -eq 1 ] &&
6906 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6907 0 \
6908 -s "Async resume" \
6909 -s "! mbedtls_ssl_handshake returned" \
6910 -s "Async sign callback: no key matches this certificate." \
6911 -s "Successful connection"
6912
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006913requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006914requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006915run_test "SSL async private: renegotiation: client-initiated; sign" \
6916 "$P_SRV \
6917 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006918 exchanges=2 renegotiation=1" \
6919 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6920 0 \
6921 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006922 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006923
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006924requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006925requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006926run_test "SSL async private: renegotiation: server-initiated; sign" \
6927 "$P_SRV \
6928 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006929 exchanges=2 renegotiation=1 renegotiate=1" \
6930 "$P_CLI exchanges=2 renegotiation=1" \
6931 0 \
6932 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006933 -s "Async resume (slot [0-9]): sign done, status=0"
6934
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006935requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006936requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6937run_test "SSL async private: renegotiation: client-initiated; decrypt" \
6938 "$P_SRV \
6939 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6940 exchanges=2 renegotiation=1" \
6941 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6942 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6943 0 \
6944 -s "Async decrypt callback: using key slot " \
6945 -s "Async resume (slot [0-9]): decrypt done, status=0"
6946
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006947requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006948requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6949run_test "SSL async private: renegotiation: server-initiated; decrypt" \
6950 "$P_SRV \
6951 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6952 exchanges=2 renegotiation=1 renegotiate=1" \
6953 "$P_CLI exchanges=2 renegotiation=1 \
6954 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6955 0 \
6956 -s "Async decrypt callback: using key slot " \
6957 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006958
Ron Eldor58093c82018-06-28 13:22:05 +03006959# Tests for ECC extensions (rfc 4492)
6960
Ron Eldor643df7c2018-06-28 16:17:00 +03006961requires_config_enabled MBEDTLS_AES_C
6962requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6963requires_config_enabled MBEDTLS_SHA256_C
6964requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006965run_test "Force a non ECC ciphersuite in the client side" \
6966 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006967 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006968 0 \
6969 -C "client hello, adding supported_elliptic_curves extension" \
6970 -C "client hello, adding supported_point_formats extension" \
6971 -S "found supported elliptic curves extension" \
6972 -S "found supported point formats extension"
6973
Ron Eldor643df7c2018-06-28 16:17:00 +03006974requires_config_enabled MBEDTLS_AES_C
6975requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6976requires_config_enabled MBEDTLS_SHA256_C
6977requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006978run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006979 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006980 "$P_CLI debug_level=3" \
6981 0 \
6982 -C "found supported_point_formats extension" \
6983 -S "server hello, supported_point_formats extension"
6984
Ron Eldor643df7c2018-06-28 16:17:00 +03006985requires_config_enabled MBEDTLS_AES_C
6986requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6987requires_config_enabled MBEDTLS_SHA256_C
6988requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006989run_test "Force an ECC ciphersuite in the client side" \
6990 "$P_SRV debug_level=3" \
6991 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6992 0 \
6993 -c "client hello, adding supported_elliptic_curves extension" \
6994 -c "client hello, adding supported_point_formats extension" \
6995 -s "found supported elliptic curves extension" \
6996 -s "found supported point formats extension"
6997
Ron Eldor643df7c2018-06-28 16:17:00 +03006998requires_config_enabled MBEDTLS_AES_C
6999requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7000requires_config_enabled MBEDTLS_SHA256_C
7001requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007002run_test "Force an ECC ciphersuite in the server side" \
7003 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7004 "$P_CLI debug_level=3" \
7005 0 \
7006 -c "found supported_point_formats extension" \
7007 -s "server hello, supported_point_formats extension"
7008
Jarno Lamsad3428052019-10-28 14:36:37 +02007009requires_config_enabled MBEDTLS_AES_C
7010requires_config_enabled MBEDTLS_CCM_C
7011requires_config_enabled MBEDTLS_SHA256_C
7012requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
7013run_test "Force an ECC ciphersuite with CCM in the client side" \
7014 "$P_SRV dtls=1 debug_level=3" \
7015 "$P_CLI dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
7016 0 \
7017 -c "client hello, adding supported_elliptic_curves extension" \
7018 -c "client hello, adding supported_point_formats extension" \
7019 -s "found supported elliptic curves extension" \
7020 -s "found supported point formats extension"
7021
7022requires_config_enabled MBEDTLS_AES_C
7023requires_config_enabled MBEDTLS_CCM_C
7024requires_config_enabled MBEDTLS_SHA256_C
7025requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
7026run_test "Force an ECC ciphersuite with CCM in the server side" \
7027 "$P_SRV dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
7028 "$P_CLI dtls=1 debug_level=3" \
7029 0 \
7030 -c "found supported_point_formats extension" \
7031 -s "server hello, supported_point_formats extension"
7032
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007033# Tests for DTLS HelloVerifyRequest
7034
7035run_test "DTLS cookie: enabled" \
7036 "$P_SRV dtls=1 debug_level=2" \
7037 "$P_CLI dtls=1 debug_level=2" \
7038 0 \
7039 -s "cookie verification failed" \
7040 -s "cookie verification passed" \
7041 -S "cookie verification skipped" \
7042 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007043 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007044 -S "SSL - The requested feature is not available"
7045
7046run_test "DTLS cookie: disabled" \
7047 "$P_SRV dtls=1 debug_level=2 cookies=0" \
7048 "$P_CLI dtls=1 debug_level=2" \
7049 0 \
7050 -S "cookie verification failed" \
7051 -S "cookie verification passed" \
7052 -s "cookie verification skipped" \
7053 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007054 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007055 -S "SSL - The requested feature is not available"
7056
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007057run_test "DTLS cookie: default (failing)" \
7058 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
7059 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
7060 1 \
7061 -s "cookie verification failed" \
7062 -S "cookie verification passed" \
7063 -S "cookie verification skipped" \
7064 -C "received hello verify request" \
Jarno Lamsab514cd32019-10-28 14:37:51 +02007065 -S "hello verification requested"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007066
7067requires_ipv6
7068run_test "DTLS cookie: enabled, IPv6" \
7069 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
7070 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
7071 0 \
7072 -s "cookie verification failed" \
7073 -s "cookie verification passed" \
7074 -S "cookie verification skipped" \
7075 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007076 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007077 -S "SSL - The requested feature is not available"
7078
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007079run_test "DTLS cookie: enabled, nbio" \
7080 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7081 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7082 0 \
7083 -s "cookie verification failed" \
7084 -s "cookie verification passed" \
7085 -S "cookie verification skipped" \
7086 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007087 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007088 -S "SSL - The requested feature is not available"
7089
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007090# Tests for client reconnecting from the same port with DTLS
7091
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007092not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007093requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007094run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007095 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7096 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007097 0 \
7098 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007099 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007100 -S "Client initiated reconnection from same port"
7101
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007102not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007103requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007104run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007105 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7106 "$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 +02007107 0 \
7108 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007109 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007110 -s "Client initiated reconnection from same port"
7111
Paul Bakker362689d2016-05-13 10:33:25 +01007112not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
Jarno Lamsa33281d52019-10-18 10:54:35 +03007113requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007114run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007115 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7116 "$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 +02007117 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007118 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007119 -s "Client initiated reconnection from same port"
7120
Paul Bakker362689d2016-05-13 10:33:25 +01007121only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
Jarno Lamsa33281d52019-10-18 10:54:35 +03007122requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007123run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7124 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7125 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7126 0 \
7127 -S "The operation timed out" \
7128 -s "Client initiated reconnection from same port"
7129
Jarno Lamsa33281d52019-10-18 10:54:35 +03007130requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007131run_test "DTLS client reconnect from same port: no cookies" \
7132 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007133 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7134 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007135 -s "The operation timed out" \
7136 -S "Client initiated reconnection from same port"
7137
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007138# Tests for various cases of client authentication with DTLS
7139# (focused on handshake flows and message parsing)
7140
7141run_test "DTLS client auth: required" \
7142 "$P_SRV dtls=1 auth_mode=required" \
7143 "$P_CLI dtls=1" \
7144 0 \
7145 -s "Verifying peer X.509 certificate... ok"
7146
Hanno Becker4a156fc2019-06-14 17:07:06 +01007147requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007148requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007149run_test "DTLS client auth: optional, client has no cert" \
7150 "$P_SRV dtls=1 auth_mode=optional" \
7151 "$P_CLI dtls=1 crt_file=none key_file=none" \
7152 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007153 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007154
Hanno Becker4a156fc2019-06-14 17:07:06 +01007155requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007156requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007157run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007158 "$P_SRV dtls=1 auth_mode=none" \
7159 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7160 0 \
7161 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007162 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007163
Jarno Lamsa33281d52019-10-18 10:54:35 +03007164requires_ciphersuite_enabled TLS-PSK-WITH-AES-128-GCM-SHA256
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007165run_test "DTLS wrong PSK: badmac alert" \
7166 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7167 "$P_CLI dtls=1 psk=abc124" \
7168 1 \
7169 -s "SSL - Verification of the message MAC failed" \
7170 -c "SSL - A fatal alert message was received from our peer"
7171
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007172# Tests for receiving fragmented handshake messages with DTLS
7173
7174requires_gnutls
7175run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7176 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007177 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007178 0 \
7179 -C "found fragmented DTLS handshake message" \
7180 -C "error"
7181
7182requires_gnutls
7183run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7184 "$G_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007185 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007186 0 \
7187 -c "found fragmented DTLS handshake message" \
7188 -C "error"
7189
7190requires_gnutls
7191run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7192 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007193 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007194 0 \
7195 -c "found fragmented DTLS handshake message" \
7196 -C "error"
7197
7198requires_gnutls
7199run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7200 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007201 "$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 +02007202 0 \
7203 -c "found fragmented DTLS handshake message" \
7204 -C "error"
7205
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007206requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007207requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007208run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7209 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007210 "$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 +02007211 0 \
7212 -c "found fragmented DTLS handshake message" \
7213 -c "client hello, adding renegotiation extension" \
7214 -c "found renegotiation extension" \
7215 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007216 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007217 -C "error" \
7218 -s "Extra-header:"
7219
7220requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007221requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007222run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7223 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007224 "$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 +02007225 0 \
7226 -c "found fragmented DTLS handshake message" \
7227 -c "client hello, adding renegotiation extension" \
7228 -c "found renegotiation extension" \
7229 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007230 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007231 -C "error" \
7232 -s "Extra-header:"
7233
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007234run_test "DTLS reassembly: no fragmentation (openssl server)" \
7235 "$O_SRV -dtls1 -mtu 2048" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007236 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007237 0 \
7238 -C "found fragmented DTLS handshake message" \
7239 -C "error"
7240
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007241run_test "DTLS reassembly: some fragmentation (openssl server)" \
7242 "$O_SRV -dtls1 -mtu 768" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007243 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007244 0 \
7245 -c "found fragmented DTLS handshake message" \
7246 -C "error"
7247
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007248run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007249 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007250 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007251 0 \
7252 -c "found fragmented DTLS handshake message" \
7253 -C "error"
7254
7255run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7256 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007257 "$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 +02007258 0 \
7259 -c "found fragmented DTLS handshake message" \
7260 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007261
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007262# Tests for sending fragmented handshake messages with DTLS
7263#
7264# Use client auth when we need the client to send large messages,
7265# and use large cert chains on both sides too (the long chains we have all use
7266# both RSA and ECDSA, but ideally we should have long chains with either).
7267# Sizes reached (UDP payload):
7268# - 2037B for server certificate
7269# - 1542B for client certificate
7270# - 1013B for newsessionticket
7271# - all others below 512B
7272# All those tests assume MAX_CONTENT_LEN is at least 2048
7273
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007274requires_config_enabled MBEDTLS_RSA_C
7275requires_config_enabled MBEDTLS_ECDSA_C
7276requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7277run_test "DTLS fragmenting: none (for reference)" \
7278 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7279 crt_file=data_files/server7_int-ca.crt \
7280 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007281 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007282 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007283 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007284 "$P_CLI dtls=1 debug_level=2 \
7285 crt_file=data_files/server8_int-ca2.crt \
7286 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007287 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007288 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007289 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007290 0 \
7291 -S "found fragmented DTLS handshake message" \
7292 -C "found fragmented DTLS handshake message" \
7293 -C "error"
7294
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007295requires_config_enabled MBEDTLS_RSA_C
7296requires_config_enabled MBEDTLS_ECDSA_C
7297requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007298run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007299 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7300 crt_file=data_files/server7_int-ca.crt \
7301 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007302 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007303 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007304 max_frag_len=1024" \
7305 "$P_CLI dtls=1 debug_level=2 \
7306 crt_file=data_files/server8_int-ca2.crt \
7307 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007308 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007309 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007310 max_frag_len=2048" \
7311 0 \
7312 -S "found fragmented DTLS handshake message" \
7313 -c "found fragmented DTLS handshake message" \
7314 -C "error"
7315
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007316# With the MFL extension, the server has no way of forcing
7317# the client to not exceed a certain MTU; hence, the following
7318# test can't be replicated with an MTU proxy such as the one
7319# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007320requires_config_enabled MBEDTLS_RSA_C
7321requires_config_enabled MBEDTLS_ECDSA_C
7322requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007323run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007324 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7325 crt_file=data_files/server7_int-ca.crt \
7326 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007327 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007328 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007329 max_frag_len=512" \
7330 "$P_CLI dtls=1 debug_level=2 \
7331 crt_file=data_files/server8_int-ca2.crt \
7332 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007333 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007334 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007335 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007336 0 \
7337 -S "found fragmented DTLS handshake message" \
7338 -c "found fragmented DTLS handshake message" \
7339 -C "error"
7340
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007341requires_config_enabled MBEDTLS_RSA_C
7342requires_config_enabled MBEDTLS_ECDSA_C
7343requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007344run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007345 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7346 crt_file=data_files/server7_int-ca.crt \
7347 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007348 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007349 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007350 max_frag_len=2048" \
7351 "$P_CLI dtls=1 debug_level=2 \
7352 crt_file=data_files/server8_int-ca2.crt \
7353 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007354 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007355 hs_timeout=2500-60000 \
7356 max_frag_len=1024" \
7357 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007358 -S "found fragmented DTLS handshake message" \
7359 -c "found fragmented DTLS handshake message" \
7360 -C "error"
7361
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007362# While not required by the standard defining the MFL extension
7363# (according to which it only applies to records, not to datagrams),
7364# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7365# as otherwise there wouldn't be any means to communicate MTU restrictions
7366# to the peer.
7367# The next test checks that no datagrams significantly larger than the
7368# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007369requires_config_enabled MBEDTLS_RSA_C
7370requires_config_enabled MBEDTLS_ECDSA_C
7371requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7372run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007373 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007374 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7375 crt_file=data_files/server7_int-ca.crt \
7376 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007377 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007378 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007379 max_frag_len=2048" \
7380 "$P_CLI dtls=1 debug_level=2 \
7381 crt_file=data_files/server8_int-ca2.crt \
7382 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007383 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007384 hs_timeout=2500-60000 \
7385 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007386 0 \
7387 -S "found fragmented DTLS handshake message" \
7388 -c "found fragmented DTLS handshake message" \
7389 -C "error"
7390
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007391requires_config_enabled MBEDTLS_RSA_C
7392requires_config_enabled MBEDTLS_ECDSA_C
7393requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007394run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007395 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7396 crt_file=data_files/server7_int-ca.crt \
7397 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007398 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007399 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007400 max_frag_len=2048" \
7401 "$P_CLI dtls=1 debug_level=2 \
7402 crt_file=data_files/server8_int-ca2.crt \
7403 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007404 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007405 hs_timeout=2500-60000 \
7406 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007407 0 \
7408 -s "found fragmented DTLS handshake message" \
7409 -c "found fragmented DTLS handshake message" \
7410 -C "error"
7411
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007412# While not required by the standard defining the MFL extension
7413# (according to which it only applies to records, not to datagrams),
7414# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7415# as otherwise there wouldn't be any means to communicate MTU restrictions
7416# to the peer.
7417# The next test checks that no datagrams significantly larger than the
7418# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007419requires_config_enabled MBEDTLS_RSA_C
7420requires_config_enabled MBEDTLS_ECDSA_C
7421requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7422run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007423 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007424 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7425 crt_file=data_files/server7_int-ca.crt \
7426 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007427 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007428 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007429 max_frag_len=2048" \
7430 "$P_CLI dtls=1 debug_level=2 \
7431 crt_file=data_files/server8_int-ca2.crt \
7432 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007433 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007434 hs_timeout=2500-60000 \
7435 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007436 0 \
7437 -s "found fragmented DTLS handshake message" \
7438 -c "found fragmented DTLS handshake message" \
7439 -C "error"
7440
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007441requires_config_enabled MBEDTLS_RSA_C
7442requires_config_enabled MBEDTLS_ECDSA_C
7443run_test "DTLS fragmenting: none (for reference) (MTU)" \
7444 "$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 \
Hanno Becker12405e72018-08-13 16:45:46 +01007449 mtu=4096" \
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 \
Hanno Becker12405e72018-08-13 16:45:46 +01007455 mtu=4096" \
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
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007461requires_config_enabled MBEDTLS_RSA_C
7462requires_config_enabled MBEDTLS_ECDSA_C
7463run_test "DTLS fragmenting: client (MTU)" \
7464 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7465 crt_file=data_files/server7_int-ca.crt \
7466 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007467 ca_file=data_files/test-ca.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007468 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007469 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007470 "$P_CLI dtls=1 debug_level=2 \
7471 crt_file=data_files/server8_int-ca2.crt \
7472 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007473 ca_file=data_files/test-ca2.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007474 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007475 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007476 0 \
7477 -s "found fragmented DTLS handshake message" \
7478 -C "found fragmented DTLS handshake message" \
7479 -C "error"
7480
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007481requires_config_enabled MBEDTLS_RSA_C
7482requires_config_enabled MBEDTLS_ECDSA_C
7483run_test "DTLS fragmenting: server (MTU)" \
7484 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7485 crt_file=data_files/server7_int-ca.crt \
7486 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007487 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007488 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007489 mtu=512" \
7490 "$P_CLI dtls=1 debug_level=2 \
7491 crt_file=data_files/server8_int-ca2.crt \
7492 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007493 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007494 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007495 mtu=2048" \
7496 0 \
7497 -S "found fragmented DTLS handshake message" \
7498 -c "found fragmented DTLS handshake message" \
7499 -C "error"
7500
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007501requires_config_enabled MBEDTLS_RSA_C
7502requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007503run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007504 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007505 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7506 crt_file=data_files/server7_int-ca.crt \
7507 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007508 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007509 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007510 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007511 "$P_CLI dtls=1 debug_level=2 \
7512 crt_file=data_files/server8_int-ca2.crt \
7513 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007514 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007515 hs_timeout=2500-60000 \
7516 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007517 0 \
7518 -s "found fragmented DTLS handshake message" \
7519 -c "found fragmented DTLS handshake message" \
7520 -C "error"
7521
Andrzej Kurek77826052018-10-11 07:34:08 -04007522# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007523requires_config_enabled MBEDTLS_RSA_C
7524requires_config_enabled MBEDTLS_ECDSA_C
7525requires_config_enabled MBEDTLS_SHA256_C
7526requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7527requires_config_enabled MBEDTLS_AES_C
7528requires_config_enabled MBEDTLS_GCM_C
7529run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007530 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007531 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7532 crt_file=data_files/server7_int-ca.crt \
7533 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007534 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007535 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007536 mtu=512" \
7537 "$P_CLI dtls=1 debug_level=2 \
7538 crt_file=data_files/server8_int-ca2.crt \
7539 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007540 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007541 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7542 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007543 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007544 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007545 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007546 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007547 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007548
Andrzej Kurek7311c782018-10-11 06:49:41 -04007549# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007550# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007551# The ratio of max/min timeout should ideally equal 4 to accept two
7552# retransmissions, but in some cases (like both the server and client using
7553# fragmentation and auto-reduction) an extra retransmission might occur,
7554# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007555not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007556requires_config_enabled MBEDTLS_RSA_C
7557requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007558requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7559requires_config_enabled MBEDTLS_AES_C
7560requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007561run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7562 -p "$P_PXY mtu=508" \
7563 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7564 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007565 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007566 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007567 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007568 "$P_CLI dtls=1 debug_level=2 \
7569 crt_file=data_files/server8_int-ca2.crt \
7570 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007571 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007572 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7573 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007574 0 \
7575 -s "found fragmented DTLS handshake message" \
7576 -c "found fragmented DTLS handshake message" \
7577 -C "error"
7578
Andrzej Kurek77826052018-10-11 07:34:08 -04007579# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007580only_with_valgrind
Hanno Becker108992e2018-08-29 17:04:18 +01007581requires_config_enabled MBEDTLS_RSA_C
7582requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007583requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7584requires_config_enabled MBEDTLS_AES_C
7585requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01007586run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7587 -p "$P_PXY mtu=508" \
7588 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7589 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007590 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007591 ca_file=data_files/test-ca.crt \
Hanno Becker108992e2018-08-29 17:04:18 +01007592 hs_timeout=250-10000" \
7593 "$P_CLI dtls=1 debug_level=2 \
7594 crt_file=data_files/server8_int-ca2.crt \
7595 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007596 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007597 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007598 hs_timeout=250-10000" \
7599 0 \
7600 -s "found fragmented DTLS handshake message" \
7601 -c "found fragmented DTLS handshake message" \
7602 -C "error"
7603
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007604# 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 +02007605# OTOH the client might resend if the server is to slow to reset after sending
7606# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007607not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007608requires_config_enabled MBEDTLS_RSA_C
7609requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007610run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007611 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007612 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7613 crt_file=data_files/server7_int-ca.crt \
7614 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007615 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007616 hs_timeout=10000-60000 \
7617 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007618 "$P_CLI dtls=1 debug_level=2 \
7619 crt_file=data_files/server8_int-ca2.crt \
7620 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007621 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007622 hs_timeout=10000-60000 \
7623 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007624 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007625 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007626 -s "found fragmented DTLS handshake message" \
7627 -c "found fragmented DTLS handshake message" \
7628 -C "error"
7629
Andrzej Kurek77826052018-10-11 07:34:08 -04007630# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007631# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7632# OTOH the client might resend if the server is to slow to reset after sending
7633# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007634not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007635requires_config_enabled MBEDTLS_RSA_C
7636requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007637requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7638requires_config_enabled MBEDTLS_AES_C
7639requires_config_enabled MBEDTLS_GCM_C
7640run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007641 -p "$P_PXY mtu=512" \
7642 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7643 crt_file=data_files/server7_int-ca.crt \
7644 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007645 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007646 hs_timeout=10000-60000 \
7647 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007648 "$P_CLI dtls=1 debug_level=2 \
7649 crt_file=data_files/server8_int-ca2.crt \
7650 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007651 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007652 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7653 hs_timeout=10000-60000 \
7654 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007655 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007656 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007657 -s "found fragmented DTLS handshake message" \
7658 -c "found fragmented DTLS handshake message" \
7659 -C "error"
7660
Andrzej Kurek7311c782018-10-11 06:49:41 -04007661not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007662requires_config_enabled MBEDTLS_RSA_C
7663requires_config_enabled MBEDTLS_ECDSA_C
7664run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007665 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007666 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7667 crt_file=data_files/server7_int-ca.crt \
7668 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007669 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007670 hs_timeout=10000-60000 \
7671 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007672 "$P_CLI dtls=1 debug_level=2 \
7673 crt_file=data_files/server8_int-ca2.crt \
7674 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007675 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007676 hs_timeout=10000-60000 \
7677 mtu=1024 nbio=2" \
7678 0 \
7679 -S "autoreduction" \
7680 -s "found fragmented DTLS handshake message" \
7681 -c "found fragmented DTLS handshake message" \
7682 -C "error"
7683
Andrzej Kurek77826052018-10-11 07:34:08 -04007684# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007685not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007686requires_config_enabled MBEDTLS_RSA_C
7687requires_config_enabled MBEDTLS_ECDSA_C
7688requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7689requires_config_enabled MBEDTLS_AES_C
7690requires_config_enabled MBEDTLS_GCM_C
7691run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7692 -p "$P_PXY mtu=512" \
7693 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7694 crt_file=data_files/server7_int-ca.crt \
7695 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007696 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007697 hs_timeout=10000-60000 \
7698 mtu=512 nbio=2" \
7699 "$P_CLI dtls=1 debug_level=2 \
7700 crt_file=data_files/server8_int-ca2.crt \
7701 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007702 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007703 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7704 hs_timeout=10000-60000 \
7705 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007706 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007707 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007708 -s "found fragmented DTLS handshake message" \
7709 -c "found fragmented DTLS handshake message" \
7710 -C "error"
7711
Andrzej Kurek77826052018-10-11 07:34:08 -04007712# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007713# This ensures things still work after session_reset().
7714# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007715# Since we don't support reading fragmented ClientHello yet,
7716# up the MTU to 1450 (larger than ClientHello with session ticket,
7717# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007718# An autoreduction on the client-side might happen if the server is
7719# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007720# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007721# resumed listening, which would result in a spurious autoreduction.
7722not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007723requires_config_enabled MBEDTLS_RSA_C
7724requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007725requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7726requires_config_enabled MBEDTLS_AES_C
7727requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007728run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7729 -p "$P_PXY mtu=1450" \
7730 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7731 crt_file=data_files/server7_int-ca.crt \
7732 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007733 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007734 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007735 mtu=1450" \
7736 "$P_CLI dtls=1 debug_level=2 \
7737 crt_file=data_files/server8_int-ca2.crt \
7738 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007739 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007740 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007741 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007742 mtu=1450 reconnect=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007743 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007744 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007745 -s "found fragmented DTLS handshake message" \
7746 -c "found fragmented DTLS handshake message" \
7747 -C "error"
7748
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007749# An autoreduction on the client-side might happen if the server is
7750# slow to reset, therefore omitting '-C "autoreduction"' below.
7751not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007752requires_config_enabled MBEDTLS_RSA_C
7753requires_config_enabled MBEDTLS_ECDSA_C
7754requires_config_enabled MBEDTLS_SHA256_C
7755requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7756requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7757requires_config_enabled MBEDTLS_CHACHAPOLY_C
7758run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7759 -p "$P_PXY mtu=512" \
7760 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7761 crt_file=data_files/server7_int-ca.crt \
7762 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007763 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007764 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007765 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007766 mtu=512" \
7767 "$P_CLI dtls=1 debug_level=2 \
7768 crt_file=data_files/server8_int-ca2.crt \
7769 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007770 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007771 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007772 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007773 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007774 mtu=512" \
7775 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007776 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007777 -s "found fragmented DTLS handshake message" \
7778 -c "found fragmented DTLS handshake message" \
7779 -C "error"
7780
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007781# An autoreduction on the client-side might happen if the server is
7782# slow to reset, therefore omitting '-C "autoreduction"' below.
7783not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007784requires_config_enabled MBEDTLS_RSA_C
7785requires_config_enabled MBEDTLS_ECDSA_C
7786requires_config_enabled MBEDTLS_SHA256_C
7787requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7788requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7789requires_config_enabled MBEDTLS_AES_C
7790requires_config_enabled MBEDTLS_GCM_C
7791run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7792 -p "$P_PXY mtu=512" \
7793 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7794 crt_file=data_files/server7_int-ca.crt \
7795 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007796 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007797 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007798 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007799 mtu=512" \
7800 "$P_CLI dtls=1 debug_level=2 \
7801 crt_file=data_files/server8_int-ca2.crt \
7802 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007803 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007804 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007805 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007806 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007807 mtu=512" \
7808 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007809 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007810 -s "found fragmented DTLS handshake message" \
7811 -c "found fragmented DTLS handshake message" \
7812 -C "error"
7813
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007814# An autoreduction on the client-side might happen if the server is
7815# slow to reset, therefore omitting '-C "autoreduction"' below.
7816not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007817requires_config_enabled MBEDTLS_RSA_C
7818requires_config_enabled MBEDTLS_ECDSA_C
7819requires_config_enabled MBEDTLS_SHA256_C
7820requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7821requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7822requires_config_enabled MBEDTLS_AES_C
7823requires_config_enabled MBEDTLS_CCM_C
7824run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007825 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007826 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7827 crt_file=data_files/server7_int-ca.crt \
7828 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007829 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007830 exchanges=2 renegotiation=1 \
7831 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007832 hs_timeout=10000-60000 \
7833 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007834 "$P_CLI dtls=1 debug_level=2 \
7835 crt_file=data_files/server8_int-ca2.crt \
7836 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007837 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007838 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007839 hs_timeout=10000-60000 \
7840 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007841 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007842 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007843 -s "found fragmented DTLS handshake message" \
7844 -c "found fragmented DTLS handshake message" \
7845 -C "error"
7846
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007847# An autoreduction on the client-side might happen if the server is
7848# slow to reset, therefore omitting '-C "autoreduction"' below.
7849not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007850requires_config_enabled MBEDTLS_RSA_C
7851requires_config_enabled MBEDTLS_ECDSA_C
7852requires_config_enabled MBEDTLS_SHA256_C
7853requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7854requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7855requires_config_enabled MBEDTLS_AES_C
7856requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7857requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7858run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007859 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007860 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7861 crt_file=data_files/server7_int-ca.crt \
7862 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007863 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007864 exchanges=2 renegotiation=1 \
7865 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007866 hs_timeout=10000-60000 \
7867 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007868 "$P_CLI dtls=1 debug_level=2 \
7869 crt_file=data_files/server8_int-ca2.crt \
7870 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007871 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007872 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007873 hs_timeout=10000-60000 \
7874 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007875 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007876 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007877 -s "found fragmented DTLS handshake message" \
7878 -c "found fragmented DTLS handshake message" \
7879 -C "error"
7880
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007881# An autoreduction on the client-side might happen if the server is
7882# slow to reset, therefore omitting '-C "autoreduction"' below.
7883not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007884requires_config_enabled MBEDTLS_RSA_C
7885requires_config_enabled MBEDTLS_ECDSA_C
7886requires_config_enabled MBEDTLS_SHA256_C
7887requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7888requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7889requires_config_enabled MBEDTLS_AES_C
7890requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7891run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007892 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007893 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7894 crt_file=data_files/server7_int-ca.crt \
7895 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007896 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007897 exchanges=2 renegotiation=1 \
7898 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007899 hs_timeout=10000-60000 \
7900 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007901 "$P_CLI dtls=1 debug_level=2 \
7902 crt_file=data_files/server8_int-ca2.crt \
7903 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007904 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007905 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007906 hs_timeout=10000-60000 \
7907 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007908 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007909 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007910 -s "found fragmented DTLS handshake message" \
7911 -c "found fragmented DTLS handshake message" \
7912 -C "error"
7913
Andrzej Kurek77826052018-10-11 07:34:08 -04007914# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007915requires_config_enabled MBEDTLS_RSA_C
7916requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007917requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7918requires_config_enabled MBEDTLS_AES_C
7919requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007920client_needs_more_time 2
7921run_test "DTLS fragmenting: proxy MTU + 3d" \
7922 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007923 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007924 crt_file=data_files/server7_int-ca.crt \
7925 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007926 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007927 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007928 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007929 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 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007932 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007933 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007934 0 \
7935 -s "found fragmented DTLS handshake message" \
7936 -c "found fragmented DTLS handshake message" \
7937 -C "error"
7938
Andrzej Kurek77826052018-10-11 07:34:08 -04007939# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007940requires_config_enabled MBEDTLS_RSA_C
7941requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007942requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7943requires_config_enabled MBEDTLS_AES_C
7944requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007945client_needs_more_time 2
7946run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7947 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7948 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7949 crt_file=data_files/server7_int-ca.crt \
7950 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007951 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007952 hs_timeout=250-10000 mtu=512 nbio=2" \
7953 "$P_CLI dtls=1 debug_level=2 \
7954 crt_file=data_files/server8_int-ca2.crt \
7955 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007956 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007957 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007958 hs_timeout=250-10000 mtu=512 nbio=2" \
7959 0 \
7960 -s "found fragmented DTLS handshake message" \
7961 -c "found fragmented DTLS handshake message" \
7962 -C "error"
7963
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007964# interop tests for DTLS fragmentating with reliable connection
7965#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007966# here and below we just want to test that the we fragment in a way that
7967# pleases other implementations, so we don't need the peer to fragment
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007968requires_config_enabled MBEDTLS_RSA_C
7969requires_config_enabled MBEDTLS_ECDSA_C
7970requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007971requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007972run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7973 "$G_SRV -u" \
7974 "$P_CLI dtls=1 debug_level=2 \
7975 crt_file=data_files/server8_int-ca2.crt \
7976 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007977 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007978 mtu=512 force_version=dtls1_2" \
7979 0 \
7980 -c "fragmenting handshake message" \
7981 -C "error"
7982
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007983requires_config_enabled MBEDTLS_RSA_C
7984requires_config_enabled MBEDTLS_ECDSA_C
7985requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007986requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007987run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
7988 "$G_SRV -u" \
7989 "$P_CLI dtls=1 debug_level=2 \
7990 crt_file=data_files/server8_int-ca2.crt \
7991 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007992 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007993 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007994 0 \
7995 -c "fragmenting handshake message" \
7996 -C "error"
7997
Hanno Beckerb9a00862018-08-28 10:20:22 +01007998# We use --insecure for the GnuTLS client because it expects
7999# the hostname / IP it connects to to be the name used in the
8000# certificate obtained from the server. Here, however, it
8001# connects to 127.0.0.1 while our test certificates use 'localhost'
8002# as the server name in the certificate. This will make the
8003# certifiate validation fail, but passing --insecure makes
8004# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008005requires_config_enabled MBEDTLS_RSA_C
8006requires_config_enabled MBEDTLS_ECDSA_C
8007requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008008requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008009requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008010run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008011 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008012 crt_file=data_files/server7_int-ca.crt \
8013 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008014 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008015 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008016 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008017 0 \
8018 -s "fragmenting handshake message"
8019
Hanno Beckerb9a00862018-08-28 10:20:22 +01008020# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008021requires_config_enabled MBEDTLS_RSA_C
8022requires_config_enabled MBEDTLS_ECDSA_C
8023requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008024requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008025requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008026run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008027 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008028 crt_file=data_files/server7_int-ca.crt \
8029 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008030 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008031 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008032 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008033 0 \
8034 -s "fragmenting handshake message"
8035
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008036requires_config_enabled MBEDTLS_RSA_C
8037requires_config_enabled MBEDTLS_ECDSA_C
8038requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8039run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
8040 "$O_SRV -dtls1_2 -verify 10" \
8041 "$P_CLI dtls=1 debug_level=2 \
8042 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é-Gonnard1218bc02018-08-17 10:51:26 +02008045 mtu=512 force_version=dtls1_2" \
8046 0 \
8047 -c "fragmenting handshake message" \
8048 -C "error"
8049
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008050requires_config_enabled MBEDTLS_RSA_C
8051requires_config_enabled MBEDTLS_ECDSA_C
8052requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8053run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
8054 "$O_SRV -dtls1 -verify 10" \
8055 "$P_CLI dtls=1 debug_level=2 \
8056 crt_file=data_files/server8_int-ca2.crt \
8057 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008058 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008059 mtu=512 force_version=dtls1" \
8060 0 \
8061 -c "fragmenting handshake message" \
8062 -C "error"
8063
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008064requires_config_enabled MBEDTLS_RSA_C
8065requires_config_enabled MBEDTLS_ECDSA_C
8066requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8067run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
8068 "$P_SRV dtls=1 debug_level=2 \
8069 crt_file=data_files/server7_int-ca.crt \
8070 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008071 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008072 mtu=512 force_version=dtls1_2" \
8073 "$O_CLI -dtls1_2" \
8074 0 \
8075 -s "fragmenting handshake message"
8076
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008077requires_config_enabled MBEDTLS_RSA_C
8078requires_config_enabled MBEDTLS_ECDSA_C
8079requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8080run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8081 "$P_SRV dtls=1 debug_level=2 \
8082 crt_file=data_files/server7_int-ca.crt \
8083 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008084 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008085 mtu=512 force_version=dtls1" \
8086 "$O_CLI -dtls1" \
8087 0 \
8088 -s "fragmenting handshake message"
8089
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008090# interop tests for DTLS fragmentating with unreliable connection
8091#
8092# again we just want to test that the we fragment in a way that
8093# pleases other implementations, so we don't need the peer to fragment
8094requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008095requires_config_enabled MBEDTLS_RSA_C
8096requires_config_enabled MBEDTLS_ECDSA_C
8097requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008098client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008099run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8100 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8101 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008102 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008103 crt_file=data_files/server8_int-ca2.crt \
8104 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008105 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008106 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008107 0 \
8108 -c "fragmenting handshake message" \
8109 -C "error"
8110
8111requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008112requires_config_enabled MBEDTLS_RSA_C
8113requires_config_enabled MBEDTLS_ECDSA_C
8114requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008115client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008116run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8117 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8118 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008119 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008120 crt_file=data_files/server8_int-ca2.crt \
8121 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008122 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008123 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008124 0 \
8125 -c "fragmenting handshake message" \
8126 -C "error"
8127
k-stachowiakabb843e2019-02-18 16:14:03 +01008128requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008129requires_config_enabled MBEDTLS_RSA_C
8130requires_config_enabled MBEDTLS_ECDSA_C
8131requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8132client_needs_more_time 4
8133run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8134 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8135 "$P_SRV dtls=1 debug_level=2 \
8136 crt_file=data_files/server7_int-ca.crt \
8137 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008138 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008139 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008140 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008141 0 \
8142 -s "fragmenting handshake message"
8143
k-stachowiakabb843e2019-02-18 16:14:03 +01008144requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008145requires_config_enabled MBEDTLS_RSA_C
8146requires_config_enabled MBEDTLS_ECDSA_C
8147requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8148client_needs_more_time 4
8149run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8150 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8151 "$P_SRV dtls=1 debug_level=2 \
8152 crt_file=data_files/server7_int-ca.crt \
8153 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008154 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008155 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008156 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008157 0 \
8158 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008159
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008160## Interop test with OpenSSL might trigger a bug in recent versions (including
8161## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008162## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008163## They should be re-enabled once a fixed version of OpenSSL is available
8164## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008165skip_next_test
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008166requires_config_enabled MBEDTLS_RSA_C
8167requires_config_enabled MBEDTLS_ECDSA_C
8168requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8169client_needs_more_time 4
8170run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8171 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8172 "$O_SRV -dtls1_2 -verify 10" \
8173 "$P_CLI dtls=1 debug_level=2 \
8174 crt_file=data_files/server8_int-ca2.crt \
8175 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008176 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008177 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8178 0 \
8179 -c "fragmenting handshake message" \
8180 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008181
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008182skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008183requires_config_enabled MBEDTLS_RSA_C
8184requires_config_enabled MBEDTLS_ECDSA_C
8185requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008186client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008187run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8188 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008189 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008190 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008191 crt_file=data_files/server8_int-ca2.crt \
8192 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008193 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008194 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008195 0 \
8196 -c "fragmenting handshake message" \
8197 -C "error"
8198
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008199skip_next_test
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008200requires_config_enabled MBEDTLS_RSA_C
8201requires_config_enabled MBEDTLS_ECDSA_C
8202requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8203client_needs_more_time 4
8204run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8205 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8206 "$P_SRV dtls=1 debug_level=2 \
8207 crt_file=data_files/server7_int-ca.crt \
8208 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008209 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008210 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8211 "$O_CLI -dtls1_2" \
8212 0 \
8213 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008214
8215# -nbio is added to prevent s_client from blocking in case of duplicated
8216# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008217skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008218requires_config_enabled MBEDTLS_RSA_C
8219requires_config_enabled MBEDTLS_ECDSA_C
8220requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008221client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008222run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8223 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008224 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008225 crt_file=data_files/server7_int-ca.crt \
8226 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008227 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008228 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008229 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008230 0 \
8231 -s "fragmenting handshake message"
8232
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008233# Tests for specific things with "unreliable" UDP connection
8234
8235not_with_valgrind # spurious resend due to timeout
8236run_test "DTLS proxy: reference" \
8237 -p "$P_PXY" \
8238 "$P_SRV dtls=1 debug_level=2" \
8239 "$P_CLI dtls=1 debug_level=2" \
8240 0 \
8241 -C "replayed record" \
8242 -S "replayed record" \
Hanno Beckere03eb7b2019-07-19 15:43:09 +01008243 -C "Buffer record from epoch" \
8244 -S "Buffer record from epoch" \
8245 -C "ssl_buffer_message" \
8246 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008247 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008248 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008249 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008250 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008251 -c "HTTP/1.0 200 OK"
8252
8253not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008254run_test "DTLS proxy: duplicate every packet" \
8255 -p "$P_PXY duplicate=1" \
Hanno Becker7f376f42019-06-12 16:20:48 +01008256 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008257 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008258 0 \
8259 -c "replayed record" \
8260 -s "replayed record" \
8261 -c "record from another epoch" \
8262 -s "record from another epoch" \
8263 -S "resend" \
8264 -s "Extra-header:" \
8265 -c "HTTP/1.0 200 OK"
8266
8267run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8268 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008269 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8270 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008271 0 \
8272 -c "replayed record" \
8273 -S "replayed record" \
8274 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008275 -s "record from another epoch" \
8276 -c "resend" \
8277 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008278 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008279 -c "HTTP/1.0 200 OK"
8280
8281run_test "DTLS proxy: multiple records in same datagram" \
8282 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008283 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8284 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008285 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008286 -c "next record in same datagram" \
8287 -s "next record in same datagram"
8288
8289run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8290 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008291 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8292 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008293 0 \
8294 -c "next record in same datagram" \
8295 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008296
Jarno Lamsa33281d52019-10-18 10:54:35 +03008297requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008298run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8299 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008300 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8301 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008302 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008303 -c "discarding invalid record (mac)" \
8304 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008305 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008306 -c "HTTP/1.0 200 OK" \
8307 -S "too many records with bad MAC" \
8308 -S "Verification of the message MAC failed"
8309
Jarno Lamsa33281d52019-10-18 10:54:35 +03008310requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008311run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8312 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008313 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8314 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008315 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008316 -C "discarding invalid record (mac)" \
8317 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008318 -S "Extra-header:" \
8319 -C "HTTP/1.0 200 OK" \
8320 -s "too many records with bad MAC" \
8321 -s "Verification of the message MAC failed"
8322
Jarno Lamsa33281d52019-10-18 10:54:35 +03008323requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008324run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8325 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008326 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8327 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008328 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008329 -c "discarding invalid record (mac)" \
8330 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008331 -s "Extra-header:" \
8332 -c "HTTP/1.0 200 OK" \
8333 -S "too many records with bad MAC" \
8334 -S "Verification of the message MAC failed"
8335
Jarno Lamsa33281d52019-10-18 10:54:35 +03008336requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008337run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8338 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008339 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8340 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008341 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008342 -c "discarding invalid record (mac)" \
8343 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008344 -s "Extra-header:" \
8345 -c "HTTP/1.0 200 OK" \
8346 -s "too many records with bad MAC" \
8347 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008348
8349run_test "DTLS proxy: delay ChangeCipherSpec" \
8350 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008351 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8352 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008353 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008354 -c "record from another epoch" \
8355 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008356 -s "Extra-header:" \
8357 -c "HTTP/1.0 200 OK"
8358
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008359# Tests for reordering support with DTLS
8360
Hanno Becker56cdfd12018-08-17 13:42:15 +01008361run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8362 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008363 "$P_SRV 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 Beckere3842212018-08-16 15:28:59 +01008367 0 \
8368 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008369 -c "Next handshake message has been buffered - load"\
8370 -S "Buffering HS message" \
8371 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008372 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008373 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008374 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008375 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008376
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008377run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8378 -p "$P_PXY delay_srv=ServerHello" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03008379 "$P_SRV mtu=256 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008380 hs_timeout=2500-60000" \
8381 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8382 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008383 0 \
8384 -c "Buffering HS message" \
8385 -c "found fragmented DTLS handshake message"\
8386 -c "Next handshake message 1 not or only partially bufffered" \
8387 -c "Next handshake message has been buffered - load"\
8388 -S "Buffering HS message" \
8389 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008390 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008391 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008392 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008393 -S "Remember CCS message"
8394
Hanno Beckera1adcca2018-08-24 14:41:07 +01008395# The client buffers the ServerKeyExchange before receiving the fragmented
8396# Certificate message; at the time of writing, together these are aroudn 1200b
8397# in size, so that the bound below ensures that the certificate can be reassembled
8398# while keeping the ServerKeyExchange.
8399requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8400run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008401 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008402 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8403 hs_timeout=2500-60000" \
8404 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8405 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008406 0 \
8407 -c "Buffering HS message" \
8408 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008409 -C "attempt to make space by freeing buffered messages" \
8410 -S "Buffering HS message" \
8411 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008412 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008413 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008414 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008415 -S "Remember CCS message"
8416
8417# The size constraints ensure that the delayed certificate message can't
8418# be reassembled while keeping the ServerKeyExchange message, but it can
8419# when dropping it first.
8420requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8421requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8422run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8423 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008424 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8425 hs_timeout=2500-60000" \
8426 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8427 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008428 0 \
8429 -c "Buffering HS message" \
8430 -c "attempt to make space by freeing buffered future messages" \
8431 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008432 -S "Buffering HS message" \
8433 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008434 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008435 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008436 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008437 -S "Remember CCS message"
8438
Hanno Becker56cdfd12018-08-17 13:42:15 +01008439run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8440 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008441 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8442 hs_timeout=2500-60000" \
8443 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8444 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008445 0 \
8446 -C "Buffering HS message" \
8447 -C "Next handshake message has been buffered - load"\
8448 -s "Buffering HS message" \
8449 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008450 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008451 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008452 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008453 -S "Remember CCS message"
8454
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02008455# This needs session tickets; otherwise CCS is the first message in its flight
8456requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008457run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8458 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008459 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8460 hs_timeout=2500-60000" \
8461 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8462 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008463 0 \
8464 -C "Buffering HS message" \
8465 -C "Next handshake message has been buffered - load"\
8466 -S "Buffering HS message" \
8467 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008468 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008469 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008470 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008471 -S "Remember CCS message"
8472
Jarno Lamsa33281d52019-10-18 10:54:35 +03008473# This needs session tickets; otherwise CCS is the first message in its flight
8474requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008475run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8476 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008477 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8478 hs_timeout=2500-60000" \
8479 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8480 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008481 0 \
8482 -C "Buffering HS message" \
8483 -C "Next handshake message has been buffered - load"\
8484 -S "Buffering HS message" \
8485 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008486 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008487 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008488 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008489 -s "Remember CCS message"
8490
Hanno Beckera1adcca2018-08-24 14:41:07 +01008491run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008492 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008493 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8494 hs_timeout=2500-60000" \
8495 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8496 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008497 0 \
8498 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008499 -s "Found buffered record from current epoch - load" \
8500 -c "Buffer record from epoch 1" \
8501 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008502
Hanno Beckera1adcca2018-08-24 14:41:07 +01008503# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8504# from the server are delayed, so that the encrypted Finished message
8505# is received and buffered. When the fragmented NewSessionTicket comes
8506# in afterwards, the encrypted Finished message must be freed in order
8507# to make space for the NewSessionTicket to be reassembled.
8508# This works only in very particular circumstances:
8509# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8510# of the NewSessionTicket, but small enough to also allow buffering of
8511# the encrypted Finished message.
8512# - The MTU setting on the server must be so small that the NewSessionTicket
8513# needs to be fragmented.
8514# - All messages sent by the server must be small enough to be either sent
8515# without fragmentation or be reassembled within the bounds of
8516# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8517# handshake, omitting CRTs.
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008518requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8519requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008520run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8521 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008522 "$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 +01008523 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8524 0 \
8525 -s "Buffer record from epoch 1" \
8526 -s "Found buffered record from current epoch - load" \
8527 -c "Buffer record from epoch 1" \
8528 -C "Found buffered record from current epoch - load" \
8529 -c "Enough space available after freeing future epoch record"
8530
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008531# Tests for "randomly unreliable connection": try a variety of flows and peers
8532
8533client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008534run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8535 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008536 "$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 +02008537 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008538 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008539 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8540 0 \
8541 -s "Extra-header:" \
8542 -c "HTTP/1.0 200 OK"
8543
Janos Follath74537a62016-09-02 13:45:28 +01008544client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008545run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8546 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008547 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8548 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008549 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8550 0 \
8551 -s "Extra-header:" \
8552 -c "HTTP/1.0 200 OK"
8553
Janos Follath74537a62016-09-02 13:45:28 +01008554client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008555run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8556 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008557 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8558 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008559 0 \
8560 -s "Extra-header:" \
8561 -c "HTTP/1.0 200 OK"
8562
Janos Follath74537a62016-09-02 13:45:28 +01008563client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008564run_test "DTLS proxy: 3d, FS, client auth" \
8565 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008566 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8567 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008568 0 \
8569 -s "Extra-header:" \
8570 -c "HTTP/1.0 200 OK"
8571
Janos Follath74537a62016-09-02 13:45:28 +01008572client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008573run_test "DTLS proxy: 3d, FS, ticket" \
8574 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008575 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8576 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008577 0 \
8578 -s "Extra-header:" \
8579 -c "HTTP/1.0 200 OK"
8580
Janos Follath74537a62016-09-02 13:45:28 +01008581client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008582run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8583 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008584 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8585 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008586 0 \
8587 -s "Extra-header:" \
8588 -c "HTTP/1.0 200 OK"
8589
Janos Follath74537a62016-09-02 13:45:28 +01008590client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008591run_test "DTLS proxy: 3d, max handshake, nbio" \
8592 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008593 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008594 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008595 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008596 0 \
8597 -s "Extra-header:" \
8598 -c "HTTP/1.0 200 OK"
8599
Janos Follath74537a62016-09-02 13:45:28 +01008600client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008601requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008602requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008603requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008604run_test "DTLS proxy: 3d, min handshake, resumption" \
8605 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008606 "$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 +02008607 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008608 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008609 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8610 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8611 0 \
8612 -s "a session has been resumed" \
8613 -c "a session has been resumed" \
8614 -s "Extra-header:" \
8615 -c "HTTP/1.0 200 OK"
8616
Janos Follath74537a62016-09-02 13:45:28 +01008617client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008618requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008619requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008620requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008621run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8622 -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é-Gonnard85beb302014-10-02 17:59:19 +02008624 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008625 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008626 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8627 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8628 0 \
8629 -s "a session has been resumed" \
8630 -c "a session has been resumed" \
8631 -s "Extra-header:" \
8632 -c "HTTP/1.0 200 OK"
8633
Janos Follath74537a62016-09-02 13:45:28 +01008634client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008635requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008636run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008637 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008638 "$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 +02008639 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008640 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008641 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008642 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8643 0 \
8644 -c "=> renegotiate" \
8645 -s "=> renegotiate" \
8646 -s "Extra-header:" \
8647 -c "HTTP/1.0 200 OK"
8648
Janos Follath74537a62016-09-02 13:45:28 +01008649client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008650requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008651run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8652 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008653 "$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 +02008654 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008655 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008656 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008657 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8658 0 \
8659 -c "=> renegotiate" \
8660 -s "=> renegotiate" \
8661 -s "Extra-header:" \
8662 -c "HTTP/1.0 200 OK"
8663
Janos Follath74537a62016-09-02 13:45:28 +01008664client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008665requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008666run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008667 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008668 "$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 +02008669 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008670 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008671 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008672 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008673 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8674 0 \
8675 -c "=> renegotiate" \
8676 -s "=> renegotiate" \
8677 -s "Extra-header:" \
8678 -c "HTTP/1.0 200 OK"
8679
Janos Follath74537a62016-09-02 13:45:28 +01008680client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008681requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008682run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008683 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008684 "$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 +02008685 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008686 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008687 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008688 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008689 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8690 0 \
8691 -c "=> renegotiate" \
8692 -s "=> renegotiate" \
8693 -s "Extra-header:" \
8694 -c "HTTP/1.0 200 OK"
8695
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008696## Interop tests with OpenSSL might trigger a bug in recent versions (including
8697## all versions installed on the CI machines), reported here:
8698## Bug report: https://github.com/openssl/openssl/issues/6902
8699## They should be re-enabled once a fixed version of OpenSSL is available
8700## (this should happen in some 1.1.1_ release according to the ticket).
8701skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008702client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008703not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008704run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008705 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8706 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008707 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008708 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008709 -c "HTTP/1.0 200 OK"
8710
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008711skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008712client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008713not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008714run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8715 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8716 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008717 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008718 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008719 -c "HTTP/1.0 200 OK"
8720
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008721skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008722client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008723not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008724run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8725 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8726 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008727 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008728 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008729 -c "HTTP/1.0 200 OK"
8730
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008731requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008732client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008733not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008734run_test "DTLS proxy: 3d, gnutls server" \
8735 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8736 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008737 "$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 +02008738 0 \
8739 -s "Extra-header:" \
8740 -c "Extra-header:"
8741
k-stachowiakabb843e2019-02-18 16:14:03 +01008742requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008743client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008744not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008745run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8746 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008747 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008748 "$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 +02008749 0 \
8750 -s "Extra-header:" \
8751 -c "Extra-header:"
8752
k-stachowiakabb843e2019-02-18 16:14:03 +01008753requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008754client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008755not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008756run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8757 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008758 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008759 "$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 +02008760 0 \
8761 -s "Extra-header:" \
8762 -c "Extra-header:"
8763
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008764# Final report
8765
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008766echo "------------------------------------------------------------------------"
8767
8768if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008769 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008770else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008771 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008772fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008773PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008774echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008775
8776exit $FAILS