blob: 67cf50233890950a428ea6e16e75f14583d6ca12 [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
Manuel Pégourié-Gonnard079864e2020-01-02 11:58:00 +01001153requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1154run_test "Default (compression enabled)" \
1155 "$P_SRV debug_level=3" \
1156 "$P_CLI debug_level=3" \
1157 0 \
1158 -s "Allocating compression buffer" \
1159 -c "Allocating compression buffer" \
1160 -s "Record expansion is unknown (compression)" \
1161 -c "Record expansion is unknown (compression)" \
1162 -S "error" \
1163 -C "error"
1164
Manuel Pégourié-Gonnard10a7f622020-01-02 11:58:00 +01001165requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1166run_test "Default (compression enabled)" \
1167 "$P_SRV debug_level=3" \
1168 "$P_CLI debug_level=3" \
1169 0 \
1170 -s "Allocating compression buffer" \
1171 -c "Allocating compression buffer" \
1172 -s "Record expansion is unknown (compression)" \
1173 -c "Record expansion is unknown (compression)" \
1174 -S "error" \
1175 -C "error"
1176
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001177# Test current time in ServerHello
1178requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001179run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001180 "$P_SRV debug_level=3" \
1181 "$P_CLI debug_level=3" \
1182 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001183 -f "check_server_hello_time" \
1184 -F "check_server_hello_time"
1185
Simon Butcher8e004102016-10-14 00:48:33 +01001186# Test for uniqueness of IVs in AEAD ciphersuites
1187run_test "Unique IV in GCM" \
1188 "$P_SRV exchanges=20 debug_level=4" \
1189 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1190 0 \
1191 -u "IV used" \
1192 -U "IV used"
1193
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001194# Tests for rc4 option
1195
Simon Butchera410af52016-05-19 22:12:18 +01001196requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001197run_test "RC4: server disabled, client enabled" \
1198 "$P_SRV" \
1199 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1200 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001201 -s "SSL - The server has no ciphersuites in common"
1202
Simon Butchera410af52016-05-19 22:12:18 +01001203requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001204run_test "RC4: server half, client enabled" \
1205 "$P_SRV arc4=1" \
1206 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1207 1 \
1208 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001209
1210run_test "RC4: server enabled, client disabled" \
1211 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1212 "$P_CLI" \
1213 1 \
1214 -s "SSL - The server has no ciphersuites in common"
1215
1216run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001217 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001218 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1219 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001220 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001221 -S "SSL - The server has no ciphersuites in common"
1222
Hanno Beckerd26bb202018-08-17 09:54:10 +01001223# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1224
1225requires_gnutls
1226requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1227run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1228 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001229 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001230 0
1231
1232requires_gnutls
1233requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1234run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1235 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001236 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001237 0
1238
Gilles Peskinebc70a182017-05-09 15:59:24 +02001239# Tests for SHA-1 support
1240
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001241requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001242requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001243requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001244run_test "SHA-1 forbidden by default in server certificate" \
1245 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1246 "$P_CLI debug_level=2 allow_sha1=0" \
1247 1 \
1248 -c "The certificate is signed with an unacceptable hash"
1249
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001250requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1251run_test "SHA-1 forbidden by default in server certificate" \
1252 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1253 "$P_CLI debug_level=2 allow_sha1=0" \
1254 0
1255
Gilles Peskinebc70a182017-05-09 15:59:24 +02001256run_test "SHA-1 explicitly allowed in server certificate" \
1257 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1258 "$P_CLI allow_sha1=1" \
1259 0
1260
1261run_test "SHA-256 allowed by default in server certificate" \
1262 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1263 "$P_CLI allow_sha1=0" \
1264 0
1265
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001266requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001267requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001268requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001269run_test "SHA-1 forbidden by default in client certificate" \
1270 "$P_SRV auth_mode=required allow_sha1=0" \
1271 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1272 1 \
1273 -s "The certificate is signed with an unacceptable hash"
1274
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001275requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1276run_test "SHA-1 forbidden by default in client certificate" \
1277 "$P_SRV auth_mode=required allow_sha1=0" \
1278 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1279 0
1280
Gilles Peskinebc70a182017-05-09 15:59:24 +02001281run_test "SHA-1 explicitly allowed in client certificate" \
1282 "$P_SRV auth_mode=required allow_sha1=1" \
1283 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1284 0
1285
1286run_test "SHA-256 allowed by default in client certificate" \
1287 "$P_SRV auth_mode=required allow_sha1=0" \
1288 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1289 0
1290
Hanno Becker7ae8a762018-08-14 15:43:35 +01001291# Tests for datagram packing
1292run_test "DTLS: multiple records in same datagram, client and server" \
1293 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1294 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1295 0 \
1296 -c "next record in same datagram" \
1297 -s "next record in same datagram"
1298
1299run_test "DTLS: multiple records in same datagram, client only" \
1300 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1301 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1302 0 \
1303 -s "next record in same datagram" \
1304 -C "next record in same datagram"
1305
1306run_test "DTLS: multiple records in same datagram, server only" \
1307 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1308 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1309 0 \
1310 -S "next record in same datagram" \
1311 -c "next record in same datagram"
1312
1313run_test "DTLS: multiple records in same datagram, neither client nor server" \
1314 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1315 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1316 0 \
1317 -S "next record in same datagram" \
1318 -C "next record in same datagram"
1319
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001320# Tests for Truncated HMAC extension
1321
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001322run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001323 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001324 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +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é-Gonnard780d6712014-02-20 17:19:59 +01001328
Hanno Becker32c55012017-11-10 08:42:54 +00001329requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001330run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001331 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001332 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001333 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001334 -s "dumping 'expected mac' (20 bytes)" \
1335 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001336
Hanno Becker32c55012017-11-10 08:42:54 +00001337requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001338run_test "Truncated HMAC: client enabled, server default" \
1339 "$P_SRV debug_level=4" \
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é-Gonnarde117a8f2015-01-09 12:39:35 +01001344
Hanno Becker32c55012017-11-10 08:42:54 +00001345requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001346run_test "Truncated HMAC: client enabled, server disabled" \
1347 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001348 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001349 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001350 -s "dumping 'expected mac' (20 bytes)" \
1351 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001352
Hanno Becker32c55012017-11-10 08:42:54 +00001353requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001354run_test "Truncated HMAC: client disabled, server enabled" \
1355 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001356 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001357 0 \
1358 -s "dumping 'expected mac' (20 bytes)" \
1359 -S "dumping 'expected mac' (10 bytes)"
1360
1361requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001362run_test "Truncated HMAC: client enabled, server enabled" \
1363 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001364 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001365 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001366 -S "dumping 'expected mac' (20 bytes)" \
1367 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001368
Jarno Lamsa33281d52019-10-18 10:54:35 +03001369requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker4c4f4102017-11-10 09:16:05 +00001370run_test "Truncated HMAC, DTLS: client default, server default" \
1371 "$P_SRV dtls=1 debug_level=4" \
1372 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1373 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 default" \
1379 "$P_SRV dtls=1 debug_level=4" \
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 default" \
1387 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001388 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001389 0 \
1390 -s "dumping 'expected mac' (20 bytes)" \
1391 -S "dumping 'expected mac' (10 bytes)"
1392
1393requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1394run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1395 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001396 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001397 0 \
1398 -s "dumping 'expected mac' (20 bytes)" \
1399 -S "dumping 'expected mac' (10 bytes)"
1400
1401requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1402run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1403 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001404 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001405 0 \
1406 -s "dumping 'expected mac' (20 bytes)" \
1407 -S "dumping 'expected mac' (10 bytes)"
1408
1409requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1410run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1411 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001412 "$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 +01001413 0 \
1414 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001415 -s "dumping 'expected mac' (10 bytes)"
1416
Jarno Lamsafa45e602019-06-04 11:33:23 +03001417# Tests for Context serialization
1418
1419requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001420run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001421 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001422 "$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 +03001423 0 \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001424 -c "Deserializing connection..." \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001425 -S "Deserializing connection..."
1426
1427requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001428run_test "Context serialization, client serializes, ChaChaPoly" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001429 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001430 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001431 0 \
1432 -c "Deserializing connection..." \
1433 -S "Deserializing connection..."
1434
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001435requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001436run_test "Context serialization, client serializes, GCM" \
1437 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1438 "$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 +03001439 0 \
1440 -c "Deserializing connection..." \
1441 -S "Deserializing connection..."
Jarno Lamsacc281b82019-06-04 15:21:13 +03001442
Jarno Lamsafa45e602019-06-04 11:33:23 +03001443requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001444requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1445run_test "Context serialization, client serializes, with CID" \
1446 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1447 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1448 0 \
1449 -c "Deserializing connection..." \
1450 -S "Deserializing connection..."
1451
1452requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001453run_test "Context serialization, server serializes, CCM" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001454 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001455 "$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 +03001456 0 \
1457 -C "Deserializing connection..." \
1458 -s "Deserializing connection..."
1459
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001460requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001461run_test "Context serialization, server serializes, ChaChaPoly" \
1462 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1463 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1464 0 \
1465 -C "Deserializing connection..." \
1466 -s "Deserializing connection..."
1467
1468requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1469run_test "Context serialization, server serializes, GCM" \
1470 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1471 "$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 +03001472 0 \
1473 -C "Deserializing connection..." \
Jarno Lamsacc281b82019-06-04 15:21:13 +03001474 -s "Deserializing connection..."
Jarno Lamsafa45e602019-06-04 11:33:23 +03001475
1476requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001477requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1478run_test "Context serialization, server serializes, with CID" \
1479 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1480 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1481 0 \
1482 -C "Deserializing connection..." \
1483 -s "Deserializing connection..."
1484
1485requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001486run_test "Context serialization, both serialize, CCM" \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001487 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001488 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1489 0 \
1490 -c "Deserializing connection..." \
1491 -s "Deserializing connection..."
1492
1493requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1494run_test "Context serialization, both serialize, ChaChaPoly" \
1495 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1496 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1497 0 \
1498 -c "Deserializing connection..." \
1499 -s "Deserializing connection..."
1500
1501requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1502run_test "Context serialization, both serialize, GCM" \
1503 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1504 "$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 +03001505 0 \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001506 -c "Deserializing connection..." \
1507 -s "Deserializing connection..."
1508
1509requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001510requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1511run_test "Context serialization, both serialize, with CID" \
1512 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1513 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1514 0 \
1515 -c "Deserializing connection..." \
1516 -s "Deserializing connection..."
1517
1518requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001519run_test "Context serialization, re-init, client serializes, CCM" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001520 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001521 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1522 0 \
1523 -c "Deserializing connection..." \
1524 -S "Deserializing connection..."
1525
1526requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1527run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1528 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1529 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1530 0 \
1531 -c "Deserializing connection..." \
1532 -S "Deserializing connection..."
1533
1534requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1535run_test "Context serialization, re-init, client serializes, GCM" \
1536 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1537 "$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 +03001538 0 \
1539 -c "Deserializing connection..." \
1540 -S "Deserializing connection..."
1541
1542requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001543requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1544run_test "Context serialization, re-init, client serializes, with CID" \
1545 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1546 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1547 0 \
1548 -c "Deserializing connection..." \
1549 -S "Deserializing connection..."
1550
1551requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001552run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001553 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001554 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1555 0 \
1556 -C "Deserializing connection..." \
1557 -s "Deserializing connection..."
1558
1559requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1560run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1561 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1562 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1563 0 \
1564 -C "Deserializing connection..." \
1565 -s "Deserializing connection..."
1566
1567requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1568run_test "Context serialization, re-init, server serializes, GCM" \
1569 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1570 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001571 0 \
1572 -C "Deserializing connection..." \
1573 -s "Deserializing connection..."
1574
1575requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001576requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1577run_test "Context serialization, re-init, server serializes, with CID" \
1578 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1579 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1580 0 \
1581 -C "Deserializing connection..." \
1582 -s "Deserializing connection..."
1583
1584requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001585run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001586 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001587 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1588 0 \
1589 -c "Deserializing connection..." \
1590 -s "Deserializing connection..."
1591
1592requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1593run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1594 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1595 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1596 0 \
1597 -c "Deserializing connection..." \
1598 -s "Deserializing connection..."
1599
1600requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1601run_test "Context serialization, re-init, both serialize, GCM" \
1602 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1603 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001604 0 \
1605 -c "Deserializing connection..." \
1606 -s "Deserializing connection..."
1607
Hanno Beckere80c1b02019-08-30 11:18:59 +01001608requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1609requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1610run_test "Context serialization, re-init, both serialize, with CID" \
1611 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1612 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001613 0 \
1614 -c "Deserializing connection..." \
Hanno Becker73455992019-04-25 17:01:43 +01001615 -s "Deserializing connection..."
Hanno Beckerc008cb52019-04-26 14:17:56 +01001616
Hanno Becker4eb05872019-04-26 16:00:29 +01001617# Tests for DTLS Connection ID extension
Hanno Beckercf2a5652019-04-26 16:13:31 +01001618
Hanno Becker5e2cd142019-04-26 16:23:52 +01001619# So far, the CID API isn't implemented, so we can't
1620# grep for output witnessing its use. This needs to be
Hanno Becker6a3ff282019-04-26 17:19:46 +01001621# changed once the CID extension is implemented.
Hanno Beckerad8e2c92019-05-08 13:19:53 +01001622
Hanno Becker2dcdc922019-04-09 18:08:47 +01001623requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckera5a2b082019-05-15 14:03:01 +01001624run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001625 "$P_SRV debug_level=3 dtls=1 cid=0" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03001626 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=dead" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001627 0 \
1628 -s "Disable use of CID extension." \
1629 -s "found CID extension" \
1630 -s "Client sent CID extension, but CID disabled" \
1631 -c "Enable use of CID extension." \
1632 -c "client hello, adding CID extension" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001633 -S "server hello, adding CID extension" \
1634 -C "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001635 -S "Copy CIDs into SSL transform" \
1636 -C "Copy CIDs into SSL transform" \
1637 -c "Use of Connection ID was rejected by the server"
1638
1639requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1640run_test "Connection ID: Cli disabled, Srv enabled" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03001641 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001642 "$P_CLI debug_level=3 dtls=1 cid=0" \
1643 0 \
1644 -c "Disable use of CID extension." \
1645 -C "client hello, adding CID extension" \
1646 -S "found CID extension" \
1647 -s "Enable use of CID extension." \
1648 -S "server hello, adding CID extension" \
1649 -C "found CID extension" \
1650 -S "Copy CIDs into SSL transform" \
1651 -C "Copy CIDs into SSL transform" \
1652 -s "Use of Connection ID was not offered by client"
1653
1654requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb60c85c2019-04-23 12:02:34 +01001655run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001656 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1657 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1658 0 \
1659 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001660 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001661 -c "client hello, adding CID extension" \
1662 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001663 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001664 -s "server hello, adding CID extension" \
1665 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001666 -c "Use of CID extension negotiated" \
1667 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001668 -c "Copy CIDs into SSL transform" \
1669 -c "Peer CID (length 2 Bytes): de ad" \
1670 -s "Peer CID (length 2 Bytes): be ef" \
1671 -s "Use of Connection ID has been negotiated" \
1672 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001673
Hanno Beckera5a2b082019-05-15 14:03:01 +01001674requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001675run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001676 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001677 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1678 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1679 0 \
1680 -c "Enable use of CID extension." \
1681 -s "Enable use of CID extension." \
1682 -c "client hello, adding CID extension" \
1683 -s "found CID extension" \
1684 -s "Use of CID extension negotiated" \
1685 -s "server hello, adding CID extension" \
1686 -c "found CID extension" \
1687 -c "Use of CID extension negotiated" \
1688 -s "Copy CIDs into SSL transform" \
1689 -c "Copy CIDs into SSL transform" \
1690 -c "Peer CID (length 2 Bytes): de ad" \
1691 -s "Peer CID (length 2 Bytes): be ef" \
1692 -s "Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001693 -c "Use of Connection ID has been negotiated" \
1694 -c "ignoring unexpected CID" \
1695 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01001696
Hanno Beckera5a2b082019-05-15 14:03:01 +01001697requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001698run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1699 -p "$P_PXY mtu=800" \
1700 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1701 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1702 0 \
1703 -c "Enable use of CID extension." \
1704 -s "Enable use of CID extension." \
1705 -c "client hello, adding CID extension" \
1706 -s "found CID extension" \
1707 -s "Use of CID extension negotiated" \
1708 -s "server hello, adding CID extension" \
1709 -c "found CID extension" \
1710 -c "Use of CID extension negotiated" \
1711 -s "Copy CIDs into SSL transform" \
1712 -c "Copy CIDs into SSL transform" \
1713 -c "Peer CID (length 2 Bytes): de ad" \
1714 -s "Peer CID (length 2 Bytes): be ef" \
1715 -s "Use of Connection ID has been negotiated" \
1716 -c "Use of Connection ID has been negotiated"
1717
Hanno Beckera5a2b082019-05-15 14:03:01 +01001718requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001719run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001720 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001721 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1722 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1723 0 \
1724 -c "Enable use of CID extension." \
1725 -s "Enable use of CID extension." \
1726 -c "client hello, adding CID extension" \
1727 -s "found CID extension" \
1728 -s "Use of CID extension negotiated" \
1729 -s "server hello, adding CID extension" \
1730 -c "found CID extension" \
1731 -c "Use of CID extension negotiated" \
1732 -s "Copy CIDs into SSL transform" \
1733 -c "Copy CIDs into SSL transform" \
1734 -c "Peer CID (length 2 Bytes): de ad" \
1735 -s "Peer CID (length 2 Bytes): be ef" \
1736 -s "Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001737 -c "Use of Connection ID has been negotiated" \
1738 -c "ignoring unexpected CID" \
1739 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01001740
Hanno Beckera5a2b082019-05-15 14:03:01 +01001741requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001742requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001743run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001744 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1745 "$P_CLI debug_level=3 dtls=1 cid=1" \
1746 0 \
1747 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001748 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001749 -c "client hello, adding CID extension" \
1750 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001751 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001752 -s "server hello, adding CID extension" \
1753 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001754 -c "Use of CID extension negotiated" \
1755 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001756 -c "Copy CIDs into SSL transform" \
1757 -c "Peer CID (length 4 Bytes): de ad be ef" \
1758 -s "Peer CID (length 0 Bytes):" \
1759 -s "Use of Connection ID has been negotiated" \
1760 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001761
Hanno Beckera5a2b082019-05-15 14:03:01 +01001762requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001763requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001764run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001765 "$P_SRV debug_level=3 dtls=1 cid=1" \
1766 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1767 0 \
1768 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001769 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001770 -c "client hello, adding CID extension" \
1771 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001772 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001773 -s "server hello, adding CID extension" \
1774 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001775 -c "Use of CID extension negotiated" \
1776 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001777 -c "Copy CIDs into SSL transform" \
1778 -s "Peer CID (length 4 Bytes): de ad be ef" \
1779 -c "Peer CID (length 0 Bytes):" \
1780 -s "Use of Connection ID has been negotiated" \
1781 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001782
Hanno Beckera5a2b082019-05-15 14:03:01 +01001783requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001784requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001785run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001786 "$P_SRV debug_level=3 dtls=1 cid=1" \
1787 "$P_CLI debug_level=3 dtls=1 cid=1" \
1788 0 \
1789 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001790 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001791 -c "client hello, adding CID extension" \
1792 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001793 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001794 -s "server hello, adding CID extension" \
1795 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001796 -c "Use of CID extension negotiated" \
1797 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001798 -c "Copy CIDs into SSL transform" \
1799 -S "Use of Connection ID has been negotiated" \
1800 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001801
Hanno Beckera5a2b082019-05-15 14:03:01 +01001802requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001803run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001804 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1805 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1806 0 \
1807 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001808 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001809 -c "client hello, adding CID extension" \
1810 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001811 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001812 -s "server hello, adding CID extension" \
1813 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001814 -c "Use of CID extension negotiated" \
1815 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001816 -c "Copy CIDs into SSL transform" \
1817 -c "Peer CID (length 2 Bytes): de ad" \
1818 -s "Peer CID (length 2 Bytes): be ef" \
1819 -s "Use of Connection ID has been negotiated" \
1820 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001821
Hanno Beckera5a2b082019-05-15 14:03:01 +01001822requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001823requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001824run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001825 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1826 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1827 0 \
1828 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001829 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001830 -c "client hello, adding CID extension" \
1831 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001832 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001833 -s "server hello, adding CID extension" \
1834 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001835 -c "Use of CID extension negotiated" \
1836 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001837 -c "Copy CIDs into SSL transform" \
1838 -c "Peer CID (length 4 Bytes): de ad be ef" \
1839 -s "Peer CID (length 0 Bytes):" \
1840 -s "Use of Connection ID has been negotiated" \
1841 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001842
Hanno Beckera5a2b082019-05-15 14:03:01 +01001843requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001844requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001845run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001846 "$P_SRV debug_level=3 dtls=1 cid=1" \
1847 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1848 0 \
1849 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001850 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001851 -c "client hello, adding CID extension" \
1852 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001853 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001854 -s "server hello, adding CID extension" \
1855 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001856 -c "Use of CID extension negotiated" \
1857 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001858 -c "Copy CIDs into SSL transform" \
1859 -s "Peer CID (length 4 Bytes): de ad be ef" \
1860 -c "Peer CID (length 0 Bytes):" \
1861 -s "Use of Connection ID has been negotiated" \
1862 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001863
Hanno Beckera5a2b082019-05-15 14:03:01 +01001864requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001865requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001866run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001867 "$P_SRV debug_level=3 dtls=1 cid=1" \
1868 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1869 0 \
1870 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001871 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001872 -c "client hello, adding CID extension" \
1873 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001874 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001875 -s "server hello, adding CID extension" \
1876 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001877 -c "Use of CID extension negotiated" \
1878 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001879 -c "Copy CIDs into SSL transform" \
1880 -S "Use of Connection ID has been negotiated" \
1881 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001882
Hanno Beckera5a2b082019-05-15 14:03:01 +01001883requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001884requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001885run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001886 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1887 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1888 0 \
1889 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001890 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001891 -c "client hello, adding CID extension" \
1892 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001893 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001894 -s "server hello, adding CID extension" \
1895 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001896 -c "Use of CID extension negotiated" \
1897 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001898 -c "Copy CIDs into SSL transform" \
1899 -c "Peer CID (length 2 Bytes): de ad" \
1900 -s "Peer CID (length 2 Bytes): be ef" \
1901 -s "Use of Connection ID has been negotiated" \
1902 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001903
Hanno Beckera5a2b082019-05-15 14:03:01 +01001904requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001905requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1906requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001907run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001908 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1909 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1910 0 \
1911 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001912 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001913 -c "client hello, adding CID extension" \
1914 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001915 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001916 -s "server hello, adding CID extension" \
1917 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001918 -c "Use of CID extension negotiated" \
1919 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001920 -c "Copy CIDs into SSL transform" \
1921 -c "Peer CID (length 4 Bytes): de ad be ef" \
1922 -s "Peer CID (length 0 Bytes):" \
1923 -s "Use of Connection ID has been negotiated" \
1924 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001925
Hanno Beckera5a2b082019-05-15 14:03:01 +01001926requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001927requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1928requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001929run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001930 "$P_SRV debug_level=3 dtls=1 cid=1" \
1931 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1932 0 \
1933 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001934 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001935 -c "client hello, adding CID extension" \
1936 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001937 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001938 -s "server hello, adding CID extension" \
1939 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001940 -c "Use of CID extension negotiated" \
1941 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001942 -c "Copy CIDs into SSL transform" \
1943 -s "Peer CID (length 4 Bytes): de ad be ef" \
1944 -c "Peer CID (length 0 Bytes):" \
1945 -s "Use of Connection ID has been negotiated" \
1946 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001947
Hanno Beckera5a2b082019-05-15 14:03:01 +01001948requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001949requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1950requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001951run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001952 "$P_SRV debug_level=3 dtls=1 cid=1" \
1953 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1954 0 \
1955 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001956 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001957 -c "client hello, adding CID extension" \
1958 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001959 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001960 -s "server hello, adding CID extension" \
1961 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001962 -c "Use of CID extension negotiated" \
1963 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001964 -c "Copy CIDs into SSL transform" \
1965 -S "Use of Connection ID has been negotiated" \
1966 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001967
Hanno Beckera5a2b082019-05-15 14:03:01 +01001968requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker963cb352019-04-23 11:52:44 +01001969requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001970run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001971 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1972 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1973 0 \
Hanno Becker96870292019-05-03 17:30:59 +01001974 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1975 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1976 -s "(initial handshake) Use of Connection ID has been negotiated" \
1977 -c "(initial handshake) Use of Connection ID has been negotiated" \
1978 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1979 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1980 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1981 -c "(after renegotiation) Use of Connection ID has been negotiated"
1982
Hanno Beckera5a2b082019-05-15 14:03:01 +01001983requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001984requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001985run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Becker96870292019-05-03 17:30:59 +01001986 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
1987 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1988 0 \
1989 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1990 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1991 -s "(initial handshake) Use of Connection ID has been negotiated" \
1992 -c "(initial handshake) Use of Connection ID has been negotiated" \
1993 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1994 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1995 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1996 -c "(after renegotiation) Use of Connection ID has been negotiated"
1997
Hanno Beckera5a2b082019-05-15 14:03:01 +01001998requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001999requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01002000run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
2001 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
2002 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2003 0 \
2004 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2005 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2006 -s "(initial handshake) Use of Connection ID has been negotiated" \
2007 -c "(initial handshake) Use of Connection ID has been negotiated" \
2008 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2009 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2010 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2011 -c "(after renegotiation) Use of Connection ID has been negotiated"
2012
Hanno Beckera5a2b082019-05-15 14:03:01 +01002013requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01002014requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002015run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002016 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002017 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2018 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2019 0 \
2020 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2021 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2022 -s "(initial handshake) Use of Connection ID has been negotiated" \
2023 -c "(initial handshake) Use of Connection ID has been negotiated" \
2024 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2025 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2026 -s "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002027 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2028 -c "ignoring unexpected CID" \
2029 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002030
Hanno Beckera5a2b082019-05-15 14:03:01 +01002031requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002032requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2033run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Becker96870292019-05-03 17:30:59 +01002034 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2035 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2036 0 \
2037 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2038 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2039 -s "(initial handshake) Use of Connection ID has been negotiated" \
2040 -c "(initial handshake) Use of Connection ID has been negotiated" \
2041 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2042 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2043 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2044 -S "(after renegotiation) Use of Connection ID has been negotiated"
2045
Hanno Beckera5a2b082019-05-15 14:03:01 +01002046requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002047requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01002048run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
2049 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2050 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2051 0 \
2052 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2053 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2054 -s "(initial handshake) Use of Connection ID has been negotiated" \
2055 -c "(initial handshake) Use of Connection ID has been negotiated" \
2056 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2057 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2058 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2059 -S "(after renegotiation) Use of Connection ID has been negotiated"
2060
Hanno Beckera5a2b082019-05-15 14:03:01 +01002061requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01002062requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002063run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002064 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002065 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2066 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2067 0 \
2068 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2069 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2070 -s "(initial handshake) Use of Connection ID has been negotiated" \
2071 -c "(initial handshake) Use of Connection ID has been negotiated" \
2072 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2073 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2074 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002075 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2076 -c "ignoring unexpected CID" \
2077 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002078
Hanno Beckera5a2b082019-05-15 14:03:01 +01002079requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002080requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2081run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002082 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2083 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2084 0 \
2085 -S "(initial handshake) Use of Connection ID has been negotiated" \
2086 -C "(initial handshake) Use of Connection ID has been negotiated" \
2087 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2088 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2089 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2090 -s "(after renegotiation) Use of Connection ID has been negotiated"
2091
Hanno Beckera5a2b082019-05-15 14:03:01 +01002092requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002093requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01002094run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2095 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2096 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2097 0 \
2098 -S "(initial handshake) Use of Connection ID has been negotiated" \
2099 -C "(initial handshake) Use of Connection ID has been negotiated" \
2100 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2101 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2102 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2103 -s "(after renegotiation) Use of Connection ID has been negotiated"
2104
Hanno Beckera5a2b082019-05-15 14:03:01 +01002105requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01002106requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002107run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002108 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002109 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2110 "$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" \
2111 0 \
2112 -S "(initial handshake) Use of Connection ID has been negotiated" \
2113 -C "(initial handshake) Use of Connection ID has been negotiated" \
2114 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2115 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2116 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002117 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2118 -c "ignoring unexpected CID" \
2119 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002120
Hanno Beckera5a2b082019-05-15 14:03:01 +01002121requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002122requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2123run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002124 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2125 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2126 0 \
2127 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2128 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2129 -s "(initial handshake) Use of Connection ID has been negotiated" \
2130 -c "(initial handshake) Use of Connection ID has been negotiated" \
2131 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2132 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2133 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2134 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2135 -s "(after renegotiation) Use of Connection ID was not offered by client"
2136
Hanno Beckera5a2b082019-05-15 14:03:01 +01002137requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002138requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002139run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002140 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002141 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2142 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2143 0 \
2144 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2145 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2146 -s "(initial handshake) Use of Connection ID has been negotiated" \
2147 -c "(initial handshake) Use of Connection ID has been negotiated" \
2148 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2149 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2150 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2151 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002152 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2153 -c "ignoring unexpected CID" \
2154 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002155
Hanno Beckera5a2b082019-05-15 14:03:01 +01002156requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002157requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2158run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2159 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2160 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2161 0 \
2162 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2163 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2164 -s "(initial handshake) Use of Connection ID has been negotiated" \
2165 -c "(initial handshake) Use of Connection ID has been negotiated" \
2166 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2167 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2168 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2169 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2170 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2171
Hanno Beckera5a2b082019-05-15 14:03:01 +01002172requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002173requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2174run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002175 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker96870292019-05-03 17:30:59 +01002176 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2177 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2178 0 \
2179 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2180 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2181 -s "(initial handshake) Use of Connection ID has been negotiated" \
2182 -c "(initial handshake) Use of Connection ID has been negotiated" \
2183 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2184 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2185 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2186 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002187 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2188 -c "ignoring unexpected CID" \
2189 -s "ignoring unexpected CID"
Hanno Becker2dcdc922019-04-09 18:08:47 +01002190
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002191# Tests for Encrypt-then-MAC extension
2192
2193run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002194 "$P_SRV debug_level=3 \
2195 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002196 "$P_CLI debug_level=3" \
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, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002206 "$P_SRV debug_level=3 etm=0 \
2207 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002208 "$P_CLI debug_level=3 etm=1" \
2209 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é-Gonnard78e745f2014-11-04 15:44:06 +01002217run_test "Encrypt then MAC: client enabled, aead cipher" \
2218 "$P_SRV debug_level=3 etm=1 \
2219 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2220 "$P_CLI debug_level=3 etm=1" \
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
2229run_test "Encrypt then MAC: client enabled, stream cipher" \
2230 "$P_SRV debug_level=3 etm=1 \
2231 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002232 "$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 +01002233 0 \
2234 -c "client hello, adding encrypt_then_mac extension" \
2235 -s "found encrypt then mac extension" \
2236 -S "server hello, adding encrypt then mac extension" \
2237 -C "found encrypt_then_mac extension" \
2238 -C "using encrypt then mac" \
2239 -S "using encrypt then mac"
2240
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002241run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002242 "$P_SRV debug_level=3 etm=1 \
2243 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002244 "$P_CLI debug_level=3 etm=0" \
2245 0 \
2246 -C "client hello, adding encrypt_then_mac extension" \
2247 -S "found encrypt then mac extension" \
2248 -S "server hello, adding encrypt then mac extension" \
2249 -C "found encrypt_then_mac extension" \
2250 -C "using encrypt then mac" \
2251 -S "using encrypt then mac"
2252
Janos Follathe2681a42016-03-07 15:57:05 +00002253requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002254run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002255 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002256 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002257 "$P_CLI debug_level=3 force_version=ssl3" \
2258 0 \
2259 -C "client hello, adding encrypt_then_mac extension" \
2260 -S "found encrypt then mac extension" \
2261 -S "server hello, adding encrypt then mac extension" \
2262 -C "found encrypt_then_mac extension" \
2263 -C "using encrypt then mac" \
2264 -S "using encrypt then mac"
2265
Janos Follathe2681a42016-03-07 15:57:05 +00002266requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002267run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002268 "$P_SRV debug_level=3 force_version=ssl3 \
2269 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002270 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002271 0 \
2272 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002273 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002274 -S "server hello, adding encrypt then mac extension" \
2275 -C "found encrypt_then_mac extension" \
2276 -C "using encrypt then mac" \
2277 -S "using encrypt then mac"
2278
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002279# Tests for Extended Master Secret extension
2280
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002281run_test "Extended Master Secret: default (not enforcing)" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002282 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0 " \
2283 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002284 0 \
2285 -c "client hello, adding extended_master_secret extension" \
2286 -s "found extended master secret extension" \
2287 -s "server hello, adding extended master secret extension" \
2288 -c "found extended_master_secret extension" \
2289 -c "session hash for extended master secret" \
2290 -s "session hash for extended master secret"
2291
2292run_test "Extended Master Secret: both enabled, both enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002293 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2294 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002295 0 \
2296 -c "client hello, adding extended_master_secret extension" \
2297 -s "found extended master secret extension" \
2298 -s "server hello, adding extended master secret extension" \
2299 -c "found extended_master_secret extension" \
2300 -c "session hash for extended master secret" \
2301 -s "session hash for extended master secret"
2302
Jarno Lamsa20095af2019-06-11 17:16:58 +03002303run_test "Extended Master Secret: both enabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002304 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2305 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002306 0 \
2307 -c "client hello, adding extended_master_secret extension" \
2308 -s "found extended master secret extension" \
2309 -s "server hello, adding extended master secret extension" \
2310 -c "found extended_master_secret extension" \
2311 -c "session hash for extended master secret" \
2312 -s "session hash for extended master secret"
2313
2314run_test "Extended Master Secret: both enabled, server enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002315 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2316 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002317 0 \
2318 -c "client hello, adding extended_master_secret extension" \
2319 -s "found extended master secret extension" \
2320 -s "server hello, adding extended master secret extension" \
2321 -c "found extended_master_secret extension" \
2322 -c "session hash for extended master secret" \
2323 -s "session hash for extended master secret"
2324
2325run_test "Extended Master Secret: client enabled, server disabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002326 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002327 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2328 1 \
2329 -c "client hello, adding extended_master_secret extension" \
2330 -s "found extended master secret extension" \
2331 -S "server hello, adding extended master secret extension" \
2332 -C "found extended_master_secret extension" \
2333 -c "Peer not offering extended master secret, while it is enforced"
2334
Jarno Lamsa20095af2019-06-11 17:16:58 +03002335run_test "Extended Master Secret enforced: client disabled, server enabled, server enforcing" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002336 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002337 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002338 1 \
2339 -C "client hello, adding extended_master_secret extension" \
2340 -S "found extended master secret extension" \
2341 -S "server hello, adding extended master secret extension" \
2342 -C "found extended_master_secret extension" \
2343 -s "Peer not offering extended master secret, while it is enforced"
2344
Jarno Lamsa20095af2019-06-11 17:16:58 +03002345run_test "Extended Master Secret: client enabled, server disabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002346 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2347 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002348 0 \
2349 -c "client hello, adding extended_master_secret extension" \
2350 -s "found extended master secret extension" \
2351 -S "server hello, adding extended master secret extension" \
2352 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002353 -C "session hash for extended master secret" \
2354 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002355
Jarno Lamsa20095af2019-06-11 17:16:58 +03002356run_test "Extended Master Secret: client disabled, server enabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002357 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2358 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002359 0 \
2360 -C "client hello, adding extended_master_secret extension" \
2361 -S "found extended master secret extension" \
2362 -S "server hello, adding extended master secret extension" \
2363 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002364 -C "session hash for extended master secret" \
2365 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002366
Jarno Lamsa20095af2019-06-11 17:16:58 +03002367run_test "Extended Master Secret: client disabled, server disabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002368 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2369 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002370 0 \
2371 -C "client hello, adding extended_master_secret extension" \
2372 -S "found extended master secret extension" \
2373 -S "server hello, adding extended master secret extension" \
2374 -C "found extended_master_secret extension" \
2375 -C "session hash for extended master secret" \
2376 -S "session hash for extended master secret"
2377
Janos Follathe2681a42016-03-07 15:57:05 +00002378requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002379run_test "Extended Master Secret: client SSLv3, server enabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002380 "$P_SRV debug_level=3 min_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2381 "$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 +02002382 0 \
2383 -C "client hello, adding extended_master_secret extension" \
2384 -S "found extended master secret extension" \
2385 -S "server hello, adding extended master secret extension" \
2386 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002387 -C "session hash for extended master secret" \
2388 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002389
Janos Follathe2681a42016-03-07 15:57:05 +00002390requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002391run_test "Extended Master Secret: client enabled, server SSLv3" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002392 "$P_SRV debug_level=3 force_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2393 "$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 +02002394 0 \
2395 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002396 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002397 -S "server hello, adding extended master secret extension" \
2398 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002399 -C "session hash for extended master secret" \
2400 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002401
Jarno Lamsaff434c22019-10-25 12:21:54 +03002402run_test "Extended Master Secret: both enabled, both enforcing, DTLS" \
2403 "$P_SRV dtls=1 debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2404 "$P_CLI dtls=1 debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2405 0 \
2406 -c "client hello, adding extended_master_secret extension" \
2407 -s "found extended master secret extension" \
2408 -s "server hello, adding extended master secret extension" \
2409 -c "found extended_master_secret extension" \
2410 -c "session hash for extended master secret" \
2411 -s "session hash for extended master secret"
2412
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002413# Tests for FALLBACK_SCSV
2414
2415run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002416 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002417 "$P_CLI debug_level=3 force_version=tls1_1" \
2418 0 \
2419 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002420 -S "received FALLBACK_SCSV" \
2421 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002422 -C "is a fatal alert message (msg 86)"
2423
2424run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002425 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002426 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2427 0 \
2428 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002429 -S "received FALLBACK_SCSV" \
2430 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002431 -C "is a fatal alert message (msg 86)"
2432
2433run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002434 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002435 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002436 1 \
2437 -c "adding FALLBACK_SCSV" \
2438 -s "received FALLBACK_SCSV" \
2439 -s "inapropriate fallback" \
2440 -c "is a fatal alert message (msg 86)"
2441
2442run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002443 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002444 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002445 0 \
2446 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002447 -s "received FALLBACK_SCSV" \
2448 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002449 -C "is a fatal alert message (msg 86)"
2450
2451requires_openssl_with_fallback_scsv
2452run_test "Fallback SCSV: default, openssl server" \
2453 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002454 "$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 +02002455 0 \
2456 -C "adding FALLBACK_SCSV" \
2457 -C "is a fatal alert message (msg 86)"
2458
2459requires_openssl_with_fallback_scsv
2460run_test "Fallback SCSV: enabled, openssl server" \
2461 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002462 "$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 +02002463 1 \
2464 -c "adding FALLBACK_SCSV" \
2465 -c "is a fatal alert message (msg 86)"
2466
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002467requires_openssl_with_fallback_scsv
2468run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002469 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002470 "$O_CLI -tls1_1" \
2471 0 \
2472 -S "received FALLBACK_SCSV" \
2473 -S "inapropriate fallback"
2474
2475requires_openssl_with_fallback_scsv
2476run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002477 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002478 "$O_CLI -tls1_1 -fallback_scsv" \
2479 1 \
2480 -s "received FALLBACK_SCSV" \
2481 -s "inapropriate fallback"
2482
2483requires_openssl_with_fallback_scsv
2484run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002485 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002486 "$O_CLI -fallback_scsv" \
2487 0 \
2488 -s "received FALLBACK_SCSV" \
2489 -S "inapropriate fallback"
2490
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002491# Test sending and receiving empty application data records
2492
2493run_test "Encrypt then MAC: empty application data record" \
2494 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2495 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2496 0 \
2497 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2498 -s "dumping 'input payload after decrypt' (0 bytes)" \
2499 -c "0 bytes written in 1 fragments"
2500
2501run_test "Default, no Encrypt then MAC: empty application data record" \
2502 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2503 "$P_CLI auth_mode=none etm=0 request_size=0" \
2504 0 \
2505 -s "dumping 'input payload after decrypt' (0 bytes)" \
2506 -c "0 bytes written in 1 fragments"
2507
2508run_test "Encrypt then MAC, DTLS: empty application data record" \
2509 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2510 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2511 0 \
2512 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2513 -s "dumping 'input payload after decrypt' (0 bytes)" \
2514 -c "0 bytes written in 1 fragments"
2515
2516run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
2517 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2518 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2519 0 \
2520 -s "dumping 'input payload after decrypt' (0 bytes)" \
2521 -c "0 bytes written in 1 fragments"
2522
Gilles Peskined50177f2017-05-16 17:53:03 +02002523## ClientHello generated with
2524## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2525## then manually twiddling the ciphersuite list.
2526## The ClientHello content is spelled out below as a hex string as
2527## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2528## The expected response is an inappropriate_fallback alert.
2529requires_openssl_with_fallback_scsv
2530run_test "Fallback SCSV: beginning of list" \
2531 "$P_SRV debug_level=2" \
2532 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2533 0 \
2534 -s "received FALLBACK_SCSV" \
2535 -s "inapropriate fallback"
2536
2537requires_openssl_with_fallback_scsv
2538run_test "Fallback SCSV: end of list" \
2539 "$P_SRV debug_level=2" \
2540 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2541 0 \
2542 -s "received FALLBACK_SCSV" \
2543 -s "inapropriate fallback"
2544
2545## Here the expected response is a valid ServerHello prefix, up to the random.
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02002546## Due to the way the clienthello was generated, this currently needs the
2547## server to have support for session tickets.
2548requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Gilles Peskined50177f2017-05-16 17:53:03 +02002549requires_openssl_with_fallback_scsv
2550run_test "Fallback SCSV: not in list" \
2551 "$P_SRV debug_level=2" \
2552 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2553 0 \
2554 -S "received FALLBACK_SCSV" \
2555 -S "inapropriate fallback"
2556
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002557# Tests for CBC 1/n-1 record splitting
2558
2559run_test "CBC Record splitting: TLS 1.2, no splitting" \
2560 "$P_SRV" \
2561 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2562 request_size=123 force_version=tls1_2" \
2563 0 \
2564 -s "Read from client: 123 bytes read" \
2565 -S "Read from client: 1 bytes read" \
2566 -S "122 bytes read"
2567
2568run_test "CBC Record splitting: TLS 1.1, no splitting" \
2569 "$P_SRV" \
2570 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2571 request_size=123 force_version=tls1_1" \
2572 0 \
2573 -s "Read from client: 123 bytes read" \
2574 -S "Read from client: 1 bytes read" \
2575 -S "122 bytes read"
2576
2577run_test "CBC Record splitting: TLS 1.0, splitting" \
2578 "$P_SRV" \
2579 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2580 request_size=123 force_version=tls1" \
2581 0 \
2582 -S "Read from client: 123 bytes read" \
2583 -s "Read from client: 1 bytes read" \
2584 -s "122 bytes read"
2585
Janos Follathe2681a42016-03-07 15:57:05 +00002586requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002587run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002588 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002589 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2590 request_size=123 force_version=ssl3" \
2591 0 \
2592 -S "Read from client: 123 bytes read" \
2593 -s "Read from client: 1 bytes read" \
2594 -s "122 bytes read"
2595
2596run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002597 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002598 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2599 request_size=123 force_version=tls1" \
2600 0 \
2601 -s "Read from client: 123 bytes read" \
2602 -S "Read from client: 1 bytes read" \
2603 -S "122 bytes read"
2604
2605run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2606 "$P_SRV" \
2607 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2608 request_size=123 force_version=tls1 recsplit=0" \
2609 0 \
2610 -s "Read from client: 123 bytes read" \
2611 -S "Read from client: 1 bytes read" \
2612 -S "122 bytes read"
2613
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002614run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2615 "$P_SRV nbio=2" \
2616 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2617 request_size=123 force_version=tls1" \
2618 0 \
2619 -S "Read from client: 123 bytes read" \
2620 -s "Read from client: 1 bytes read" \
2621 -s "122 bytes read"
2622
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002623# Tests for Session Tickets
2624
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002625requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002626requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002627run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002628 "$P_SRV debug_level=3 tickets=1" \
2629 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002630 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002631 -c "client hello, adding session ticket extension" \
2632 -s "found session ticket extension" \
2633 -s "server hello, adding session ticket extension" \
2634 -c "found session_ticket extension" \
2635 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002636 -S "session successfully restored from cache" \
2637 -s "session successfully restored from ticket" \
2638 -s "a session has been resumed" \
2639 -c "a session has been resumed"
2640
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002641requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002642requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002643run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002644 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2645 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002646 0 \
2647 -c "client hello, adding session ticket extension" \
2648 -s "found session ticket extension" \
2649 -s "server hello, adding session ticket extension" \
2650 -c "found session_ticket extension" \
2651 -c "parse new session ticket" \
2652 -S "session successfully restored from cache" \
2653 -s "session successfully restored from ticket" \
2654 -s "a session has been resumed" \
2655 -c "a session has been resumed"
2656
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002657requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002658requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002659run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002660 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2661 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002662 0 \
2663 -c "client hello, adding session ticket extension" \
2664 -s "found session ticket extension" \
2665 -s "server hello, adding session ticket extension" \
2666 -c "found session_ticket extension" \
2667 -c "parse new session ticket" \
2668 -S "session successfully restored from cache" \
2669 -S "session successfully restored from ticket" \
2670 -S "a session has been resumed" \
2671 -C "a session has been resumed"
2672
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002673requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002674requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002675run_test "Session resume using tickets: session copy" \
2676 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2677 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2678 0 \
2679 -c "client hello, adding session ticket extension" \
2680 -s "found session ticket extension" \
2681 -s "server hello, adding session ticket extension" \
2682 -c "found session_ticket extension" \
2683 -c "parse new session ticket" \
2684 -S "session successfully restored from cache" \
2685 -s "session successfully restored from ticket" \
2686 -s "a session has been resumed" \
2687 -c "a session has been resumed"
2688
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002689requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002690requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002691run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002692 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002693 "$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 +01002694 0 \
2695 -c "client hello, adding session ticket extension" \
2696 -c "found session_ticket extension" \
2697 -c "parse new session ticket" \
2698 -c "a session has been resumed"
2699
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002700requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002701requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002702run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002703 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002704 "( $O_CLI -sess_out $SESSION; \
2705 $O_CLI -sess_in $SESSION; \
2706 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002707 0 \
2708 -s "found session ticket extension" \
2709 -s "server hello, adding session ticket extension" \
2710 -S "session successfully restored from cache" \
2711 -s "session successfully restored from ticket" \
2712 -s "a session has been resumed"
2713
Hanno Becker1d739932018-08-21 13:55:22 +01002714# Tests for Session Tickets with DTLS
2715
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002716requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002717requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002718run_test "Session resume using tickets, DTLS: basic" \
2719 "$P_SRV debug_level=3 dtls=1 tickets=1" \
2720 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2721 0 \
2722 -c "client hello, adding session ticket extension" \
2723 -s "found session ticket extension" \
2724 -s "server hello, adding session ticket extension" \
2725 -c "found session_ticket extension" \
2726 -c "parse new session ticket" \
2727 -S "session successfully restored from cache" \
2728 -s "session successfully restored from ticket" \
2729 -s "a session has been resumed" \
2730 -c "a session has been resumed"
2731
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002732requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002733requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002734run_test "Session resume using tickets, DTLS: cache disabled" \
2735 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2736 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
2737 0 \
2738 -c "client hello, adding session ticket extension" \
2739 -s "found session ticket extension" \
2740 -s "server hello, adding session ticket extension" \
2741 -c "found session_ticket extension" \
2742 -c "parse new session ticket" \
2743 -S "session successfully restored from cache" \
2744 -s "session successfully restored from ticket" \
2745 -s "a session has been resumed" \
2746 -c "a session has been resumed"
2747
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002748requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002749requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002750run_test "Session resume using tickets, DTLS: timeout" \
2751 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
2752 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \
2753 0 \
2754 -c "client hello, adding session ticket extension" \
2755 -s "found session ticket extension" \
2756 -s "server hello, adding session ticket extension" \
2757 -c "found session_ticket extension" \
2758 -c "parse new session ticket" \
2759 -S "session successfully restored from cache" \
2760 -S "session successfully restored from ticket" \
2761 -S "a session has been resumed" \
2762 -C "a session has been resumed"
2763
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002764requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002765requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002766run_test "Session resume using tickets, DTLS: session copy" \
2767 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2768 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_mode=0" \
2769 0 \
2770 -c "client hello, adding session ticket extension" \
2771 -s "found session ticket extension" \
2772 -s "server hello, adding session ticket extension" \
2773 -c "found session_ticket extension" \
2774 -c "parse new session ticket" \
2775 -S "session successfully restored from cache" \
2776 -s "session successfully restored from ticket" \
2777 -s "a session has been resumed" \
2778 -c "a session has been resumed"
2779
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002780requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002781requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002782run_test "Session resume using tickets, DTLS: openssl server" \
2783 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002784 "$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 +01002785 0 \
2786 -c "client hello, adding session ticket extension" \
2787 -c "found session_ticket extension" \
2788 -c "parse new session ticket" \
2789 -c "a session has been resumed"
2790
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002791requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002792requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002793run_test "Session resume using tickets, DTLS: openssl client" \
2794 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2795 "( $O_CLI -dtls1 -sess_out $SESSION; \
2796 $O_CLI -dtls1 -sess_in $SESSION; \
2797 rm -f $SESSION )" \
2798 0 \
2799 -s "found session ticket extension" \
2800 -s "server hello, adding session ticket extension" \
2801 -S "session successfully restored from cache" \
2802 -s "session successfully restored from ticket" \
2803 -s "a session has been resumed"
2804
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002805# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002806
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002807requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002808requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002809requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002810run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002811 "$P_SRV debug_level=3 tickets=0" \
2812 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002813 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002814 -c "client hello, adding session ticket extension" \
2815 -s "found session ticket extension" \
2816 -S "server hello, adding session ticket extension" \
2817 -C "found session_ticket extension" \
2818 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002819 -s "session successfully restored from cache" \
2820 -S "session successfully restored from ticket" \
2821 -s "a session has been resumed" \
2822 -c "a session has been resumed"
2823
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002824requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002825requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002826requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002827run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002828 "$P_SRV debug_level=3 tickets=1" \
2829 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002830 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002831 -C "client hello, adding session ticket extension" \
2832 -S "found session ticket extension" \
2833 -S "server hello, adding session ticket extension" \
2834 -C "found session_ticket extension" \
2835 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002836 -s "session successfully restored from cache" \
2837 -S "session successfully restored from ticket" \
2838 -s "a session has been resumed" \
2839 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002840
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002841requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2842requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002843run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002844 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2845 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002846 0 \
2847 -S "session successfully restored from cache" \
2848 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002849 -S "a session has been resumed" \
2850 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002851
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002852requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2853requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002854run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002855 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2856 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002857 0 \
2858 -s "session successfully restored from cache" \
2859 -S "session successfully restored from ticket" \
2860 -s "a session has been resumed" \
2861 -c "a session has been resumed"
2862
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002863requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2864requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002865run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002866 "$P_SRV debug_level=3 tickets=0" \
2867 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002868 0 \
2869 -s "session successfully restored from cache" \
2870 -S "session successfully restored from ticket" \
2871 -s "a session has been resumed" \
2872 -c "a session has been resumed"
2873
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002874requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2875requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002876run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002877 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2878 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002879 0 \
2880 -S "session successfully restored from cache" \
2881 -S "session successfully restored from ticket" \
2882 -S "a session has been resumed" \
2883 -C "a session has been resumed"
2884
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002885requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2886requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002887run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002888 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2889 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002890 0 \
2891 -s "session successfully restored from cache" \
2892 -S "session successfully restored from ticket" \
2893 -s "a session has been resumed" \
2894 -c "a session has been resumed"
2895
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002896requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2897requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002898run_test "Session resume using cache: session copy" \
2899 "$P_SRV debug_level=3 tickets=0" \
2900 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2901 0 \
2902 -s "session successfully restored from cache" \
2903 -S "session successfully restored from ticket" \
2904 -s "a session has been resumed" \
2905 -c "a session has been resumed"
2906
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002907requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2908requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002909run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002910 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002911 "( $O_CLI -sess_out $SESSION; \
2912 $O_CLI -sess_in $SESSION; \
2913 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002914 0 \
2915 -s "found session ticket extension" \
2916 -S "server hello, adding session ticket extension" \
2917 -s "session successfully restored from cache" \
2918 -S "session successfully restored from ticket" \
2919 -s "a session has been resumed"
2920
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002921requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2922requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002923run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002924 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002925 "$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 +01002926 0 \
2927 -C "found session_ticket extension" \
2928 -C "parse new session ticket" \
2929 -c "a session has been resumed"
2930
Hanno Becker1d739932018-08-21 13:55:22 +01002931# Tests for Session Resume based on session-ID and cache, DTLS
2932
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002933requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002934requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002935requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002936run_test "Session resume using cache, DTLS: tickets enabled on client" \
2937 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2938 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2939 0 \
2940 -c "client hello, adding session ticket extension" \
2941 -s "found session ticket extension" \
2942 -S "server hello, adding session ticket extension" \
2943 -C "found session_ticket extension" \
2944 -C "parse new session ticket" \
2945 -s "session successfully restored from cache" \
2946 -S "session successfully restored from ticket" \
2947 -s "a session has been resumed" \
2948 -c "a session has been resumed"
2949
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002950requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002951requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002952requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002953run_test "Session resume using cache, DTLS: tickets enabled on server" \
2954 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2955 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2956 0 \
2957 -C "client hello, adding session ticket extension" \
2958 -S "found session ticket extension" \
2959 -S "server hello, adding session ticket extension" \
2960 -C "found session_ticket extension" \
2961 -C "parse new session ticket" \
2962 -s "session successfully restored from cache" \
2963 -S "session successfully restored from ticket" \
2964 -s "a session has been resumed" \
2965 -c "a session has been resumed"
2966
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002967requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2968requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002969run_test "Session resume using cache, DTLS: cache_max=0" \
2970 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
2971 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2972 0 \
2973 -S "session successfully restored from cache" \
2974 -S "session successfully restored from ticket" \
2975 -S "a session has been resumed" \
2976 -C "a session has been resumed"
2977
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002978requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2979requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002980run_test "Session resume using cache, DTLS: cache_max=1" \
2981 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
2982 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2983 0 \
2984 -s "session successfully restored from cache" \
2985 -S "session successfully restored from ticket" \
2986 -s "a session has been resumed" \
2987 -c "a session has been resumed"
2988
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002989requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2990requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002991run_test "Session resume using cache, DTLS: timeout > delay" \
2992 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2993 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
2994 0 \
2995 -s "session successfully restored from cache" \
2996 -S "session successfully restored from ticket" \
2997 -s "a session has been resumed" \
2998 -c "a session has been resumed"
2999
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03003000requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3001requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01003002run_test "Session resume using cache, DTLS: timeout < delay" \
3003 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
3004 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
3005 0 \
3006 -S "session successfully restored from cache" \
3007 -S "session successfully restored from ticket" \
3008 -S "a session has been resumed" \
3009 -C "a session has been resumed"
3010
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03003011requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3012requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01003013run_test "Session resume using cache, DTLS: no timeout" \
3014 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
3015 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
3016 0 \
3017 -s "session successfully restored from cache" \
3018 -S "session successfully restored from ticket" \
3019 -s "a session has been resumed" \
3020 -c "a session has been resumed"
3021
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03003022requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3023requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02003024run_test "Session resume using cache, DTLS: session copy" \
3025 "$P_SRV dtls=1 debug_level=3 tickets=0" \
3026 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
3027 0 \
3028 -s "session successfully restored from cache" \
3029 -S "session successfully restored from ticket" \
3030 -s "a session has been resumed" \
3031 -c "a session has been resumed"
3032
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03003033requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3034requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01003035run_test "Session resume using cache, DTLS: openssl client" \
3036 "$P_SRV dtls=1 debug_level=3 tickets=0" \
3037 "( $O_CLI -dtls1 -sess_out $SESSION; \
3038 $O_CLI -dtls1 -sess_in $SESSION; \
3039 rm -f $SESSION )" \
3040 0 \
3041 -s "found session ticket extension" \
3042 -S "server hello, adding session ticket extension" \
3043 -s "session successfully restored from cache" \
3044 -S "session successfully restored from ticket" \
3045 -s "a session has been resumed"
3046
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03003047requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3048requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01003049run_test "Session resume using cache, DTLS: openssl server" \
3050 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003051 "$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 +01003052 0 \
3053 -C "found session_ticket extension" \
3054 -C "parse new session ticket" \
3055 -c "a session has been resumed"
3056
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003057# Tests for Max Fragment Length extension
3058
Angus Grattonc4dd0732018-04-11 16:28:39 +10003059if [ $MAX_CONTENT_LEN -ne 16384 ]; then
3060 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
3061fi
3062
Hanno Becker4aed27e2017-09-18 15:00:34 +01003063requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003064run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003065 "$P_SRV debug_level=3" \
3066 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003067 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003068 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3069 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003070 -C "client hello, adding max_fragment_length extension" \
3071 -S "found max fragment length extension" \
3072 -S "server hello, max_fragment_length extension" \
3073 -C "found max_fragment_length extension"
3074
Hanno Becker4aed27e2017-09-18 15:00:34 +01003075requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003076run_test "Max fragment length: enabled, default, larger message" \
3077 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003078 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003079 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003080 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3081 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003082 -C "client hello, adding max_fragment_length extension" \
3083 -S "found max fragment length extension" \
3084 -S "server hello, max_fragment_length extension" \
3085 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003086 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3087 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003088 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003089
3090requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003091requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Hanno Beckerc5266962017-09-18 15:01:50 +01003092run_test "Max fragment length, DTLS: enabled, default, larger message" \
3093 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003094 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003095 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003096 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3097 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003098 -C "client hello, adding max_fragment_length extension" \
3099 -S "found max fragment length extension" \
3100 -S "server hello, max_fragment_length extension" \
3101 -C "found max_fragment_length extension" \
3102 -c "fragment larger than.*maximum "
3103
Angus Grattonc4dd0732018-04-11 16:28:39 +10003104# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3105# (session fragment length will be 16384 regardless of mbedtls
3106# content length configuration.)
3107
Hanno Beckerc5266962017-09-18 15:01:50 +01003108requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003109requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 16384
Hanno Beckerc5266962017-09-18 15:01:50 +01003110run_test "Max fragment length: disabled, larger message" \
3111 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003112 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003113 0 \
3114 -C "Maximum fragment length is 16384" \
3115 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003116 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3117 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003118 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003119
3120requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003121requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 16384
Hanno Beckerc5266962017-09-18 15:01:50 +01003122run_test "Max fragment length DTLS: disabled, larger message" \
3123 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003124 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003125 1 \
3126 -C "Maximum fragment length is 16384" \
3127 -S "Maximum fragment length is 16384" \
3128 -c "fragment larger than.*maximum "
3129
3130requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003131requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003132run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003133 "$P_SRV debug_level=3" \
3134 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003135 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003136 -c "Maximum fragment length is 4096" \
3137 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003138 -c "client hello, adding max_fragment_length extension" \
3139 -s "found max fragment length extension" \
3140 -s "server hello, 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 Kinnunen3f1190d2019-09-26 17:18:57 +03003144requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003145run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003146 "$P_SRV debug_level=3 max_frag_len=4096" \
3147 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003148 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003149 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003150 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003151 -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"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003155
Hanno Becker4aed27e2017-09-18 15:00:34 +01003156requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003157requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003158requires_gnutls
3159run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003160 "$G_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003161 "$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 +02003162 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003163 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003164 -c "client hello, adding max_fragment_length extension" \
3165 -c "found max_fragment_length extension"
3166
Hanno Becker4aed27e2017-09-18 15:00:34 +01003167requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003168requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003169run_test "Max fragment length: client, message just fits" \
3170 "$P_SRV debug_level=3" \
3171 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3172 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003173 -c "Maximum fragment length is 2048" \
3174 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003175 -c "client hello, adding max_fragment_length extension" \
3176 -s "found max fragment length extension" \
3177 -s "server hello, max_fragment_length extension" \
3178 -c "found max_fragment_length extension" \
3179 -c "2048 bytes written in 1 fragments" \
3180 -s "2048 bytes read"
3181
Hanno Becker4aed27e2017-09-18 15:00:34 +01003182requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003183requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003184run_test "Max fragment length: client, larger message" \
3185 "$P_SRV debug_level=3" \
3186 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3187 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003188 -c "Maximum fragment length is 2048" \
3189 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003190 -c "client hello, adding max_fragment_length extension" \
3191 -s "found max fragment length extension" \
3192 -s "server hello, max_fragment_length extension" \
3193 -c "found max_fragment_length extension" \
3194 -c "2345 bytes written in 2 fragments" \
3195 -s "2048 bytes read" \
3196 -s "297 bytes read"
3197
Hanno Becker4aed27e2017-09-18 15:00:34 +01003198requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003199requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003200run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003201 "$P_SRV debug_level=3 dtls=1" \
3202 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3203 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003204 -c "Maximum fragment length is 2048" \
3205 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003206 -c "client hello, adding max_fragment_length extension" \
3207 -s "found max fragment length extension" \
3208 -s "server hello, max_fragment_length extension" \
3209 -c "found max_fragment_length extension" \
3210 -c "fragment larger than.*maximum"
3211
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003212# Tests for renegotiation
3213
Hanno Becker6a243642017-10-12 15:18:45 +01003214# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003215run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003216 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003217 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003218 0 \
3219 -C "client hello, adding renegotiation extension" \
3220 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3221 -S "found renegotiation extension" \
3222 -s "server hello, secure renegotiation extension" \
3223 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003224 -C "=> renegotiate" \
3225 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003226 -S "write hello request"
3227
Hanno Becker6a243642017-10-12 15:18:45 +01003228requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003229run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003230 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003231 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003232 0 \
3233 -c "client hello, adding renegotiation extension" \
3234 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3235 -s "found renegotiation extension" \
3236 -s "server hello, secure renegotiation extension" \
3237 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003238 -c "=> renegotiate" \
3239 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003240 -S "write hello request"
3241
Hanno Becker6a243642017-10-12 15:18:45 +01003242requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003243run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003244 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003245 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003246 0 \
3247 -c "client hello, adding renegotiation extension" \
3248 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3249 -s "found renegotiation extension" \
3250 -s "server hello, secure renegotiation extension" \
3251 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003252 -c "=> renegotiate" \
3253 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003254 -s "write hello request"
3255
Janos Follathb0f148c2017-10-05 12:29:42 +01003256# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3257# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3258# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003259requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003260run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3261 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3262 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3263 0 \
3264 -c "client hello, adding renegotiation extension" \
3265 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3266 -s "found renegotiation extension" \
3267 -s "server hello, secure renegotiation extension" \
3268 -c "found renegotiation extension" \
3269 -c "=> renegotiate" \
3270 -s "=> renegotiate" \
3271 -S "write hello request" \
3272 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3273
3274# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3275# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3276# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003277requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003278run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3279 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3280 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3281 0 \
3282 -c "client hello, adding renegotiation extension" \
3283 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3284 -s "found renegotiation extension" \
3285 -s "server hello, secure renegotiation extension" \
3286 -c "found renegotiation extension" \
3287 -c "=> renegotiate" \
3288 -s "=> renegotiate" \
3289 -s "write hello request" \
3290 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3291
Hanno Becker6a243642017-10-12 15:18:45 +01003292requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003293run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003294 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003295 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003296 0 \
3297 -c "client hello, adding renegotiation extension" \
3298 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3299 -s "found renegotiation extension" \
3300 -s "server hello, secure renegotiation extension" \
3301 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003302 -c "=> renegotiate" \
3303 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003304 -s "write hello request"
3305
Hanno Becker6a243642017-10-12 15:18:45 +01003306requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003307run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003308 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003309 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003310 1 \
3311 -c "client hello, adding renegotiation extension" \
3312 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3313 -S "found renegotiation extension" \
3314 -s "server hello, secure renegotiation extension" \
3315 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003316 -c "=> renegotiate" \
3317 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003318 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003319 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003320 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003321
Hanno Becker6a243642017-10-12 15:18:45 +01003322requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003323run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003324 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003325 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003326 0 \
3327 -C "client hello, adding renegotiation extension" \
3328 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3329 -S "found renegotiation extension" \
3330 -s "server hello, secure renegotiation extension" \
3331 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003332 -C "=> renegotiate" \
3333 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003334 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003335 -S "SSL - An unexpected message was received from our peer" \
3336 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003337
Hanno Becker6a243642017-10-12 15:18:45 +01003338requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003339run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003340 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003341 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003342 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003343 0 \
3344 -C "client hello, adding renegotiation extension" \
3345 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3346 -S "found renegotiation extension" \
3347 -s "server hello, secure renegotiation extension" \
3348 -c "found renegotiation extension" \
3349 -C "=> renegotiate" \
3350 -S "=> renegotiate" \
3351 -s "write hello request" \
3352 -S "SSL - An unexpected message was received from our peer" \
3353 -S "failed"
3354
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003355# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003356requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003357run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003358 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003359 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003360 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003361 0 \
3362 -C "client hello, adding renegotiation extension" \
3363 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3364 -S "found renegotiation extension" \
3365 -s "server hello, secure renegotiation extension" \
3366 -c "found renegotiation extension" \
3367 -C "=> renegotiate" \
3368 -S "=> renegotiate" \
3369 -s "write hello request" \
3370 -S "SSL - An unexpected message was received from our peer" \
3371 -S "failed"
3372
Hanno Becker6a243642017-10-12 15:18:45 +01003373requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003374run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003375 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003376 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003377 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003378 0 \
3379 -C "client hello, adding renegotiation extension" \
3380 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3381 -S "found renegotiation extension" \
3382 -s "server hello, secure renegotiation extension" \
3383 -c "found renegotiation extension" \
3384 -C "=> renegotiate" \
3385 -S "=> renegotiate" \
3386 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003387 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003388
Hanno Becker6a243642017-10-12 15:18:45 +01003389requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003390run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003391 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003392 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003393 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003394 0 \
3395 -c "client hello, adding renegotiation extension" \
3396 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3397 -s "found renegotiation extension" \
3398 -s "server hello, secure renegotiation extension" \
3399 -c "found renegotiation extension" \
3400 -c "=> renegotiate" \
3401 -s "=> renegotiate" \
3402 -s "write hello request" \
3403 -S "SSL - An unexpected message was received from our peer" \
3404 -S "failed"
3405
Hanno Becker6a243642017-10-12 15:18:45 +01003406requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003407run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003408 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003409 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3410 0 \
3411 -C "client hello, adding renegotiation extension" \
3412 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3413 -S "found renegotiation extension" \
3414 -s "server hello, secure renegotiation extension" \
3415 -c "found renegotiation extension" \
3416 -S "record counter limit reached: renegotiate" \
3417 -C "=> renegotiate" \
3418 -S "=> renegotiate" \
3419 -S "write hello request" \
3420 -S "SSL - An unexpected message was received from our peer" \
3421 -S "failed"
3422
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003423# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003424requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003425run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003426 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003427 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003428 0 \
3429 -c "client hello, adding renegotiation extension" \
3430 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3431 -s "found renegotiation extension" \
3432 -s "server hello, secure renegotiation extension" \
3433 -c "found renegotiation extension" \
3434 -s "record counter limit reached: renegotiate" \
3435 -c "=> renegotiate" \
3436 -s "=> renegotiate" \
3437 -s "write hello request" \
3438 -S "SSL - An unexpected message was received from our peer" \
3439 -S "failed"
3440
Hanno Becker6a243642017-10-12 15:18:45 +01003441requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003442run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003443 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003444 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003445 0 \
3446 -c "client hello, adding renegotiation extension" \
3447 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3448 -s "found renegotiation extension" \
3449 -s "server hello, secure renegotiation extension" \
3450 -c "found renegotiation extension" \
3451 -s "record counter limit reached: renegotiate" \
3452 -c "=> renegotiate" \
3453 -s "=> renegotiate" \
3454 -s "write hello request" \
3455 -S "SSL - An unexpected message was received from our peer" \
3456 -S "failed"
3457
Hanno Becker6a243642017-10-12 15:18:45 +01003458requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003459run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003460 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003461 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3462 0 \
3463 -C "client hello, adding renegotiation extension" \
3464 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3465 -S "found renegotiation extension" \
3466 -s "server hello, secure renegotiation extension" \
3467 -c "found renegotiation extension" \
3468 -S "record counter limit reached: renegotiate" \
3469 -C "=> renegotiate" \
3470 -S "=> renegotiate" \
3471 -S "write hello request" \
3472 -S "SSL - An unexpected message was received from our peer" \
3473 -S "failed"
3474
Hanno Becker6a243642017-10-12 15:18:45 +01003475requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003476run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003477 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003478 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003479 0 \
3480 -c "client hello, adding renegotiation extension" \
3481 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3482 -s "found renegotiation extension" \
3483 -s "server hello, secure renegotiation extension" \
3484 -c "found renegotiation extension" \
3485 -c "=> renegotiate" \
3486 -s "=> renegotiate" \
3487 -S "write hello request"
3488
Hanno Becker6a243642017-10-12 15:18:45 +01003489requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003490run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003491 "$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 +02003492 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003493 0 \
3494 -c "client hello, adding renegotiation extension" \
3495 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3496 -s "found renegotiation extension" \
3497 -s "server hello, secure renegotiation extension" \
3498 -c "found renegotiation extension" \
3499 -c "=> renegotiate" \
3500 -s "=> renegotiate" \
3501 -s "write hello request"
3502
Hanno Becker6a243642017-10-12 15:18:45 +01003503requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003504run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003505 "$O_SRV -www" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003506 "$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 +02003507 0 \
3508 -c "client hello, adding renegotiation extension" \
3509 -c "found renegotiation extension" \
3510 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003511 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003512 -C "error" \
3513 -c "HTTP/1.0 200 [Oo][Kk]"
3514
Paul Bakker539d9722015-02-08 16:18:35 +01003515requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003516requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003517run_test "Renegotiation: gnutls server strict, client-initiated" \
3518 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003519 "$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 +02003520 0 \
3521 -c "client hello, adding renegotiation extension" \
3522 -c "found renegotiation extension" \
3523 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003524 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003525 -C "error" \
3526 -c "HTTP/1.0 200 [Oo][Kk]"
3527
Paul Bakker539d9722015-02-08 16:18:35 +01003528requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003529requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003530run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3531 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003532 "$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 +01003533 1 \
3534 -c "client hello, adding renegotiation extension" \
3535 -C "found renegotiation extension" \
3536 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003537 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003538 -c "error" \
3539 -C "HTTP/1.0 200 [Oo][Kk]"
3540
Paul Bakker539d9722015-02-08 16:18:35 +01003541requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003542requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003543run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3544 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003545 "$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 +01003546 allow_legacy=0" \
3547 1 \
3548 -c "client hello, adding renegotiation extension" \
3549 -C "found renegotiation extension" \
3550 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003551 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003552 -c "error" \
3553 -C "HTTP/1.0 200 [Oo][Kk]"
3554
Paul Bakker539d9722015-02-08 16:18:35 +01003555requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003556requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003557run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3558 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003559 "$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 +01003560 allow_legacy=1" \
3561 0 \
3562 -c "client hello, adding renegotiation extension" \
3563 -C "found renegotiation extension" \
3564 -c "=> renegotiate" \
3565 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003566 -C "error" \
3567 -c "HTTP/1.0 200 [Oo][Kk]"
3568
Hanno Becker6a243642017-10-12 15:18:45 +01003569requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003570run_test "Renegotiation: DTLS, client-initiated" \
3571 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3572 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3573 0 \
3574 -c "client hello, adding renegotiation extension" \
3575 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3576 -s "found renegotiation extension" \
3577 -s "server hello, secure renegotiation extension" \
3578 -c "found renegotiation extension" \
3579 -c "=> renegotiate" \
3580 -s "=> renegotiate" \
3581 -S "write hello request"
3582
Hanno Becker6a243642017-10-12 15:18:45 +01003583requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003584run_test "Renegotiation: DTLS, server-initiated" \
3585 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003586 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3587 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003588 0 \
3589 -c "client hello, adding renegotiation extension" \
3590 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3591 -s "found renegotiation extension" \
3592 -s "server hello, secure renegotiation extension" \
3593 -c "found renegotiation extension" \
3594 -c "=> renegotiate" \
3595 -s "=> renegotiate" \
3596 -s "write hello request"
3597
Hanno Becker6a243642017-10-12 15:18:45 +01003598requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003599run_test "Renegotiation: DTLS, renego_period overflow" \
3600 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3601 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3602 0 \
3603 -c "client hello, adding renegotiation extension" \
3604 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3605 -s "found renegotiation extension" \
3606 -s "server hello, secure renegotiation extension" \
3607 -s "record counter limit reached: renegotiate" \
3608 -c "=> renegotiate" \
3609 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003610 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003611
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003612requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003613requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003614run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3615 "$G_SRV -u --mtu 4096" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003616 "$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 +02003617 0 \
3618 -c "client hello, adding renegotiation extension" \
3619 -c "found renegotiation extension" \
3620 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003621 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003622 -C "error" \
3623 -s "Extra-header:"
3624
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003625# Test for the "secure renegotation" extension only (no actual renegotiation)
3626
Paul Bakker539d9722015-02-08 16:18:35 +01003627requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003628run_test "Renego ext: gnutls server strict, client default" \
3629 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003630 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003631 0 \
3632 -c "found renegotiation extension" \
3633 -C "error" \
3634 -c "HTTP/1.0 200 [Oo][Kk]"
3635
Paul Bakker539d9722015-02-08 16:18:35 +01003636requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003637run_test "Renego ext: gnutls server unsafe, client default" \
3638 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003639 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003640 0 \
3641 -C "found renegotiation extension" \
3642 -C "error" \
3643 -c "HTTP/1.0 200 [Oo][Kk]"
3644
Paul Bakker539d9722015-02-08 16:18:35 +01003645requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003646run_test "Renego ext: gnutls server unsafe, client break legacy" \
3647 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3648 "$P_CLI debug_level=3 allow_legacy=-1" \
3649 1 \
3650 -C "found renegotiation extension" \
3651 -c "error" \
3652 -C "HTTP/1.0 200 [Oo][Kk]"
3653
Paul Bakker539d9722015-02-08 16:18:35 +01003654requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003655run_test "Renego ext: gnutls client strict, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003656 "$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 +02003657 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003658 0 \
3659 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3660 -s "server hello, secure renegotiation extension"
3661
Paul Bakker539d9722015-02-08 16:18:35 +01003662requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003663run_test "Renego ext: gnutls client unsafe, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003664 "$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 +02003665 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003666 0 \
3667 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3668 -S "server hello, secure renegotiation extension"
3669
Paul Bakker539d9722015-02-08 16:18:35 +01003670requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003671run_test "Renego ext: gnutls client unsafe, server break legacy" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003672 "$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 +02003673 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003674 1 \
3675 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3676 -S "server hello, secure renegotiation extension"
3677
Janos Follath0b242342016-02-17 10:11:21 +00003678# Tests for silently dropping trailing extra bytes in .der certificates
3679
3680requires_gnutls
3681run_test "DER format: no trailing bytes" \
3682 "$P_SRV crt_file=data_files/server5-der0.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 a trailing zero byte" \
3690 "$P_SRV crt_file=data_files/server5-der1a.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 a trailing random byte" \
3698 "$P_SRV crt_file=data_files/server5-der1b.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 2 trailing random bytes" \
3706 "$P_SRV crt_file=data_files/server5-der2.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
3712requires_gnutls
3713run_test "DER format: with 4 trailing random bytes" \
3714 "$P_SRV crt_file=data_files/server5-der4.crt \
3715 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003716 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003717 0 \
3718 -c "Handshake was completed" \
3719
3720requires_gnutls
3721run_test "DER format: with 8 trailing random bytes" \
3722 "$P_SRV crt_file=data_files/server5-der8.crt \
3723 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003724 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003725 0 \
3726 -c "Handshake was completed" \
3727
3728requires_gnutls
3729run_test "DER format: with 9 trailing random bytes" \
3730 "$P_SRV crt_file=data_files/server5-der9.crt \
3731 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003732 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003733 0 \
3734 -c "Handshake was completed" \
3735
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003736# Tests for auth_mode
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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003740run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003741 "$P_SRV crt_file=data_files/server5-badsign.crt \
3742 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003743 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003744 1 \
3745 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003746 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003747 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003748 -c "X509 - Certificate verification failed"
3749
Hanno Becker4a156fc2019-06-14 17:07:06 +01003750requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003751requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003752run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003753 "$P_SRV crt_file=data_files/server5-badsign.crt \
3754 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003755 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003756 0 \
3757 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003758 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003759 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003760 -C "X509 - Certificate verification failed"
3761
Hanno Becker4a156fc2019-06-14 17:07:06 +01003762requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003763requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003764run_test "Authentication: server goodcert, client optional, no trusted CA" \
3765 "$P_SRV" \
3766 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3767 0 \
3768 -c "x509_verify_cert() returned" \
3769 -c "! The certificate is not correctly signed by the trusted CA" \
3770 -c "! Certificate verification flags"\
3771 -C "! mbedtls_ssl_handshake returned" \
3772 -C "X509 - Certificate verification failed" \
3773 -C "SSL - No CA Chain is set, but required to operate"
3774
Hanno Becker4a156fc2019-06-14 17:07:06 +01003775requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003776requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003777run_test "Authentication: server goodcert, client required, no trusted CA" \
3778 "$P_SRV" \
3779 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3780 1 \
3781 -c "x509_verify_cert() returned" \
3782 -c "! The certificate is not correctly signed by the trusted CA" \
3783 -c "! Certificate verification flags"\
3784 -c "! mbedtls_ssl_handshake returned" \
3785 -c "SSL - No CA Chain is set, but required to operate"
3786
3787# The purpose of the next two tests is to test the client's behaviour when receiving a server
3788# certificate with an unsupported elliptic curve. This should usually not happen because
3789# the client informs the server about the supported curves - it does, though, in the
3790# corner case of a static ECDH suite, because the server doesn't check the curve on that
3791# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3792# different means to have the server ignoring the client's supported curve list.
3793
3794requires_config_enabled MBEDTLS_ECP_C
3795run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3796 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3797 crt_file=data_files/server5.ku-ka.crt" \
3798 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3799 1 \
3800 -c "bad certificate (EC key curve)"\
3801 -c "! Certificate verification flags"\
3802 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3803
3804requires_config_enabled MBEDTLS_ECP_C
3805run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3806 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3807 crt_file=data_files/server5.ku-ka.crt" \
3808 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3809 1 \
3810 -c "bad certificate (EC key curve)"\
3811 -c "! Certificate verification flags"\
3812 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3813
Jarno Lamsa6ba32ca2019-10-29 15:16:40 +02003814requires_config_enabled MBEDTLS_USE_TINYCRYPT
Jarno Lamsa2e2fa5e2019-10-30 15:08:26 +02003815run_test "Authentication: DTLS server ECDH p256, client required, server goodcert" \
Jarno Lamsa6ba32ca2019-10-29 15:16:40 +02003816 "$P_SRV dtls=1 debug_level=1 key_file=data_files/server11.key.der \
3817 crt_file=data_files/server11.crt.der" \
3818 "$P_CLI dtls=1 debug_level=3 auth_mode=required" \
3819 0 \
3820 -C "bad certificate (EC key curve)"\
3821 -C "! Certificate verification flags"\
3822 -C "! mbedtls_ssl_handshake returned"
3823
3824requires_config_enabled MBEDTLS_USE_TINYCRYPT
Jarno Lamsa2e2fa5e2019-10-30 15:08:26 +02003825run_test "Authentication: DTLS server ECDH p256, client required, server badcert" \
Jarno Lamsa6ba32ca2019-10-29 15:16:40 +02003826 "$P_SRV dtls=1 debug_level=1 key_file=data_files/server11.key.der \
3827 crt_file=data_files/server11-bad.crt.der" \
3828 "$P_CLI dtls=1 debug_level=3 auth_mode=required" \
3829 1 \
3830 -c "! Certificate verification flags"\
3831 -c "! mbedtls_ssl_handshake returned"
3832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003833run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003834 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003835 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003836 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003837 0 \
3838 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003839 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003840 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003841 -C "X509 - Certificate verification failed"
3842
Simon Butcher99000142016-10-13 17:21:01 +01003843run_test "Authentication: client SHA256, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003844 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003845 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3846 key_file=data_files/server6.key \
3847 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3848 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003849 -c "Supported Signature Algorithm found: 5,"
3850
3851run_test "Authentication: client SHA384, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003852 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003853 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3854 key_file=data_files/server6.key \
3855 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3856 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003857 -c "Supported Signature Algorithm found: 5,"
3858
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003859requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3860run_test "Authentication: client has no cert, server required (SSLv3)" \
3861 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3862 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3863 key_file=data_files/server5.key" \
3864 1 \
3865 -S "skip write certificate request" \
3866 -C "skip parse certificate request" \
3867 -c "got a certificate request" \
3868 -c "got no certificate to send" \
3869 -S "x509_verify_cert() returned" \
3870 -s "client has no certificate" \
3871 -s "! mbedtls_ssl_handshake returned" \
3872 -c "! mbedtls_ssl_handshake returned" \
3873 -s "No client certification received from the client, but required by the authentication mode"
3874
3875run_test "Authentication: client has no cert, server required (TLS)" \
3876 "$P_SRV debug_level=3 auth_mode=required" \
3877 "$P_CLI debug_level=3 crt_file=none \
3878 key_file=data_files/server5.key" \
3879 1 \
3880 -S "skip write certificate request" \
3881 -C "skip parse certificate request" \
3882 -c "got a certificate request" \
3883 -c "= write certificate$" \
3884 -C "skip write certificate$" \
3885 -S "x509_verify_cert() returned" \
3886 -s "client has no certificate" \
3887 -s "! mbedtls_ssl_handshake returned" \
3888 -c "! mbedtls_ssl_handshake returned" \
3889 -s "No client certification received from the client, but required by the authentication mode"
3890
Hanno Becker4a156fc2019-06-14 17:07:06 +01003891requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003892requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003893run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003894 "$P_SRV debug_level=3 auth_mode=required" \
3895 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003896 key_file=data_files/server5.key" \
3897 1 \
3898 -S "skip write certificate request" \
3899 -C "skip parse certificate request" \
3900 -c "got a certificate request" \
3901 -C "skip write certificate" \
3902 -C "skip write certificate verify" \
3903 -S "skip parse certificate verify" \
3904 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003905 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003906 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003907 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003908 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003909 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003910# We don't check that the client receives the alert because it might
3911# detect that its write end of the connection is closed and abort
3912# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003913
Hanno Becker4a156fc2019-06-14 17:07:06 +01003914requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003915requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01003916run_test "Authentication: client cert not trusted, server required" \
3917 "$P_SRV debug_level=3 auth_mode=required" \
3918 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3919 key_file=data_files/server5.key" \
3920 1 \
3921 -S "skip write certificate request" \
3922 -C "skip parse certificate request" \
3923 -c "got a certificate request" \
3924 -C "skip write certificate" \
3925 -C "skip write certificate verify" \
3926 -S "skip parse certificate verify" \
3927 -s "x509_verify_cert() returned" \
3928 -s "! The certificate is not correctly signed by the trusted CA" \
3929 -s "! mbedtls_ssl_handshake returned" \
3930 -c "! mbedtls_ssl_handshake returned" \
3931 -s "X509 - Certificate verification failed"
3932
Hanno Becker4a156fc2019-06-14 17:07:06 +01003933requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003934requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003935run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003936 "$P_SRV debug_level=3 auth_mode=optional" \
3937 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003938 key_file=data_files/server5.key" \
3939 0 \
3940 -S "skip write certificate request" \
3941 -C "skip parse certificate request" \
3942 -c "got a certificate request" \
3943 -C "skip write certificate" \
3944 -C "skip write certificate verify" \
3945 -S "skip parse certificate verify" \
3946 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003947 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003948 -S "! mbedtls_ssl_handshake returned" \
3949 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003950 -S "X509 - Certificate verification failed"
3951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003952run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003953 "$P_SRV debug_level=3 auth_mode=none" \
3954 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003955 key_file=data_files/server5.key" \
3956 0 \
3957 -s "skip write certificate request" \
3958 -C "skip parse certificate request" \
3959 -c "got no certificate request" \
3960 -c "skip write certificate" \
3961 -c "skip write certificate verify" \
3962 -s "skip parse certificate verify" \
3963 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003964 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003965 -S "! mbedtls_ssl_handshake returned" \
3966 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003967 -S "X509 - Certificate verification failed"
3968
Hanno Becker4a156fc2019-06-14 17:07:06 +01003969requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003970requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003971run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003972 "$P_SRV debug_level=3 auth_mode=optional" \
3973 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003974 0 \
3975 -S "skip write certificate request" \
3976 -C "skip parse certificate request" \
3977 -c "got a certificate request" \
3978 -C "skip write certificate$" \
3979 -C "got no certificate to send" \
3980 -S "SSLv3 client has no certificate" \
3981 -c "skip write certificate verify" \
3982 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003983 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003984 -S "! mbedtls_ssl_handshake returned" \
3985 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003986 -S "X509 - Certificate verification failed"
3987
Hanno Becker4a156fc2019-06-14 17:07:06 +01003988requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003989requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003990run_test "Authentication: openssl client no cert, server optional" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003991 "$P_SRV debug_level=3 auth_mode=optional ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003992 "$O_CLI" \
3993 0 \
3994 -S "skip write certificate request" \
3995 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003996 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003997 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003998 -S "X509 - Certificate verification failed"
3999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004000run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004001 "$O_SRV -verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004002 "$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 +01004003 0 \
4004 -C "skip parse certificate request" \
4005 -c "got a certificate request" \
4006 -C "skip write certificate$" \
4007 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004008 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004009
Gilles Peskinefd8332e2017-05-03 16:25:07 +02004010run_test "Authentication: client no cert, openssl server required" \
4011 "$O_SRV -Verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004012 "$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 +02004013 1 \
4014 -C "skip parse certificate request" \
4015 -c "got a certificate request" \
4016 -C "skip write certificate$" \
4017 -c "skip write certificate verify" \
4018 -c "! mbedtls_ssl_handshake returned"
4019
Janos Follathe2681a42016-03-07 15:57:05 +00004020requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Hanno Beckerb2c63832019-06-17 08:35:16 +01004021requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004022requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004023run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004024 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004025 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004026 0 \
4027 -S "skip write certificate request" \
4028 -C "skip parse certificate request" \
4029 -c "got a certificate request" \
4030 -C "skip write certificate$" \
4031 -c "skip write certificate verify" \
4032 -c "got no certificate to send" \
4033 -s "SSLv3 client has no certificate" \
4034 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004035 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004036 -S "! mbedtls_ssl_handshake returned" \
4037 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004038 -S "X509 - Certificate verification failed"
4039
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02004040# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
4041# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004042
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004043MAX_IM_CA='8'
Arto Kinnunen78213522019-09-26 11:06:39 +03004044MAX_IM_CA_CONFIG="$( get_config_value_or_default MBEDTLS_X509_MAX_INTERMEDIATE_CA )"
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004045
Angus Grattonc4dd0732018-04-11 16:28:39 +10004046requires_full_size_output_buffer
Arto Kinnunenc457ab12019-09-27 12:00:51 +03004047requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004048run_test "Authentication: server max_int chain, client default" \
4049 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4050 key_file=data_files/dir-maxpath/09.key" \
4051 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4052 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004053 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004054
Angus Grattonc4dd0732018-04-11 16:28:39 +10004055requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004056requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004057run_test "Authentication: server max_int+1 chain, client default" \
4058 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4059 key_file=data_files/dir-maxpath/10.key" \
4060 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4061 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004062 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004063
Angus Grattonc4dd0732018-04-11 16:28:39 +10004064requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004065requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004066run_test "Authentication: server max_int+1 chain, client optional" \
4067 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4068 key_file=data_files/dir-maxpath/10.key" \
4069 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4070 auth_mode=optional" \
4071 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004072 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004073
Angus Grattonc4dd0732018-04-11 16:28:39 +10004074requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004075requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004076run_test "Authentication: server max_int+1 chain, client none" \
4077 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4078 key_file=data_files/dir-maxpath/10.key" \
4079 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4080 auth_mode=none" \
4081 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004082 -C "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+1 chain, server default" \
4086 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4087 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4088 key_file=data_files/dir-maxpath/10.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
Angus Grattonc4dd0732018-04-11 16:28:39 +10004092requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004093run_test "Authentication: client max_int+1 chain, server optional" \
4094 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4095 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4096 key_file=data_files/dir-maxpath/10.key" \
4097 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004098 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004099
Angus Grattonc4dd0732018-04-11 16:28:39 +10004100requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004101run_test "Authentication: client max_int+1 chain, server required" \
4102 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4103 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4104 key_file=data_files/dir-maxpath/10.key" \
4105 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004106 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004107
Angus Grattonc4dd0732018-04-11 16:28:39 +10004108requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004109run_test "Authentication: client max_int chain, server required" \
4110 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4111 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4112 key_file=data_files/dir-maxpath/09.key" \
4113 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004114 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004115
Janos Follath89baba22017-04-10 14:34:35 +01004116# Tests for CA list in CertificateRequest messages
4117
4118run_test "Authentication: send CA list in CertificateRequest (default)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004119 "$P_SRV debug_level=3 auth_mode=required ca_file=data_files/test-ca2.crt" \
Janos Follath89baba22017-04-10 14:34:35 +01004120 "$P_CLI crt_file=data_files/server6.crt \
4121 key_file=data_files/server6.key" \
4122 0 \
4123 -s "requested DN"
4124
4125run_test "Authentication: do not send CA list in CertificateRequest" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004126 "$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 +01004127 "$P_CLI crt_file=data_files/server6.crt \
4128 key_file=data_files/server6.key" \
4129 0 \
4130 -S "requested DN"
4131
Hanno Becker4a156fc2019-06-14 17:07:06 +01004132requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004133requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01004134run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4135 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4136 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4137 key_file=data_files/server5.key" \
4138 1 \
4139 -S "requested DN" \
4140 -s "x509_verify_cert() returned" \
4141 -s "! The certificate is not correctly signed by the trusted CA" \
4142 -s "! mbedtls_ssl_handshake returned" \
4143 -c "! mbedtls_ssl_handshake returned" \
4144 -s "X509 - Certificate verification failed"
4145
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004146# Tests for certificate selection based on SHA verson
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.2 -> SHA-2" \
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_2 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 -> SHA-1" \
4163 "$P_SRV crt_file=data_files/server5.crt \
4164 key_file=data_files/server5.key \
4165 crt_file2=data_files/server5-sha1.crt \
4166 key_file2=data_files/server5.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 "signed using.*ECDSA with SHA256" \
4170 -c "signed using.*ECDSA with SHA1"
4171
Hanno Becker4a156fc2019-06-14 17:07:06 +01004172requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004173requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004174run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4175 "$P_SRV crt_file=data_files/server5.crt \
4176 key_file=data_files/server5.key \
4177 crt_file2=data_files/server5-sha1.crt \
4178 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004179 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004180 0 \
4181 -C "signed using.*ECDSA with SHA256" \
4182 -c "signed using.*ECDSA with SHA1"
4183
Hanno Becker4a156fc2019-06-14 17:07:06 +01004184requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004185requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004186run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4187 "$P_SRV crt_file=data_files/server5.crt \
4188 key_file=data_files/server5.key \
4189 crt_file2=data_files/server6.crt \
4190 key_file2=data_files/server6.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004191 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004192 0 \
4193 -c "serial number.*09" \
4194 -c "signed using.*ECDSA with SHA256" \
4195 -C "signed using.*ECDSA with SHA1"
4196
Hanno Becker4a156fc2019-06-14 17:07:06 +01004197requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004198requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004199run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4200 "$P_SRV crt_file=data_files/server6.crt \
4201 key_file=data_files/server6.key \
4202 crt_file2=data_files/server5.crt \
4203 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004204 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004205 0 \
4206 -c "serial number.*0A" \
4207 -c "signed using.*ECDSA with SHA256" \
4208 -C "signed using.*ECDSA with SHA1"
4209
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004210# tests for SNI
4211
Hanno Becker4a156fc2019-06-14 17:07:06 +01004212requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004213requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004214run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004215 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004216 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004217 "$P_CLI server_name=localhost ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004218 0 \
4219 -S "parse ServerName extension" \
4220 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4221 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004222
Hanno Becker4a156fc2019-06-14 17:07:06 +01004223requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004224requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004225requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004226run_test "SNI: matching cert 1" \
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,-,-,-" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004230 "$P_CLI server_name=localhost ca_file=data_files/test-ca.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004231 0 \
4232 -s "parse ServerName extension" \
4233 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4234 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004235
Hanno Becker4a156fc2019-06-14 17:07:06 +01004236requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004237requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004238requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004239run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004240 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004241 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004242 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 +02004243 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004244 0 \
4245 -s "parse ServerName extension" \
4246 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4247 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004248
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004249requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004250run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004251 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004252 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004253 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 +02004254 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004255 1 \
4256 -s "parse ServerName extension" \
4257 -s "ssl_sni_wrapper() returned" \
4258 -s "mbedtls_ssl_handshake returned" \
4259 -c "mbedtls_ssl_handshake returned" \
4260 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004261
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004262run_test "SNI: client auth no override: optional" \
4263 "$P_SRV debug_level=3 auth_mode=optional \
4264 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4265 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4266 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004267 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004268 -S "skip write certificate request" \
4269 -C "skip parse certificate request" \
4270 -c "got a certificate request" \
4271 -C "skip write certificate" \
4272 -C "skip write certificate verify" \
4273 -S "skip parse certificate verify"
4274
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004275requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004276run_test "SNI: client auth override: none -> optional" \
4277 "$P_SRV debug_level=3 auth_mode=none \
4278 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4279 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4280 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004281 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004282 -S "skip write certificate request" \
4283 -C "skip parse certificate request" \
4284 -c "got a certificate request" \
4285 -C "skip write certificate" \
4286 -C "skip write certificate verify" \
4287 -S "skip parse certificate verify"
4288
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004289requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004290run_test "SNI: client auth override: optional -> none" \
4291 "$P_SRV debug_level=3 auth_mode=optional \
4292 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4293 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4294 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004295 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004296 -s "skip write certificate request" \
4297 -C "skip parse certificate request" \
4298 -c "got no certificate request" \
4299 -c "skip write certificate" \
4300 -c "skip write certificate verify" \
4301 -s "skip parse certificate verify"
4302
Hanno Becker4a156fc2019-06-14 17:07:06 +01004303requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004304requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004305requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004306run_test "SNI: CA no override" \
4307 "$P_SRV debug_level=3 auth_mode=optional \
4308 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4309 ca_file=data_files/test-ca.crt \
4310 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4311 "$P_CLI debug_level=3 server_name=localhost \
4312 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4313 1 \
4314 -S "skip write certificate request" \
4315 -C "skip parse certificate request" \
4316 -c "got a certificate request" \
4317 -C "skip write certificate" \
4318 -C "skip write certificate verify" \
4319 -S "skip parse certificate verify" \
4320 -s "x509_verify_cert() returned" \
4321 -s "! The certificate is not correctly signed by the trusted CA" \
4322 -S "The certificate has been revoked (is on a CRL)"
4323
Hanno Becker4a156fc2019-06-14 17:07:06 +01004324requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004325requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004326requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004327run_test "SNI: CA override" \
4328 "$P_SRV debug_level=3 auth_mode=optional \
4329 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4330 ca_file=data_files/test-ca.crt \
4331 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4332 "$P_CLI debug_level=3 server_name=localhost \
4333 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4334 0 \
4335 -S "skip write certificate request" \
4336 -C "skip parse certificate request" \
4337 -c "got a certificate request" \
4338 -C "skip write certificate" \
4339 -C "skip write certificate verify" \
4340 -S "skip parse certificate verify" \
4341 -S "x509_verify_cert() returned" \
4342 -S "! The certificate is not correctly signed by the trusted CA" \
4343 -S "The certificate has been revoked (is on a CRL)"
4344
Hanno Becker4a156fc2019-06-14 17:07:06 +01004345requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004346requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004347requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004348run_test "SNI: CA override with CRL" \
4349 "$P_SRV debug_level=3 auth_mode=optional \
4350 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4351 ca_file=data_files/test-ca.crt \
4352 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4353 "$P_CLI debug_level=3 server_name=localhost \
4354 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4355 1 \
4356 -S "skip write certificate request" \
4357 -C "skip parse certificate request" \
4358 -c "got a certificate request" \
4359 -C "skip write certificate" \
4360 -C "skip write certificate verify" \
4361 -S "skip parse certificate verify" \
4362 -s "x509_verify_cert() returned" \
4363 -S "! The certificate is not correctly signed by the trusted CA" \
4364 -s "The certificate has been revoked (is on a CRL)"
4365
Andres AG1a834452016-12-07 10:01:30 +00004366# Tests for SNI and DTLS
4367
Hanno Becker4a156fc2019-06-14 17:07:06 +01004368requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004369requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004370run_test "SNI: DTLS, no SNI callback" \
4371 "$P_SRV debug_level=3 dtls=1 \
4372 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004373 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca2.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004374 0 \
4375 -S "parse ServerName extension" \
4376 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4377 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4378
Hanno Becker4a156fc2019-06-14 17:07:06 +01004379requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004380requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004381requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004382run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004383 "$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,-,-,-" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004386 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca.crt" \
Andres AG1a834452016-12-07 10:01:30 +00004387 0 \
4388 -s "parse ServerName extension" \
4389 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4390 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4391
Hanno Becker4a156fc2019-06-14 17:07:06 +01004392requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004393requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004394requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004395run_test "SNI: DTLS, matching cert 2" \
4396 "$P_SRV debug_level=3 dtls=1 \
4397 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4398 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 +01004399 "$P_CLI server_name=polarssl.example dtls=1 ca_file=data_files/test-ca.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004400 0 \
4401 -s "parse ServerName extension" \
4402 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4403 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4404
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004405requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004406run_test "SNI: DTLS, no matching cert" \
4407 "$P_SRV debug_level=3 dtls=1 \
4408 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4409 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4410 "$P_CLI server_name=nonesuch.example dtls=1" \
4411 1 \
4412 -s "parse ServerName extension" \
4413 -s "ssl_sni_wrapper() returned" \
4414 -s "mbedtls_ssl_handshake returned" \
4415 -c "mbedtls_ssl_handshake returned" \
4416 -c "SSL - A fatal alert message was received from our peer"
4417
4418run_test "SNI: DTLS, client auth no override: optional" \
4419 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4420 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4421 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4422 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4423 0 \
4424 -S "skip write certificate request" \
4425 -C "skip parse certificate request" \
4426 -c "got a certificate request" \
4427 -C "skip write certificate" \
4428 -C "skip write certificate verify" \
4429 -S "skip parse certificate verify"
4430
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004431requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004432run_test "SNI: DTLS, client auth override: none -> optional" \
4433 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4434 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4435 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4436 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4437 0 \
4438 -S "skip write certificate request" \
4439 -C "skip parse certificate request" \
4440 -c "got a certificate request" \
4441 -C "skip write certificate" \
4442 -C "skip write certificate verify" \
4443 -S "skip parse certificate verify"
4444
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004445requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004446run_test "SNI: DTLS, client auth override: optional -> none" \
4447 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4448 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4449 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4450 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4451 0 \
4452 -s "skip write certificate request" \
4453 -C "skip parse certificate request" \
4454 -c "got no certificate request" \
4455 -c "skip write certificate" \
4456 -c "skip write certificate verify" \
4457 -s "skip parse certificate verify"
4458
Hanno Becker4a156fc2019-06-14 17:07:06 +01004459requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004460requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004461requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004462run_test "SNI: DTLS, CA no override" \
4463 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4464 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4465 ca_file=data_files/test-ca.crt \
4466 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4467 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4468 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4469 1 \
4470 -S "skip write certificate request" \
4471 -C "skip parse certificate request" \
4472 -c "got a certificate request" \
4473 -C "skip write certificate" \
4474 -C "skip write certificate verify" \
4475 -S "skip parse certificate verify" \
4476 -s "x509_verify_cert() returned" \
4477 -s "! The certificate is not correctly signed by the trusted CA" \
4478 -S "The certificate has been revoked (is on a CRL)"
4479
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004480requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004481run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004482 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4483 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4484 ca_file=data_files/test-ca.crt \
4485 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4486 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4487 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4488 0 \
4489 -S "skip write certificate request" \
4490 -C "skip parse certificate request" \
4491 -c "got a certificate request" \
4492 -C "skip write certificate" \
4493 -C "skip write certificate verify" \
4494 -S "skip parse certificate verify" \
4495 -S "x509_verify_cert() returned" \
4496 -S "! The certificate is not correctly signed by the trusted CA" \
4497 -S "The certificate has been revoked (is on a CRL)"
4498
Hanno Becker4a156fc2019-06-14 17:07:06 +01004499requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004500requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004501requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004502run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004503 "$P_SRV debug_level=3 auth_mode=optional \
4504 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4505 ca_file=data_files/test-ca.crt \
4506 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4507 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4508 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4509 1 \
4510 -S "skip write certificate request" \
4511 -C "skip parse certificate request" \
4512 -c "got a certificate request" \
4513 -C "skip write certificate" \
4514 -C "skip write certificate verify" \
4515 -S "skip parse certificate verify" \
4516 -s "x509_verify_cert() returned" \
4517 -S "! The certificate is not correctly signed by the trusted CA" \
4518 -s "The certificate has been revoked (is on a CRL)"
4519
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004520# Tests for non-blocking I/O: exercise a variety of handshake flows
4521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004522run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004523 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4524 "$P_CLI nbio=2 tickets=0" \
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: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004531 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4532 "$P_CLI nbio=2 tickets=0" \
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" \
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" \
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: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004547 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4548 "$P_CLI nbio=2 tickets=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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004554run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004555 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4556 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4557 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004558 -S "mbedtls_ssl_handshake returned" \
4559 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004560 -c "Read from server: .* bytes read"
4561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004562run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004563 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4564 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4565 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004566 -S "mbedtls_ssl_handshake returned" \
4567 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004568 -c "Read from server: .* bytes read"
4569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004570run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004571 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4572 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4573 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004574 -S "mbedtls_ssl_handshake returned" \
4575 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004576 -c "Read from server: .* bytes read"
4577
Hanno Becker00076712017-11-15 16:39:08 +00004578# Tests for event-driven I/O: exercise a variety of handshake flows
4579
4580run_test "Event-driven I/O: basic handshake" \
4581 "$P_SRV event=1 tickets=0 auth_mode=none" \
4582 "$P_CLI event=1 tickets=0" \
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: client auth" \
4589 "$P_SRV event=1 tickets=0 auth_mode=required" \
4590 "$P_CLI event=1 tickets=0" \
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" \
4597 "$P_SRV event=1 tickets=1 auth_mode=none" \
4598 "$P_CLI event=1 tickets=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: ticket + client auth" \
4605 "$P_SRV event=1 tickets=1 auth_mode=required" \
4606 "$P_CLI event=1 tickets=1" \
4607 0 \
4608 -S "mbedtls_ssl_handshake returned" \
4609 -C "mbedtls_ssl_handshake returned" \
4610 -c "Read from server: .* bytes read"
4611
4612run_test "Event-driven I/O: ticket + client auth + resume" \
4613 "$P_SRV event=1 tickets=1 auth_mode=required" \
4614 "$P_CLI event=1 tickets=1 reconnect=1" \
4615 0 \
4616 -S "mbedtls_ssl_handshake returned" \
4617 -C "mbedtls_ssl_handshake returned" \
4618 -c "Read from server: .* bytes read"
4619
4620run_test "Event-driven I/O: ticket + resume" \
4621 "$P_SRV event=1 tickets=1 auth_mode=none" \
4622 "$P_CLI event=1 tickets=1 reconnect=1" \
4623 0 \
4624 -S "mbedtls_ssl_handshake returned" \
4625 -C "mbedtls_ssl_handshake returned" \
4626 -c "Read from server: .* bytes read"
4627
4628run_test "Event-driven I/O: session-id resume" \
4629 "$P_SRV event=1 tickets=0 auth_mode=none" \
4630 "$P_CLI event=1 tickets=0 reconnect=1" \
4631 0 \
4632 -S "mbedtls_ssl_handshake returned" \
4633 -C "mbedtls_ssl_handshake returned" \
4634 -c "Read from server: .* bytes read"
4635
Hanno Becker6a33f592018-03-13 11:38:46 +00004636run_test "Event-driven I/O, DTLS: basic handshake" \
4637 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4638 "$P_CLI dtls=1 event=1 tickets=0" \
4639 0 \
4640 -c "Read from server: .* bytes read"
4641
4642run_test "Event-driven I/O, DTLS: client auth" \
4643 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4644 "$P_CLI dtls=1 event=1 tickets=0" \
4645 0 \
4646 -c "Read from server: .* bytes read"
4647
4648run_test "Event-driven I/O, DTLS: ticket" \
4649 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4650 "$P_CLI dtls=1 event=1 tickets=1" \
4651 0 \
4652 -c "Read from server: .* bytes read"
4653
4654run_test "Event-driven I/O, DTLS: ticket + client auth" \
4655 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4656 "$P_CLI dtls=1 event=1 tickets=1" \
4657 0 \
4658 -c "Read from server: .* bytes read"
4659
4660run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4661 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4662 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4663 0 \
4664 -c "Read from server: .* bytes read"
4665
4666run_test "Event-driven I/O, DTLS: ticket + resume" \
4667 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4668 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
4669 0 \
4670 -c "Read from server: .* bytes read"
4671
4672run_test "Event-driven I/O, DTLS: session-id resume" \
4673 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4674 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4675 0 \
4676 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004677
4678# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4679# During session resumption, the client will send its ApplicationData record
4680# within the same datagram as the Finished messages. In this situation, the
4681# server MUST NOT idle on the underlying transport after handshake completion,
4682# because the ApplicationData request has already been queued internally.
4683run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004684 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004685 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4686 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
4687 0 \
4688 -c "Read from server: .* bytes read"
4689
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004690# Tests for version negotiation
4691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004692run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004693 "$P_SRV" \
4694 "$P_CLI" \
4695 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004696 -S "mbedtls_ssl_handshake returned" \
4697 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004698 -s "Protocol is TLSv1.2" \
4699 -c "Protocol is TLSv1.2"
4700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004701run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004702 "$P_SRV" \
4703 "$P_CLI max_version=tls1_1" \
4704 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004705 -S "mbedtls_ssl_handshake returned" \
4706 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004707 -s "Protocol is TLSv1.1" \
4708 -c "Protocol is TLSv1.1"
4709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004710run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004711 "$P_SRV max_version=tls1_1" \
4712 "$P_CLI" \
4713 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004714 -S "mbedtls_ssl_handshake returned" \
4715 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004716 -s "Protocol is TLSv1.1" \
4717 -c "Protocol is TLSv1.1"
4718
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004719run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004720 "$P_SRV max_version=tls1_1" \
4721 "$P_CLI max_version=tls1_1" \
4722 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004723 -S "mbedtls_ssl_handshake returned" \
4724 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004725 -s "Protocol is TLSv1.1" \
4726 -c "Protocol is TLSv1.1"
4727
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004728run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004729 "$P_SRV min_version=tls1_1" \
4730 "$P_CLI max_version=tls1_1" \
4731 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004732 -S "mbedtls_ssl_handshake returned" \
4733 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004734 -s "Protocol is TLSv1.1" \
4735 -c "Protocol is TLSv1.1"
4736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004737run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004738 "$P_SRV max_version=tls1_1" \
4739 "$P_CLI min_version=tls1_1" \
4740 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004741 -S "mbedtls_ssl_handshake returned" \
4742 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004743 -s "Protocol is TLSv1.1" \
4744 -c "Protocol is TLSv1.1"
4745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004746run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004747 "$P_SRV max_version=tls1_1" \
4748 "$P_CLI min_version=tls1_2" \
4749 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004750 -s "mbedtls_ssl_handshake returned" \
4751 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004752 -c "SSL - Handshake protocol not within min/max boundaries"
4753
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004754run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004755 "$P_SRV min_version=tls1_2" \
4756 "$P_CLI max_version=tls1_1" \
4757 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004758 -s "mbedtls_ssl_handshake returned" \
4759 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004760 -s "SSL - Handshake protocol not within min/max boundaries"
4761
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004762# Tests for ALPN extension
4763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004764run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004765 "$P_SRV debug_level=3" \
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"
4775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004776run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004777 "$P_SRV debug_level=3" \
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 (none)" \
4786 -S "Application Layer Protocol is"
4787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004788run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004789 "$P_SRV debug_level=3 alpn=abc,1234" \
4790 "$P_CLI debug_level=3" \
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" \
4798 -s "Application Layer Protocol is (none)"
4799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004800run_test "ALPN: both, common cli1-srv1" \
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=abc,1234" \
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 abc" \
4810 -s "Application Layer Protocol is abc"
4811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004812run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004813 "$P_SRV debug_level=3 alpn=abc,1234" \
4814 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004815 0 \
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 abc" \
4822 -s "Application Layer Protocol is abc"
4823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004824run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004825 "$P_SRV debug_level=3 alpn=abc,1234" \
4826 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004827 0 \
4828 -c "client hello, adding alpn extension" \
4829 -s "found alpn extension" \
4830 -C "got an alert message, type: \\[2:120]" \
4831 -s "server hello, adding alpn extension" \
4832 -c "found alpn extension" \
4833 -c "Application Layer Protocol is 1234" \
4834 -s "Application Layer Protocol is 1234"
4835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004836run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004837 "$P_SRV debug_level=3 alpn=abc,123" \
4838 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004839 1 \
4840 -c "client hello, adding alpn extension" \
4841 -s "found alpn extension" \
4842 -c "got an alert message, type: \\[2:120]" \
4843 -S "server hello, adding alpn extension" \
4844 -C "found alpn extension" \
4845 -C "Application Layer Protocol is 1234" \
4846 -S "Application Layer Protocol is 1234"
4847
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02004848
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004849# Tests for keyUsage in leaf certificates, part 1:
4850# server-side certificate/suite selection
4851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004852run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004853 "$P_SRV key_file=data_files/server2.key \
4854 crt_file=data_files/server2.ku-ds.crt" \
4855 "$P_CLI" \
4856 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02004857 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004858
4859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004860run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004861 "$P_SRV key_file=data_files/server2.key \
4862 crt_file=data_files/server2.ku-ke.crt" \
4863 "$P_CLI" \
4864 0 \
4865 -c "Ciphersuite is TLS-RSA-WITH-"
4866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004867run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004868 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004869 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004870 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004871 1 \
4872 -C "Ciphersuite is "
4873
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004874run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004875 "$P_SRV key_file=data_files/server5.key \
4876 crt_file=data_files/server5.ku-ds.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004877 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004878 0 \
4879 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
4880
Jarno Lamsac5118b72019-10-28 10:30:58 +02004881run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA p256" \
4882 "$P_SRV dtls=1 key_file=data_files/server11.key.der \
4883 crt_file=data_files/server11.crt.der" \
4884 "$P_CLI dtls=1 ca_file=data_files/test-ca3.crt.der" \
4885 0 \
4886 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004888run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004889 "$P_SRV key_file=data_files/server5.key \
4890 crt_file=data_files/server5.ku-ka.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004891 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004892 0 \
4893 -c "Ciphersuite is TLS-ECDH-"
4894
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004895run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004896 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004897 crt_file=data_files/server5.ku-ke.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004898 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004899 1 \
4900 -C "Ciphersuite is "
4901
4902# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004903# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004905run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004906 "$O_SRV -key data_files/server2.key \
4907 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004908 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004909 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4910 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004911 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004912 -C "Processing of the Certificate handshake message failed" \
4913 -c "Ciphersuite is TLS-"
4914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004915run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004916 "$O_SRV -key data_files/server2.key \
4917 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004918 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004919 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4920 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004921 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004922 -C "Processing of the Certificate handshake message failed" \
4923 -c "Ciphersuite is TLS-"
4924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004925run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004926 "$O_SRV -key data_files/server2.key \
4927 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004928 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004929 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4930 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004931 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004932 -C "Processing of the Certificate handshake message failed" \
4933 -c "Ciphersuite is TLS-"
4934
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004935run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004936 "$O_SRV -key data_files/server2.key \
4937 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004938 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004939 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4940 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004941 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004942 -c "Processing of the Certificate handshake message failed" \
4943 -C "Ciphersuite is TLS-"
4944
Hanno Becker4a156fc2019-06-14 17:07:06 +01004945requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004946requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004947run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
4948 "$O_SRV -key data_files/server2.key \
4949 -cert data_files/server2.ku-ke.crt" \
4950 "$P_CLI debug_level=1 auth_mode=optional \
4951 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4952 0 \
4953 -c "bad certificate (usage extensions)" \
4954 -C "Processing of the Certificate handshake message failed" \
4955 -c "Ciphersuite is TLS-" \
4956 -c "! Usage does not match the keyUsage extension"
4957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004958run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004959 "$O_SRV -key data_files/server2.key \
4960 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004961 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004962 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4963 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004964 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004965 -C "Processing of the Certificate handshake message failed" \
4966 -c "Ciphersuite is TLS-"
4967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004968run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004969 "$O_SRV -key data_files/server2.key \
4970 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004971 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004972 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4973 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004974 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004975 -c "Processing of the Certificate handshake message failed" \
4976 -C "Ciphersuite is TLS-"
4977
Hanno Becker4a156fc2019-06-14 17:07:06 +01004978requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004979requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004980run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
4981 "$O_SRV -key data_files/server2.key \
4982 -cert data_files/server2.ku-ds.crt" \
4983 "$P_CLI debug_level=1 auth_mode=optional \
4984 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4985 0 \
4986 -c "bad certificate (usage extensions)" \
4987 -C "Processing of the Certificate handshake message failed" \
4988 -c "Ciphersuite is TLS-" \
4989 -c "! Usage does not match the keyUsage extension"
4990
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004991# Tests for keyUsage in leaf certificates, part 3:
4992# server-side checking of client cert
4993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004994run_test "keyUsage cli-auth: RSA, 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/server2.key \
4997 -cert data_files/server2.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: RSA, KeyEncipherment: 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/server2.key \
5005 -cert data_files/server2.ku-ke.crt" \
5006 0 \
5007 -s "bad certificate (usage extensions)" \
5008 -S "Processing of the Certificate handshake message failed"
5009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005010run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005011 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005012 "$O_CLI -key data_files/server2.key \
5013 -cert data_files/server2.ku-ke.crt" \
5014 1 \
5015 -s "bad certificate (usage extensions)" \
5016 -s "Processing of the Certificate handshake message failed"
5017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005018run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005019 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005020 "$O_CLI -key data_files/server5.key \
5021 -cert data_files/server5.ku-ds.crt" \
5022 0 \
5023 -S "bad certificate (usage extensions)" \
5024 -S "Processing of the Certificate handshake message failed"
5025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005026run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005027 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005028 "$O_CLI -key data_files/server5.key \
5029 -cert data_files/server5.ku-ka.crt" \
5030 0 \
5031 -s "bad certificate (usage extensions)" \
5032 -S "Processing of the Certificate handshake message failed"
5033
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005034# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
5035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005036run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005037 "$P_SRV key_file=data_files/server5.key \
5038 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005039 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005040 0
5041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005042run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005043 "$P_SRV key_file=data_files/server5.key \
5044 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005045 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005046 0
5047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005048run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005049 "$P_SRV key_file=data_files/server5.key \
5050 crt_file=data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005051 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005052 0
5053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005054run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005055 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005056 crt_file=data_files/server5.eku-cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005057 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005058 1
5059
5060# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005062run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005063 "$O_SRV -key data_files/server5.key \
5064 -cert data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005065 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005066 0 \
5067 -C "bad certificate (usage extensions)" \
5068 -C "Processing of the Certificate handshake message failed" \
5069 -c "Ciphersuite is TLS-"
5070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005071run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005072 "$O_SRV -key data_files/server5.key \
5073 -cert data_files/server5.eku-srv_cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005074 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005075 0 \
5076 -C "bad certificate (usage extensions)" \
5077 -C "Processing of the Certificate handshake message failed" \
5078 -c "Ciphersuite is TLS-"
5079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005080run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005081 "$O_SRV -key data_files/server5.key \
5082 -cert data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005083 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005084 0 \
5085 -C "bad certificate (usage extensions)" \
5086 -C "Processing of the Certificate handshake message failed" \
5087 -c "Ciphersuite is TLS-"
5088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005089run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005090 "$O_SRV -key data_files/server5.key \
5091 -cert data_files/server5.eku-cs.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005092 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005093 1 \
5094 -c "bad certificate (usage extensions)" \
5095 -c "Processing of the Certificate handshake message failed" \
5096 -C "Ciphersuite is TLS-"
5097
5098# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005100run_test "extKeyUsage cli-auth: clientAuth -> OK" \
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-cli.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: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005109 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005110 "$O_CLI -key data_files/server5.key \
5111 -cert data_files/server5.eku-srv_cli.crt" \
5112 0 \
5113 -S "bad certificate (usage extensions)" \
5114 -S "Processing of the Certificate handshake message failed"
5115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005116run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005117 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005118 "$O_CLI -key data_files/server5.key \
5119 -cert data_files/server5.eku-cs_any.crt" \
5120 0 \
5121 -S "bad certificate (usage extensions)" \
5122 -S "Processing of the Certificate handshake message failed"
5123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005124run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005125 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005126 "$O_CLI -key data_files/server5.key \
5127 -cert data_files/server5.eku-cs.crt" \
5128 0 \
5129 -s "bad certificate (usage extensions)" \
5130 -S "Processing of the Certificate handshake message failed"
5131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005132run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005133 "$P_SRV debug_level=1 auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005134 "$O_CLI -key data_files/server5.key \
5135 -cert data_files/server5.eku-cs.crt" \
5136 1 \
5137 -s "bad certificate (usage extensions)" \
5138 -s "Processing of the Certificate handshake message failed"
5139
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005140# Tests for DHM parameters loading
5141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005142run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005143 "$P_SRV" \
5144 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5145 debug_level=3" \
5146 0 \
5147 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005148 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005149
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005150run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005151 "$P_SRV dhm_file=data_files/dhparams.pem" \
5152 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5153 debug_level=3" \
5154 0 \
5155 -c "value of 'DHM: P ' (1024 bits)" \
5156 -c "value of 'DHM: G ' (2 bits)"
5157
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005158# Tests for DHM client-side size checking
5159
5160run_test "DHM size: server default, client default, OK" \
5161 "$P_SRV" \
5162 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5163 debug_level=1" \
5164 0 \
5165 -C "DHM prime too short:"
5166
5167run_test "DHM size: server default, client 2048, OK" \
5168 "$P_SRV" \
5169 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5170 debug_level=1 dhmlen=2048" \
5171 0 \
5172 -C "DHM prime too short:"
5173
5174run_test "DHM size: server 1024, client default, OK" \
5175 "$P_SRV dhm_file=data_files/dhparams.pem" \
5176 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5177 debug_level=1" \
5178 0 \
5179 -C "DHM prime too short:"
5180
5181run_test "DHM size: server 1000, client default, rejected" \
5182 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5183 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5184 debug_level=1" \
5185 1 \
5186 -c "DHM prime too short:"
5187
5188run_test "DHM size: server default, client 2049, rejected" \
5189 "$P_SRV" \
5190 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5191 debug_level=1 dhmlen=2049" \
5192 1 \
5193 -c "DHM prime too short:"
5194
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005195# Tests for PSK callback
5196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005197run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005198 "$P_SRV psk=abc123 psk_identity=foo" \
5199 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5200 psk_identity=foo psk=abc123" \
5201 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005202 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005203 -S "SSL - Unknown identity received" \
5204 -S "SSL - Verification of the message MAC failed"
5205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005206run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005207 "$P_SRV" \
5208 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5209 psk_identity=foo psk=abc123" \
5210 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005211 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005212 -S "SSL - Unknown identity received" \
5213 -S "SSL - Verification of the message MAC failed"
5214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005215run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005216 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5217 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5218 psk_identity=foo psk=abc123" \
5219 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005220 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005221 -s "SSL - Unknown identity received" \
5222 -S "SSL - Verification of the message MAC failed"
5223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005224run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005225 "$P_SRV psk_list=abc,dead,def,beef" \
5226 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5227 psk_identity=abc psk=dead" \
5228 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005229 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005230 -S "SSL - Unknown identity received" \
5231 -S "SSL - Verification of the message MAC failed"
5232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005233run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005234 "$P_SRV psk_list=abc,dead,def,beef" \
5235 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5236 psk_identity=def psk=beef" \
5237 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005238 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005239 -S "SSL - Unknown identity received" \
5240 -S "SSL - Verification of the message MAC failed"
5241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005242run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005243 "$P_SRV psk_list=abc,dead,def,beef" \
5244 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5245 psk_identity=ghi psk=beef" \
5246 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005247 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005248 -s "SSL - Unknown identity received" \
5249 -S "SSL - Verification of the message MAC failed"
5250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005251run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005252 "$P_SRV psk_list=abc,dead,def,beef" \
5253 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5254 psk_identity=abc psk=beef" \
5255 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005256 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005257 -S "SSL - Unknown identity received" \
5258 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005259
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005260# Tests for EC J-PAKE
5261
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005262requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005263run_test "ECJPAKE: client not configured" \
5264 "$P_SRV debug_level=3" \
5265 "$P_CLI debug_level=3" \
5266 0 \
5267 -C "add ciphersuite: c0ff" \
5268 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005269 -S "found ecjpake kkpp extension" \
5270 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005271 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005272 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005273 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005274 -S "None of the common ciphersuites is usable"
5275
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005276requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005277run_test "ECJPAKE: server not configured" \
5278 "$P_SRV debug_level=3" \
5279 "$P_CLI debug_level=3 ecjpake_pw=bla \
5280 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5281 1 \
5282 -c "add ciphersuite: c0ff" \
5283 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005284 -s "found ecjpake kkpp extension" \
5285 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005286 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005287 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005288 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005289 -s "None of the common ciphersuites is usable"
5290
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005291requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005292run_test "ECJPAKE: working, TLS" \
5293 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5294 "$P_CLI debug_level=3 ecjpake_pw=bla \
5295 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005296 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005297 -c "add ciphersuite: c0ff" \
5298 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005299 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005300 -s "found ecjpake kkpp extension" \
5301 -S "skip ecjpake kkpp extension" \
5302 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005303 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005304 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005305 -S "None of the common ciphersuites is usable" \
5306 -S "SSL - Verification of the message MAC failed"
5307
Janos Follath74537a62016-09-02 13:45:28 +01005308server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005309requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005310run_test "ECJPAKE: password mismatch, TLS" \
5311 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5312 "$P_CLI debug_level=3 ecjpake_pw=bad \
5313 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5314 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005315 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005316 -s "SSL - Verification of the message MAC failed"
5317
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005318requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005319run_test "ECJPAKE: working, DTLS" \
5320 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5321 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5322 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5323 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005324 -c "re-using cached ecjpake parameters" \
5325 -S "SSL - Verification of the message MAC failed"
5326
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005327requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005328run_test "ECJPAKE: working, DTLS, no cookie" \
5329 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5330 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5331 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5332 0 \
5333 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005334 -S "SSL - Verification of the message MAC failed"
5335
Janos Follath74537a62016-09-02 13:45:28 +01005336server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005337requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005338run_test "ECJPAKE: password mismatch, DTLS" \
5339 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5340 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5341 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5342 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005343 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005344 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005345
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005346# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005347requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005348run_test "ECJPAKE: working, DTLS, nolog" \
5349 "$P_SRV dtls=1 ecjpake_pw=bla" \
5350 "$P_CLI dtls=1 ecjpake_pw=bla \
5351 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5352 0
5353
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005354# Tests for ciphersuites per version
5355
Janos Follathe2681a42016-03-07 15:57:05 +00005356requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005357requires_config_enabled MBEDTLS_CAMELLIA_C
5358requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005359run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005360 "$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 +02005361 "$P_CLI force_version=ssl3" \
5362 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005363 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005364
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005365requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5366requires_config_enabled MBEDTLS_CAMELLIA_C
5367requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005368run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005369 "$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 +01005370 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005371 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005372 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005373
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005374requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5375requires_config_enabled MBEDTLS_CAMELLIA_C
5376requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005377run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005378 "$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 +02005379 "$P_CLI force_version=tls1_1" \
5380 0 \
5381 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5382
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005383requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5384requires_config_enabled MBEDTLS_CAMELLIA_C
5385requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005386run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005387 "$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 +02005388 "$P_CLI force_version=tls1_2" \
5389 0 \
5390 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5391
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005392# Test for ClientHello without extensions
5393
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005394requires_gnutls
Manuel Pégourié-Gonnardd817f542020-01-30 12:45:14 +01005395run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7006ca12020-01-30 10:58:57 +01005396 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005397 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005398 0 \
5399 -s "dumping 'client hello extensions' (0 bytes)"
5400
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005401# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005402
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005403run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005404 "$P_SRV" \
5405 "$P_CLI request_size=100" \
5406 0 \
5407 -s "Read from client: 100 bytes read$"
5408
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005409run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005410 "$P_SRV" \
5411 "$P_CLI request_size=500" \
5412 0 \
5413 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005414
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005415# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005416
Janos Follathe2681a42016-03-07 15:57:05 +00005417requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005418run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005419 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005420 "$P_CLI request_size=1 force_version=ssl3 \
5421 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5422 0 \
5423 -s "Read from client: 1 bytes read"
5424
Janos Follathe2681a42016-03-07 15:57:05 +00005425requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005426run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005427 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005428 "$P_CLI request_size=1 force_version=ssl3 \
5429 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5430 0 \
5431 -s "Read from client: 1 bytes read"
5432
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005433run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005434 "$P_SRV" \
5435 "$P_CLI request_size=1 force_version=tls1 \
5436 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5437 0 \
5438 -s "Read from client: 1 bytes read"
5439
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005440run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005441 "$P_SRV" \
5442 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5443 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5444 0 \
5445 -s "Read from client: 1 bytes read"
5446
Hanno Becker32c55012017-11-10 08:42:54 +00005447requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005448run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005449 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005450 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005451 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005452 0 \
5453 -s "Read from client: 1 bytes read"
5454
Hanno Becker32c55012017-11-10 08:42:54 +00005455requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005456run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005457 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005458 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005459 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005460 0 \
5461 -s "Read from client: 1 bytes read"
5462
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005463run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005464 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005465 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005466 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5467 0 \
5468 -s "Read from client: 1 bytes read"
5469
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005470run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005471 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5472 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005473 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005474 0 \
5475 -s "Read from client: 1 bytes read"
5476
5477requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005478run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005479 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005480 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005481 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005482 0 \
5483 -s "Read from client: 1 bytes read"
5484
Hanno Becker8501f982017-11-10 08:59:04 +00005485requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005486run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005487 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5488 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5489 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005490 0 \
5491 -s "Read from client: 1 bytes read"
5492
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005493run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005494 "$P_SRV" \
5495 "$P_CLI request_size=1 force_version=tls1_1 \
5496 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5497 0 \
5498 -s "Read from client: 1 bytes read"
5499
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005500run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005501 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005502 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005503 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005504 0 \
5505 -s "Read from client: 1 bytes read"
5506
5507requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005508run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005509 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005510 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005511 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005512 0 \
5513 -s "Read from client: 1 bytes read"
5514
5515requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005516run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005517 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005518 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005519 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005520 0 \
5521 -s "Read from client: 1 bytes read"
5522
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005523run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005524 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005525 "$P_CLI request_size=1 force_version=tls1_1 \
5526 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5527 0 \
5528 -s "Read from client: 1 bytes read"
5529
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005530run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005531 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005532 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005533 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005534 0 \
5535 -s "Read from client: 1 bytes read"
5536
Hanno Becker8501f982017-11-10 08:59:04 +00005537requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005538run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005539 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005540 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005541 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005542 0 \
5543 -s "Read from client: 1 bytes read"
5544
Hanno Becker32c55012017-11-10 08:42:54 +00005545requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005546run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005547 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005548 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005549 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005550 0 \
5551 -s "Read from client: 1 bytes read"
5552
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005553run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005554 "$P_SRV" \
5555 "$P_CLI request_size=1 force_version=tls1_2 \
5556 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5557 0 \
5558 -s "Read from client: 1 bytes read"
5559
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005560run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005561 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005562 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005563 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005564 0 \
5565 -s "Read from client: 1 bytes read"
5566
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005567run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005568 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005569 "$P_CLI request_size=1 force_version=tls1_2 \
5570 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005571 0 \
5572 -s "Read from client: 1 bytes read"
5573
Hanno Becker32c55012017-11-10 08:42:54 +00005574requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005575run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005576 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005577 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005578 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005579 0 \
5580 -s "Read from client: 1 bytes read"
5581
Hanno Becker8501f982017-11-10 08:59:04 +00005582requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005583run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005584 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005585 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005586 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005587 0 \
5588 -s "Read from client: 1 bytes read"
5589
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005590run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005591 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005592 "$P_CLI request_size=1 force_version=tls1_2 \
5593 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5594 0 \
5595 -s "Read from client: 1 bytes read"
5596
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005597run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005598 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005599 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005600 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005601 0 \
5602 -s "Read from client: 1 bytes read"
5603
Hanno Becker32c55012017-11-10 08:42:54 +00005604requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005605run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005606 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005607 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005608 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005609 0 \
5610 -s "Read from client: 1 bytes read"
5611
Hanno Becker8501f982017-11-10 08:59:04 +00005612requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005613run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005614 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005615 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005616 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005617 0 \
5618 -s "Read from client: 1 bytes read"
5619
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005620run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005621 "$P_SRV" \
5622 "$P_CLI request_size=1 force_version=tls1_2 \
5623 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5624 0 \
5625 -s "Read from client: 1 bytes read"
5626
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005627run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005628 "$P_SRV" \
5629 "$P_CLI request_size=1 force_version=tls1_2 \
5630 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5631 0 \
5632 -s "Read from client: 1 bytes read"
5633
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005634# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005635
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005636run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005637 "$P_SRV dtls=1 force_version=dtls1" \
5638 "$P_CLI dtls=1 request_size=1 \
5639 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5640 0 \
5641 -s "Read from client: 1 bytes read"
5642
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005643run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00005644 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
5645 "$P_CLI dtls=1 request_size=1 \
5646 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5647 0 \
5648 -s "Read from client: 1 bytes read"
5649
Hanno Beckere2148042017-11-10 08:59:18 +00005650requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005651run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005652 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
5653 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00005654 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5655 0 \
5656 -s "Read from client: 1 bytes read"
5657
Hanno Beckere2148042017-11-10 08:59:18 +00005658requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005659run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005660 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005661 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005662 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005663 0 \
5664 -s "Read from client: 1 bytes read"
5665
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005666run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00005667 "$P_SRV dtls=1 force_version=dtls1_2" \
5668 "$P_CLI dtls=1 request_size=1 \
5669 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5670 0 \
5671 -s "Read from client: 1 bytes read"
5672
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005673run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005674 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005675 "$P_CLI dtls=1 request_size=1 \
5676 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5677 0 \
5678 -s "Read from client: 1 bytes read"
5679
Hanno Beckere2148042017-11-10 08:59:18 +00005680requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005681run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005682 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005683 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005684 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005685 0 \
5686 -s "Read from client: 1 bytes read"
5687
Hanno Beckere2148042017-11-10 08:59:18 +00005688requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005689run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005690 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005691 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005692 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005693 0 \
5694 -s "Read from client: 1 bytes read"
5695
Jarno Lamsa0ed68082019-10-28 14:10:59 +02005696run_test "Small client packet DTLS, ECDHE-ECDSA" \
5697 "$P_SRV dtls=1" \
5698 "$P_CLI dtls=1 request_size=1 \
5699 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
5700 0 \
5701 -s "Read from client: 1 bytes read"
5702
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005703# Tests for small server packets
5704
5705requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5706run_test "Small server packet SSLv3 BlockCipher" \
5707 "$P_SRV response_size=1 min_version=ssl3" \
5708 "$P_CLI force_version=ssl3 \
5709 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5710 0 \
5711 -c "Read from server: 1 bytes read"
5712
5713requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5714run_test "Small server packet SSLv3 StreamCipher" \
5715 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5716 "$P_CLI force_version=ssl3 \
5717 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5718 0 \
5719 -c "Read from server: 1 bytes read"
5720
5721run_test "Small server packet TLS 1.0 BlockCipher" \
5722 "$P_SRV response_size=1" \
5723 "$P_CLI force_version=tls1 \
5724 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5725 0 \
5726 -c "Read from server: 1 bytes read"
5727
5728run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
5729 "$P_SRV response_size=1" \
5730 "$P_CLI force_version=tls1 etm=0 \
5731 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5732 0 \
5733 -c "Read from server: 1 bytes read"
5734
5735requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5736run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
5737 "$P_SRV response_size=1 trunc_hmac=1" \
5738 "$P_CLI force_version=tls1 \
5739 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5740 0 \
5741 -c "Read from server: 1 bytes read"
5742
5743requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5744run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
5745 "$P_SRV response_size=1 trunc_hmac=1" \
5746 "$P_CLI force_version=tls1 \
5747 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5748 0 \
5749 -c "Read from server: 1 bytes read"
5750
5751run_test "Small server packet TLS 1.0 StreamCipher" \
5752 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5753 "$P_CLI force_version=tls1 \
5754 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5755 0 \
5756 -c "Read from server: 1 bytes read"
5757
5758run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
5759 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5760 "$P_CLI force_version=tls1 \
5761 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5762 0 \
5763 -c "Read from server: 1 bytes read"
5764
5765requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5766run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
5767 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5768 "$P_CLI force_version=tls1 \
5769 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5770 0 \
5771 -c "Read from server: 1 bytes read"
5772
5773requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5774run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5775 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5776 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5777 trunc_hmac=1 etm=0" \
5778 0 \
5779 -c "Read from server: 1 bytes read"
5780
5781run_test "Small server packet TLS 1.1 BlockCipher" \
5782 "$P_SRV response_size=1" \
5783 "$P_CLI force_version=tls1_1 \
5784 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5785 0 \
5786 -c "Read from server: 1 bytes read"
5787
5788run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
5789 "$P_SRV response_size=1" \
5790 "$P_CLI force_version=tls1_1 \
5791 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5792 0 \
5793 -c "Read from server: 1 bytes read"
5794
5795requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5796run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
5797 "$P_SRV response_size=1 trunc_hmac=1" \
5798 "$P_CLI force_version=tls1_1 \
5799 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5800 0 \
5801 -c "Read from server: 1 bytes read"
5802
5803requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5804run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5805 "$P_SRV response_size=1 trunc_hmac=1" \
5806 "$P_CLI force_version=tls1_1 \
5807 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5808 0 \
5809 -c "Read from server: 1 bytes read"
5810
5811run_test "Small server packet TLS 1.1 StreamCipher" \
5812 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5813 "$P_CLI force_version=tls1_1 \
5814 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5815 0 \
5816 -c "Read from server: 1 bytes read"
5817
5818run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
5819 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5820 "$P_CLI force_version=tls1_1 \
5821 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5822 0 \
5823 -c "Read from server: 1 bytes read"
5824
5825requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5826run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
5827 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5828 "$P_CLI force_version=tls1_1 \
5829 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5830 0 \
5831 -c "Read from server: 1 bytes read"
5832
5833requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5834run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5835 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5836 "$P_CLI force_version=tls1_1 \
5837 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5838 0 \
5839 -c "Read from server: 1 bytes read"
5840
5841run_test "Small server packet TLS 1.2 BlockCipher" \
5842 "$P_SRV response_size=1" \
5843 "$P_CLI force_version=tls1_2 \
5844 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5845 0 \
5846 -c "Read from server: 1 bytes read"
5847
5848run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5849 "$P_SRV response_size=1" \
5850 "$P_CLI force_version=tls1_2 \
5851 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5852 0 \
5853 -c "Read from server: 1 bytes read"
5854
5855run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5856 "$P_SRV response_size=1" \
5857 "$P_CLI force_version=tls1_2 \
5858 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5859 0 \
5860 -c "Read from server: 1 bytes read"
5861
5862requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5863run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5864 "$P_SRV response_size=1 trunc_hmac=1" \
5865 "$P_CLI force_version=tls1_2 \
5866 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5867 0 \
5868 -c "Read from server: 1 bytes read"
5869
5870requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5871run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5872 "$P_SRV response_size=1 trunc_hmac=1" \
5873 "$P_CLI force_version=tls1_2 \
5874 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5875 0 \
5876 -c "Read from server: 1 bytes read"
5877
5878run_test "Small server packet TLS 1.2 StreamCipher" \
5879 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5880 "$P_CLI force_version=tls1_2 \
5881 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5882 0 \
5883 -c "Read from server: 1 bytes read"
5884
5885run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
5886 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5887 "$P_CLI force_version=tls1_2 \
5888 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5889 0 \
5890 -c "Read from server: 1 bytes read"
5891
5892requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5893run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
5894 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5895 "$P_CLI force_version=tls1_2 \
5896 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5897 0 \
5898 -c "Read from server: 1 bytes read"
5899
5900requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5901run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5902 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5903 "$P_CLI force_version=tls1_2 \
5904 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5905 0 \
5906 -c "Read from server: 1 bytes read"
5907
5908run_test "Small server packet TLS 1.2 AEAD" \
5909 "$P_SRV response_size=1" \
5910 "$P_CLI force_version=tls1_2 \
5911 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5912 0 \
5913 -c "Read from server: 1 bytes read"
5914
5915run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5916 "$P_SRV response_size=1" \
5917 "$P_CLI force_version=tls1_2 \
5918 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5919 0 \
5920 -c "Read from server: 1 bytes read"
5921
5922# Tests for small server packets in DTLS
5923
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005924run_test "Small server packet DTLS 1.0" \
5925 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
5926 "$P_CLI dtls=1 \
5927 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5928 0 \
5929 -c "Read from server: 1 bytes read"
5930
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005931run_test "Small server packet DTLS 1.0, without EtM" \
5932 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
5933 "$P_CLI dtls=1 \
5934 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5935 0 \
5936 -c "Read from server: 1 bytes read"
5937
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005938requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5939run_test "Small server packet DTLS 1.0, truncated hmac" \
5940 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
5941 "$P_CLI dtls=1 trunc_hmac=1 \
5942 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5943 0 \
5944 -c "Read from server: 1 bytes read"
5945
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005946requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5947run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
5948 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
5949 "$P_CLI dtls=1 \
5950 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5951 0 \
5952 -c "Read from server: 1 bytes read"
5953
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005954run_test "Small server packet DTLS 1.2" \
5955 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
5956 "$P_CLI dtls=1 \
5957 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5958 0 \
5959 -c "Read from server: 1 bytes read"
5960
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005961run_test "Small server packet DTLS 1.2, without EtM" \
5962 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5963 "$P_CLI dtls=1 \
5964 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5965 0 \
5966 -c "Read from server: 1 bytes read"
5967
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005968requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5969run_test "Small server packet DTLS 1.2, truncated hmac" \
5970 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5971 "$P_CLI dtls=1 \
5972 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5973 0 \
5974 -c "Read from server: 1 bytes read"
5975
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005976requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5977run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5978 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5979 "$P_CLI dtls=1 \
5980 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5981 0 \
5982 -c "Read from server: 1 bytes read"
5983
Jarno Lamsac40184b2019-10-28 14:16:12 +02005984run_test "Small server packet DTLS, ECDHE-ECDSA" \
5985 "$P_SRV dtls=1 response_size=1" \
5986 "$P_CLI dtls=1 \
5987 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
5988 0 \
5989 -c "Read from server: 1 bytes read"
5990
Janos Follath00efff72016-05-06 13:48:23 +01005991# A test for extensions in SSLv3
5992
5993requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5994run_test "SSLv3 with extensions, server side" \
5995 "$P_SRV min_version=ssl3 debug_level=3" \
5996 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
5997 0 \
5998 -S "dumping 'client hello extensions'" \
5999 -S "server hello, total extension length:"
6000
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006001# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006002
Angus Grattonc4dd0732018-04-11 16:28:39 +10006003# How many fragments do we expect to write $1 bytes?
6004fragments_for_write() {
6005 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
6006}
6007
Janos Follathe2681a42016-03-07 15:57:05 +00006008requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006009run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01006010 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006011 "$P_CLI request_size=16384 force_version=ssl3 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
Janos Follathe2681a42016-03-07 15:57:05 +00006017requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006018run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006019 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006020 "$P_CLI request_size=16384 force_version=ssl3 \
6021 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6022 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006023 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6024 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006025
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006026run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006027 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006028 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006029 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6030 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006031 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6032 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006033
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006034run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006035 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006036 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
6037 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6038 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
Hanno Becker32c55012017-11-10 08:42:54 +00006041requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006042run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006043 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006044 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006045 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006046 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006047 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6048 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006049
Hanno Becker32c55012017-11-10 08:42:54 +00006050requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006051run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006052 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006053 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006054 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006055 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006056 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006057
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006058run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006059 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006060 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006061 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6062 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006063 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006064
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006065run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006066 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6067 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006068 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006069 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006070 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006071
6072requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006073run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006074 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006075 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006076 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006077 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006078 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006079
Hanno Becker278fc7a2017-11-10 09:16:28 +00006080requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006081run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006082 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006083 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006084 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006085 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006086 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6087 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006088
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006089run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006090 "$P_SRV" \
6091 "$P_CLI request_size=16384 force_version=tls1_1 \
6092 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6093 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006094 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6095 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006096
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006097run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006098 "$P_SRV" \
6099 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6100 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006101 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006102 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006103
Hanno Becker32c55012017-11-10 08:42:54 +00006104requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006105run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006106 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006107 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006108 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006109 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006110 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006111
Hanno Becker32c55012017-11-10 08:42:54 +00006112requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006113run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006114 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006115 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006116 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006117 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006118 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006119
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006120run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006121 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6122 "$P_CLI request_size=16384 force_version=tls1_1 \
6123 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6124 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006125 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6126 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006127
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006128run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006129 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006130 "$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 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
Hanno Becker278fc7a2017-11-10 09:16:28 +00006136requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006137run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006138 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006139 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006140 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006141 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006142 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006143
Hanno Becker278fc7a2017-11-10 09:16:28 +00006144requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006145run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006146 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006147 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006148 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006149 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006150 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6151 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006152
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006153run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006154 "$P_SRV" \
6155 "$P_CLI request_size=16384 force_version=tls1_2 \
6156 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6157 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006158 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6159 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006160
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006161run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006162 "$P_SRV" \
6163 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6164 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6165 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006166 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006167
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006168run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006169 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006170 "$P_CLI request_size=16384 force_version=tls1_2 \
6171 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
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
Hanno Becker32c55012017-11-10 08:42:54 +00006176requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006177run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006178 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006179 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006180 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006181 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006182 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006183
Hanno Becker278fc7a2017-11-10 09:16:28 +00006184requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006185run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006186 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006187 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006188 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006189 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006190 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6191 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006192
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006193run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006194 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006195 "$P_CLI request_size=16384 force_version=tls1_2 \
6196 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6197 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006198 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6199 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006200
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006201run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006202 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006203 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006204 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6205 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006206 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006207
Hanno Becker32c55012017-11-10 08:42:54 +00006208requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006209run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006210 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006211 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006212 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006213 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006214 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006215
Hanno Becker278fc7a2017-11-10 09:16:28 +00006216requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006217run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006218 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006219 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006220 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006221 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006222 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6223 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006224
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006225run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006226 "$P_SRV" \
6227 "$P_CLI request_size=16384 force_version=tls1_2 \
6228 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6229 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006230 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6231 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006232
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006233run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006234 "$P_SRV" \
6235 "$P_CLI request_size=16384 force_version=tls1_2 \
6236 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6237 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006238 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6239 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006240
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006241# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006242requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6243run_test "Large server packet SSLv3 StreamCipher" \
6244 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6245 "$P_CLI force_version=ssl3 \
6246 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6247 0 \
6248 -c "Read from server: 16384 bytes read"
6249
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006250# Checking next 4 tests logs for 1n-1 split against BEAST too
6251requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6252run_test "Large server packet SSLv3 BlockCipher" \
6253 "$P_SRV response_size=16384 min_version=ssl3" \
6254 "$P_CLI force_version=ssl3 recsplit=0 \
6255 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6256 0 \
6257 -c "Read from server: 1 bytes read"\
6258 -c "16383 bytes read"\
6259 -C "Read from server: 16384 bytes read"
6260
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006261run_test "Large server packet TLS 1.0 BlockCipher" \
6262 "$P_SRV response_size=16384" \
6263 "$P_CLI force_version=tls1 recsplit=0 \
6264 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6265 0 \
6266 -c "Read from server: 1 bytes read"\
6267 -c "16383 bytes read"\
6268 -C "Read from server: 16384 bytes read"
6269
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006270run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6271 "$P_SRV response_size=16384" \
6272 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6273 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6274 0 \
6275 -c "Read from server: 1 bytes read"\
6276 -c "16383 bytes read"\
6277 -C "Read from server: 16384 bytes read"
6278
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006279requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6280run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6281 "$P_SRV response_size=16384" \
6282 "$P_CLI force_version=tls1 recsplit=0 \
6283 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6284 trunc_hmac=1" \
6285 0 \
6286 -c "Read from server: 1 bytes read"\
6287 -c "16383 bytes read"\
6288 -C "Read from server: 16384 bytes read"
6289
6290requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6291run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
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 \
6295 trunc_hmac=1" \
6296 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006297 -s "16384 bytes written in 1 fragments" \
6298 -c "Read from server: 16384 bytes read"
6299
6300run_test "Large server packet TLS 1.0 StreamCipher" \
6301 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6302 "$P_CLI force_version=tls1 \
6303 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6304 0 \
6305 -s "16384 bytes written in 1 fragments" \
6306 -c "Read from server: 16384 bytes read"
6307
6308run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6309 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6310 "$P_CLI force_version=tls1 \
6311 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6312 0 \
6313 -s "16384 bytes written in 1 fragments" \
6314 -c "Read from server: 16384 bytes read"
6315
6316requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6317run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6318 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6319 "$P_CLI force_version=tls1 \
6320 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6321 0 \
6322 -s "16384 bytes written in 1 fragments" \
6323 -c "Read from server: 16384 bytes read"
6324
6325requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6326run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6327 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6328 "$P_CLI force_version=tls1 \
6329 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6330 0 \
6331 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006332 -c "Read from server: 16384 bytes read"
6333
6334run_test "Large server packet TLS 1.1 BlockCipher" \
6335 "$P_SRV response_size=16384" \
6336 "$P_CLI force_version=tls1_1 \
6337 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6338 0 \
6339 -c "Read from server: 16384 bytes read"
6340
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006341run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6342 "$P_SRV response_size=16384" \
6343 "$P_CLI force_version=tls1_1 etm=0 \
6344 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006345 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006346 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006347 -c "Read from server: 16384 bytes read"
6348
6349requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6350run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6351 "$P_SRV response_size=16384" \
6352 "$P_CLI force_version=tls1_1 \
6353 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6354 trunc_hmac=1" \
6355 0 \
6356 -c "Read from server: 16384 bytes read"
6357
6358requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006359run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6360 "$P_SRV response_size=16384 trunc_hmac=1" \
6361 "$P_CLI force_version=tls1_1 \
6362 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6363 0 \
6364 -s "16384 bytes written in 1 fragments" \
6365 -c "Read from server: 16384 bytes read"
6366
6367run_test "Large server packet TLS 1.1 StreamCipher" \
6368 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6369 "$P_CLI force_version=tls1_1 \
6370 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6371 0 \
6372 -c "Read from server: 16384 bytes read"
6373
6374run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6375 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6376 "$P_CLI force_version=tls1_1 \
6377 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6378 0 \
6379 -s "16384 bytes written in 1 fragments" \
6380 -c "Read from server: 16384 bytes read"
6381
6382requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006383run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6384 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6385 "$P_CLI force_version=tls1_1 \
6386 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6387 trunc_hmac=1" \
6388 0 \
6389 -c "Read from server: 16384 bytes read"
6390
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006391run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6392 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6393 "$P_CLI force_version=tls1_1 \
6394 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6395 0 \
6396 -s "16384 bytes written in 1 fragments" \
6397 -c "Read from server: 16384 bytes read"
6398
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006399run_test "Large server packet TLS 1.2 BlockCipher" \
6400 "$P_SRV response_size=16384" \
6401 "$P_CLI force_version=tls1_2 \
6402 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6403 0 \
6404 -c "Read from server: 16384 bytes read"
6405
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006406run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6407 "$P_SRV response_size=16384" \
6408 "$P_CLI force_version=tls1_2 etm=0 \
6409 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6410 0 \
6411 -s "16384 bytes written in 1 fragments" \
6412 -c "Read from server: 16384 bytes read"
6413
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006414run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6415 "$P_SRV response_size=16384" \
6416 "$P_CLI force_version=tls1_2 \
6417 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6418 0 \
6419 -c "Read from server: 16384 bytes read"
6420
6421requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6422run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6423 "$P_SRV response_size=16384" \
6424 "$P_CLI force_version=tls1_2 \
6425 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6426 trunc_hmac=1" \
6427 0 \
6428 -c "Read from server: 16384 bytes read"
6429
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006430run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6431 "$P_SRV response_size=16384 trunc_hmac=1" \
6432 "$P_CLI force_version=tls1_2 \
6433 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6434 0 \
6435 -s "16384 bytes written in 1 fragments" \
6436 -c "Read from server: 16384 bytes read"
6437
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006438run_test "Large server packet TLS 1.2 StreamCipher" \
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 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006443 -s "16384 bytes written in 1 fragments" \
6444 -c "Read from server: 16384 bytes read"
6445
6446run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6447 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6448 "$P_CLI force_version=tls1_2 \
6449 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6450 0 \
6451 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006452 -c "Read from server: 16384 bytes read"
6453
6454requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6455run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6456 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6457 "$P_CLI force_version=tls1_2 \
6458 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6459 trunc_hmac=1" \
6460 0 \
6461 -c "Read from server: 16384 bytes read"
6462
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006463requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6464run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6465 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6466 "$P_CLI force_version=tls1_2 \
6467 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6468 0 \
6469 -s "16384 bytes written in 1 fragments" \
6470 -c "Read from server: 16384 bytes read"
6471
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006472run_test "Large server packet TLS 1.2 AEAD" \
6473 "$P_SRV response_size=16384" \
6474 "$P_CLI force_version=tls1_2 \
6475 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6476 0 \
6477 -c "Read from server: 16384 bytes read"
6478
6479run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6480 "$P_SRV response_size=16384" \
6481 "$P_CLI force_version=tls1_2 \
6482 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6483 0 \
6484 -c "Read from server: 16384 bytes read"
6485
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006486# Tests for restartable ECC
6487
6488requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6489run_test "EC restart: TLS, default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006490 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006491 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006492 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006493 debug_level=1" \
6494 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006495 -C "x509_verify_cert.*4b00" \
6496 -C "mbedtls_pk_verify.*4b00" \
6497 -C "mbedtls_ecdh_make_public.*4b00" \
6498 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006499
6500requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6501run_test "EC restart: TLS, max_ops=0" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006502 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006503 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006504 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006505 debug_level=1 ec_max_ops=0" \
6506 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006507 -C "x509_verify_cert.*4b00" \
6508 -C "mbedtls_pk_verify.*4b00" \
6509 -C "mbedtls_ecdh_make_public.*4b00" \
6510 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006511
6512requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6513run_test "EC restart: TLS, max_ops=65535" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006514 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006515 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006516 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006517 debug_level=1 ec_max_ops=65535" \
6518 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006519 -C "x509_verify_cert.*4b00" \
6520 -C "mbedtls_pk_verify.*4b00" \
6521 -C "mbedtls_ecdh_make_public.*4b00" \
6522 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006523
6524requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6525run_test "EC restart: TLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006526 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006527 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006528 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006529 debug_level=1 ec_max_ops=1000" \
6530 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006531 -c "x509_verify_cert.*4b00" \
6532 -c "mbedtls_pk_verify.*4b00" \
6533 -c "mbedtls_ecdh_make_public.*4b00" \
6534 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006535
6536requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Hanno Becker4a156fc2019-06-14 17:07:06 +01006537requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006538run_test "EC restart: TLS, max_ops=1000, badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006539 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006540 crt_file=data_files/server5-badsign.crt \
6541 key_file=data_files/server5.key" \
6542 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker03d77462019-08-27 16:24:56 +01006543 key_file=data_files/server5.key crt_file=data_files/server5.crt ca_file=data_files/test-ca2.crt \
6544 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" \
Hanno Becker03d77462019-08-27 16:24:56 +01006547 -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" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006551
Hanno Becker4a156fc2019-06-14 17:07:06 +01006552requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006553requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6554run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006555 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006556 crt_file=data_files/server5-badsign.crt \
6557 key_file=data_files/server5.key" \
6558 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6559 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006560 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006561 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6562 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006563 -c "x509_verify_cert.*4b00" \
6564 -c "mbedtls_pk_verify.*4b00" \
6565 -c "mbedtls_ecdh_make_public.*4b00" \
6566 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006567 -c "! The certificate is not correctly signed by the trusted CA" \
6568 -C "! mbedtls_ssl_handshake returned" \
6569 -C "X509 - Certificate verification failed"
6570
Hanno Becker4a156fc2019-06-14 17:07:06 +01006571requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006572requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006573requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6574run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006575 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006576 crt_file=data_files/server5-badsign.crt \
6577 key_file=data_files/server5.key" \
6578 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006579 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006580 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6581 debug_level=1 ec_max_ops=1000 auth_mode=none" \
6582 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006583 -C "x509_verify_cert.*4b00" \
6584 -c "mbedtls_pk_verify.*4b00" \
6585 -c "mbedtls_ecdh_make_public.*4b00" \
6586 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006587 -C "! The certificate is not correctly signed by the trusted CA" \
6588 -C "! mbedtls_ssl_handshake returned" \
6589 -C "X509 - Certificate verification failed"
6590
6591requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006592run_test "EC restart: DTLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006593 "$P_SRV auth_mode=required dtls=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006594 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006595 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006596 dtls=1 debug_level=1 ec_max_ops=1000" \
6597 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006598 -c "x509_verify_cert.*4b00" \
6599 -c "mbedtls_pk_verify.*4b00" \
6600 -c "mbedtls_ecdh_make_public.*4b00" \
6601 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006602
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006603requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6604run_test "EC restart: TLS, max_ops=1000 no client auth" \
6605 "$P_SRV" \
6606 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6607 debug_level=1 ec_max_ops=1000" \
6608 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006609 -c "x509_verify_cert.*4b00" \
6610 -c "mbedtls_pk_verify.*4b00" \
6611 -c "mbedtls_ecdh_make_public.*4b00" \
6612 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006613
6614requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6615run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6616 "$P_SRV psk=abc123" \
6617 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6618 psk=abc123 debug_level=1 ec_max_ops=1000" \
6619 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006620 -C "x509_verify_cert.*4b00" \
6621 -C "mbedtls_pk_verify.*4b00" \
6622 -C "mbedtls_ecdh_make_public.*4b00" \
6623 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006624
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006625# Tests of asynchronous private key support in SSL
6626
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006627requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006628run_test "SSL async private: sign, delay=0" \
6629 "$P_SRV \
6630 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006631 "$P_CLI" \
6632 0 \
6633 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006634 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006635
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006636requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006637run_test "SSL async private: sign, delay=1" \
6638 "$P_SRV \
6639 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006640 "$P_CLI" \
6641 0 \
6642 -s "Async sign callback: using key slot " \
6643 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006644 -s "Async resume (slot [0-9]): sign done, status=0"
6645
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006646requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6647run_test "SSL async private: sign, delay=2" \
6648 "$P_SRV \
6649 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6650 "$P_CLI" \
6651 0 \
6652 -s "Async sign callback: using key slot " \
6653 -U "Async sign callback: using key slot " \
6654 -s "Async resume (slot [0-9]): call 1 more times." \
6655 -s "Async resume (slot [0-9]): call 0 more times." \
6656 -s "Async resume (slot [0-9]): sign done, status=0"
6657
Gilles Peskined3268832018-04-26 06:23:59 +02006658# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
6659# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
6660requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6661requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6662run_test "SSL async private: sign, RSA, TLS 1.1" \
6663 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
6664 async_operations=s async_private_delay1=0 async_private_delay2=0" \
6665 "$P_CLI force_version=tls1_1" \
6666 0 \
6667 -s "Async sign callback: using key slot " \
6668 -s "Async resume (slot [0-9]): sign done, status=0"
6669
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006670requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerb2c63832019-06-17 08:35:16 +01006671requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03006672requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006673requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskine807d74a2018-04-30 10:30:49 +02006674run_test "SSL async private: sign, SNI" \
6675 "$P_SRV debug_level=3 \
6676 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6677 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6678 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6679 "$P_CLI server_name=polarssl.example" \
6680 0 \
6681 -s "Async sign callback: using key slot " \
6682 -s "Async resume (slot [0-9]): sign done, status=0" \
6683 -s "parse ServerName extension" \
6684 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6685 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6686
6687requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006688run_test "SSL async private: decrypt, delay=0" \
6689 "$P_SRV \
6690 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6691 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6692 0 \
6693 -s "Async decrypt callback: using key slot " \
6694 -s "Async resume (slot [0-9]): decrypt done, status=0"
6695
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006696requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006697run_test "SSL async private: decrypt, delay=1" \
6698 "$P_SRV \
6699 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6700 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6701 0 \
6702 -s "Async decrypt callback: using key slot " \
6703 -s "Async resume (slot [0-9]): call 0 more times." \
6704 -s "Async resume (slot [0-9]): decrypt done, status=0"
6705
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006706requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006707run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6708 "$P_SRV psk=abc123 \
6709 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6710 "$P_CLI psk=abc123 \
6711 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6712 0 \
6713 -s "Async decrypt callback: using key slot " \
6714 -s "Async resume (slot [0-9]): decrypt done, status=0"
6715
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006716requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006717run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6718 "$P_SRV psk=abc123 \
6719 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6720 "$P_CLI psk=abc123 \
6721 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6722 0 \
6723 -s "Async decrypt callback: using key slot " \
6724 -s "Async resume (slot [0-9]): call 0 more times." \
6725 -s "Async resume (slot [0-9]): decrypt done, status=0"
6726
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006727requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006728run_test "SSL async private: sign callback not present" \
6729 "$P_SRV \
6730 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6731 "$P_CLI; [ \$? -eq 1 ] &&
6732 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6733 0 \
6734 -S "Async sign callback" \
6735 -s "! mbedtls_ssl_handshake returned" \
6736 -s "The own private key or pre-shared key is not set, but needed" \
6737 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6738 -s "Successful connection"
6739
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006740requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006741run_test "SSL async private: decrypt callback not present" \
6742 "$P_SRV debug_level=1 \
6743 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6744 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6745 [ \$? -eq 1 ] && $P_CLI" \
6746 0 \
6747 -S "Async decrypt callback" \
6748 -s "! mbedtls_ssl_handshake returned" \
6749 -s "got no RSA private key" \
6750 -s "Async resume (slot [0-9]): sign done, status=0" \
6751 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006752
6753# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006754requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006755run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006756 "$P_SRV \
6757 async_operations=s async_private_delay1=1 \
6758 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6759 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006760 "$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 +01006761 0 \
6762 -s "Async sign callback: using key slot 0," \
6763 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006764 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006765
6766# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006767requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006768run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006769 "$P_SRV \
6770 async_operations=s async_private_delay2=1 \
6771 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6772 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006773 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6774 0 \
6775 -s "Async sign callback: using key slot 0," \
6776 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006777 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006778
6779# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006780requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006781run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006782 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006783 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006784 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6785 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006786 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6787 0 \
6788 -s "Async sign callback: using key slot 1," \
6789 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006790 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006791
6792# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006793requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006794run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006795 "$P_SRV \
6796 async_operations=s async_private_delay1=1 \
6797 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6798 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006799 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6800 0 \
6801 -s "Async sign callback: no key matches this certificate."
6802
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006803requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006804run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006805 "$P_SRV \
6806 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6807 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006808 "$P_CLI" \
6809 1 \
6810 -s "Async sign callback: injected error" \
6811 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006812 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006813 -s "! mbedtls_ssl_handshake returned"
6814
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006815requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006816run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006817 "$P_SRV \
6818 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6819 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006820 "$P_CLI" \
6821 1 \
6822 -s "Async sign callback: using key slot " \
6823 -S "Async resume" \
6824 -s "Async cancel"
6825
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006826requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006827run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006828 "$P_SRV \
6829 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6830 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006831 "$P_CLI" \
6832 1 \
6833 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006834 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006835 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006836 -s "! mbedtls_ssl_handshake returned"
6837
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006838requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006839run_test "SSL async private: decrypt, error in start" \
6840 "$P_SRV \
6841 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6842 async_private_error=1" \
6843 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6844 1 \
6845 -s "Async decrypt callback: injected error" \
6846 -S "Async resume" \
6847 -S "Async cancel" \
6848 -s "! mbedtls_ssl_handshake returned"
6849
6850requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6851run_test "SSL async private: decrypt, cancel after start" \
6852 "$P_SRV \
6853 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6854 async_private_error=2" \
6855 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6856 1 \
6857 -s "Async decrypt callback: using key slot " \
6858 -S "Async resume" \
6859 -s "Async cancel"
6860
6861requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6862run_test "SSL async private: decrypt, error in resume" \
6863 "$P_SRV \
6864 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6865 async_private_error=3" \
6866 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6867 1 \
6868 -s "Async decrypt callback: using key slot " \
6869 -s "Async resume callback: decrypt done but injected error" \
6870 -S "Async cancel" \
6871 -s "! mbedtls_ssl_handshake returned"
6872
6873requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006874run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006875 "$P_SRV \
6876 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6877 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006878 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6879 0 \
6880 -s "Async cancel" \
6881 -s "! mbedtls_ssl_handshake returned" \
6882 -s "Async resume" \
6883 -s "Successful connection"
6884
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006885requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006886run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006887 "$P_SRV \
6888 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6889 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006890 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6891 0 \
6892 -s "! mbedtls_ssl_handshake returned" \
6893 -s "Async resume" \
6894 -s "Successful connection"
6895
6896# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006897requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006898run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006899 "$P_SRV \
6900 async_operations=s async_private_delay1=1 async_private_error=-2 \
6901 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6902 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006903 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6904 [ \$? -eq 1 ] &&
6905 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6906 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006907 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006908 -S "Async resume" \
6909 -s "Async cancel" \
6910 -s "! mbedtls_ssl_handshake returned" \
6911 -s "Async sign callback: no key matches this certificate." \
6912 -s "Successful connection"
6913
6914# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006915requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006916run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006917 "$P_SRV \
6918 async_operations=s async_private_delay1=1 async_private_error=-3 \
6919 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6920 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006921 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6922 [ \$? -eq 1 ] &&
6923 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6924 0 \
6925 -s "Async resume" \
6926 -s "! mbedtls_ssl_handshake returned" \
6927 -s "Async sign callback: no key matches this certificate." \
6928 -s "Successful connection"
6929
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006930requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006931requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006932run_test "SSL async private: renegotiation: client-initiated; sign" \
6933 "$P_SRV \
6934 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006935 exchanges=2 renegotiation=1" \
6936 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6937 0 \
6938 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006939 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006940
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006941requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006942requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006943run_test "SSL async private: renegotiation: server-initiated; sign" \
6944 "$P_SRV \
6945 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006946 exchanges=2 renegotiation=1 renegotiate=1" \
6947 "$P_CLI exchanges=2 renegotiation=1" \
6948 0 \
6949 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006950 -s "Async resume (slot [0-9]): sign done, status=0"
6951
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006952requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006953requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6954run_test "SSL async private: renegotiation: client-initiated; decrypt" \
6955 "$P_SRV \
6956 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6957 exchanges=2 renegotiation=1" \
6958 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6959 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6960 0 \
6961 -s "Async decrypt callback: using key slot " \
6962 -s "Async resume (slot [0-9]): decrypt done, status=0"
6963
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006964requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006965requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6966run_test "SSL async private: renegotiation: server-initiated; decrypt" \
6967 "$P_SRV \
6968 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6969 exchanges=2 renegotiation=1 renegotiate=1" \
6970 "$P_CLI exchanges=2 renegotiation=1 \
6971 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6972 0 \
6973 -s "Async decrypt callback: using key slot " \
6974 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006975
Ron Eldor58093c82018-06-28 13:22:05 +03006976# Tests for ECC extensions (rfc 4492)
6977
Ron Eldor643df7c2018-06-28 16:17:00 +03006978requires_config_enabled MBEDTLS_AES_C
6979requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6980requires_config_enabled MBEDTLS_SHA256_C
6981requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006982run_test "Force a non ECC ciphersuite in the client side" \
6983 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006984 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006985 0 \
6986 -C "client hello, adding supported_elliptic_curves extension" \
6987 -C "client hello, adding supported_point_formats extension" \
6988 -S "found supported elliptic curves extension" \
6989 -S "found supported point formats extension"
6990
Ron Eldor643df7c2018-06-28 16:17:00 +03006991requires_config_enabled MBEDTLS_AES_C
6992requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6993requires_config_enabled MBEDTLS_SHA256_C
6994requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006995run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006996 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006997 "$P_CLI debug_level=3" \
6998 0 \
6999 -C "found supported_point_formats extension" \
7000 -S "server hello, supported_point_formats extension"
7001
Ron Eldor643df7c2018-06-28 16:17:00 +03007002requires_config_enabled MBEDTLS_AES_C
7003requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7004requires_config_enabled MBEDTLS_SHA256_C
7005requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007006run_test "Force an ECC ciphersuite in the client side" \
7007 "$P_SRV debug_level=3" \
7008 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7009 0 \
7010 -c "client hello, adding supported_elliptic_curves extension" \
7011 -c "client hello, adding supported_point_formats extension" \
7012 -s "found supported elliptic curves extension" \
7013 -s "found supported point formats extension"
7014
Ron Eldor643df7c2018-06-28 16:17:00 +03007015requires_config_enabled MBEDTLS_AES_C
7016requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7017requires_config_enabled MBEDTLS_SHA256_C
7018requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007019run_test "Force an ECC ciphersuite in the server side" \
7020 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7021 "$P_CLI debug_level=3" \
7022 0 \
7023 -c "found supported_point_formats extension" \
7024 -s "server hello, supported_point_formats extension"
7025
Jarno Lamsa2e2fa5e2019-10-30 15:08:26 +02007026requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
Jarno Lamsad3428052019-10-28 14:36:37 +02007027run_test "Force an ECC ciphersuite with CCM in the client side" \
7028 "$P_SRV dtls=1 debug_level=3" \
7029 "$P_CLI dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
7030 0 \
7031 -c "client hello, adding supported_elliptic_curves extension" \
7032 -c "client hello, adding supported_point_formats extension" \
7033 -s "found supported elliptic curves extension" \
7034 -s "found supported point formats extension"
7035
Jarno Lamsa2e2fa5e2019-10-30 15:08:26 +02007036requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
Jarno Lamsad3428052019-10-28 14:36:37 +02007037run_test "Force an ECC ciphersuite with CCM in the server side" \
7038 "$P_SRV dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
7039 "$P_CLI dtls=1 debug_level=3" \
7040 0 \
7041 -c "found supported_point_formats extension" \
7042 -s "server hello, supported_point_formats extension"
7043
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007044# Tests for DTLS HelloVerifyRequest
7045
7046run_test "DTLS cookie: enabled" \
7047 "$P_SRV dtls=1 debug_level=2" \
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
7057run_test "DTLS cookie: disabled" \
7058 "$P_SRV dtls=1 debug_level=2 cookies=0" \
7059 "$P_CLI dtls=1 debug_level=2" \
7060 0 \
7061 -S "cookie verification failed" \
7062 -S "cookie verification passed" \
7063 -s "cookie verification skipped" \
7064 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007065 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007066 -S "SSL - The requested feature is not available"
7067
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007068run_test "DTLS cookie: default (failing)" \
7069 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
7070 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
7071 1 \
7072 -s "cookie verification failed" \
7073 -S "cookie verification passed" \
7074 -S "cookie verification skipped" \
7075 -C "received hello verify request" \
Jarno Lamsab514cd32019-10-28 14:37:51 +02007076 -S "hello verification requested"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007077
7078requires_ipv6
7079run_test "DTLS cookie: enabled, IPv6" \
7080 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
7081 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
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é-Gonnard0eb6cab2014-07-23 20:17:47 +02007088 -S "SSL - The requested feature is not available"
7089
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007090run_test "DTLS cookie: enabled, nbio" \
7091 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7092 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7093 0 \
7094 -s "cookie verification failed" \
7095 -s "cookie verification passed" \
7096 -S "cookie verification skipped" \
7097 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007098 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007099 -S "SSL - The requested feature is not available"
7100
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007101# Tests for client reconnecting from the same port with DTLS
7102
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007103not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007104requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007105run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007106 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7107 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007108 0 \
7109 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007110 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007111 -S "Client initiated reconnection from same port"
7112
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007113not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007114requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007115run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007116 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7117 "$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 +02007118 0 \
7119 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007120 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007121 -s "Client initiated reconnection from same port"
7122
Paul Bakker362689d2016-05-13 10:33:25 +01007123not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
Jarno Lamsa33281d52019-10-18 10:54:35 +03007124requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007125run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007126 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7127 "$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 +02007128 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007129 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007130 -s "Client initiated reconnection from same port"
7131
Paul Bakker362689d2016-05-13 10:33:25 +01007132only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
Jarno Lamsa33281d52019-10-18 10:54:35 +03007133requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007134run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7135 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7136 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7137 0 \
7138 -S "The operation timed out" \
7139 -s "Client initiated reconnection from same port"
7140
Jarno Lamsa33281d52019-10-18 10:54:35 +03007141requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007142run_test "DTLS client reconnect from same port: no cookies" \
7143 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007144 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7145 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007146 -s "The operation timed out" \
7147 -S "Client initiated reconnection from same port"
7148
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007149# Tests for various cases of client authentication with DTLS
7150# (focused on handshake flows and message parsing)
7151
7152run_test "DTLS client auth: required" \
7153 "$P_SRV dtls=1 auth_mode=required" \
7154 "$P_CLI dtls=1" \
7155 0 \
7156 -s "Verifying peer X.509 certificate... ok"
7157
Hanno Becker4a156fc2019-06-14 17:07:06 +01007158requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007159requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007160run_test "DTLS client auth: optional, client has no cert" \
7161 "$P_SRV dtls=1 auth_mode=optional" \
7162 "$P_CLI dtls=1 crt_file=none key_file=none" \
7163 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007164 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007165
Hanno Becker4a156fc2019-06-14 17:07:06 +01007166requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007167requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007168run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007169 "$P_SRV dtls=1 auth_mode=none" \
7170 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7171 0 \
7172 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007173 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007174
Jarno Lamsa33281d52019-10-18 10:54:35 +03007175requires_ciphersuite_enabled TLS-PSK-WITH-AES-128-GCM-SHA256
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007176run_test "DTLS wrong PSK: badmac alert" \
7177 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7178 "$P_CLI dtls=1 psk=abc124" \
7179 1 \
7180 -s "SSL - Verification of the message MAC failed" \
7181 -c "SSL - A fatal alert message was received from our peer"
7182
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007183# Tests for receiving fragmented handshake messages with DTLS
7184
7185requires_gnutls
7186run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7187 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007188 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007189 0 \
7190 -C "found fragmented DTLS handshake message" \
7191 -C "error"
7192
7193requires_gnutls
7194run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7195 "$G_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007196 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007197 0 \
7198 -c "found fragmented DTLS handshake message" \
7199 -C "error"
7200
7201requires_gnutls
7202run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7203 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007204 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007205 0 \
7206 -c "found fragmented DTLS handshake message" \
7207 -C "error"
7208
7209requires_gnutls
7210run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7211 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007212 "$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 +02007213 0 \
7214 -c "found fragmented DTLS handshake message" \
7215 -C "error"
7216
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007217requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007218requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007219run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7220 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007221 "$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 +02007222 0 \
7223 -c "found fragmented DTLS handshake message" \
7224 -c "client hello, adding renegotiation extension" \
7225 -c "found renegotiation extension" \
7226 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007227 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007228 -C "error" \
7229 -s "Extra-header:"
7230
7231requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007232requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007233run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7234 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007235 "$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 +02007236 0 \
7237 -c "found fragmented DTLS handshake message" \
7238 -c "client hello, adding renegotiation extension" \
7239 -c "found renegotiation extension" \
7240 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007241 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007242 -C "error" \
7243 -s "Extra-header:"
7244
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007245run_test "DTLS reassembly: no fragmentation (openssl server)" \
7246 "$O_SRV -dtls1 -mtu 2048" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007247 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007248 0 \
7249 -C "found fragmented DTLS handshake message" \
7250 -C "error"
7251
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007252run_test "DTLS reassembly: some fragmentation (openssl server)" \
7253 "$O_SRV -dtls1 -mtu 768" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007254 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007255 0 \
7256 -c "found fragmented DTLS handshake message" \
7257 -C "error"
7258
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007259run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007260 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007261 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007262 0 \
7263 -c "found fragmented DTLS handshake message" \
7264 -C "error"
7265
7266run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7267 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007268 "$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 +02007269 0 \
7270 -c "found fragmented DTLS handshake message" \
7271 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007272
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007273# Tests for sending fragmented handshake messages with DTLS
7274#
7275# Use client auth when we need the client to send large messages,
7276# and use large cert chains on both sides too (the long chains we have all use
7277# both RSA and ECDSA, but ideally we should have long chains with either).
7278# Sizes reached (UDP payload):
7279# - 2037B for server certificate
7280# - 1542B for client certificate
7281# - 1013B for newsessionticket
7282# - all others below 512B
7283# All those tests assume MAX_CONTENT_LEN is at least 2048
7284
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007285requires_config_enabled MBEDTLS_RSA_C
7286requires_config_enabled MBEDTLS_ECDSA_C
7287requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7288run_test "DTLS fragmenting: none (for reference)" \
7289 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7290 crt_file=data_files/server7_int-ca.crt \
7291 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007292 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007293 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007294 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007295 "$P_CLI dtls=1 debug_level=2 \
7296 crt_file=data_files/server8_int-ca2.crt \
7297 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007298 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007299 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007300 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007301 0 \
7302 -S "found fragmented DTLS handshake message" \
7303 -C "found fragmented DTLS handshake message" \
7304 -C "error"
7305
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007306requires_config_enabled MBEDTLS_RSA_C
7307requires_config_enabled MBEDTLS_ECDSA_C
7308requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007309run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007310 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7311 crt_file=data_files/server7_int-ca.crt \
7312 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007313 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007314 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007315 max_frag_len=1024" \
7316 "$P_CLI dtls=1 debug_level=2 \
7317 crt_file=data_files/server8_int-ca2.crt \
7318 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007319 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007320 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007321 max_frag_len=2048" \
7322 0 \
7323 -S "found fragmented DTLS handshake message" \
7324 -c "found fragmented DTLS handshake message" \
7325 -C "error"
7326
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007327# With the MFL extension, the server has no way of forcing
7328# the client to not exceed a certain MTU; hence, the following
7329# test can't be replicated with an MTU proxy such as the one
7330# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007331requires_config_enabled MBEDTLS_RSA_C
7332requires_config_enabled MBEDTLS_ECDSA_C
7333requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007334run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007335 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7336 crt_file=data_files/server7_int-ca.crt \
7337 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007338 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007339 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007340 max_frag_len=512" \
7341 "$P_CLI dtls=1 debug_level=2 \
7342 crt_file=data_files/server8_int-ca2.crt \
7343 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007344 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007345 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007346 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007347 0 \
7348 -S "found fragmented DTLS handshake message" \
7349 -c "found fragmented DTLS handshake message" \
7350 -C "error"
7351
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007352requires_config_enabled MBEDTLS_RSA_C
7353requires_config_enabled MBEDTLS_ECDSA_C
7354requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007355run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007356 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7357 crt_file=data_files/server7_int-ca.crt \
7358 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007359 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007360 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007361 max_frag_len=2048" \
7362 "$P_CLI dtls=1 debug_level=2 \
7363 crt_file=data_files/server8_int-ca2.crt \
7364 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007365 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007366 hs_timeout=2500-60000 \
7367 max_frag_len=1024" \
7368 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007369 -S "found fragmented DTLS handshake message" \
7370 -c "found fragmented DTLS handshake message" \
7371 -C "error"
7372
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007373# While not required by the standard defining the MFL extension
7374# (according to which it only applies to records, not to datagrams),
7375# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7376# as otherwise there wouldn't be any means to communicate MTU restrictions
7377# to the peer.
7378# The next test checks that no datagrams significantly larger than the
7379# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007380requires_config_enabled MBEDTLS_RSA_C
7381requires_config_enabled MBEDTLS_ECDSA_C
7382requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7383run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007384 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007385 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7386 crt_file=data_files/server7_int-ca.crt \
7387 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007388 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007389 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007390 max_frag_len=2048" \
7391 "$P_CLI dtls=1 debug_level=2 \
7392 crt_file=data_files/server8_int-ca2.crt \
7393 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007394 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007395 hs_timeout=2500-60000 \
7396 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007397 0 \
7398 -S "found fragmented DTLS handshake message" \
7399 -c "found fragmented DTLS handshake message" \
7400 -C "error"
7401
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007402requires_config_enabled MBEDTLS_RSA_C
7403requires_config_enabled MBEDTLS_ECDSA_C
7404requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007405run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007406 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7407 crt_file=data_files/server7_int-ca.crt \
7408 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007409 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007410 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007411 max_frag_len=2048" \
7412 "$P_CLI dtls=1 debug_level=2 \
7413 crt_file=data_files/server8_int-ca2.crt \
7414 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007415 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007416 hs_timeout=2500-60000 \
7417 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007418 0 \
7419 -s "found fragmented DTLS handshake message" \
7420 -c "found fragmented DTLS handshake message" \
7421 -C "error"
7422
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007423# While not required by the standard defining the MFL extension
7424# (according to which it only applies to records, not to datagrams),
7425# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7426# as otherwise there wouldn't be any means to communicate MTU restrictions
7427# to the peer.
7428# The next test checks that no datagrams significantly larger than the
7429# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007430requires_config_enabled MBEDTLS_RSA_C
7431requires_config_enabled MBEDTLS_ECDSA_C
7432requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7433run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007434 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007435 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7436 crt_file=data_files/server7_int-ca.crt \
7437 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007438 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007439 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007440 max_frag_len=2048" \
7441 "$P_CLI dtls=1 debug_level=2 \
7442 crt_file=data_files/server8_int-ca2.crt \
7443 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007444 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007445 hs_timeout=2500-60000 \
7446 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007447 0 \
7448 -s "found fragmented DTLS handshake message" \
7449 -c "found fragmented DTLS handshake message" \
7450 -C "error"
7451
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007452requires_config_enabled MBEDTLS_RSA_C
7453requires_config_enabled MBEDTLS_ECDSA_C
7454run_test "DTLS fragmenting: none (for reference) (MTU)" \
7455 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7456 crt_file=data_files/server7_int-ca.crt \
7457 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007458 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007459 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007460 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007461 "$P_CLI dtls=1 debug_level=2 \
7462 crt_file=data_files/server8_int-ca2.crt \
7463 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007464 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007465 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007466 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007467 0 \
7468 -S "found fragmented DTLS handshake message" \
7469 -C "found fragmented DTLS handshake message" \
7470 -C "error"
7471
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007472requires_config_enabled MBEDTLS_RSA_C
7473requires_config_enabled MBEDTLS_ECDSA_C
7474run_test "DTLS fragmenting: client (MTU)" \
7475 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7476 crt_file=data_files/server7_int-ca.crt \
7477 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007478 ca_file=data_files/test-ca.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007479 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007480 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007481 "$P_CLI dtls=1 debug_level=2 \
7482 crt_file=data_files/server8_int-ca2.crt \
7483 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007484 ca_file=data_files/test-ca2.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007485 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007486 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007487 0 \
7488 -s "found fragmented DTLS handshake message" \
7489 -C "found fragmented DTLS handshake message" \
7490 -C "error"
7491
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007492requires_config_enabled MBEDTLS_RSA_C
7493requires_config_enabled MBEDTLS_ECDSA_C
7494run_test "DTLS fragmenting: server (MTU)" \
7495 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7496 crt_file=data_files/server7_int-ca.crt \
7497 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007498 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007499 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007500 mtu=512" \
7501 "$P_CLI dtls=1 debug_level=2 \
7502 crt_file=data_files/server8_int-ca2.crt \
7503 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007504 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007505 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007506 mtu=2048" \
7507 0 \
7508 -S "found fragmented DTLS handshake message" \
7509 -c "found fragmented DTLS handshake message" \
7510 -C "error"
7511
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007512requires_config_enabled MBEDTLS_RSA_C
7513requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007514run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007515 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007516 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7517 crt_file=data_files/server7_int-ca.crt \
7518 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007519 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007520 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007521 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007522 "$P_CLI dtls=1 debug_level=2 \
7523 crt_file=data_files/server8_int-ca2.crt \
7524 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007525 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007526 hs_timeout=2500-60000 \
7527 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007528 0 \
7529 -s "found fragmented DTLS handshake message" \
7530 -c "found fragmented DTLS handshake message" \
7531 -C "error"
7532
Andrzej Kurek77826052018-10-11 07:34:08 -04007533# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007534requires_config_enabled MBEDTLS_RSA_C
7535requires_config_enabled MBEDTLS_ECDSA_C
7536requires_config_enabled MBEDTLS_SHA256_C
7537requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7538requires_config_enabled MBEDTLS_AES_C
7539requires_config_enabled MBEDTLS_GCM_C
7540run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007541 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007542 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7543 crt_file=data_files/server7_int-ca.crt \
7544 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007545 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007546 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007547 mtu=512" \
7548 "$P_CLI dtls=1 debug_level=2 \
7549 crt_file=data_files/server8_int-ca2.crt \
7550 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007551 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007552 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7553 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007554 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007555 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007556 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007557 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007558 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007559
Andrzej Kurek7311c782018-10-11 06:49:41 -04007560# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007561# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007562# The ratio of max/min timeout should ideally equal 4 to accept two
7563# retransmissions, but in some cases (like both the server and client using
7564# fragmentation and auto-reduction) an extra retransmission might occur,
7565# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007566not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007567requires_config_enabled MBEDTLS_RSA_C
7568requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007569requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7570requires_config_enabled MBEDTLS_AES_C
7571requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007572run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7573 -p "$P_PXY mtu=508" \
7574 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7575 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007576 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007577 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007578 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007579 "$P_CLI dtls=1 debug_level=2 \
7580 crt_file=data_files/server8_int-ca2.crt \
7581 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007582 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007583 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7584 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007585 0 \
7586 -s "found fragmented DTLS handshake message" \
7587 -c "found fragmented DTLS handshake message" \
7588 -C "error"
7589
Andrzej Kurek77826052018-10-11 07:34:08 -04007590# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007591only_with_valgrind
Hanno Becker108992e2018-08-29 17:04:18 +01007592requires_config_enabled MBEDTLS_RSA_C
7593requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007594requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7595requires_config_enabled MBEDTLS_AES_C
7596requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01007597run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7598 -p "$P_PXY mtu=508" \
7599 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7600 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007601 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007602 ca_file=data_files/test-ca.crt \
Hanno Becker108992e2018-08-29 17:04:18 +01007603 hs_timeout=250-10000" \
7604 "$P_CLI dtls=1 debug_level=2 \
7605 crt_file=data_files/server8_int-ca2.crt \
7606 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007607 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007608 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007609 hs_timeout=250-10000" \
7610 0 \
7611 -s "found fragmented DTLS handshake message" \
7612 -c "found fragmented DTLS handshake message" \
7613 -C "error"
7614
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007615# 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 +02007616# OTOH the client might resend if the server is to slow to reset after sending
7617# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007618not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007619requires_config_enabled MBEDTLS_RSA_C
7620requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007621run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007622 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007623 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7624 crt_file=data_files/server7_int-ca.crt \
7625 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007626 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007627 hs_timeout=10000-60000 \
7628 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007629 "$P_CLI dtls=1 debug_level=2 \
7630 crt_file=data_files/server8_int-ca2.crt \
7631 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007632 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007633 hs_timeout=10000-60000 \
7634 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007635 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007636 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007637 -s "found fragmented DTLS handshake message" \
7638 -c "found fragmented DTLS handshake message" \
7639 -C "error"
7640
Andrzej Kurek77826052018-10-11 07:34:08 -04007641# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007642# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7643# OTOH the client might resend if the server is to slow to reset after sending
7644# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007645not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007646requires_config_enabled MBEDTLS_RSA_C
7647requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007648requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7649requires_config_enabled MBEDTLS_AES_C
7650requires_config_enabled MBEDTLS_GCM_C
7651run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007652 -p "$P_PXY mtu=512" \
7653 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7654 crt_file=data_files/server7_int-ca.crt \
7655 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007656 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007657 hs_timeout=10000-60000 \
7658 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007659 "$P_CLI dtls=1 debug_level=2 \
7660 crt_file=data_files/server8_int-ca2.crt \
7661 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007662 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007663 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7664 hs_timeout=10000-60000 \
7665 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007666 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007667 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007668 -s "found fragmented DTLS handshake message" \
7669 -c "found fragmented DTLS handshake message" \
7670 -C "error"
7671
Andrzej Kurek7311c782018-10-11 06:49:41 -04007672not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007673requires_config_enabled MBEDTLS_RSA_C
7674requires_config_enabled MBEDTLS_ECDSA_C
7675run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007676 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007677 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7678 crt_file=data_files/server7_int-ca.crt \
7679 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007680 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007681 hs_timeout=10000-60000 \
7682 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007683 "$P_CLI dtls=1 debug_level=2 \
7684 crt_file=data_files/server8_int-ca2.crt \
7685 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007686 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007687 hs_timeout=10000-60000 \
7688 mtu=1024 nbio=2" \
7689 0 \
7690 -S "autoreduction" \
7691 -s "found fragmented DTLS handshake message" \
7692 -c "found fragmented DTLS handshake message" \
7693 -C "error"
7694
Andrzej Kurek77826052018-10-11 07:34:08 -04007695# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007696not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007697requires_config_enabled MBEDTLS_RSA_C
7698requires_config_enabled MBEDTLS_ECDSA_C
7699requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7700requires_config_enabled MBEDTLS_AES_C
7701requires_config_enabled MBEDTLS_GCM_C
7702run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7703 -p "$P_PXY mtu=512" \
7704 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7705 crt_file=data_files/server7_int-ca.crt \
7706 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007707 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007708 hs_timeout=10000-60000 \
7709 mtu=512 nbio=2" \
7710 "$P_CLI dtls=1 debug_level=2 \
7711 crt_file=data_files/server8_int-ca2.crt \
7712 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007713 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007714 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7715 hs_timeout=10000-60000 \
7716 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007717 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007718 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007719 -s "found fragmented DTLS handshake message" \
7720 -c "found fragmented DTLS handshake message" \
7721 -C "error"
7722
Andrzej Kurek77826052018-10-11 07:34:08 -04007723# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007724# This ensures things still work after session_reset().
7725# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007726# Since we don't support reading fragmented ClientHello yet,
7727# up the MTU to 1450 (larger than ClientHello with session ticket,
7728# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007729# An autoreduction on the client-side might happen if the server is
7730# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007731# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007732# resumed listening, which would result in a spurious autoreduction.
7733not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007734requires_config_enabled MBEDTLS_RSA_C
7735requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007736requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7737requires_config_enabled MBEDTLS_AES_C
7738requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007739run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7740 -p "$P_PXY mtu=1450" \
7741 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7742 crt_file=data_files/server7_int-ca.crt \
7743 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007744 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007745 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007746 mtu=1450" \
7747 "$P_CLI dtls=1 debug_level=2 \
7748 crt_file=data_files/server8_int-ca2.crt \
7749 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007750 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007751 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007752 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007753 mtu=1450 reconnect=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007754 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007755 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007756 -s "found fragmented DTLS handshake message" \
7757 -c "found fragmented DTLS handshake message" \
7758 -C "error"
7759
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007760# An autoreduction on the client-side might happen if the server is
7761# slow to reset, therefore omitting '-C "autoreduction"' below.
7762not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007763requires_config_enabled MBEDTLS_RSA_C
7764requires_config_enabled MBEDTLS_ECDSA_C
7765requires_config_enabled MBEDTLS_SHA256_C
7766requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7767requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7768requires_config_enabled MBEDTLS_CHACHAPOLY_C
7769run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7770 -p "$P_PXY mtu=512" \
7771 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7772 crt_file=data_files/server7_int-ca.crt \
7773 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007774 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007775 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007776 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007777 mtu=512" \
7778 "$P_CLI dtls=1 debug_level=2 \
7779 crt_file=data_files/server8_int-ca2.crt \
7780 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007781 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007782 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007783 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007784 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007785 mtu=512" \
7786 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007787 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007788 -s "found fragmented DTLS handshake message" \
7789 -c "found fragmented DTLS handshake message" \
7790 -C "error"
7791
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007792# An autoreduction on the client-side might happen if the server is
7793# slow to reset, therefore omitting '-C "autoreduction"' below.
7794not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007795requires_config_enabled MBEDTLS_RSA_C
7796requires_config_enabled MBEDTLS_ECDSA_C
7797requires_config_enabled MBEDTLS_SHA256_C
7798requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7799requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7800requires_config_enabled MBEDTLS_AES_C
7801requires_config_enabled MBEDTLS_GCM_C
7802run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7803 -p "$P_PXY mtu=512" \
7804 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7805 crt_file=data_files/server7_int-ca.crt \
7806 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007807 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007808 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007809 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007810 mtu=512" \
7811 "$P_CLI dtls=1 debug_level=2 \
7812 crt_file=data_files/server8_int-ca2.crt \
7813 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007814 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007815 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007816 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007817 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007818 mtu=512" \
7819 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007820 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007821 -s "found fragmented DTLS handshake message" \
7822 -c "found fragmented DTLS handshake message" \
7823 -C "error"
7824
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007825# An autoreduction on the client-side might happen if the server is
7826# slow to reset, therefore omitting '-C "autoreduction"' below.
7827not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007828requires_config_enabled MBEDTLS_RSA_C
7829requires_config_enabled MBEDTLS_ECDSA_C
7830requires_config_enabled MBEDTLS_SHA256_C
7831requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7832requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7833requires_config_enabled MBEDTLS_AES_C
7834requires_config_enabled MBEDTLS_CCM_C
7835run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007836 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007837 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7838 crt_file=data_files/server7_int-ca.crt \
7839 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007840 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007841 exchanges=2 renegotiation=1 \
7842 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007843 hs_timeout=10000-60000 \
7844 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007845 "$P_CLI dtls=1 debug_level=2 \
7846 crt_file=data_files/server8_int-ca2.crt \
7847 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007848 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007849 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007850 hs_timeout=10000-60000 \
7851 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007852 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007853 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007854 -s "found fragmented DTLS handshake message" \
7855 -c "found fragmented DTLS handshake message" \
7856 -C "error"
7857
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007858# An autoreduction on the client-side might happen if the server is
7859# slow to reset, therefore omitting '-C "autoreduction"' below.
7860not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007861requires_config_enabled MBEDTLS_RSA_C
7862requires_config_enabled MBEDTLS_ECDSA_C
7863requires_config_enabled MBEDTLS_SHA256_C
7864requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7865requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7866requires_config_enabled MBEDTLS_AES_C
7867requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7868requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7869run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007870 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007871 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7872 crt_file=data_files/server7_int-ca.crt \
7873 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007874 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007875 exchanges=2 renegotiation=1 \
7876 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007877 hs_timeout=10000-60000 \
7878 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007879 "$P_CLI dtls=1 debug_level=2 \
7880 crt_file=data_files/server8_int-ca2.crt \
7881 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007882 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007883 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007884 hs_timeout=10000-60000 \
7885 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007886 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007887 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007888 -s "found fragmented DTLS handshake message" \
7889 -c "found fragmented DTLS handshake message" \
7890 -C "error"
7891
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007892# An autoreduction on the client-side might happen if the server is
7893# slow to reset, therefore omitting '-C "autoreduction"' below.
7894not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007895requires_config_enabled MBEDTLS_RSA_C
7896requires_config_enabled MBEDTLS_ECDSA_C
7897requires_config_enabled MBEDTLS_SHA256_C
7898requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7899requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7900requires_config_enabled MBEDTLS_AES_C
7901requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7902run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007903 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007904 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7905 crt_file=data_files/server7_int-ca.crt \
7906 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007907 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007908 exchanges=2 renegotiation=1 \
7909 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007910 hs_timeout=10000-60000 \
7911 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007912 "$P_CLI dtls=1 debug_level=2 \
7913 crt_file=data_files/server8_int-ca2.crt \
7914 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007915 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007916 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007917 hs_timeout=10000-60000 \
7918 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007919 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007920 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007921 -s "found fragmented DTLS handshake message" \
7922 -c "found fragmented DTLS handshake message" \
7923 -C "error"
7924
Andrzej Kurek77826052018-10-11 07:34:08 -04007925# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007926requires_config_enabled MBEDTLS_RSA_C
7927requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007928requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7929requires_config_enabled MBEDTLS_AES_C
7930requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007931client_needs_more_time 2
7932run_test "DTLS fragmenting: proxy MTU + 3d" \
7933 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007934 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007935 crt_file=data_files/server7_int-ca.crt \
7936 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007937 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007938 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007939 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007940 crt_file=data_files/server8_int-ca2.crt \
7941 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007942 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007943 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007944 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007945 0 \
7946 -s "found fragmented DTLS handshake message" \
7947 -c "found fragmented DTLS handshake message" \
7948 -C "error"
7949
Andrzej Kurek77826052018-10-11 07:34:08 -04007950# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007951requires_config_enabled MBEDTLS_RSA_C
7952requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007953requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7954requires_config_enabled MBEDTLS_AES_C
7955requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007956client_needs_more_time 2
7957run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7958 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7959 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7960 crt_file=data_files/server7_int-ca.crt \
7961 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007962 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007963 hs_timeout=250-10000 mtu=512 nbio=2" \
7964 "$P_CLI dtls=1 debug_level=2 \
7965 crt_file=data_files/server8_int-ca2.crt \
7966 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007967 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007968 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007969 hs_timeout=250-10000 mtu=512 nbio=2" \
7970 0 \
7971 -s "found fragmented DTLS handshake message" \
7972 -c "found fragmented DTLS handshake message" \
7973 -C "error"
7974
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007975# interop tests for DTLS fragmentating with reliable connection
7976#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007977# here and below we just want to test that the we fragment in a way that
7978# pleases other implementations, so we don't need the peer to fragment
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007979requires_config_enabled MBEDTLS_RSA_C
7980requires_config_enabled MBEDTLS_ECDSA_C
7981requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007982requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007983run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7984 "$G_SRV -u" \
7985 "$P_CLI dtls=1 debug_level=2 \
7986 crt_file=data_files/server8_int-ca2.crt \
7987 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007988 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007989 mtu=512 force_version=dtls1_2" \
7990 0 \
7991 -c "fragmenting handshake message" \
7992 -C "error"
7993
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007994requires_config_enabled MBEDTLS_RSA_C
7995requires_config_enabled MBEDTLS_ECDSA_C
7996requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007997requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007998run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
7999 "$G_SRV -u" \
8000 "$P_CLI dtls=1 debug_level=2 \
8001 crt_file=data_files/server8_int-ca2.crt \
8002 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008003 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008004 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008005 0 \
8006 -c "fragmenting handshake message" \
8007 -C "error"
8008
Hanno Beckerb9a00862018-08-28 10:20:22 +01008009# We use --insecure for the GnuTLS client because it expects
8010# the hostname / IP it connects to to be the name used in the
8011# certificate obtained from the server. Here, however, it
8012# connects to 127.0.0.1 while our test certificates use 'localhost'
8013# as the server name in the certificate. This will make the
8014# certifiate validation fail, but passing --insecure makes
8015# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008016requires_config_enabled MBEDTLS_RSA_C
8017requires_config_enabled MBEDTLS_ECDSA_C
8018requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008019requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008020requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008021run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008022 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008023 crt_file=data_files/server7_int-ca.crt \
8024 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008025 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008026 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008027 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008028 0 \
8029 -s "fragmenting handshake message"
8030
Hanno Beckerb9a00862018-08-28 10:20:22 +01008031# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008032requires_config_enabled MBEDTLS_RSA_C
8033requires_config_enabled MBEDTLS_ECDSA_C
8034requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008035requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008036requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008037run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008038 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008039 crt_file=data_files/server7_int-ca.crt \
8040 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008041 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008042 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008043 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008044 0 \
8045 -s "fragmenting handshake message"
8046
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008047requires_config_enabled MBEDTLS_RSA_C
8048requires_config_enabled MBEDTLS_ECDSA_C
8049requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8050run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
8051 "$O_SRV -dtls1_2 -verify 10" \
8052 "$P_CLI dtls=1 debug_level=2 \
8053 crt_file=data_files/server8_int-ca2.crt \
8054 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008055 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008056 mtu=512 force_version=dtls1_2" \
8057 0 \
8058 -c "fragmenting handshake message" \
8059 -C "error"
8060
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008061requires_config_enabled MBEDTLS_RSA_C
8062requires_config_enabled MBEDTLS_ECDSA_C
8063requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8064run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
8065 "$O_SRV -dtls1 -verify 10" \
8066 "$P_CLI dtls=1 debug_level=2 \
8067 crt_file=data_files/server8_int-ca2.crt \
8068 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008069 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008070 mtu=512 force_version=dtls1" \
8071 0 \
8072 -c "fragmenting handshake message" \
8073 -C "error"
8074
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008075requires_config_enabled MBEDTLS_RSA_C
8076requires_config_enabled MBEDTLS_ECDSA_C
8077requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8078run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
8079 "$P_SRV dtls=1 debug_level=2 \
8080 crt_file=data_files/server7_int-ca.crt \
8081 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008082 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008083 mtu=512 force_version=dtls1_2" \
8084 "$O_CLI -dtls1_2" \
8085 0 \
8086 -s "fragmenting handshake message"
8087
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008088requires_config_enabled MBEDTLS_RSA_C
8089requires_config_enabled MBEDTLS_ECDSA_C
8090requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8091run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8092 "$P_SRV dtls=1 debug_level=2 \
8093 crt_file=data_files/server7_int-ca.crt \
8094 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008095 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008096 mtu=512 force_version=dtls1" \
8097 "$O_CLI -dtls1" \
8098 0 \
8099 -s "fragmenting handshake message"
8100
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008101# interop tests for DTLS fragmentating with unreliable connection
8102#
8103# again we just want to test that the we fragment in a way that
8104# pleases other implementations, so we don't need the peer to fragment
8105requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008106requires_config_enabled MBEDTLS_RSA_C
8107requires_config_enabled MBEDTLS_ECDSA_C
8108requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008109client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008110run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8111 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8112 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008113 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008114 crt_file=data_files/server8_int-ca2.crt \
8115 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008116 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008117 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008118 0 \
8119 -c "fragmenting handshake message" \
8120 -C "error"
8121
8122requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008123requires_config_enabled MBEDTLS_RSA_C
8124requires_config_enabled MBEDTLS_ECDSA_C
8125requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008126client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008127run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8128 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8129 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008130 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008131 crt_file=data_files/server8_int-ca2.crt \
8132 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008133 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008134 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008135 0 \
8136 -c "fragmenting handshake message" \
8137 -C "error"
8138
k-stachowiakabb843e2019-02-18 16:14:03 +01008139requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008140requires_config_enabled MBEDTLS_RSA_C
8141requires_config_enabled MBEDTLS_ECDSA_C
8142requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8143client_needs_more_time 4
8144run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8145 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8146 "$P_SRV dtls=1 debug_level=2 \
8147 crt_file=data_files/server7_int-ca.crt \
8148 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008149 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008150 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008151 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008152 0 \
8153 -s "fragmenting handshake message"
8154
k-stachowiakabb843e2019-02-18 16:14:03 +01008155requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008156requires_config_enabled MBEDTLS_RSA_C
8157requires_config_enabled MBEDTLS_ECDSA_C
8158requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8159client_needs_more_time 4
8160run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8161 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8162 "$P_SRV dtls=1 debug_level=2 \
8163 crt_file=data_files/server7_int-ca.crt \
8164 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008165 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008166 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008167 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008168 0 \
8169 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008170
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008171## Interop test with OpenSSL might trigger a bug in recent versions (including
8172## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008173## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008174## They should be re-enabled once a fixed version of OpenSSL is available
8175## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008176skip_next_test
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008177requires_config_enabled MBEDTLS_RSA_C
8178requires_config_enabled MBEDTLS_ECDSA_C
8179requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8180client_needs_more_time 4
8181run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8182 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8183 "$O_SRV -dtls1_2 -verify 10" \
8184 "$P_CLI dtls=1 debug_level=2 \
8185 crt_file=data_files/server8_int-ca2.crt \
8186 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008187 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008188 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8189 0 \
8190 -c "fragmenting handshake message" \
8191 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008192
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008193skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008194requires_config_enabled MBEDTLS_RSA_C
8195requires_config_enabled MBEDTLS_ECDSA_C
8196requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008197client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008198run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8199 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008200 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008201 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008202 crt_file=data_files/server8_int-ca2.crt \
8203 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008204 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008205 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008206 0 \
8207 -c "fragmenting handshake message" \
8208 -C "error"
8209
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008210skip_next_test
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008211requires_config_enabled MBEDTLS_RSA_C
8212requires_config_enabled MBEDTLS_ECDSA_C
8213requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8214client_needs_more_time 4
8215run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8216 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8217 "$P_SRV dtls=1 debug_level=2 \
8218 crt_file=data_files/server7_int-ca.crt \
8219 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008220 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008221 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8222 "$O_CLI -dtls1_2" \
8223 0 \
8224 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008225
8226# -nbio is added to prevent s_client from blocking in case of duplicated
8227# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008228skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008229requires_config_enabled MBEDTLS_RSA_C
8230requires_config_enabled MBEDTLS_ECDSA_C
8231requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008232client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008233run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8234 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008235 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008236 crt_file=data_files/server7_int-ca.crt \
8237 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008238 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008239 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008240 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008241 0 \
8242 -s "fragmenting handshake message"
8243
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008244# Tests for specific things with "unreliable" UDP connection
8245
8246not_with_valgrind # spurious resend due to timeout
8247run_test "DTLS proxy: reference" \
8248 -p "$P_PXY" \
8249 "$P_SRV dtls=1 debug_level=2" \
8250 "$P_CLI dtls=1 debug_level=2" \
8251 0 \
8252 -C "replayed record" \
8253 -S "replayed record" \
Hanno Beckere03eb7b2019-07-19 15:43:09 +01008254 -C "Buffer record from epoch" \
8255 -S "Buffer record from epoch" \
8256 -C "ssl_buffer_message" \
8257 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008258 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008259 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008260 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008261 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008262 -c "HTTP/1.0 200 OK"
8263
8264not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008265run_test "DTLS proxy: duplicate every packet" \
8266 -p "$P_PXY duplicate=1" \
Hanno Becker7f376f42019-06-12 16:20:48 +01008267 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008268 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008269 0 \
8270 -c "replayed record" \
8271 -s "replayed record" \
8272 -c "record from another epoch" \
8273 -s "record from another epoch" \
8274 -S "resend" \
8275 -s "Extra-header:" \
8276 -c "HTTP/1.0 200 OK"
8277
8278run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8279 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008280 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8281 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008282 0 \
8283 -c "replayed record" \
8284 -S "replayed record" \
8285 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008286 -s "record from another epoch" \
8287 -c "resend" \
8288 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008289 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008290 -c "HTTP/1.0 200 OK"
8291
8292run_test "DTLS proxy: multiple records in same datagram" \
8293 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008294 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8295 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008296 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008297 -c "next record in same datagram" \
8298 -s "next record in same datagram"
8299
8300run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8301 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008302 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8303 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008304 0 \
8305 -c "next record in same datagram" \
8306 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008307
Jarno Lamsa33281d52019-10-18 10:54:35 +03008308requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008309run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8310 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008311 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8312 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008313 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008314 -c "discarding invalid record (mac)" \
8315 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008316 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008317 -c "HTTP/1.0 200 OK" \
8318 -S "too many records with bad MAC" \
8319 -S "Verification of the message MAC failed"
8320
Jarno Lamsa33281d52019-10-18 10:54:35 +03008321requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008322run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8323 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008324 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8325 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008326 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008327 -C "discarding invalid record (mac)" \
8328 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008329 -S "Extra-header:" \
8330 -C "HTTP/1.0 200 OK" \
8331 -s "too many records with bad MAC" \
8332 -s "Verification of the message MAC failed"
8333
Jarno Lamsa33281d52019-10-18 10:54:35 +03008334requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008335run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8336 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008337 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8338 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008339 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008340 -c "discarding invalid record (mac)" \
8341 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008342 -s "Extra-header:" \
8343 -c "HTTP/1.0 200 OK" \
8344 -S "too many records with bad MAC" \
8345 -S "Verification of the message MAC failed"
8346
Jarno Lamsa33281d52019-10-18 10:54:35 +03008347requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008348run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8349 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008350 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8351 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008352 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008353 -c "discarding invalid record (mac)" \
8354 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008355 -s "Extra-header:" \
8356 -c "HTTP/1.0 200 OK" \
8357 -s "too many records with bad MAC" \
8358 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008359
8360run_test "DTLS proxy: delay ChangeCipherSpec" \
8361 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008362 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8363 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008364 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008365 -c "record from another epoch" \
8366 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008367 -s "Extra-header:" \
8368 -c "HTTP/1.0 200 OK"
8369
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008370# Tests for reordering support with DTLS
8371
Hanno Becker56cdfd12018-08-17 13:42:15 +01008372run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8373 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008374 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8375 hs_timeout=2500-60000" \
8376 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8377 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008378 0 \
8379 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008380 -c "Next handshake message has been buffered - load"\
8381 -S "Buffering HS message" \
8382 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008383 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008384 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008385 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008386 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008387
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008388run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8389 -p "$P_PXY delay_srv=ServerHello" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03008390 "$P_SRV mtu=256 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008391 hs_timeout=2500-60000" \
8392 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8393 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008394 0 \
8395 -c "Buffering HS message" \
8396 -c "found fragmented DTLS handshake message"\
8397 -c "Next handshake message 1 not or only partially bufffered" \
8398 -c "Next handshake message has been buffered - load"\
8399 -S "Buffering HS message" \
8400 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008401 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008402 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008403 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008404 -S "Remember CCS message"
8405
Hanno Beckera1adcca2018-08-24 14:41:07 +01008406# The client buffers the ServerKeyExchange before receiving the fragmented
8407# Certificate message; at the time of writing, together these are aroudn 1200b
8408# in size, so that the bound below ensures that the certificate can be reassembled
8409# while keeping the ServerKeyExchange.
8410requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8411run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008412 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008413 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8414 hs_timeout=2500-60000" \
8415 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8416 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008417 0 \
8418 -c "Buffering HS message" \
8419 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008420 -C "attempt to make space by freeing buffered messages" \
8421 -S "Buffering HS message" \
8422 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008423 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008424 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008425 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008426 -S "Remember CCS message"
8427
8428# The size constraints ensure that the delayed certificate message can't
8429# be reassembled while keeping the ServerKeyExchange message, but it can
8430# when dropping it first.
8431requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8432requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8433run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8434 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008435 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8436 hs_timeout=2500-60000" \
8437 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8438 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008439 0 \
8440 -c "Buffering HS message" \
8441 -c "attempt to make space by freeing buffered future messages" \
8442 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008443 -S "Buffering HS message" \
8444 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008445 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008446 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008447 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008448 -S "Remember CCS message"
8449
Hanno Becker56cdfd12018-08-17 13:42:15 +01008450run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8451 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008452 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8453 hs_timeout=2500-60000" \
8454 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8455 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008456 0 \
8457 -C "Buffering HS message" \
8458 -C "Next handshake message has been buffered - load"\
8459 -s "Buffering HS message" \
8460 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008461 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008462 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008463 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008464 -S "Remember CCS message"
8465
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02008466# This needs session tickets; otherwise CCS is the first message in its flight
8467requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008468run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8469 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008470 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8471 hs_timeout=2500-60000" \
8472 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8473 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008474 0 \
8475 -C "Buffering HS message" \
8476 -C "Next handshake message has been buffered - load"\
8477 -S "Buffering HS message" \
8478 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008479 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008480 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008481 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008482 -S "Remember CCS message"
8483
Jarno Lamsa33281d52019-10-18 10:54:35 +03008484# This needs session tickets; otherwise CCS is the first message in its flight
8485requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008486run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8487 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008488 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8489 hs_timeout=2500-60000" \
8490 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8491 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008492 0 \
8493 -C "Buffering HS message" \
8494 -C "Next handshake message has been buffered - load"\
8495 -S "Buffering HS message" \
8496 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008497 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008498 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008499 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008500 -s "Remember CCS message"
8501
Hanno Beckera1adcca2018-08-24 14:41:07 +01008502run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008503 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008504 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8505 hs_timeout=2500-60000" \
8506 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8507 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008508 0 \
8509 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008510 -s "Found buffered record from current epoch - load" \
8511 -c "Buffer record from epoch 1" \
8512 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008513
Hanno Beckera1adcca2018-08-24 14:41:07 +01008514# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8515# from the server are delayed, so that the encrypted Finished message
8516# is received and buffered. When the fragmented NewSessionTicket comes
8517# in afterwards, the encrypted Finished message must be freed in order
8518# to make space for the NewSessionTicket to be reassembled.
8519# This works only in very particular circumstances:
8520# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8521# of the NewSessionTicket, but small enough to also allow buffering of
8522# the encrypted Finished message.
8523# - The MTU setting on the server must be so small that the NewSessionTicket
8524# needs to be fragmented.
8525# - All messages sent by the server must be small enough to be either sent
8526# without fragmentation or be reassembled within the bounds of
8527# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8528# handshake, omitting CRTs.
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008529requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8530requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008531run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8532 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008533 "$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 +01008534 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8535 0 \
8536 -s "Buffer record from epoch 1" \
8537 -s "Found buffered record from current epoch - load" \
8538 -c "Buffer record from epoch 1" \
8539 -C "Found buffered record from current epoch - load" \
8540 -c "Enough space available after freeing future epoch record"
8541
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008542# Tests for "randomly unreliable connection": try a variety of flows and peers
8543
8544client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008545run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK 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 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008548 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008549 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008550 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8551 0 \
8552 -s "Extra-header:" \
8553 -c "HTTP/1.0 200 OK"
8554
Janos Follath74537a62016-09-02 13:45:28 +01008555client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008556run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8557 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008558 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8559 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008560 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8561 0 \
8562 -s "Extra-header:" \
8563 -c "HTTP/1.0 200 OK"
8564
Janos Follath74537a62016-09-02 13:45:28 +01008565client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008566run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8567 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008568 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8569 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008570 0 \
8571 -s "Extra-header:" \
8572 -c "HTTP/1.0 200 OK"
8573
Janos Follath74537a62016-09-02 13:45:28 +01008574client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008575run_test "DTLS proxy: 3d, FS, client auth" \
8576 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008577 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8578 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008579 0 \
8580 -s "Extra-header:" \
8581 -c "HTTP/1.0 200 OK"
8582
Janos Follath74537a62016-09-02 13:45:28 +01008583client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008584run_test "DTLS proxy: 3d, FS, ticket" \
8585 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008586 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8587 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008588 0 \
8589 -s "Extra-header:" \
8590 -c "HTTP/1.0 200 OK"
8591
Janos Follath74537a62016-09-02 13:45:28 +01008592client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008593run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8594 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008595 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8596 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008597 0 \
8598 -s "Extra-header:" \
8599 -c "HTTP/1.0 200 OK"
8600
Janos Follath74537a62016-09-02 13:45:28 +01008601client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008602run_test "DTLS proxy: 3d, max handshake, nbio" \
8603 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008604 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008605 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008606 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008607 0 \
8608 -s "Extra-header:" \
8609 -c "HTTP/1.0 200 OK"
8610
Janos Follath74537a62016-09-02 13:45:28 +01008611client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008612requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008613requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008614requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008615run_test "DTLS proxy: 3d, min handshake, resumption" \
8616 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008617 "$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 +02008618 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008619 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008620 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8621 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8622 0 \
8623 -s "a session has been resumed" \
8624 -c "a session has been resumed" \
8625 -s "Extra-header:" \
8626 -c "HTTP/1.0 200 OK"
8627
Janos Follath74537a62016-09-02 13:45:28 +01008628client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008629requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008630requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008631requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008632run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8633 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008634 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008635 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008636 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008637 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8638 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8639 0 \
8640 -s "a session has been resumed" \
8641 -c "a session has been resumed" \
8642 -s "Extra-header:" \
8643 -c "HTTP/1.0 200 OK"
8644
Janos Follath74537a62016-09-02 13:45:28 +01008645client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008646requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008647run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008648 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008649 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008650 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008651 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008652 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008653 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8654 0 \
8655 -c "=> renegotiate" \
8656 -s "=> renegotiate" \
8657 -s "Extra-header:" \
8658 -c "HTTP/1.0 200 OK"
8659
Janos Follath74537a62016-09-02 13:45:28 +01008660client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008661requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008662run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8663 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008664 "$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 +02008665 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008666 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008667 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008668 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8669 0 \
8670 -c "=> renegotiate" \
8671 -s "=> renegotiate" \
8672 -s "Extra-header:" \
8673 -c "HTTP/1.0 200 OK"
8674
Janos Follath74537a62016-09-02 13:45:28 +01008675client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008676requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008677run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008678 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008679 "$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 +02008680 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008681 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008682 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008683 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008684 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8685 0 \
8686 -c "=> renegotiate" \
8687 -s "=> renegotiate" \
8688 -s "Extra-header:" \
8689 -c "HTTP/1.0 200 OK"
8690
Janos Follath74537a62016-09-02 13:45:28 +01008691client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008692requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008693run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008694 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008695 "$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 +02008696 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008697 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008698 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008699 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008700 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8701 0 \
8702 -c "=> renegotiate" \
8703 -s "=> renegotiate" \
8704 -s "Extra-header:" \
8705 -c "HTTP/1.0 200 OK"
8706
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008707## Interop tests with OpenSSL might trigger a bug in recent versions (including
8708## all versions installed on the CI machines), reported here:
8709## Bug report: https://github.com/openssl/openssl/issues/6902
8710## They should be re-enabled once a fixed version of OpenSSL is available
8711## (this should happen in some 1.1.1_ release according to the ticket).
8712skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008713client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008714not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008715run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008716 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8717 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008718 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008719 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008720 -c "HTTP/1.0 200 OK"
8721
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008722skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008723client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008724not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008725run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8726 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8727 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008728 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008729 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008730 -c "HTTP/1.0 200 OK"
8731
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008732skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008733client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008734not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008735run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8736 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8737 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008738 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008739 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008740 -c "HTTP/1.0 200 OK"
8741
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008742requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008743client_needs_more_time 6
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" \
8746 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8747 "$G_SRV -u --mtu 2048 -a" \
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é-Gonnard9590e0a2014-09-26 16:27:59 +02008756run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
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 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008760 0 \
8761 -s "Extra-header:" \
8762 -c "Extra-header:"
8763
k-stachowiakabb843e2019-02-18 16:14:03 +01008764requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008765client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008766not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008767run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8768 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008769 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008770 "$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 +02008771 0 \
8772 -s "Extra-header:" \
8773 -c "Extra-header:"
8774
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008775# Final report
8776
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008777echo "------------------------------------------------------------------------"
8778
8779if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008780 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008781else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008782 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008783fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008784PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008785echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008786
8787exit $FAILS