blob: 784fedfecdddd04229e27278215c2145cd395124 [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
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005395run_test "ClientHello without extensions, SHA-1 allowed" \
Ron Eldorb76e7652019-01-16 23:14:41 +02005396 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +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
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005401requires_gnutls
5402run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
5403 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005404 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005405 0 \
5406 -s "dumping 'client hello extensions' (0 bytes)"
5407
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005408# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005409
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005410run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005411 "$P_SRV" \
5412 "$P_CLI request_size=100" \
5413 0 \
5414 -s "Read from client: 100 bytes read$"
5415
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005416run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005417 "$P_SRV" \
5418 "$P_CLI request_size=500" \
5419 0 \
5420 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005421
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005422# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005423
Janos Follathe2681a42016-03-07 15:57:05 +00005424requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005425run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005426 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005427 "$P_CLI request_size=1 force_version=ssl3 \
5428 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5429 0 \
5430 -s "Read from client: 1 bytes read"
5431
Janos Follathe2681a42016-03-07 15:57:05 +00005432requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005433run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005434 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005435 "$P_CLI request_size=1 force_version=ssl3 \
5436 force_ciphersuite=TLS-RSA-WITH-RC4-128-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" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005441 "$P_SRV" \
5442 "$P_CLI request_size=1 force_version=tls1 \
5443 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5444 0 \
5445 -s "Read from client: 1 bytes read"
5446
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005447run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005448 "$P_SRV" \
5449 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5450 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5451 0 \
5452 -s "Read from client: 1 bytes read"
5453
Hanno Becker32c55012017-11-10 08:42:54 +00005454requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005455run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005456 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005457 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005458 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005459 0 \
5460 -s "Read from client: 1 bytes read"
5461
Hanno Becker32c55012017-11-10 08:42:54 +00005462requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005463run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005464 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005465 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005466 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005467 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" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005471 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005472 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005473 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5474 0 \
5475 -s "Read from client: 1 bytes read"
5476
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005477run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005478 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5479 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005480 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005481 0 \
5482 -s "Read from client: 1 bytes read"
5483
5484requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005485run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005486 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005487 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005488 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005489 0 \
5490 -s "Read from client: 1 bytes read"
5491
Hanno Becker8501f982017-11-10 08:59:04 +00005492requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005493run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005494 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5495 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5496 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005497 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" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005501 "$P_SRV" \
5502 "$P_CLI request_size=1 force_version=tls1_1 \
5503 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5504 0 \
5505 -s "Read from client: 1 bytes read"
5506
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005507run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005508 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005509 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005510 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005511 0 \
5512 -s "Read from client: 1 bytes read"
5513
5514requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005515run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005516 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005517 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005518 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005519 0 \
5520 -s "Read from client: 1 bytes read"
5521
5522requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005523run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005524 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005525 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005526 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005527 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" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005531 "$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 \
5533 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5534 0 \
5535 -s "Read from client: 1 bytes read"
5536
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005537run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005538 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005539 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005540 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005541 0 \
5542 -s "Read from client: 1 bytes read"
5543
Hanno Becker8501f982017-11-10 08:59:04 +00005544requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005545run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005546 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005547 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005548 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005549 0 \
5550 -s "Read from client: 1 bytes read"
5551
Hanno Becker32c55012017-11-10 08:42:54 +00005552requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005553run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005554 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005555 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005556 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005557 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" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005561 "$P_SRV" \
5562 "$P_CLI request_size=1 force_version=tls1_2 \
5563 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5564 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, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005568 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005569 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005570 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005571 0 \
5572 -s "Read from client: 1 bytes read"
5573
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005574run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005575 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005576 "$P_CLI request_size=1 force_version=tls1_2 \
5577 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005578 0 \
5579 -s "Read from client: 1 bytes read"
5580
Hanno Becker32c55012017-11-10 08:42:54 +00005581requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005582run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005583 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005584 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005585 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005586 0 \
5587 -s "Read from client: 1 bytes read"
5588
Hanno Becker8501f982017-11-10 08:59:04 +00005589requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005590run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005591 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005592 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005593 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005594 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" \
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 \
5600 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5601 0 \
5602 -s "Read from client: 1 bytes read"
5603
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005604run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005605 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005606 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005607 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005608 0 \
5609 -s "Read from client: 1 bytes read"
5610
Hanno Becker32c55012017-11-10 08:42:54 +00005611requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005612run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005613 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005614 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005615 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005616 0 \
5617 -s "Read from client: 1 bytes read"
5618
Hanno Becker8501f982017-11-10 08:59:04 +00005619requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005620run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005621 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005622 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005623 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005624 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" \
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" \
5631 0 \
5632 -s "Read from client: 1 bytes read"
5633
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005634run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005635 "$P_SRV" \
5636 "$P_CLI request_size=1 force_version=tls1_2 \
5637 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5638 0 \
5639 -s "Read from client: 1 bytes read"
5640
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005641# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005642
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005643run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005644 "$P_SRV dtls=1 force_version=dtls1" \
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
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005650run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00005651 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
5652 "$P_CLI dtls=1 request_size=1 \
5653 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5654 0 \
5655 -s "Read from client: 1 bytes read"
5656
Hanno Beckere2148042017-11-10 08:59:18 +00005657requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005658run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005659 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
5660 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00005661 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5662 0 \
5663 -s "Read from client: 1 bytes read"
5664
Hanno Beckere2148042017-11-10 08:59:18 +00005665requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005666run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005667 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005668 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005669 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005670 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" \
Hanno Beckere2148042017-11-10 08:59:18 +00005674 "$P_SRV dtls=1 force_version=dtls1_2" \
5675 "$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
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005680run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005681 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005682 "$P_CLI dtls=1 request_size=1 \
5683 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5684 0 \
5685 -s "Read from client: 1 bytes read"
5686
Hanno Beckere2148042017-11-10 08:59:18 +00005687requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005688run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005689 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005690 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005691 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005692 0 \
5693 -s "Read from client: 1 bytes read"
5694
Hanno Beckere2148042017-11-10 08:59:18 +00005695requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005696run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005697 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005698 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005699 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005700 0 \
5701 -s "Read from client: 1 bytes read"
5702
Jarno Lamsa0ed68082019-10-28 14:10:59 +02005703run_test "Small client packet DTLS, ECDHE-ECDSA" \
5704 "$P_SRV dtls=1" \
5705 "$P_CLI dtls=1 request_size=1 \
5706 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
5707 0 \
5708 -s "Read from client: 1 bytes read"
5709
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005710# Tests for small server packets
5711
5712requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5713run_test "Small server packet SSLv3 BlockCipher" \
5714 "$P_SRV response_size=1 min_version=ssl3" \
5715 "$P_CLI force_version=ssl3 \
5716 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5717 0 \
5718 -c "Read from server: 1 bytes read"
5719
5720requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5721run_test "Small server packet SSLv3 StreamCipher" \
5722 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5723 "$P_CLI force_version=ssl3 \
5724 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5725 0 \
5726 -c "Read from server: 1 bytes read"
5727
5728run_test "Small server packet TLS 1.0 BlockCipher" \
5729 "$P_SRV response_size=1" \
5730 "$P_CLI force_version=tls1 \
5731 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5732 0 \
5733 -c "Read from server: 1 bytes read"
5734
5735run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
5736 "$P_SRV response_size=1" \
5737 "$P_CLI force_version=tls1 etm=0 \
5738 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5739 0 \
5740 -c "Read from server: 1 bytes read"
5741
5742requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5743run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
5744 "$P_SRV response_size=1 trunc_hmac=1" \
5745 "$P_CLI force_version=tls1 \
5746 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5747 0 \
5748 -c "Read from server: 1 bytes read"
5749
5750requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5751run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
5752 "$P_SRV response_size=1 trunc_hmac=1" \
5753 "$P_CLI force_version=tls1 \
5754 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5755 0 \
5756 -c "Read from server: 1 bytes read"
5757
5758run_test "Small server packet TLS 1.0 StreamCipher" \
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" \
5762 0 \
5763 -c "Read from server: 1 bytes read"
5764
5765run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
5766 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5767 "$P_CLI force_version=tls1 \
5768 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5769 0 \
5770 -c "Read from server: 1 bytes read"
5771
5772requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5773run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
5774 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5775 "$P_CLI force_version=tls1 \
5776 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5777 0 \
5778 -c "Read from server: 1 bytes read"
5779
5780requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5781run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5782 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5783 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5784 trunc_hmac=1 etm=0" \
5785 0 \
5786 -c "Read from server: 1 bytes read"
5787
5788run_test "Small server packet TLS 1.1 BlockCipher" \
5789 "$P_SRV response_size=1" \
5790 "$P_CLI force_version=tls1_1 \
5791 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5792 0 \
5793 -c "Read from server: 1 bytes read"
5794
5795run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
5796 "$P_SRV response_size=1" \
5797 "$P_CLI force_version=tls1_1 \
5798 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5799 0 \
5800 -c "Read from server: 1 bytes read"
5801
5802requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5803run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
5804 "$P_SRV response_size=1 trunc_hmac=1" \
5805 "$P_CLI force_version=tls1_1 \
5806 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5807 0 \
5808 -c "Read from server: 1 bytes read"
5809
5810requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5811run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5812 "$P_SRV response_size=1 trunc_hmac=1" \
5813 "$P_CLI force_version=tls1_1 \
5814 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5815 0 \
5816 -c "Read from server: 1 bytes read"
5817
5818run_test "Small server packet TLS 1.1 StreamCipher" \
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" \
5822 0 \
5823 -c "Read from server: 1 bytes read"
5824
5825run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
5826 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5827 "$P_CLI force_version=tls1_1 \
5828 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5829 0 \
5830 -c "Read from server: 1 bytes read"
5831
5832requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5833run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
5834 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5835 "$P_CLI force_version=tls1_1 \
5836 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5837 0 \
5838 -c "Read from server: 1 bytes read"
5839
5840requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5841run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5842 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5843 "$P_CLI force_version=tls1_1 \
5844 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5845 0 \
5846 -c "Read from server: 1 bytes read"
5847
5848run_test "Small server packet TLS 1.2 BlockCipher" \
5849 "$P_SRV response_size=1" \
5850 "$P_CLI force_version=tls1_2 \
5851 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5852 0 \
5853 -c "Read from server: 1 bytes read"
5854
5855run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5856 "$P_SRV response_size=1" \
5857 "$P_CLI force_version=tls1_2 \
5858 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5859 0 \
5860 -c "Read from server: 1 bytes read"
5861
5862run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5863 "$P_SRV response_size=1" \
5864 "$P_CLI force_version=tls1_2 \
5865 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5866 0 \
5867 -c "Read from server: 1 bytes read"
5868
5869requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5870run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5871 "$P_SRV response_size=1 trunc_hmac=1" \
5872 "$P_CLI force_version=tls1_2 \
5873 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5874 0 \
5875 -c "Read from server: 1 bytes read"
5876
5877requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5878run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5879 "$P_SRV response_size=1 trunc_hmac=1" \
5880 "$P_CLI force_version=tls1_2 \
5881 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5882 0 \
5883 -c "Read from server: 1 bytes read"
5884
5885run_test "Small server packet TLS 1.2 StreamCipher" \
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" \
5889 0 \
5890 -c "Read from server: 1 bytes read"
5891
5892run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
5893 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5894 "$P_CLI force_version=tls1_2 \
5895 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5896 0 \
5897 -c "Read from server: 1 bytes read"
5898
5899requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5900run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
5901 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5902 "$P_CLI force_version=tls1_2 \
5903 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5904 0 \
5905 -c "Read from server: 1 bytes read"
5906
5907requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5908run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5909 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5910 "$P_CLI force_version=tls1_2 \
5911 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5912 0 \
5913 -c "Read from server: 1 bytes read"
5914
5915run_test "Small server packet TLS 1.2 AEAD" \
5916 "$P_SRV response_size=1" \
5917 "$P_CLI force_version=tls1_2 \
5918 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5919 0 \
5920 -c "Read from server: 1 bytes read"
5921
5922run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5923 "$P_SRV response_size=1" \
5924 "$P_CLI force_version=tls1_2 \
5925 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5926 0 \
5927 -c "Read from server: 1 bytes read"
5928
5929# Tests for small server packets in DTLS
5930
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005931run_test "Small server packet DTLS 1.0" \
5932 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
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 -04005938run_test "Small server packet DTLS 1.0, without EtM" \
5939 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
5940 "$P_CLI dtls=1 \
5941 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5942 0 \
5943 -c "Read from server: 1 bytes read"
5944
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005945requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5946run_test "Small server packet DTLS 1.0, truncated hmac" \
5947 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
5948 "$P_CLI dtls=1 trunc_hmac=1 \
5949 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5950 0 \
5951 -c "Read from server: 1 bytes read"
5952
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005953requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5954run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
5955 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
5956 "$P_CLI dtls=1 \
5957 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
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" \
5962 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
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 -04005968run_test "Small server packet DTLS 1.2, without EtM" \
5969 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5970 "$P_CLI dtls=1 \
5971 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5972 0 \
5973 -c "Read from server: 1 bytes read"
5974
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005975requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5976run_test "Small server packet DTLS 1.2, truncated hmac" \
5977 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5978 "$P_CLI dtls=1 \
5979 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5980 0 \
5981 -c "Read from server: 1 bytes read"
5982
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005983requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5984run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5985 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5986 "$P_CLI dtls=1 \
5987 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5988 0 \
5989 -c "Read from server: 1 bytes read"
5990
Jarno Lamsac40184b2019-10-28 14:16:12 +02005991run_test "Small server packet DTLS, ECDHE-ECDSA" \
5992 "$P_SRV dtls=1 response_size=1" \
5993 "$P_CLI dtls=1 \
5994 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
5995 0 \
5996 -c "Read from server: 1 bytes read"
5997
Janos Follath00efff72016-05-06 13:48:23 +01005998# A test for extensions in SSLv3
5999
6000requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6001run_test "SSLv3 with extensions, server side" \
6002 "$P_SRV min_version=ssl3 debug_level=3" \
6003 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
6004 0 \
6005 -S "dumping 'client hello extensions'" \
6006 -S "server hello, total extension length:"
6007
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006008# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006009
Angus Grattonc4dd0732018-04-11 16:28:39 +10006010# How many fragments do we expect to write $1 bytes?
6011fragments_for_write() {
6012 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
6013}
6014
Janos Follathe2681a42016-03-07 15:57:05 +00006015requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006016run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01006017 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006018 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006019 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6020 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006021 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6022 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006023
Janos Follathe2681a42016-03-07 15:57:05 +00006024requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006025run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006026 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006027 "$P_CLI request_size=16384 force_version=ssl3 \
6028 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6029 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006030 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6031 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006032
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006033run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006034 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006035 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006036 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6037 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006038 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6039 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006040
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006041run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006042 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006043 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
6044 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6045 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006046 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006047
Hanno Becker32c55012017-11-10 08:42:54 +00006048requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006049run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006050 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006051 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006052 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006053 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006054 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6055 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006056
Hanno Becker32c55012017-11-10 08:42:54 +00006057requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006058run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006059 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006060 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006061 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006062 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" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006066 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006067 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006068 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6069 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
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006072run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006073 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6074 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006075 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006076 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006077 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006078
6079requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006080run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006081 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006082 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006083 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006084 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006085 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006086
Hanno Becker278fc7a2017-11-10 09:16:28 +00006087requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006088run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006089 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006090 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006091 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006092 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006093 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6094 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006095
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006096run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006097 "$P_SRV" \
6098 "$P_CLI request_size=16384 force_version=tls1_1 \
6099 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6100 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006101 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6102 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006103
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006104run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006105 "$P_SRV" \
6106 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6107 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006108 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006109 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006110
Hanno Becker32c55012017-11-10 08:42:54 +00006111requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006112run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006113 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006114 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006115 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006116 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006117 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006118
Hanno Becker32c55012017-11-10 08:42:54 +00006119requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006120run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006121 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006122 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006123 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006124 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006125 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006126
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006127run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006128 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6129 "$P_CLI request_size=16384 force_version=tls1_1 \
6130 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6131 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006132 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6133 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006134
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006135run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006136 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006137 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006138 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006139 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006140 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6141 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006142
Hanno Becker278fc7a2017-11-10 09:16:28 +00006143requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006144run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006145 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006146 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006147 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006148 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006149 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006150
Hanno Becker278fc7a2017-11-10 09:16:28 +00006151requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006152run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006153 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006154 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006155 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006156 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006157 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6158 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006159
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006160run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006161 "$P_SRV" \
6162 "$P_CLI request_size=16384 force_version=tls1_2 \
6163 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6164 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006165 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6166 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006167
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006168run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006169 "$P_SRV" \
6170 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6171 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6172 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006173 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006174
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006175run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006176 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006177 "$P_CLI request_size=16384 force_version=tls1_2 \
6178 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006179 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006180 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6181 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006182
Hanno Becker32c55012017-11-10 08:42:54 +00006183requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006184run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006185 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006186 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006187 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006188 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006189 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006190
Hanno Becker278fc7a2017-11-10 09:16:28 +00006191requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006192run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006193 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006194 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006195 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006196 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006197 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6198 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006199
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006200run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006201 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006202 "$P_CLI request_size=16384 force_version=tls1_2 \
6203 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6204 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006205 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6206 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006207
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006208run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006209 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006210 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006211 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6212 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006213 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006214
Hanno Becker32c55012017-11-10 08:42:54 +00006215requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006216run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006217 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006218 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006219 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006220 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006221 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006222
Hanno Becker278fc7a2017-11-10 09:16:28 +00006223requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006224run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006225 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006226 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006227 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006228 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006229 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6230 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006231
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006232run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006233 "$P_SRV" \
6234 "$P_CLI request_size=16384 force_version=tls1_2 \
6235 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6236 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006237 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6238 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006239
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006240run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006241 "$P_SRV" \
6242 "$P_CLI request_size=16384 force_version=tls1_2 \
6243 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6244 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006245 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6246 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006247
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006248# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006249requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6250run_test "Large server packet SSLv3 StreamCipher" \
6251 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6252 "$P_CLI force_version=ssl3 \
6253 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6254 0 \
6255 -c "Read from server: 16384 bytes read"
6256
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006257# Checking next 4 tests logs for 1n-1 split against BEAST too
6258requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6259run_test "Large server packet SSLv3 BlockCipher" \
6260 "$P_SRV response_size=16384 min_version=ssl3" \
6261 "$P_CLI force_version=ssl3 recsplit=0 \
6262 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6263 0 \
6264 -c "Read from server: 1 bytes read"\
6265 -c "16383 bytes read"\
6266 -C "Read from server: 16384 bytes read"
6267
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006268run_test "Large server packet TLS 1.0 BlockCipher" \
6269 "$P_SRV response_size=16384" \
6270 "$P_CLI force_version=tls1 recsplit=0 \
6271 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6272 0 \
6273 -c "Read from server: 1 bytes read"\
6274 -c "16383 bytes read"\
6275 -C "Read from server: 16384 bytes read"
6276
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006277run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6278 "$P_SRV response_size=16384" \
6279 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6280 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6281 0 \
6282 -c "Read from server: 1 bytes read"\
6283 -c "16383 bytes read"\
6284 -C "Read from server: 16384 bytes read"
6285
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006286requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6287run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6288 "$P_SRV response_size=16384" \
6289 "$P_CLI force_version=tls1 recsplit=0 \
6290 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6291 trunc_hmac=1" \
6292 0 \
6293 -c "Read from server: 1 bytes read"\
6294 -c "16383 bytes read"\
6295 -C "Read from server: 16384 bytes read"
6296
6297requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6298run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6299 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6300 "$P_CLI force_version=tls1 \
6301 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6302 trunc_hmac=1" \
6303 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006304 -s "16384 bytes written in 1 fragments" \
6305 -c "Read from server: 16384 bytes read"
6306
6307run_test "Large server packet TLS 1.0 StreamCipher" \
6308 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6309 "$P_CLI force_version=tls1 \
6310 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6311 0 \
6312 -s "16384 bytes written in 1 fragments" \
6313 -c "Read from server: 16384 bytes read"
6314
6315run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6316 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6317 "$P_CLI force_version=tls1 \
6318 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6319 0 \
6320 -s "16384 bytes written in 1 fragments" \
6321 -c "Read from server: 16384 bytes read"
6322
6323requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6324run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6325 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6326 "$P_CLI force_version=tls1 \
6327 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6328 0 \
6329 -s "16384 bytes written in 1 fragments" \
6330 -c "Read from server: 16384 bytes read"
6331
6332requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6333run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6334 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6335 "$P_CLI force_version=tls1 \
6336 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6337 0 \
6338 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006339 -c "Read from server: 16384 bytes read"
6340
6341run_test "Large server packet TLS 1.1 BlockCipher" \
6342 "$P_SRV response_size=16384" \
6343 "$P_CLI force_version=tls1_1 \
6344 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6345 0 \
6346 -c "Read from server: 16384 bytes read"
6347
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006348run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6349 "$P_SRV response_size=16384" \
6350 "$P_CLI force_version=tls1_1 etm=0 \
6351 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006352 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006353 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006354 -c "Read from server: 16384 bytes read"
6355
6356requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6357run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6358 "$P_SRV response_size=16384" \
6359 "$P_CLI force_version=tls1_1 \
6360 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6361 trunc_hmac=1" \
6362 0 \
6363 -c "Read from server: 16384 bytes read"
6364
6365requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006366run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6367 "$P_SRV response_size=16384 trunc_hmac=1" \
6368 "$P_CLI force_version=tls1_1 \
6369 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6370 0 \
6371 -s "16384 bytes written in 1 fragments" \
6372 -c "Read from server: 16384 bytes read"
6373
6374run_test "Large server packet TLS 1.1 StreamCipher" \
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" \
6378 0 \
6379 -c "Read from server: 16384 bytes read"
6380
6381run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6382 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6383 "$P_CLI force_version=tls1_1 \
6384 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6385 0 \
6386 -s "16384 bytes written in 1 fragments" \
6387 -c "Read from server: 16384 bytes read"
6388
6389requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006390run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6391 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6392 "$P_CLI force_version=tls1_1 \
6393 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6394 trunc_hmac=1" \
6395 0 \
6396 -c "Read from server: 16384 bytes read"
6397
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006398run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6399 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6400 "$P_CLI force_version=tls1_1 \
6401 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6402 0 \
6403 -s "16384 bytes written in 1 fragments" \
6404 -c "Read from server: 16384 bytes read"
6405
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006406run_test "Large server packet TLS 1.2 BlockCipher" \
6407 "$P_SRV response_size=16384" \
6408 "$P_CLI force_version=tls1_2 \
6409 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6410 0 \
6411 -c "Read from server: 16384 bytes read"
6412
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006413run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6414 "$P_SRV response_size=16384" \
6415 "$P_CLI force_version=tls1_2 etm=0 \
6416 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6417 0 \
6418 -s "16384 bytes written in 1 fragments" \
6419 -c "Read from server: 16384 bytes read"
6420
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006421run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6422 "$P_SRV response_size=16384" \
6423 "$P_CLI force_version=tls1_2 \
6424 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6425 0 \
6426 -c "Read from server: 16384 bytes read"
6427
6428requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6429run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6430 "$P_SRV response_size=16384" \
6431 "$P_CLI force_version=tls1_2 \
6432 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6433 trunc_hmac=1" \
6434 0 \
6435 -c "Read from server: 16384 bytes read"
6436
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006437run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6438 "$P_SRV response_size=16384 trunc_hmac=1" \
6439 "$P_CLI force_version=tls1_2 \
6440 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6441 0 \
6442 -s "16384 bytes written in 1 fragments" \
6443 -c "Read from server: 16384 bytes read"
6444
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006445run_test "Large server packet TLS 1.2 StreamCipher" \
6446 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6447 "$P_CLI force_version=tls1_2 \
6448 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6449 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006450 -s "16384 bytes written in 1 fragments" \
6451 -c "Read from server: 16384 bytes read"
6452
6453run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6454 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6455 "$P_CLI force_version=tls1_2 \
6456 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6457 0 \
6458 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006459 -c "Read from server: 16384 bytes read"
6460
6461requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6462run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6463 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6464 "$P_CLI force_version=tls1_2 \
6465 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6466 trunc_hmac=1" \
6467 0 \
6468 -c "Read from server: 16384 bytes read"
6469
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006470requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6471run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6472 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6473 "$P_CLI force_version=tls1_2 \
6474 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6475 0 \
6476 -s "16384 bytes written in 1 fragments" \
6477 -c "Read from server: 16384 bytes read"
6478
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006479run_test "Large server packet TLS 1.2 AEAD" \
6480 "$P_SRV response_size=16384" \
6481 "$P_CLI force_version=tls1_2 \
6482 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6483 0 \
6484 -c "Read from server: 16384 bytes read"
6485
6486run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6487 "$P_SRV response_size=16384" \
6488 "$P_CLI force_version=tls1_2 \
6489 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6490 0 \
6491 -c "Read from server: 16384 bytes read"
6492
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006493# Tests for restartable ECC
6494
6495requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6496run_test "EC restart: TLS, default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006497 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006498 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006499 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006500 debug_level=1" \
6501 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006502 -C "x509_verify_cert.*4b00" \
6503 -C "mbedtls_pk_verify.*4b00" \
6504 -C "mbedtls_ecdh_make_public.*4b00" \
6505 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006506
6507requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6508run_test "EC restart: TLS, max_ops=0" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006509 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006510 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006511 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006512 debug_level=1 ec_max_ops=0" \
6513 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006514 -C "x509_verify_cert.*4b00" \
6515 -C "mbedtls_pk_verify.*4b00" \
6516 -C "mbedtls_ecdh_make_public.*4b00" \
6517 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006518
6519requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6520run_test "EC restart: TLS, max_ops=65535" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006521 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006522 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006523 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006524 debug_level=1 ec_max_ops=65535" \
6525 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006526 -C "x509_verify_cert.*4b00" \
6527 -C "mbedtls_pk_verify.*4b00" \
6528 -C "mbedtls_ecdh_make_public.*4b00" \
6529 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006530
6531requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6532run_test "EC restart: TLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006533 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006534 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006535 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006536 debug_level=1 ec_max_ops=1000" \
6537 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006538 -c "x509_verify_cert.*4b00" \
6539 -c "mbedtls_pk_verify.*4b00" \
6540 -c "mbedtls_ecdh_make_public.*4b00" \
6541 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006542
6543requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Hanno Becker4a156fc2019-06-14 17:07:06 +01006544requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006545run_test "EC restart: TLS, max_ops=1000, badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006546 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006547 crt_file=data_files/server5-badsign.crt \
6548 key_file=data_files/server5.key" \
6549 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker03d77462019-08-27 16:24:56 +01006550 key_file=data_files/server5.key crt_file=data_files/server5.crt ca_file=data_files/test-ca2.crt \
6551 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6552 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006553 -c "x509_verify_cert.*4b00" \
Hanno Becker03d77462019-08-27 16:24:56 +01006554 -c "mbedtls_pk_verify.*4b00" \
6555 -c "mbedtls_ecdh_make_public.*4b00" \
6556 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006557 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006558
Hanno Becker4a156fc2019-06-14 17:07:06 +01006559requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006560requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6561run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006562 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006563 crt_file=data_files/server5-badsign.crt \
6564 key_file=data_files/server5.key" \
6565 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6566 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006567 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006568 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6569 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006570 -c "x509_verify_cert.*4b00" \
6571 -c "mbedtls_pk_verify.*4b00" \
6572 -c "mbedtls_ecdh_make_public.*4b00" \
6573 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006574 -c "! The certificate is not correctly signed by the trusted CA" \
6575 -C "! mbedtls_ssl_handshake returned" \
6576 -C "X509 - Certificate verification failed"
6577
Hanno Becker4a156fc2019-06-14 17:07:06 +01006578requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006579requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006580requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6581run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006582 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006583 crt_file=data_files/server5-badsign.crt \
6584 key_file=data_files/server5.key" \
6585 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006586 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006587 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6588 debug_level=1 ec_max_ops=1000 auth_mode=none" \
6589 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006590 -C "x509_verify_cert.*4b00" \
6591 -c "mbedtls_pk_verify.*4b00" \
6592 -c "mbedtls_ecdh_make_public.*4b00" \
6593 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006594 -C "! The certificate is not correctly signed by the trusted CA" \
6595 -C "! mbedtls_ssl_handshake returned" \
6596 -C "X509 - Certificate verification failed"
6597
6598requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006599run_test "EC restart: DTLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006600 "$P_SRV auth_mode=required dtls=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006601 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006602 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006603 dtls=1 debug_level=1 ec_max_ops=1000" \
6604 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006605 -c "x509_verify_cert.*4b00" \
6606 -c "mbedtls_pk_verify.*4b00" \
6607 -c "mbedtls_ecdh_make_public.*4b00" \
6608 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006609
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006610requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6611run_test "EC restart: TLS, max_ops=1000 no client auth" \
6612 "$P_SRV" \
6613 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6614 debug_level=1 ec_max_ops=1000" \
6615 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006616 -c "x509_verify_cert.*4b00" \
6617 -c "mbedtls_pk_verify.*4b00" \
6618 -c "mbedtls_ecdh_make_public.*4b00" \
6619 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006620
6621requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6622run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6623 "$P_SRV psk=abc123" \
6624 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6625 psk=abc123 debug_level=1 ec_max_ops=1000" \
6626 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006627 -C "x509_verify_cert.*4b00" \
6628 -C "mbedtls_pk_verify.*4b00" \
6629 -C "mbedtls_ecdh_make_public.*4b00" \
6630 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006631
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006632# Tests of asynchronous private key support in SSL
6633
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006634requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006635run_test "SSL async private: sign, delay=0" \
6636 "$P_SRV \
6637 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006638 "$P_CLI" \
6639 0 \
6640 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006641 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006642
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006643requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006644run_test "SSL async private: sign, delay=1" \
6645 "$P_SRV \
6646 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006647 "$P_CLI" \
6648 0 \
6649 -s "Async sign callback: using key slot " \
6650 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006651 -s "Async resume (slot [0-9]): sign done, status=0"
6652
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006653requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6654run_test "SSL async private: sign, delay=2" \
6655 "$P_SRV \
6656 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6657 "$P_CLI" \
6658 0 \
6659 -s "Async sign callback: using key slot " \
6660 -U "Async sign callback: using key slot " \
6661 -s "Async resume (slot [0-9]): call 1 more times." \
6662 -s "Async resume (slot [0-9]): call 0 more times." \
6663 -s "Async resume (slot [0-9]): sign done, status=0"
6664
Gilles Peskined3268832018-04-26 06:23:59 +02006665# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
6666# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
6667requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6668requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6669run_test "SSL async private: sign, RSA, TLS 1.1" \
6670 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
6671 async_operations=s async_private_delay1=0 async_private_delay2=0" \
6672 "$P_CLI force_version=tls1_1" \
6673 0 \
6674 -s "Async sign callback: using key slot " \
6675 -s "Async resume (slot [0-9]): sign done, status=0"
6676
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006677requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerb2c63832019-06-17 08:35:16 +01006678requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03006679requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006680requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskine807d74a2018-04-30 10:30:49 +02006681run_test "SSL async private: sign, SNI" \
6682 "$P_SRV debug_level=3 \
6683 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6684 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6685 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6686 "$P_CLI server_name=polarssl.example" \
6687 0 \
6688 -s "Async sign callback: using key slot " \
6689 -s "Async resume (slot [0-9]): sign done, status=0" \
6690 -s "parse ServerName extension" \
6691 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6692 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6693
6694requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006695run_test "SSL async private: decrypt, delay=0" \
6696 "$P_SRV \
6697 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6698 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6699 0 \
6700 -s "Async decrypt callback: using key slot " \
6701 -s "Async resume (slot [0-9]): decrypt done, status=0"
6702
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006703requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006704run_test "SSL async private: decrypt, delay=1" \
6705 "$P_SRV \
6706 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6707 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6708 0 \
6709 -s "Async decrypt callback: using key slot " \
6710 -s "Async resume (slot [0-9]): call 0 more times." \
6711 -s "Async resume (slot [0-9]): decrypt done, status=0"
6712
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006713requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006714run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6715 "$P_SRV psk=abc123 \
6716 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6717 "$P_CLI psk=abc123 \
6718 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6719 0 \
6720 -s "Async decrypt callback: using key slot " \
6721 -s "Async resume (slot [0-9]): decrypt done, status=0"
6722
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006723requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006724run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6725 "$P_SRV psk=abc123 \
6726 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6727 "$P_CLI psk=abc123 \
6728 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6729 0 \
6730 -s "Async decrypt callback: using key slot " \
6731 -s "Async resume (slot [0-9]): call 0 more times." \
6732 -s "Async resume (slot [0-9]): decrypt done, status=0"
6733
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006734requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006735run_test "SSL async private: sign callback not present" \
6736 "$P_SRV \
6737 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6738 "$P_CLI; [ \$? -eq 1 ] &&
6739 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6740 0 \
6741 -S "Async sign callback" \
6742 -s "! mbedtls_ssl_handshake returned" \
6743 -s "The own private key or pre-shared key is not set, but needed" \
6744 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6745 -s "Successful connection"
6746
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006747requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006748run_test "SSL async private: decrypt callback not present" \
6749 "$P_SRV debug_level=1 \
6750 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6751 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6752 [ \$? -eq 1 ] && $P_CLI" \
6753 0 \
6754 -S "Async decrypt callback" \
6755 -s "! mbedtls_ssl_handshake returned" \
6756 -s "got no RSA private key" \
6757 -s "Async resume (slot [0-9]): sign done, status=0" \
6758 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006759
6760# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006761requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006762run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006763 "$P_SRV \
6764 async_operations=s async_private_delay1=1 \
6765 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6766 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006767 "$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 +01006768 0 \
6769 -s "Async sign callback: using key slot 0," \
6770 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006771 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006772
6773# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006774requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006775run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006776 "$P_SRV \
6777 async_operations=s async_private_delay2=1 \
6778 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6779 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006780 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6781 0 \
6782 -s "Async sign callback: using key slot 0," \
6783 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006784 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006785
6786# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006787requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006788run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006789 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006790 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006791 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6792 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006793 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6794 0 \
6795 -s "Async sign callback: using key slot 1," \
6796 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006797 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006798
6799# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006800requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006801run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006802 "$P_SRV \
6803 async_operations=s async_private_delay1=1 \
6804 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6805 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006806 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6807 0 \
6808 -s "Async sign callback: no key matches this certificate."
6809
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006810requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006811run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006812 "$P_SRV \
6813 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6814 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006815 "$P_CLI" \
6816 1 \
6817 -s "Async sign callback: injected error" \
6818 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006819 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006820 -s "! mbedtls_ssl_handshake returned"
6821
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006822requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006823run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006824 "$P_SRV \
6825 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6826 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006827 "$P_CLI" \
6828 1 \
6829 -s "Async sign callback: using key slot " \
6830 -S "Async resume" \
6831 -s "Async cancel"
6832
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006833requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006834run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006835 "$P_SRV \
6836 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6837 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006838 "$P_CLI" \
6839 1 \
6840 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006841 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006842 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006843 -s "! mbedtls_ssl_handshake returned"
6844
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006845requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006846run_test "SSL async private: decrypt, error in start" \
6847 "$P_SRV \
6848 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6849 async_private_error=1" \
6850 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6851 1 \
6852 -s "Async decrypt callback: injected error" \
6853 -S "Async resume" \
6854 -S "Async cancel" \
6855 -s "! mbedtls_ssl_handshake returned"
6856
6857requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6858run_test "SSL async private: decrypt, cancel after start" \
6859 "$P_SRV \
6860 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6861 async_private_error=2" \
6862 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6863 1 \
6864 -s "Async decrypt callback: using key slot " \
6865 -S "Async resume" \
6866 -s "Async cancel"
6867
6868requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6869run_test "SSL async private: decrypt, error in resume" \
6870 "$P_SRV \
6871 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6872 async_private_error=3" \
6873 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6874 1 \
6875 -s "Async decrypt callback: using key slot " \
6876 -s "Async resume callback: decrypt done but injected error" \
6877 -S "Async cancel" \
6878 -s "! mbedtls_ssl_handshake returned"
6879
6880requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006881run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006882 "$P_SRV \
6883 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6884 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006885 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6886 0 \
6887 -s "Async cancel" \
6888 -s "! mbedtls_ssl_handshake returned" \
6889 -s "Async resume" \
6890 -s "Successful connection"
6891
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006892requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006893run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006894 "$P_SRV \
6895 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6896 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006897 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6898 0 \
6899 -s "! mbedtls_ssl_handshake returned" \
6900 -s "Async resume" \
6901 -s "Successful connection"
6902
6903# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006904requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006905run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006906 "$P_SRV \
6907 async_operations=s async_private_delay1=1 async_private_error=-2 \
6908 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6909 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006910 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6911 [ \$? -eq 1 ] &&
6912 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6913 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006914 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006915 -S "Async resume" \
6916 -s "Async cancel" \
6917 -s "! mbedtls_ssl_handshake returned" \
6918 -s "Async sign callback: no key matches this certificate." \
6919 -s "Successful connection"
6920
6921# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006922requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006923run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006924 "$P_SRV \
6925 async_operations=s async_private_delay1=1 async_private_error=-3 \
6926 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6927 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006928 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6929 [ \$? -eq 1 ] &&
6930 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6931 0 \
6932 -s "Async resume" \
6933 -s "! mbedtls_ssl_handshake returned" \
6934 -s "Async sign callback: no key matches this certificate." \
6935 -s "Successful connection"
6936
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006937requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006938requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006939run_test "SSL async private: renegotiation: client-initiated; sign" \
6940 "$P_SRV \
6941 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006942 exchanges=2 renegotiation=1" \
6943 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6944 0 \
6945 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006946 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006947
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006948requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006949requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006950run_test "SSL async private: renegotiation: server-initiated; sign" \
6951 "$P_SRV \
6952 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006953 exchanges=2 renegotiation=1 renegotiate=1" \
6954 "$P_CLI exchanges=2 renegotiation=1" \
6955 0 \
6956 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006957 -s "Async resume (slot [0-9]): sign done, status=0"
6958
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006959requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006960requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6961run_test "SSL async private: renegotiation: client-initiated; decrypt" \
6962 "$P_SRV \
6963 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6964 exchanges=2 renegotiation=1" \
6965 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6966 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6967 0 \
6968 -s "Async decrypt callback: using key slot " \
6969 -s "Async resume (slot [0-9]): decrypt done, status=0"
6970
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006971requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006972requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6973run_test "SSL async private: renegotiation: server-initiated; decrypt" \
6974 "$P_SRV \
6975 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6976 exchanges=2 renegotiation=1 renegotiate=1" \
6977 "$P_CLI exchanges=2 renegotiation=1 \
6978 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6979 0 \
6980 -s "Async decrypt callback: using key slot " \
6981 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006982
Ron Eldor58093c82018-06-28 13:22:05 +03006983# Tests for ECC extensions (rfc 4492)
6984
Ron Eldor643df7c2018-06-28 16:17:00 +03006985requires_config_enabled MBEDTLS_AES_C
6986requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6987requires_config_enabled MBEDTLS_SHA256_C
6988requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006989run_test "Force a non ECC ciphersuite in the client side" \
6990 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006991 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006992 0 \
6993 -C "client hello, adding supported_elliptic_curves extension" \
6994 -C "client hello, adding supported_point_formats extension" \
6995 -S "found supported elliptic curves extension" \
6996 -S "found supported point formats extension"
6997
Ron Eldor643df7c2018-06-28 16:17:00 +03006998requires_config_enabled MBEDTLS_AES_C
6999requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7000requires_config_enabled MBEDTLS_SHA256_C
7001requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007002run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03007003 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03007004 "$P_CLI debug_level=3" \
7005 0 \
7006 -C "found supported_point_formats extension" \
7007 -S "server hello, supported_point_formats extension"
7008
Ron Eldor643df7c2018-06-28 16:17:00 +03007009requires_config_enabled MBEDTLS_AES_C
7010requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7011requires_config_enabled MBEDTLS_SHA256_C
7012requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007013run_test "Force an ECC ciphersuite in the client side" \
7014 "$P_SRV debug_level=3" \
7015 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7016 0 \
7017 -c "client hello, adding supported_elliptic_curves extension" \
7018 -c "client hello, adding supported_point_formats extension" \
7019 -s "found supported elliptic curves extension" \
7020 -s "found supported point formats extension"
7021
Ron Eldor643df7c2018-06-28 16:17:00 +03007022requires_config_enabled MBEDTLS_AES_C
7023requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7024requires_config_enabled MBEDTLS_SHA256_C
7025requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007026run_test "Force an ECC ciphersuite in the server side" \
7027 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7028 "$P_CLI debug_level=3" \
7029 0 \
7030 -c "found supported_point_formats extension" \
7031 -s "server hello, supported_point_formats extension"
7032
Jarno Lamsa2e2fa5e2019-10-30 15:08:26 +02007033requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
Jarno Lamsad3428052019-10-28 14:36:37 +02007034run_test "Force an ECC ciphersuite with CCM in the client side" \
7035 "$P_SRV dtls=1 debug_level=3" \
7036 "$P_CLI dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
7037 0 \
7038 -c "client hello, adding supported_elliptic_curves extension" \
7039 -c "client hello, adding supported_point_formats extension" \
7040 -s "found supported elliptic curves extension" \
7041 -s "found supported point formats extension"
7042
Jarno Lamsa2e2fa5e2019-10-30 15:08:26 +02007043requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
Jarno Lamsad3428052019-10-28 14:36:37 +02007044run_test "Force an ECC ciphersuite with CCM in the server side" \
7045 "$P_SRV dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
7046 "$P_CLI dtls=1 debug_level=3" \
7047 0 \
7048 -c "found supported_point_formats extension" \
7049 -s "server hello, supported_point_formats extension"
7050
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007051# Tests for DTLS HelloVerifyRequest
7052
7053run_test "DTLS cookie: enabled" \
7054 "$P_SRV dtls=1 debug_level=2" \
7055 "$P_CLI dtls=1 debug_level=2" \
7056 0 \
7057 -s "cookie verification failed" \
7058 -s "cookie verification passed" \
7059 -S "cookie verification skipped" \
7060 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007061 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007062 -S "SSL - The requested feature is not available"
7063
7064run_test "DTLS cookie: disabled" \
7065 "$P_SRV dtls=1 debug_level=2 cookies=0" \
7066 "$P_CLI dtls=1 debug_level=2" \
7067 0 \
7068 -S "cookie verification failed" \
7069 -S "cookie verification passed" \
7070 -s "cookie verification skipped" \
7071 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007072 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007073 -S "SSL - The requested feature is not available"
7074
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007075run_test "DTLS cookie: default (failing)" \
7076 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
7077 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
7078 1 \
7079 -s "cookie verification failed" \
7080 -S "cookie verification passed" \
7081 -S "cookie verification skipped" \
7082 -C "received hello verify request" \
Jarno Lamsab514cd32019-10-28 14:37:51 +02007083 -S "hello verification requested"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007084
7085requires_ipv6
7086run_test "DTLS cookie: enabled, IPv6" \
7087 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
7088 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
7089 0 \
7090 -s "cookie verification failed" \
7091 -s "cookie verification passed" \
7092 -S "cookie verification skipped" \
7093 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007094 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007095 -S "SSL - The requested feature is not available"
7096
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007097run_test "DTLS cookie: enabled, nbio" \
7098 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7099 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7100 0 \
7101 -s "cookie verification failed" \
7102 -s "cookie verification passed" \
7103 -S "cookie verification skipped" \
7104 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007105 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007106 -S "SSL - The requested feature is not available"
7107
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007108# Tests for client reconnecting from the same port with DTLS
7109
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007110not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007111requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007112run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007113 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7114 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007115 0 \
7116 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007117 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007118 -S "Client initiated reconnection from same port"
7119
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007120not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007121requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007122run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007123 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
7124 "$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 +02007125 0 \
7126 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007127 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007128 -s "Client initiated reconnection from same port"
7129
Paul Bakker362689d2016-05-13 10:33:25 +01007130not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
Jarno Lamsa33281d52019-10-18 10:54:35 +03007131requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007132run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007133 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7134 "$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 +02007135 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007136 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007137 -s "Client initiated reconnection from same port"
7138
Paul Bakker362689d2016-05-13 10:33:25 +01007139only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
Jarno Lamsa33281d52019-10-18 10:54:35 +03007140requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Paul Bakker362689d2016-05-13 10:33:25 +01007141run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7142 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7143 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7144 0 \
7145 -S "The operation timed out" \
7146 -s "Client initiated reconnection from same port"
7147
Jarno Lamsa33281d52019-10-18 10:54:35 +03007148requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007149run_test "DTLS client reconnect from same port: no cookies" \
7150 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007151 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7152 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007153 -s "The operation timed out" \
7154 -S "Client initiated reconnection from same port"
7155
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007156# Tests for various cases of client authentication with DTLS
7157# (focused on handshake flows and message parsing)
7158
7159run_test "DTLS client auth: required" \
7160 "$P_SRV dtls=1 auth_mode=required" \
7161 "$P_CLI dtls=1" \
7162 0 \
7163 -s "Verifying peer X.509 certificate... ok"
7164
Hanno Becker4a156fc2019-06-14 17:07:06 +01007165requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007166requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007167run_test "DTLS client auth: optional, client has no cert" \
7168 "$P_SRV dtls=1 auth_mode=optional" \
7169 "$P_CLI dtls=1 crt_file=none key_file=none" \
7170 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007171 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007172
Hanno Becker4a156fc2019-06-14 17:07:06 +01007173requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007174requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007175run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007176 "$P_SRV dtls=1 auth_mode=none" \
7177 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7178 0 \
7179 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007180 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007181
Jarno Lamsa33281d52019-10-18 10:54:35 +03007182requires_ciphersuite_enabled TLS-PSK-WITH-AES-128-GCM-SHA256
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007183run_test "DTLS wrong PSK: badmac alert" \
7184 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7185 "$P_CLI dtls=1 psk=abc124" \
7186 1 \
7187 -s "SSL - Verification of the message MAC failed" \
7188 -c "SSL - A fatal alert message was received from our peer"
7189
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007190# Tests for receiving fragmented handshake messages with DTLS
7191
7192requires_gnutls
7193run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7194 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007195 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007196 0 \
7197 -C "found fragmented DTLS handshake message" \
7198 -C "error"
7199
7200requires_gnutls
7201run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7202 "$G_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007203 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007204 0 \
7205 -c "found fragmented DTLS handshake message" \
7206 -C "error"
7207
7208requires_gnutls
7209run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7210 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007211 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007212 0 \
7213 -c "found fragmented DTLS handshake message" \
7214 -C "error"
7215
7216requires_gnutls
7217run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7218 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007219 "$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 +02007220 0 \
7221 -c "found fragmented DTLS handshake message" \
7222 -C "error"
7223
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007224requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007225requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007226run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7227 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007228 "$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 +02007229 0 \
7230 -c "found fragmented DTLS handshake message" \
7231 -c "client hello, adding renegotiation extension" \
7232 -c "found renegotiation extension" \
7233 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007234 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007235 -C "error" \
7236 -s "Extra-header:"
7237
7238requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007239requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007240run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7241 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007242 "$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 +02007243 0 \
7244 -c "found fragmented DTLS handshake message" \
7245 -c "client hello, adding renegotiation extension" \
7246 -c "found renegotiation extension" \
7247 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007248 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007249 -C "error" \
7250 -s "Extra-header:"
7251
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007252run_test "DTLS reassembly: no fragmentation (openssl server)" \
7253 "$O_SRV -dtls1 -mtu 2048" \
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é-Gonnarda7756172014-08-31 18:37:01 +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: some fragmentation (openssl server)" \
7260 "$O_SRV -dtls1 -mtu 768" \
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
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007266run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007267 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007268 "$P_CLI dtls=1 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"
7272
7273run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7274 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007275 "$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 +02007276 0 \
7277 -c "found fragmented DTLS handshake message" \
7278 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007279
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007280# Tests for sending fragmented handshake messages with DTLS
7281#
7282# Use client auth when we need the client to send large messages,
7283# and use large cert chains on both sides too (the long chains we have all use
7284# both RSA and ECDSA, but ideally we should have long chains with either).
7285# Sizes reached (UDP payload):
7286# - 2037B for server certificate
7287# - 1542B for client certificate
7288# - 1013B for newsessionticket
7289# - all others below 512B
7290# All those tests assume MAX_CONTENT_LEN is at least 2048
7291
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007292requires_config_enabled MBEDTLS_RSA_C
7293requires_config_enabled MBEDTLS_ECDSA_C
7294requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7295run_test "DTLS fragmenting: none (for reference)" \
7296 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7297 crt_file=data_files/server7_int-ca.crt \
7298 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007299 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007300 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007301 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007302 "$P_CLI dtls=1 debug_level=2 \
7303 crt_file=data_files/server8_int-ca2.crt \
7304 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007305 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007306 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007307 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007308 0 \
7309 -S "found fragmented DTLS handshake message" \
7310 -C "found fragmented DTLS handshake message" \
7311 -C "error"
7312
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007313requires_config_enabled MBEDTLS_RSA_C
7314requires_config_enabled MBEDTLS_ECDSA_C
7315requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007316run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007317 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7318 crt_file=data_files/server7_int-ca.crt \
7319 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007320 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007321 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007322 max_frag_len=1024" \
7323 "$P_CLI dtls=1 debug_level=2 \
7324 crt_file=data_files/server8_int-ca2.crt \
7325 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007326 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007327 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007328 max_frag_len=2048" \
7329 0 \
7330 -S "found fragmented DTLS handshake message" \
7331 -c "found fragmented DTLS handshake message" \
7332 -C "error"
7333
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007334# With the MFL extension, the server has no way of forcing
7335# the client to not exceed a certain MTU; hence, the following
7336# test can't be replicated with an MTU proxy such as the one
7337# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007338requires_config_enabled MBEDTLS_RSA_C
7339requires_config_enabled MBEDTLS_ECDSA_C
7340requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007341run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007342 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7343 crt_file=data_files/server7_int-ca.crt \
7344 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007345 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007346 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007347 max_frag_len=512" \
7348 "$P_CLI dtls=1 debug_level=2 \
7349 crt_file=data_files/server8_int-ca2.crt \
7350 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007351 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007352 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007353 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007354 0 \
7355 -S "found fragmented DTLS handshake message" \
7356 -c "found fragmented DTLS handshake message" \
7357 -C "error"
7358
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007359requires_config_enabled MBEDTLS_RSA_C
7360requires_config_enabled MBEDTLS_ECDSA_C
7361requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007362run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007363 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7364 crt_file=data_files/server7_int-ca.crt \
7365 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007366 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007367 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007368 max_frag_len=2048" \
7369 "$P_CLI dtls=1 debug_level=2 \
7370 crt_file=data_files/server8_int-ca2.crt \
7371 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007372 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007373 hs_timeout=2500-60000 \
7374 max_frag_len=1024" \
7375 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007376 -S "found fragmented DTLS handshake message" \
7377 -c "found fragmented DTLS handshake message" \
7378 -C "error"
7379
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007380# While not required by the standard defining the MFL extension
7381# (according to which it only applies to records, not to datagrams),
7382# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7383# as otherwise there wouldn't be any means to communicate MTU restrictions
7384# to the peer.
7385# The next test checks that no datagrams significantly larger than the
7386# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007387requires_config_enabled MBEDTLS_RSA_C
7388requires_config_enabled MBEDTLS_ECDSA_C
7389requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7390run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007391 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007392 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7393 crt_file=data_files/server7_int-ca.crt \
7394 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007395 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007396 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007397 max_frag_len=2048" \
7398 "$P_CLI dtls=1 debug_level=2 \
7399 crt_file=data_files/server8_int-ca2.crt \
7400 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007401 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007402 hs_timeout=2500-60000 \
7403 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007404 0 \
7405 -S "found fragmented DTLS handshake message" \
7406 -c "found fragmented DTLS handshake message" \
7407 -C "error"
7408
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007409requires_config_enabled MBEDTLS_RSA_C
7410requires_config_enabled MBEDTLS_ECDSA_C
7411requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007412run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007413 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7414 crt_file=data_files/server7_int-ca.crt \
7415 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007416 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007417 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007418 max_frag_len=2048" \
7419 "$P_CLI dtls=1 debug_level=2 \
7420 crt_file=data_files/server8_int-ca2.crt \
7421 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007422 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007423 hs_timeout=2500-60000 \
7424 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007425 0 \
7426 -s "found fragmented DTLS handshake message" \
7427 -c "found fragmented DTLS handshake message" \
7428 -C "error"
7429
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007430# While not required by the standard defining the MFL extension
7431# (according to which it only applies to records, not to datagrams),
7432# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7433# as otherwise there wouldn't be any means to communicate MTU restrictions
7434# to the peer.
7435# The next test checks that no datagrams significantly larger than the
7436# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007437requires_config_enabled MBEDTLS_RSA_C
7438requires_config_enabled MBEDTLS_ECDSA_C
7439requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7440run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007441 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007442 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7443 crt_file=data_files/server7_int-ca.crt \
7444 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007445 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007446 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007447 max_frag_len=2048" \
7448 "$P_CLI dtls=1 debug_level=2 \
7449 crt_file=data_files/server8_int-ca2.crt \
7450 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007451 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007452 hs_timeout=2500-60000 \
7453 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007454 0 \
7455 -s "found fragmented DTLS handshake message" \
7456 -c "found fragmented DTLS handshake message" \
7457 -C "error"
7458
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007459requires_config_enabled MBEDTLS_RSA_C
7460requires_config_enabled MBEDTLS_ECDSA_C
7461run_test "DTLS fragmenting: none (for reference) (MTU)" \
7462 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7463 crt_file=data_files/server7_int-ca.crt \
7464 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007465 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007466 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007467 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007468 "$P_CLI dtls=1 debug_level=2 \
7469 crt_file=data_files/server8_int-ca2.crt \
7470 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007471 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007472 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007473 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007474 0 \
7475 -S "found fragmented DTLS handshake message" \
7476 -C "found fragmented DTLS handshake message" \
7477 -C "error"
7478
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007479requires_config_enabled MBEDTLS_RSA_C
7480requires_config_enabled MBEDTLS_ECDSA_C
7481run_test "DTLS fragmenting: client (MTU)" \
7482 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7483 crt_file=data_files/server7_int-ca.crt \
7484 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007485 ca_file=data_files/test-ca.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007486 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007487 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007488 "$P_CLI dtls=1 debug_level=2 \
7489 crt_file=data_files/server8_int-ca2.crt \
7490 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007491 ca_file=data_files/test-ca2.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007492 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007493 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007494 0 \
7495 -s "found fragmented DTLS handshake message" \
7496 -C "found fragmented DTLS handshake message" \
7497 -C "error"
7498
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007499requires_config_enabled MBEDTLS_RSA_C
7500requires_config_enabled MBEDTLS_ECDSA_C
7501run_test "DTLS fragmenting: server (MTU)" \
7502 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7503 crt_file=data_files/server7_int-ca.crt \
7504 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007505 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007506 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007507 mtu=512" \
7508 "$P_CLI dtls=1 debug_level=2 \
7509 crt_file=data_files/server8_int-ca2.crt \
7510 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007511 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007512 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007513 mtu=2048" \
7514 0 \
7515 -S "found fragmented DTLS handshake message" \
7516 -c "found fragmented DTLS handshake message" \
7517 -C "error"
7518
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007519requires_config_enabled MBEDTLS_RSA_C
7520requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007521run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007522 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007523 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7524 crt_file=data_files/server7_int-ca.crt \
7525 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007526 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007527 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007528 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007529 "$P_CLI dtls=1 debug_level=2 \
7530 crt_file=data_files/server8_int-ca2.crt \
7531 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007532 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007533 hs_timeout=2500-60000 \
7534 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007535 0 \
7536 -s "found fragmented DTLS handshake message" \
7537 -c "found fragmented DTLS handshake message" \
7538 -C "error"
7539
Andrzej Kurek77826052018-10-11 07:34:08 -04007540# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007541requires_config_enabled MBEDTLS_RSA_C
7542requires_config_enabled MBEDTLS_ECDSA_C
7543requires_config_enabled MBEDTLS_SHA256_C
7544requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7545requires_config_enabled MBEDTLS_AES_C
7546requires_config_enabled MBEDTLS_GCM_C
7547run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007548 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007549 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7550 crt_file=data_files/server7_int-ca.crt \
7551 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007552 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007553 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007554 mtu=512" \
7555 "$P_CLI dtls=1 debug_level=2 \
7556 crt_file=data_files/server8_int-ca2.crt \
7557 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007558 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007559 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7560 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007561 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007562 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007563 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007564 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007565 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007566
Andrzej Kurek7311c782018-10-11 06:49:41 -04007567# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007568# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007569# The ratio of max/min timeout should ideally equal 4 to accept two
7570# retransmissions, but in some cases (like both the server and client using
7571# fragmentation and auto-reduction) an extra retransmission might occur,
7572# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007573not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007574requires_config_enabled MBEDTLS_RSA_C
7575requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007576requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7577requires_config_enabled MBEDTLS_AES_C
7578requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007579run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7580 -p "$P_PXY mtu=508" \
7581 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7582 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007583 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007584 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007585 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007586 "$P_CLI dtls=1 debug_level=2 \
7587 crt_file=data_files/server8_int-ca2.crt \
7588 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007589 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007590 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7591 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007592 0 \
7593 -s "found fragmented DTLS handshake message" \
7594 -c "found fragmented DTLS handshake message" \
7595 -C "error"
7596
Andrzej Kurek77826052018-10-11 07:34:08 -04007597# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007598only_with_valgrind
Hanno Becker108992e2018-08-29 17:04:18 +01007599requires_config_enabled MBEDTLS_RSA_C
7600requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007601requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7602requires_config_enabled MBEDTLS_AES_C
7603requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01007604run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7605 -p "$P_PXY mtu=508" \
7606 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7607 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007608 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007609 ca_file=data_files/test-ca.crt \
Hanno Becker108992e2018-08-29 17:04:18 +01007610 hs_timeout=250-10000" \
7611 "$P_CLI dtls=1 debug_level=2 \
7612 crt_file=data_files/server8_int-ca2.crt \
7613 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007614 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007615 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007616 hs_timeout=250-10000" \
7617 0 \
7618 -s "found fragmented DTLS handshake message" \
7619 -c "found fragmented DTLS handshake message" \
7620 -C "error"
7621
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007622# 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 +02007623# OTOH the client might resend if the server is to slow to reset after sending
7624# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007625not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007626requires_config_enabled MBEDTLS_RSA_C
7627requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007628run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007629 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007630 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7631 crt_file=data_files/server7_int-ca.crt \
7632 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007633 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007634 hs_timeout=10000-60000 \
7635 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007636 "$P_CLI dtls=1 debug_level=2 \
7637 crt_file=data_files/server8_int-ca2.crt \
7638 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007639 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007640 hs_timeout=10000-60000 \
7641 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007642 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007643 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007644 -s "found fragmented DTLS handshake message" \
7645 -c "found fragmented DTLS handshake message" \
7646 -C "error"
7647
Andrzej Kurek77826052018-10-11 07:34:08 -04007648# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007649# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7650# OTOH the client might resend if the server is to slow to reset after sending
7651# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007652not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007653requires_config_enabled MBEDTLS_RSA_C
7654requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007655requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7656requires_config_enabled MBEDTLS_AES_C
7657requires_config_enabled MBEDTLS_GCM_C
7658run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007659 -p "$P_PXY mtu=512" \
7660 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7661 crt_file=data_files/server7_int-ca.crt \
7662 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007663 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007664 hs_timeout=10000-60000 \
7665 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007666 "$P_CLI dtls=1 debug_level=2 \
7667 crt_file=data_files/server8_int-ca2.crt \
7668 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007669 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007670 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7671 hs_timeout=10000-60000 \
7672 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007673 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007674 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007675 -s "found fragmented DTLS handshake message" \
7676 -c "found fragmented DTLS handshake message" \
7677 -C "error"
7678
Andrzej Kurek7311c782018-10-11 06:49:41 -04007679not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007680requires_config_enabled MBEDTLS_RSA_C
7681requires_config_enabled MBEDTLS_ECDSA_C
7682run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007683 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007684 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7685 crt_file=data_files/server7_int-ca.crt \
7686 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007687 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007688 hs_timeout=10000-60000 \
7689 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007690 "$P_CLI dtls=1 debug_level=2 \
7691 crt_file=data_files/server8_int-ca2.crt \
7692 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007693 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007694 hs_timeout=10000-60000 \
7695 mtu=1024 nbio=2" \
7696 0 \
7697 -S "autoreduction" \
7698 -s "found fragmented DTLS handshake message" \
7699 -c "found fragmented DTLS handshake message" \
7700 -C "error"
7701
Andrzej Kurek77826052018-10-11 07:34:08 -04007702# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007703not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007704requires_config_enabled MBEDTLS_RSA_C
7705requires_config_enabled MBEDTLS_ECDSA_C
7706requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7707requires_config_enabled MBEDTLS_AES_C
7708requires_config_enabled MBEDTLS_GCM_C
7709run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7710 -p "$P_PXY mtu=512" \
7711 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7712 crt_file=data_files/server7_int-ca.crt \
7713 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007714 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007715 hs_timeout=10000-60000 \
7716 mtu=512 nbio=2" \
7717 "$P_CLI dtls=1 debug_level=2 \
7718 crt_file=data_files/server8_int-ca2.crt \
7719 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007720 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007721 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7722 hs_timeout=10000-60000 \
7723 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007724 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007725 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007726 -s "found fragmented DTLS handshake message" \
7727 -c "found fragmented DTLS handshake message" \
7728 -C "error"
7729
Andrzej Kurek77826052018-10-11 07:34:08 -04007730# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007731# This ensures things still work after session_reset().
7732# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007733# Since we don't support reading fragmented ClientHello yet,
7734# up the MTU to 1450 (larger than ClientHello with session ticket,
7735# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007736# An autoreduction on the client-side might happen if the server is
7737# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007738# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007739# resumed listening, which would result in a spurious autoreduction.
7740not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007741requires_config_enabled MBEDTLS_RSA_C
7742requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007743requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7744requires_config_enabled MBEDTLS_AES_C
7745requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007746run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7747 -p "$P_PXY mtu=1450" \
7748 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7749 crt_file=data_files/server7_int-ca.crt \
7750 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007751 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007752 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007753 mtu=1450" \
7754 "$P_CLI dtls=1 debug_level=2 \
7755 crt_file=data_files/server8_int-ca2.crt \
7756 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007757 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007758 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007759 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007760 mtu=1450 reconnect=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007761 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007762 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007763 -s "found fragmented DTLS handshake message" \
7764 -c "found fragmented DTLS handshake message" \
7765 -C "error"
7766
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007767# An autoreduction on the client-side might happen if the server is
7768# slow to reset, therefore omitting '-C "autoreduction"' below.
7769not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007770requires_config_enabled MBEDTLS_RSA_C
7771requires_config_enabled MBEDTLS_ECDSA_C
7772requires_config_enabled MBEDTLS_SHA256_C
7773requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7774requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7775requires_config_enabled MBEDTLS_CHACHAPOLY_C
7776run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7777 -p "$P_PXY mtu=512" \
7778 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7779 crt_file=data_files/server7_int-ca.crt \
7780 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007781 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007782 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007783 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007784 mtu=512" \
7785 "$P_CLI dtls=1 debug_level=2 \
7786 crt_file=data_files/server8_int-ca2.crt \
7787 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007788 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007789 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007790 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007791 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007792 mtu=512" \
7793 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007794 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007795 -s "found fragmented DTLS handshake message" \
7796 -c "found fragmented DTLS handshake message" \
7797 -C "error"
7798
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007799# An autoreduction on the client-side might happen if the server is
7800# slow to reset, therefore omitting '-C "autoreduction"' below.
7801not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007802requires_config_enabled MBEDTLS_RSA_C
7803requires_config_enabled MBEDTLS_ECDSA_C
7804requires_config_enabled MBEDTLS_SHA256_C
7805requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7806requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7807requires_config_enabled MBEDTLS_AES_C
7808requires_config_enabled MBEDTLS_GCM_C
7809run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7810 -p "$P_PXY mtu=512" \
7811 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7812 crt_file=data_files/server7_int-ca.crt \
7813 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007814 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007815 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007816 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007817 mtu=512" \
7818 "$P_CLI dtls=1 debug_level=2 \
7819 crt_file=data_files/server8_int-ca2.crt \
7820 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007821 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007822 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007823 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007824 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007825 mtu=512" \
7826 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007827 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007828 -s "found fragmented DTLS handshake message" \
7829 -c "found fragmented DTLS handshake message" \
7830 -C "error"
7831
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007832# An autoreduction on the client-side might happen if the server is
7833# slow to reset, therefore omitting '-C "autoreduction"' below.
7834not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007835requires_config_enabled MBEDTLS_RSA_C
7836requires_config_enabled MBEDTLS_ECDSA_C
7837requires_config_enabled MBEDTLS_SHA256_C
7838requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7839requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7840requires_config_enabled MBEDTLS_AES_C
7841requires_config_enabled MBEDTLS_CCM_C
7842run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007843 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007844 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7845 crt_file=data_files/server7_int-ca.crt \
7846 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007847 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007848 exchanges=2 renegotiation=1 \
7849 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
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 "$P_CLI dtls=1 debug_level=2 \
7853 crt_file=data_files/server8_int-ca2.crt \
7854 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007855 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007856 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007857 hs_timeout=10000-60000 \
7858 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007859 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007860 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007861 -s "found fragmented DTLS handshake message" \
7862 -c "found fragmented DTLS handshake message" \
7863 -C "error"
7864
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007865# An autoreduction on the client-side might happen if the server is
7866# slow to reset, therefore omitting '-C "autoreduction"' below.
7867not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007868requires_config_enabled MBEDTLS_RSA_C
7869requires_config_enabled MBEDTLS_ECDSA_C
7870requires_config_enabled MBEDTLS_SHA256_C
7871requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7872requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7873requires_config_enabled MBEDTLS_AES_C
7874requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7875requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7876run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007877 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007878 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7879 crt_file=data_files/server7_int-ca.crt \
7880 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007881 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007882 exchanges=2 renegotiation=1 \
7883 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
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 "$P_CLI dtls=1 debug_level=2 \
7887 crt_file=data_files/server8_int-ca2.crt \
7888 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007889 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007890 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007891 hs_timeout=10000-60000 \
7892 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007893 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007894 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007895 -s "found fragmented DTLS handshake message" \
7896 -c "found fragmented DTLS handshake message" \
7897 -C "error"
7898
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007899# An autoreduction on the client-side might happen if the server is
7900# slow to reset, therefore omitting '-C "autoreduction"' below.
7901not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007902requires_config_enabled MBEDTLS_RSA_C
7903requires_config_enabled MBEDTLS_ECDSA_C
7904requires_config_enabled MBEDTLS_SHA256_C
7905requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7906requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7907requires_config_enabled MBEDTLS_AES_C
7908requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7909run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007910 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007911 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7912 crt_file=data_files/server7_int-ca.crt \
7913 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007914 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007915 exchanges=2 renegotiation=1 \
7916 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
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 "$P_CLI dtls=1 debug_level=2 \
7920 crt_file=data_files/server8_int-ca2.crt \
7921 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007922 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007923 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007924 hs_timeout=10000-60000 \
7925 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007926 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007927 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007928 -s "found fragmented DTLS handshake message" \
7929 -c "found fragmented DTLS handshake message" \
7930 -C "error"
7931
Andrzej Kurek77826052018-10-11 07:34:08 -04007932# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007933requires_config_enabled MBEDTLS_RSA_C
7934requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007935requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7936requires_config_enabled MBEDTLS_AES_C
7937requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007938client_needs_more_time 2
7939run_test "DTLS fragmenting: proxy MTU + 3d" \
7940 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007941 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007942 crt_file=data_files/server7_int-ca.crt \
7943 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007944 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007945 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007946 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007947 crt_file=data_files/server8_int-ca2.crt \
7948 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007949 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007950 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007951 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007952 0 \
7953 -s "found fragmented DTLS handshake message" \
7954 -c "found fragmented DTLS handshake message" \
7955 -C "error"
7956
Andrzej Kurek77826052018-10-11 07:34:08 -04007957# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007958requires_config_enabled MBEDTLS_RSA_C
7959requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007960requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7961requires_config_enabled MBEDTLS_AES_C
7962requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007963client_needs_more_time 2
7964run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7965 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7966 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7967 crt_file=data_files/server7_int-ca.crt \
7968 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007969 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007970 hs_timeout=250-10000 mtu=512 nbio=2" \
7971 "$P_CLI dtls=1 debug_level=2 \
7972 crt_file=data_files/server8_int-ca2.crt \
7973 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007974 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007975 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007976 hs_timeout=250-10000 mtu=512 nbio=2" \
7977 0 \
7978 -s "found fragmented DTLS handshake message" \
7979 -c "found fragmented DTLS handshake message" \
7980 -C "error"
7981
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007982# interop tests for DTLS fragmentating with reliable connection
7983#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007984# here and below we just want to test that the we fragment in a way that
7985# pleases other implementations, so we don't need the peer to fragment
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007986requires_config_enabled MBEDTLS_RSA_C
7987requires_config_enabled MBEDTLS_ECDSA_C
7988requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007989requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007990run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7991 "$G_SRV -u" \
7992 "$P_CLI dtls=1 debug_level=2 \
7993 crt_file=data_files/server8_int-ca2.crt \
7994 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007995 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007996 mtu=512 force_version=dtls1_2" \
7997 0 \
7998 -c "fragmenting handshake message" \
7999 -C "error"
8000
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008001requires_config_enabled MBEDTLS_RSA_C
8002requires_config_enabled MBEDTLS_ECDSA_C
8003requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008004requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008005run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
8006 "$G_SRV -u" \
8007 "$P_CLI dtls=1 debug_level=2 \
8008 crt_file=data_files/server8_int-ca2.crt \
8009 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008010 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008011 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008012 0 \
8013 -c "fragmenting handshake message" \
8014 -C "error"
8015
Hanno Beckerb9a00862018-08-28 10:20:22 +01008016# We use --insecure for the GnuTLS client because it expects
8017# the hostname / IP it connects to to be the name used in the
8018# certificate obtained from the server. Here, however, it
8019# connects to 127.0.0.1 while our test certificates use 'localhost'
8020# as the server name in the certificate. This will make the
8021# certifiate validation fail, but passing --insecure makes
8022# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008023requires_config_enabled MBEDTLS_RSA_C
8024requires_config_enabled MBEDTLS_ECDSA_C
8025requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008026requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008027requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008028run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008029 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008030 crt_file=data_files/server7_int-ca.crt \
8031 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008032 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008033 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008034 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008035 0 \
8036 -s "fragmenting handshake message"
8037
Hanno Beckerb9a00862018-08-28 10:20:22 +01008038# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008039requires_config_enabled MBEDTLS_RSA_C
8040requires_config_enabled MBEDTLS_ECDSA_C
8041requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008042requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008043requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008044run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008045 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008046 crt_file=data_files/server7_int-ca.crt \
8047 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008048 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008049 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008050 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008051 0 \
8052 -s "fragmenting handshake message"
8053
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008054requires_config_enabled MBEDTLS_RSA_C
8055requires_config_enabled MBEDTLS_ECDSA_C
8056requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8057run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
8058 "$O_SRV -dtls1_2 -verify 10" \
8059 "$P_CLI dtls=1 debug_level=2 \
8060 crt_file=data_files/server8_int-ca2.crt \
8061 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008062 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008063 mtu=512 force_version=dtls1_2" \
8064 0 \
8065 -c "fragmenting handshake message" \
8066 -C "error"
8067
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008068requires_config_enabled MBEDTLS_RSA_C
8069requires_config_enabled MBEDTLS_ECDSA_C
8070requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8071run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
8072 "$O_SRV -dtls1 -verify 10" \
8073 "$P_CLI dtls=1 debug_level=2 \
8074 crt_file=data_files/server8_int-ca2.crt \
8075 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008076 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008077 mtu=512 force_version=dtls1" \
8078 0 \
8079 -c "fragmenting handshake message" \
8080 -C "error"
8081
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008082requires_config_enabled MBEDTLS_RSA_C
8083requires_config_enabled MBEDTLS_ECDSA_C
8084requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8085run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
8086 "$P_SRV dtls=1 debug_level=2 \
8087 crt_file=data_files/server7_int-ca.crt \
8088 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008089 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008090 mtu=512 force_version=dtls1_2" \
8091 "$O_CLI -dtls1_2" \
8092 0 \
8093 -s "fragmenting handshake message"
8094
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008095requires_config_enabled MBEDTLS_RSA_C
8096requires_config_enabled MBEDTLS_ECDSA_C
8097requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8098run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8099 "$P_SRV dtls=1 debug_level=2 \
8100 crt_file=data_files/server7_int-ca.crt \
8101 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008102 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008103 mtu=512 force_version=dtls1" \
8104 "$O_CLI -dtls1" \
8105 0 \
8106 -s "fragmenting handshake message"
8107
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008108# interop tests for DTLS fragmentating with unreliable connection
8109#
8110# again we just want to test that the we fragment in a way that
8111# pleases other implementations, so we don't need the peer to fragment
8112requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008113requires_config_enabled MBEDTLS_RSA_C
8114requires_config_enabled MBEDTLS_ECDSA_C
8115requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008116client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008117run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8118 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8119 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008120 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008121 crt_file=data_files/server8_int-ca2.crt \
8122 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008123 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008124 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008125 0 \
8126 -c "fragmenting handshake message" \
8127 -C "error"
8128
8129requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008130requires_config_enabled MBEDTLS_RSA_C
8131requires_config_enabled MBEDTLS_ECDSA_C
8132requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008133client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008134run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8135 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8136 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008137 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008138 crt_file=data_files/server8_int-ca2.crt \
8139 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008140 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008141 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008142 0 \
8143 -c "fragmenting handshake message" \
8144 -C "error"
8145
k-stachowiakabb843e2019-02-18 16:14:03 +01008146requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008147requires_config_enabled MBEDTLS_RSA_C
8148requires_config_enabled MBEDTLS_ECDSA_C
8149requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8150client_needs_more_time 4
8151run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8152 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8153 "$P_SRV dtls=1 debug_level=2 \
8154 crt_file=data_files/server7_int-ca.crt \
8155 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008156 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008157 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008158 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008159 0 \
8160 -s "fragmenting handshake message"
8161
k-stachowiakabb843e2019-02-18 16:14:03 +01008162requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008163requires_config_enabled MBEDTLS_RSA_C
8164requires_config_enabled MBEDTLS_ECDSA_C
8165requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8166client_needs_more_time 4
8167run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8168 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8169 "$P_SRV dtls=1 debug_level=2 \
8170 crt_file=data_files/server7_int-ca.crt \
8171 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008172 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008173 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008174 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008175 0 \
8176 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008177
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008178## Interop test with OpenSSL might trigger a bug in recent versions (including
8179## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008180## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008181## They should be re-enabled once a fixed version of OpenSSL is available
8182## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008183skip_next_test
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008184requires_config_enabled MBEDTLS_RSA_C
8185requires_config_enabled MBEDTLS_ECDSA_C
8186requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8187client_needs_more_time 4
8188run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8189 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8190 "$O_SRV -dtls1_2 -verify 10" \
8191 "$P_CLI dtls=1 debug_level=2 \
8192 crt_file=data_files/server8_int-ca2.crt \
8193 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008194 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008195 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8196 0 \
8197 -c "fragmenting handshake message" \
8198 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008199
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008200skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008201requires_config_enabled MBEDTLS_RSA_C
8202requires_config_enabled MBEDTLS_ECDSA_C
8203requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008204client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008205run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8206 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008207 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008208 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008209 crt_file=data_files/server8_int-ca2.crt \
8210 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008211 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008212 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008213 0 \
8214 -c "fragmenting handshake message" \
8215 -C "error"
8216
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008217skip_next_test
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008218requires_config_enabled MBEDTLS_RSA_C
8219requires_config_enabled MBEDTLS_ECDSA_C
8220requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8221client_needs_more_time 4
8222run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8223 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8224 "$P_SRV dtls=1 debug_level=2 \
8225 crt_file=data_files/server7_int-ca.crt \
8226 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008227 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008228 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8229 "$O_CLI -dtls1_2" \
8230 0 \
8231 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008232
8233# -nbio is added to prevent s_client from blocking in case of duplicated
8234# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008235skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008236requires_config_enabled MBEDTLS_RSA_C
8237requires_config_enabled MBEDTLS_ECDSA_C
8238requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008239client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008240run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8241 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008242 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008243 crt_file=data_files/server7_int-ca.crt \
8244 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008245 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008246 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008247 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008248 0 \
8249 -s "fragmenting handshake message"
8250
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008251# Tests for specific things with "unreliable" UDP connection
8252
8253not_with_valgrind # spurious resend due to timeout
8254run_test "DTLS proxy: reference" \
8255 -p "$P_PXY" \
8256 "$P_SRV dtls=1 debug_level=2" \
8257 "$P_CLI dtls=1 debug_level=2" \
8258 0 \
8259 -C "replayed record" \
8260 -S "replayed record" \
Hanno Beckere03eb7b2019-07-19 15:43:09 +01008261 -C "Buffer record from epoch" \
8262 -S "Buffer record from epoch" \
8263 -C "ssl_buffer_message" \
8264 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008265 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008266 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008267 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008268 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008269 -c "HTTP/1.0 200 OK"
8270
8271not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008272run_test "DTLS proxy: duplicate every packet" \
8273 -p "$P_PXY duplicate=1" \
Hanno Becker7f376f42019-06-12 16:20:48 +01008274 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008275 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008276 0 \
8277 -c "replayed record" \
8278 -s "replayed record" \
8279 -c "record from another epoch" \
8280 -s "record from another epoch" \
8281 -S "resend" \
8282 -s "Extra-header:" \
8283 -c "HTTP/1.0 200 OK"
8284
8285run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8286 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008287 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8288 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008289 0 \
8290 -c "replayed record" \
8291 -S "replayed record" \
8292 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008293 -s "record from another epoch" \
8294 -c "resend" \
8295 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008296 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008297 -c "HTTP/1.0 200 OK"
8298
8299run_test "DTLS proxy: multiple records in same datagram" \
8300 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008301 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8302 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008303 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008304 -c "next record in same datagram" \
8305 -s "next record in same datagram"
8306
8307run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8308 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008309 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8310 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008311 0 \
8312 -c "next record in same datagram" \
8313 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008314
Jarno Lamsa33281d52019-10-18 10:54:35 +03008315requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008316run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8317 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008318 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8319 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008320 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008321 -c "discarding invalid record (mac)" \
8322 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008323 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008324 -c "HTTP/1.0 200 OK" \
8325 -S "too many records with bad MAC" \
8326 -S "Verification of the message MAC failed"
8327
Jarno Lamsa33281d52019-10-18 10:54:35 +03008328requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008329run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8330 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008331 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8332 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008333 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008334 -C "discarding invalid record (mac)" \
8335 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008336 -S "Extra-header:" \
8337 -C "HTTP/1.0 200 OK" \
8338 -s "too many records with bad MAC" \
8339 -s "Verification of the message MAC failed"
8340
Jarno Lamsa33281d52019-10-18 10:54:35 +03008341requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008342run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8343 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008344 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8345 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008346 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008347 -c "discarding invalid record (mac)" \
8348 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008349 -s "Extra-header:" \
8350 -c "HTTP/1.0 200 OK" \
8351 -S "too many records with bad MAC" \
8352 -S "Verification of the message MAC failed"
8353
Jarno Lamsa33281d52019-10-18 10:54:35 +03008354requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008355run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8356 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008357 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8358 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008359 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008360 -c "discarding invalid record (mac)" \
8361 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008362 -s "Extra-header:" \
8363 -c "HTTP/1.0 200 OK" \
8364 -s "too many records with bad MAC" \
8365 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008366
8367run_test "DTLS proxy: delay ChangeCipherSpec" \
8368 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008369 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8370 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008371 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008372 -c "record from another epoch" \
8373 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008374 -s "Extra-header:" \
8375 -c "HTTP/1.0 200 OK"
8376
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008377# Tests for reordering support with DTLS
8378
Hanno Becker56cdfd12018-08-17 13:42:15 +01008379run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8380 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008381 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8382 hs_timeout=2500-60000" \
8383 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8384 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008385 0 \
8386 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008387 -c "Next handshake message has been buffered - load"\
8388 -S "Buffering HS message" \
8389 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008390 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008391 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008392 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008393 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008394
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008395run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8396 -p "$P_PXY delay_srv=ServerHello" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03008397 "$P_SRV mtu=256 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008398 hs_timeout=2500-60000" \
8399 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8400 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008401 0 \
8402 -c "Buffering HS message" \
8403 -c "found fragmented DTLS handshake message"\
8404 -c "Next handshake message 1 not or only partially bufffered" \
8405 -c "Next handshake message has been buffered - load"\
8406 -S "Buffering HS message" \
8407 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008408 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008409 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008410 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008411 -S "Remember CCS message"
8412
Hanno Beckera1adcca2018-08-24 14:41:07 +01008413# The client buffers the ServerKeyExchange before receiving the fragmented
8414# Certificate message; at the time of writing, together these are aroudn 1200b
8415# in size, so that the bound below ensures that the certificate can be reassembled
8416# while keeping the ServerKeyExchange.
8417requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8418run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008419 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008420 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8421 hs_timeout=2500-60000" \
8422 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8423 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008424 0 \
8425 -c "Buffering HS message" \
8426 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008427 -C "attempt to make space by freeing buffered messages" \
8428 -S "Buffering HS message" \
8429 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008430 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008431 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008432 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008433 -S "Remember CCS message"
8434
8435# The size constraints ensure that the delayed certificate message can't
8436# be reassembled while keeping the ServerKeyExchange message, but it can
8437# when dropping it first.
8438requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8439requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8440run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8441 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008442 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8443 hs_timeout=2500-60000" \
8444 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8445 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008446 0 \
8447 -c "Buffering HS message" \
8448 -c "attempt to make space by freeing buffered future messages" \
8449 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008450 -S "Buffering HS message" \
8451 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008452 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008453 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008454 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008455 -S "Remember CCS message"
8456
Hanno Becker56cdfd12018-08-17 13:42:15 +01008457run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8458 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008459 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8460 hs_timeout=2500-60000" \
8461 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8462 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008463 0 \
8464 -C "Buffering HS message" \
8465 -C "Next handshake message has been buffered - load"\
8466 -s "Buffering HS message" \
8467 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008468 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008469 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008470 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008471 -S "Remember CCS message"
8472
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02008473# This needs session tickets; otherwise CCS is the first message in its flight
8474requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008475run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8476 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008477 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8478 hs_timeout=2500-60000" \
8479 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8480 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008481 0 \
8482 -C "Buffering HS message" \
8483 -C "Next handshake message has been buffered - load"\
8484 -S "Buffering HS message" \
8485 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008486 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008487 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008488 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008489 -S "Remember CCS message"
8490
Jarno Lamsa33281d52019-10-18 10:54:35 +03008491# This needs session tickets; otherwise CCS is the first message in its flight
8492requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008493run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8494 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008495 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8496 hs_timeout=2500-60000" \
8497 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8498 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008499 0 \
8500 -C "Buffering HS message" \
8501 -C "Next handshake message has been buffered - load"\
8502 -S "Buffering HS message" \
8503 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008504 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008505 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008506 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008507 -s "Remember CCS message"
8508
Hanno Beckera1adcca2018-08-24 14:41:07 +01008509run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008510 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008511 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8512 hs_timeout=2500-60000" \
8513 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8514 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008515 0 \
8516 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008517 -s "Found buffered record from current epoch - load" \
8518 -c "Buffer record from epoch 1" \
8519 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008520
Hanno Beckera1adcca2018-08-24 14:41:07 +01008521# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8522# from the server are delayed, so that the encrypted Finished message
8523# is received and buffered. When the fragmented NewSessionTicket comes
8524# in afterwards, the encrypted Finished message must be freed in order
8525# to make space for the NewSessionTicket to be reassembled.
8526# This works only in very particular circumstances:
8527# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8528# of the NewSessionTicket, but small enough to also allow buffering of
8529# the encrypted Finished message.
8530# - The MTU setting on the server must be so small that the NewSessionTicket
8531# needs to be fragmented.
8532# - All messages sent by the server must be small enough to be either sent
8533# without fragmentation or be reassembled within the bounds of
8534# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8535# handshake, omitting CRTs.
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008536requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8537requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008538run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8539 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008540 "$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 +01008541 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8542 0 \
8543 -s "Buffer record from epoch 1" \
8544 -s "Found buffered record from current epoch - load" \
8545 -c "Buffer record from epoch 1" \
8546 -C "Found buffered record from current epoch - load" \
8547 -c "Enough space available after freeing future epoch record"
8548
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008549# Tests for "randomly unreliable connection": try a variety of flows and peers
8550
8551client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008552run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8553 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008554 "$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 +02008555 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008556 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008557 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8558 0 \
8559 -s "Extra-header:" \
8560 -c "HTTP/1.0 200 OK"
8561
Janos Follath74537a62016-09-02 13:45:28 +01008562client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008563run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8564 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008565 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8566 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008567 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8568 0 \
8569 -s "Extra-header:" \
8570 -c "HTTP/1.0 200 OK"
8571
Janos Follath74537a62016-09-02 13:45:28 +01008572client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008573run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8574 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008575 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8576 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008577 0 \
8578 -s "Extra-header:" \
8579 -c "HTTP/1.0 200 OK"
8580
Janos Follath74537a62016-09-02 13:45:28 +01008581client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008582run_test "DTLS proxy: 3d, FS, client auth" \
8583 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008584 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8585 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008586 0 \
8587 -s "Extra-header:" \
8588 -c "HTTP/1.0 200 OK"
8589
Janos Follath74537a62016-09-02 13:45:28 +01008590client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008591run_test "DTLS proxy: 3d, FS, ticket" \
8592 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008593 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8594 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008595 0 \
8596 -s "Extra-header:" \
8597 -c "HTTP/1.0 200 OK"
8598
Janos Follath74537a62016-09-02 13:45:28 +01008599client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008600run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8601 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008602 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8603 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008604 0 \
8605 -s "Extra-header:" \
8606 -c "HTTP/1.0 200 OK"
8607
Janos Follath74537a62016-09-02 13:45:28 +01008608client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008609run_test "DTLS proxy: 3d, max handshake, nbio" \
8610 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008611 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008612 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008613 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008614 0 \
8615 -s "Extra-header:" \
8616 -c "HTTP/1.0 200 OK"
8617
Janos Follath74537a62016-09-02 13:45:28 +01008618client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008619requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008620requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008621requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008622run_test "DTLS proxy: 3d, min handshake, resumption" \
8623 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008624 "$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 +02008625 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008626 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008627 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8628 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8629 0 \
8630 -s "a session has been resumed" \
8631 -c "a session has been resumed" \
8632 -s "Extra-header:" \
8633 -c "HTTP/1.0 200 OK"
8634
Janos Follath74537a62016-09-02 13:45:28 +01008635client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008636requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008637requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008638requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008639run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8640 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008641 "$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 +02008642 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008643 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008644 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
8645 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8646 0 \
8647 -s "a session has been resumed" \
8648 -c "a session has been resumed" \
8649 -s "Extra-header:" \
8650 -c "HTTP/1.0 200 OK"
8651
Janos Follath74537a62016-09-02 13:45:28 +01008652client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008653requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008654run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008655 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008656 "$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 +02008657 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008658 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008659 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008660 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8661 0 \
8662 -c "=> renegotiate" \
8663 -s "=> renegotiate" \
8664 -s "Extra-header:" \
8665 -c "HTTP/1.0 200 OK"
8666
Janos Follath74537a62016-09-02 13:45:28 +01008667client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008668requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008669run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8670 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008671 "$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 +02008672 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008673 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008674 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008675 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8676 0 \
8677 -c "=> renegotiate" \
8678 -s "=> renegotiate" \
8679 -s "Extra-header:" \
8680 -c "HTTP/1.0 200 OK"
8681
Janos Follath74537a62016-09-02 13:45:28 +01008682client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008683requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008684run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008685 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008686 "$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 +02008687 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008688 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008689 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008690 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008691 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8692 0 \
8693 -c "=> renegotiate" \
8694 -s "=> renegotiate" \
8695 -s "Extra-header:" \
8696 -c "HTTP/1.0 200 OK"
8697
Janos Follath74537a62016-09-02 13:45:28 +01008698client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008699requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008700run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008701 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008702 "$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 +02008703 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008704 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008705 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008706 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008707 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8708 0 \
8709 -c "=> renegotiate" \
8710 -s "=> renegotiate" \
8711 -s "Extra-header:" \
8712 -c "HTTP/1.0 200 OK"
8713
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008714## Interop tests with OpenSSL might trigger a bug in recent versions (including
8715## all versions installed on the CI machines), reported here:
8716## Bug report: https://github.com/openssl/openssl/issues/6902
8717## They should be re-enabled once a fixed version of OpenSSL is available
8718## (this should happen in some 1.1.1_ release according to the ticket).
8719skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008720client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008721not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008722run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008723 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8724 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008725 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008726 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008727 -c "HTTP/1.0 200 OK"
8728
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008729skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008730client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008731not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008732run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8733 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8734 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008735 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008736 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008737 -c "HTTP/1.0 200 OK"
8738
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008739skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008740client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008741not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008742run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8743 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8744 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008745 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008746 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008747 -c "HTTP/1.0 200 OK"
8748
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008749requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008750client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008751not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008752run_test "DTLS proxy: 3d, gnutls server" \
8753 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8754 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008755 "$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 +02008756 0 \
8757 -s "Extra-header:" \
8758 -c "Extra-header:"
8759
k-stachowiakabb843e2019-02-18 16:14:03 +01008760requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008761client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008762not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008763run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8764 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008765 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008766 "$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 +02008767 0 \
8768 -s "Extra-header:" \
8769 -c "Extra-header:"
8770
k-stachowiakabb843e2019-02-18 16:14:03 +01008771requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008772client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008773not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008774run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8775 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008776 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008777 "$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 +02008778 0 \
8779 -s "Extra-header:" \
8780 -c "Extra-header:"
8781
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008782# Final report
8783
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008784echo "------------------------------------------------------------------------"
8785
8786if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008787 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008788else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008789 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008790fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008791PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008792echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008793
8794exit $FAILS