blob: b2113103ef874b612470968a868d9af46513db7d [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
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001165# Test current time in ServerHello
1166requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001167run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001168 "$P_SRV debug_level=3" \
1169 "$P_CLI debug_level=3" \
1170 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001171 -f "check_server_hello_time" \
1172 -F "check_server_hello_time"
1173
Simon Butcher8e004102016-10-14 00:48:33 +01001174# Test for uniqueness of IVs in AEAD ciphersuites
1175run_test "Unique IV in GCM" \
1176 "$P_SRV exchanges=20 debug_level=4" \
1177 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1178 0 \
1179 -u "IV used" \
1180 -U "IV used"
1181
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001182# Tests for rc4 option
1183
Simon Butchera410af52016-05-19 22:12:18 +01001184requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001185run_test "RC4: server disabled, client enabled" \
1186 "$P_SRV" \
1187 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1188 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001189 -s "SSL - The server has no ciphersuites in common"
1190
Simon Butchera410af52016-05-19 22:12:18 +01001191requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001192run_test "RC4: server half, client enabled" \
1193 "$P_SRV arc4=1" \
1194 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1195 1 \
1196 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001197
1198run_test "RC4: server enabled, client disabled" \
1199 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1200 "$P_CLI" \
1201 1 \
1202 -s "SSL - The server has no ciphersuites in common"
1203
1204run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001205 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001206 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1207 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001208 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001209 -S "SSL - The server has no ciphersuites in common"
1210
Hanno Beckerd26bb202018-08-17 09:54:10 +01001211# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1212
1213requires_gnutls
1214requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1215run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1216 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001217 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001218 0
1219
1220requires_gnutls
1221requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1222run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1223 "$G_SRV"\
Hanno Becker843f5bb2019-08-23 17:17:09 +01001224 "$P_CLI force_version=tls1 ca_file=data_files/test-ca2.crt" \
Hanno Beckerd26bb202018-08-17 09:54:10 +01001225 0
1226
Gilles Peskinebc70a182017-05-09 15:59:24 +02001227# Tests for SHA-1 support
1228
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001229requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001230requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001231requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001232run_test "SHA-1 forbidden by default in server certificate" \
1233 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1234 "$P_CLI debug_level=2 allow_sha1=0" \
1235 1 \
1236 -c "The certificate is signed with an unacceptable hash"
1237
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001238requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1239run_test "SHA-1 forbidden by default in server certificate" \
1240 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1241 "$P_CLI debug_level=2 allow_sha1=0" \
1242 0
1243
Gilles Peskinebc70a182017-05-09 15:59:24 +02001244run_test "SHA-1 explicitly allowed in server certificate" \
1245 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1246 "$P_CLI allow_sha1=1" \
1247 0
1248
1249run_test "SHA-256 allowed by default in server certificate" \
1250 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1251 "$P_CLI allow_sha1=0" \
1252 0
1253
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001254requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Hanno Becker4a156fc2019-06-14 17:07:06 +01001255requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01001256requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskinebc70a182017-05-09 15:59:24 +02001257run_test "SHA-1 forbidden by default in client certificate" \
1258 "$P_SRV auth_mode=required allow_sha1=0" \
1259 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1260 1 \
1261 -s "The certificate is signed with an unacceptable hash"
1262
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001263requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1264run_test "SHA-1 forbidden by default in client certificate" \
1265 "$P_SRV auth_mode=required allow_sha1=0" \
1266 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1267 0
1268
Gilles Peskinebc70a182017-05-09 15:59:24 +02001269run_test "SHA-1 explicitly allowed in client certificate" \
1270 "$P_SRV auth_mode=required allow_sha1=1" \
1271 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1272 0
1273
1274run_test "SHA-256 allowed by default in client certificate" \
1275 "$P_SRV auth_mode=required allow_sha1=0" \
1276 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1277 0
1278
Hanno Becker7ae8a762018-08-14 15:43:35 +01001279# Tests for datagram packing
1280run_test "DTLS: multiple records in same datagram, client and server" \
1281 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1282 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1283 0 \
1284 -c "next record in same datagram" \
1285 -s "next record in same datagram"
1286
1287run_test "DTLS: multiple records in same datagram, client only" \
1288 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1289 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1290 0 \
1291 -s "next record in same datagram" \
1292 -C "next record in same datagram"
1293
1294run_test "DTLS: multiple records in same datagram, server only" \
1295 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1296 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1297 0 \
1298 -S "next record in same datagram" \
1299 -c "next record in same datagram"
1300
1301run_test "DTLS: multiple records in same datagram, neither client nor server" \
1302 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1303 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1304 0 \
1305 -S "next record in same datagram" \
1306 -C "next record in same datagram"
1307
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001308# Tests for Truncated HMAC extension
1309
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001310run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001311 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001312 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001313 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001314 -s "dumping 'expected mac' (20 bytes)" \
1315 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001316
Hanno Becker32c55012017-11-10 08:42:54 +00001317requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001318run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001319 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001320 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001321 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001322 -s "dumping 'expected mac' (20 bytes)" \
1323 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001324
Hanno Becker32c55012017-11-10 08:42:54 +00001325requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001326run_test "Truncated HMAC: client enabled, server default" \
1327 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001328 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001329 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001330 -s "dumping 'expected mac' (20 bytes)" \
1331 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001332
Hanno Becker32c55012017-11-10 08:42:54 +00001333requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001334run_test "Truncated HMAC: client enabled, server disabled" \
1335 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001336 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001337 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001338 -s "dumping 'expected mac' (20 bytes)" \
1339 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001340
Hanno Becker32c55012017-11-10 08:42:54 +00001341requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001342run_test "Truncated HMAC: client disabled, server enabled" \
1343 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001344 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001345 0 \
1346 -s "dumping 'expected mac' (20 bytes)" \
1347 -S "dumping 'expected mac' (10 bytes)"
1348
1349requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001350run_test "Truncated HMAC: client enabled, server enabled" \
1351 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001352 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001353 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001354 -S "dumping 'expected mac' (20 bytes)" \
1355 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001356
Jarno Lamsa33281d52019-10-18 10:54:35 +03001357requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker4c4f4102017-11-10 09:16:05 +00001358run_test "Truncated HMAC, DTLS: client default, server default" \
1359 "$P_SRV dtls=1 debug_level=4" \
1360 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1361 0 \
1362 -s "dumping 'expected mac' (20 bytes)" \
1363 -S "dumping 'expected mac' (10 bytes)"
1364
1365requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1366run_test "Truncated HMAC, DTLS: client disabled, server default" \
1367 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001368 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001369 0 \
1370 -s "dumping 'expected mac' (20 bytes)" \
1371 -S "dumping 'expected mac' (10 bytes)"
1372
1373requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1374run_test "Truncated HMAC, DTLS: client enabled, server default" \
1375 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001376 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001377 0 \
1378 -s "dumping 'expected mac' (20 bytes)" \
1379 -S "dumping 'expected mac' (10 bytes)"
1380
1381requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1382run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1383 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001384 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001385 0 \
1386 -s "dumping 'expected mac' (20 bytes)" \
1387 -S "dumping 'expected mac' (10 bytes)"
1388
1389requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1390run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1391 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001392 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001393 0 \
1394 -s "dumping 'expected mac' (20 bytes)" \
1395 -S "dumping 'expected mac' (10 bytes)"
1396
1397requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1398run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1399 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001400 "$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 +01001401 0 \
1402 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001403 -s "dumping 'expected mac' (10 bytes)"
1404
Jarno Lamsafa45e602019-06-04 11:33:23 +03001405# Tests for Context serialization
1406
1407requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001408run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001409 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001410 "$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 +03001411 0 \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001412 -c "Deserializing connection..." \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001413 -S "Deserializing connection..."
1414
1415requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001416run_test "Context serialization, client serializes, ChaChaPoly" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001417 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001418 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001419 0 \
1420 -c "Deserializing connection..." \
1421 -S "Deserializing connection..."
1422
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001423requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001424run_test "Context serialization, client serializes, GCM" \
1425 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1426 "$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 +03001427 0 \
1428 -c "Deserializing connection..." \
1429 -S "Deserializing connection..."
Jarno Lamsacc281b82019-06-04 15:21:13 +03001430
Jarno Lamsafa45e602019-06-04 11:33:23 +03001431requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001432requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1433run_test "Context serialization, client serializes, with CID" \
1434 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1435 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1436 0 \
1437 -c "Deserializing connection..." \
1438 -S "Deserializing connection..."
1439
1440requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001441run_test "Context serialization, server serializes, CCM" \
Jarno Lamsafa45e602019-06-04 11:33:23 +03001442 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001443 "$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 +03001444 0 \
1445 -C "Deserializing connection..." \
1446 -s "Deserializing connection..."
1447
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001448requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001449run_test "Context serialization, server serializes, ChaChaPoly" \
1450 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1451 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1452 0 \
1453 -C "Deserializing connection..." \
1454 -s "Deserializing connection..."
1455
1456requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1457run_test "Context serialization, server serializes, GCM" \
1458 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1459 "$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 +03001460 0 \
1461 -C "Deserializing connection..." \
Jarno Lamsacc281b82019-06-04 15:21:13 +03001462 -s "Deserializing connection..."
Jarno Lamsafa45e602019-06-04 11:33:23 +03001463
1464requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001465requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1466run_test "Context serialization, server serializes, with CID" \
1467 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1468 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1469 0 \
1470 -C "Deserializing connection..." \
1471 -s "Deserializing connection..."
1472
1473requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001474run_test "Context serialization, both serialize, CCM" \
Jarno Lamsadcfc2a72019-06-04 15:18:19 +03001475 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001476 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1477 0 \
1478 -c "Deserializing connection..." \
1479 -s "Deserializing connection..."
1480
1481requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1482run_test "Context serialization, both serialize, ChaChaPoly" \
1483 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1484 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1485 0 \
1486 -c "Deserializing connection..." \
1487 -s "Deserializing connection..."
1488
1489requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1490run_test "Context serialization, both serialize, GCM" \
1491 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1492 "$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 +03001493 0 \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001494 -c "Deserializing connection..." \
1495 -s "Deserializing connection..."
1496
1497requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001498requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1499run_test "Context serialization, both serialize, with CID" \
1500 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1501 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1502 0 \
1503 -c "Deserializing connection..." \
1504 -s "Deserializing connection..."
1505
1506requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001507run_test "Context serialization, re-init, client serializes, CCM" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001508 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001509 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1510 0 \
1511 -c "Deserializing connection..." \
1512 -S "Deserializing connection..."
1513
1514requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1515run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1516 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1517 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1518 0 \
1519 -c "Deserializing connection..." \
1520 -S "Deserializing connection..."
1521
1522requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1523run_test "Context serialization, re-init, client serializes, GCM" \
1524 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1525 "$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 +03001526 0 \
1527 -c "Deserializing connection..." \
1528 -S "Deserializing connection..."
1529
1530requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001531requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1532run_test "Context serialization, re-init, client serializes, with CID" \
1533 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1534 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1535 0 \
1536 -c "Deserializing connection..." \
1537 -S "Deserializing connection..."
1538
1539requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001540run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001541 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001542 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1543 0 \
1544 -C "Deserializing connection..." \
1545 -s "Deserializing connection..."
1546
1547requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1548run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1549 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1550 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1551 0 \
1552 -C "Deserializing connection..." \
1553 -s "Deserializing connection..."
1554
1555requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1556run_test "Context serialization, re-init, server serializes, GCM" \
1557 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1558 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001559 0 \
1560 -C "Deserializing connection..." \
1561 -s "Deserializing connection..."
1562
1563requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere80c1b02019-08-30 11:18:59 +01001564requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1565run_test "Context serialization, re-init, server serializes, with CID" \
1566 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1567 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1568 0 \
1569 -C "Deserializing connection..." \
1570 -s "Deserializing connection..."
1571
1572requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker2e72dd82019-08-30 11:32:12 +01001573run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard0d832712019-07-23 14:13:43 +02001574 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Becker2e72dd82019-08-30 11:32:12 +01001575 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1576 0 \
1577 -c "Deserializing connection..." \
1578 -s "Deserializing connection..."
1579
1580requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1581run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1582 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1583 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1584 0 \
1585 -c "Deserializing connection..." \
1586 -s "Deserializing connection..."
1587
1588requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1589run_test "Context serialization, re-init, both serialize, GCM" \
1590 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1591 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsa8a91c062019-06-06 10:44:14 +03001592 0 \
1593 -c "Deserializing connection..." \
1594 -s "Deserializing connection..."
1595
Hanno Beckere80c1b02019-08-30 11:18:59 +01001596requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1597requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1598run_test "Context serialization, re-init, both serialize, with CID" \
1599 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1600 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001601 0 \
1602 -c "Deserializing connection..." \
Hanno Becker73455992019-04-25 17:01:43 +01001603 -s "Deserializing connection..."
Hanno Beckerc008cb52019-04-26 14:17:56 +01001604
Hanno Becker4eb05872019-04-26 16:00:29 +01001605# Tests for DTLS Connection ID extension
Hanno Beckercf2a5652019-04-26 16:13:31 +01001606
Hanno Becker5e2cd142019-04-26 16:23:52 +01001607# So far, the CID API isn't implemented, so we can't
1608# grep for output witnessing its use. This needs to be
Hanno Becker6a3ff282019-04-26 17:19:46 +01001609# changed once the CID extension is implemented.
Hanno Beckerad8e2c92019-05-08 13:19:53 +01001610
Hanno Becker2dcdc922019-04-09 18:08:47 +01001611requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckera5a2b082019-05-15 14:03:01 +01001612run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001613 "$P_SRV debug_level=3 dtls=1 cid=0" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03001614 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=dead" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001615 0 \
1616 -s "Disable use of CID extension." \
1617 -s "found CID extension" \
1618 -s "Client sent CID extension, but CID disabled" \
1619 -c "Enable use of CID extension." \
1620 -c "client hello, adding CID extension" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001621 -S "server hello, adding CID extension" \
1622 -C "found CID extension" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001623 -S "Copy CIDs into SSL transform" \
1624 -C "Copy CIDs into SSL transform" \
1625 -c "Use of Connection ID was rejected by the server"
1626
1627requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1628run_test "Connection ID: Cli disabled, Srv enabled" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03001629 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
Hanno Becker2dcdc922019-04-09 18:08:47 +01001630 "$P_CLI debug_level=3 dtls=1 cid=0" \
1631 0 \
1632 -c "Disable use of CID extension." \
1633 -C "client hello, adding CID extension" \
1634 -S "found CID extension" \
1635 -s "Enable use of CID extension." \
1636 -S "server hello, adding CID extension" \
1637 -C "found CID extension" \
1638 -S "Copy CIDs into SSL transform" \
1639 -C "Copy CIDs into SSL transform" \
1640 -s "Use of Connection ID was not offered by client"
1641
1642requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb60c85c2019-04-23 12:02:34 +01001643run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001644 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1645 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1646 0 \
1647 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001648 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001649 -c "client hello, adding CID extension" \
1650 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001651 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001652 -s "server hello, adding CID extension" \
1653 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001654 -c "Use of CID extension negotiated" \
1655 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001656 -c "Copy CIDs into SSL transform" \
1657 -c "Peer CID (length 2 Bytes): de ad" \
1658 -s "Peer CID (length 2 Bytes): be ef" \
1659 -s "Use of Connection ID has been negotiated" \
1660 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001661
Hanno Beckera5a2b082019-05-15 14:03:01 +01001662requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001663run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001664 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001665 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1666 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1667 0 \
1668 -c "Enable use of CID extension." \
1669 -s "Enable use of CID extension." \
1670 -c "client hello, adding CID extension" \
1671 -s "found CID extension" \
1672 -s "Use of CID extension negotiated" \
1673 -s "server hello, adding CID extension" \
1674 -c "found CID extension" \
1675 -c "Use of CID extension negotiated" \
1676 -s "Copy CIDs into SSL transform" \
1677 -c "Copy CIDs into SSL transform" \
1678 -c "Peer CID (length 2 Bytes): de ad" \
1679 -s "Peer CID (length 2 Bytes): be ef" \
1680 -s "Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001681 -c "Use of Connection ID has been negotiated" \
1682 -c "ignoring unexpected CID" \
1683 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01001684
Hanno Beckera5a2b082019-05-15 14:03:01 +01001685requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001686run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1687 -p "$P_PXY mtu=800" \
1688 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1689 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1690 0 \
1691 -c "Enable use of CID extension." \
1692 -s "Enable use of CID extension." \
1693 -c "client hello, adding CID extension" \
1694 -s "found CID extension" \
1695 -s "Use of CID extension negotiated" \
1696 -s "server hello, adding CID extension" \
1697 -c "found CID extension" \
1698 -c "Use of CID extension negotiated" \
1699 -s "Copy CIDs into SSL transform" \
1700 -c "Copy CIDs into SSL transform" \
1701 -c "Peer CID (length 2 Bytes): de ad" \
1702 -s "Peer CID (length 2 Bytes): be ef" \
1703 -s "Use of Connection ID has been negotiated" \
1704 -c "Use of Connection ID has been negotiated"
1705
Hanno Beckera5a2b082019-05-15 14:03:01 +01001706requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001707run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001708 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01001709 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1710 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1711 0 \
1712 -c "Enable use of CID extension." \
1713 -s "Enable use of CID extension." \
1714 -c "client hello, adding CID extension" \
1715 -s "found CID extension" \
1716 -s "Use of CID extension negotiated" \
1717 -s "server hello, adding CID extension" \
1718 -c "found CID extension" \
1719 -c "Use of CID extension negotiated" \
1720 -s "Copy CIDs into SSL transform" \
1721 -c "Copy CIDs into SSL transform" \
1722 -c "Peer CID (length 2 Bytes): de ad" \
1723 -s "Peer CID (length 2 Bytes): be ef" \
1724 -s "Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01001725 -c "Use of Connection ID has been negotiated" \
1726 -c "ignoring unexpected CID" \
1727 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01001728
Hanno Beckera5a2b082019-05-15 14:03:01 +01001729requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001730requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001731run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001732 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1733 "$P_CLI debug_level=3 dtls=1 cid=1" \
1734 0 \
1735 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001736 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001737 -c "client hello, adding CID extension" \
1738 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001739 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001740 -s "server hello, adding CID extension" \
1741 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001742 -c "Use of CID extension negotiated" \
1743 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001744 -c "Copy CIDs into SSL transform" \
1745 -c "Peer CID (length 4 Bytes): de ad be ef" \
1746 -s "Peer CID (length 0 Bytes):" \
1747 -s "Use of Connection ID has been negotiated" \
1748 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001749
Hanno Beckera5a2b082019-05-15 14:03:01 +01001750requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001751requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001752run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001753 "$P_SRV debug_level=3 dtls=1 cid=1" \
1754 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1755 0 \
1756 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001757 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001758 -c "client hello, adding CID extension" \
1759 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001760 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001761 -s "server hello, adding CID extension" \
1762 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001763 -c "Use of CID extension negotiated" \
1764 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001765 -c "Copy CIDs into SSL transform" \
1766 -s "Peer CID (length 4 Bytes): de ad be ef" \
1767 -c "Peer CID (length 0 Bytes):" \
1768 -s "Use of Connection ID has been negotiated" \
1769 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001770
Hanno Beckera5a2b082019-05-15 14:03:01 +01001771requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001772requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001773run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001774 "$P_SRV debug_level=3 dtls=1 cid=1" \
1775 "$P_CLI debug_level=3 dtls=1 cid=1" \
1776 0 \
1777 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001778 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001779 -c "client hello, adding CID extension" \
1780 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001781 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001782 -s "server hello, adding CID extension" \
1783 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001784 -c "Use of CID extension negotiated" \
1785 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001786 -c "Copy CIDs into SSL transform" \
1787 -S "Use of Connection ID has been negotiated" \
1788 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001789
Hanno Beckera5a2b082019-05-15 14:03:01 +01001790requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01001791run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001792 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1793 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1794 0 \
1795 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001796 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001797 -c "client hello, adding CID extension" \
1798 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001799 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001800 -s "server hello, adding CID extension" \
1801 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001802 -c "Use of CID extension negotiated" \
1803 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001804 -c "Copy CIDs into SSL transform" \
1805 -c "Peer CID (length 2 Bytes): de ad" \
1806 -s "Peer CID (length 2 Bytes): be ef" \
1807 -s "Use of Connection ID has been negotiated" \
1808 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001809
Hanno Beckera5a2b082019-05-15 14:03:01 +01001810requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001811requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001812run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001813 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1814 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1815 0 \
1816 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001817 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001818 -c "client hello, adding CID extension" \
1819 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001820 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001821 -s "server hello, adding CID extension" \
1822 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001823 -c "Use of CID extension negotiated" \
1824 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001825 -c "Copy CIDs into SSL transform" \
1826 -c "Peer CID (length 4 Bytes): de ad be ef" \
1827 -s "Peer CID (length 0 Bytes):" \
1828 -s "Use of Connection ID has been negotiated" \
1829 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001830
Hanno Beckera5a2b082019-05-15 14:03:01 +01001831requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001832requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001833run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001834 "$P_SRV debug_level=3 dtls=1 cid=1" \
1835 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1836 0 \
1837 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001838 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001839 -c "client hello, adding CID extension" \
1840 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001841 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001842 -s "server hello, adding CID extension" \
1843 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001844 -c "Use of CID extension negotiated" \
1845 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001846 -c "Copy CIDs into SSL transform" \
1847 -s "Peer CID (length 4 Bytes): de ad be ef" \
1848 -c "Peer CID (length 0 Bytes):" \
1849 -s "Use of Connection ID has been negotiated" \
1850 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001851
Hanno Beckera5a2b082019-05-15 14:03:01 +01001852requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001853requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
Hanno Becker04ca04c2019-05-08 13:31:15 +01001854run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001855 "$P_SRV debug_level=3 dtls=1 cid=1" \
1856 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1857 0 \
1858 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001859 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001860 -c "client hello, adding CID extension" \
1861 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001862 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001863 -s "server hello, adding CID extension" \
1864 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001865 -c "Use of CID extension negotiated" \
1866 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001867 -c "Copy CIDs into SSL transform" \
1868 -S "Use of Connection ID has been negotiated" \
1869 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001870
Hanno Beckera5a2b082019-05-15 14:03:01 +01001871requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001872requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001873run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001874 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1875 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1876 0 \
1877 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001878 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001879 -c "client hello, adding CID extension" \
1880 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001881 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001882 -s "server hello, adding CID extension" \
1883 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001884 -c "Use of CID extension negotiated" \
1885 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001886 -c "Copy CIDs into SSL transform" \
1887 -c "Peer CID (length 2 Bytes): de ad" \
1888 -s "Peer CID (length 2 Bytes): be ef" \
1889 -s "Use of Connection ID has been negotiated" \
1890 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001891
Hanno Beckera5a2b082019-05-15 14:03:01 +01001892requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001893requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1894requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001895run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001896 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1897 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1898 0 \
1899 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001900 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001901 -c "client hello, adding CID extension" \
1902 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001903 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001904 -s "server hello, adding CID extension" \
1905 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001906 -c "Use of CID extension negotiated" \
1907 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001908 -c "Copy CIDs into SSL transform" \
1909 -c "Peer CID (length 4 Bytes): de ad be ef" \
1910 -s "Peer CID (length 0 Bytes):" \
1911 -s "Use of Connection ID has been negotiated" \
1912 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001913
Hanno Beckera5a2b082019-05-15 14:03:01 +01001914requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001915requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1916requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001917run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001918 "$P_SRV debug_level=3 dtls=1 cid=1" \
1919 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1920 0 \
1921 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001922 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001923 -c "client hello, adding CID extension" \
1924 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001925 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001926 -s "server hello, adding CID extension" \
1927 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001928 -c "Use of CID extension negotiated" \
1929 -s "Copy CIDs into SSL transform" \
Hanno Beckerb7f9e9c2019-05-03 17:04:23 +01001930 -c "Copy CIDs into SSL transform" \
1931 -s "Peer CID (length 4 Bytes): de ad be ef" \
1932 -c "Peer CID (length 0 Bytes):" \
1933 -s "Use of Connection ID has been negotiated" \
1934 -c "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001935
Hanno Beckera5a2b082019-05-15 14:03:01 +01001936requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Jarno Lamsa33281d52019-10-18 10:54:35 +03001937requires_config_disabled MBEDTLS_SSL_CONF_CID_LEN
1938requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
Hanno Becker04ca04c2019-05-08 13:31:15 +01001939run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001940 "$P_SRV debug_level=3 dtls=1 cid=1" \
1941 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1942 0 \
1943 -c "Enable use of CID extension." \
Hanno Becker73455992019-04-25 17:01:43 +01001944 -s "Enable use of CID extension." \
Hanno Beckerc008cb52019-04-26 14:17:56 +01001945 -c "client hello, adding CID extension" \
1946 -s "found CID extension" \
Hanno Becker4eb05872019-04-26 16:00:29 +01001947 -s "Use of CID extension negotiated" \
Hanno Beckercf2a5652019-04-26 16:13:31 +01001948 -s "server hello, adding CID extension" \
1949 -c "found CID extension" \
Hanno Becker5e2cd142019-04-26 16:23:52 +01001950 -c "Use of CID extension negotiated" \
1951 -s "Copy CIDs into SSL transform" \
Hanno Becker6a3ff282019-04-26 17:19:46 +01001952 -c "Copy CIDs into SSL transform" \
1953 -S "Use of Connection ID has been negotiated" \
1954 -C "Use of Connection ID has been negotiated"
Hanno Becker2dcdc922019-04-09 18:08:47 +01001955
Hanno Beckera5a2b082019-05-15 14:03:01 +01001956requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker963cb352019-04-23 11:52:44 +01001957requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001958run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
Hanno Becker9dae9fd2019-04-25 16:05:45 +01001959 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
1960 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
1961 0 \
Hanno Becker96870292019-05-03 17:30:59 +01001962 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1963 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1964 -s "(initial handshake) Use of Connection ID has been negotiated" \
1965 -c "(initial handshake) Use of Connection ID has been negotiated" \
1966 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1967 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1968 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1969 -c "(after renegotiation) Use of Connection ID has been negotiated"
1970
Hanno Beckera5a2b082019-05-15 14:03:01 +01001971requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001972requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01001973run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Becker96870292019-05-03 17:30:59 +01001974 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
1975 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1976 0 \
1977 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1978 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1979 -s "(initial handshake) Use of Connection ID has been negotiated" \
1980 -c "(initial handshake) Use of Connection ID has been negotiated" \
1981 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1982 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1983 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1984 -c "(after renegotiation) Use of Connection ID has been negotiated"
1985
Hanno Beckera5a2b082019-05-15 14:03:01 +01001986requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01001987requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01001988run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
1989 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
1990 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
1991 0 \
1992 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
1993 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
1994 -s "(initial handshake) Use of Connection ID has been negotiated" \
1995 -c "(initial handshake) Use of Connection ID has been negotiated" \
1996 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
1997 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
1998 -s "(after renegotiation) Use of Connection ID has been negotiated" \
1999 -c "(after renegotiation) Use of Connection ID has been negotiated"
2000
Hanno Beckera5a2b082019-05-15 14:03:01 +01002001requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01002002requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002003run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002004 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002005 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2006 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2007 0 \
2008 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2009 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2010 -s "(initial handshake) Use of Connection ID has been negotiated" \
2011 -c "(initial handshake) Use of Connection ID has been negotiated" \
2012 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2013 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2014 -s "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002015 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2016 -c "ignoring unexpected CID" \
2017 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002018
Hanno Beckera5a2b082019-05-15 14:03:01 +01002019requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002020requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2021run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Becker96870292019-05-03 17:30:59 +01002022 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2023 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2024 0 \
2025 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2026 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2027 -s "(initial handshake) Use of Connection ID has been negotiated" \
2028 -c "(initial handshake) Use of Connection ID has been negotiated" \
2029 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2030 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2031 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2032 -S "(after renegotiation) Use of Connection ID has been negotiated"
2033
Hanno Beckera5a2b082019-05-15 14:03:01 +01002034requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002035requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01002036run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
2037 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2038 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2039 0 \
2040 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2041 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2042 -s "(initial handshake) Use of Connection ID has been negotiated" \
2043 -c "(initial handshake) Use of Connection ID has been negotiated" \
2044 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2045 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2046 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2047 -S "(after renegotiation) Use of Connection ID has been negotiated"
2048
Hanno Beckera5a2b082019-05-15 14:03:01 +01002049requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01002050requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002051run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002052 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002053 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2054 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2055 0 \
2056 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2057 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2058 -s "(initial handshake) Use of Connection ID has been negotiated" \
2059 -c "(initial handshake) Use of Connection ID has been negotiated" \
2060 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2061 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2062 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002063 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2064 -c "ignoring unexpected CID" \
2065 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002066
Hanno Beckera5a2b082019-05-15 14:03:01 +01002067requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002068requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2069run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002070 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2071 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2072 0 \
2073 -S "(initial handshake) Use of Connection ID has been negotiated" \
2074 -C "(initial handshake) Use of Connection ID has been negotiated" \
2075 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2076 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2077 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2078 -s "(after renegotiation) Use of Connection ID has been negotiated"
2079
Hanno Beckera5a2b082019-05-15 14:03:01 +01002080requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002081requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker84bbc512019-05-08 16:20:46 +01002082run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2083 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2084 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2085 0 \
2086 -S "(initial handshake) Use of Connection ID has been negotiated" \
2087 -C "(initial handshake) Use of Connection ID has been negotiated" \
2088 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2089 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2090 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2091 -s "(after renegotiation) Use of Connection ID has been negotiated"
2092
Hanno Beckera5a2b082019-05-15 14:03:01 +01002093requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker84bbc512019-05-08 16:20:46 +01002094requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002095run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002096 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002097 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2098 "$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" \
2099 0 \
2100 -S "(initial handshake) Use of Connection ID has been negotiated" \
2101 -C "(initial handshake) Use of Connection ID has been negotiated" \
2102 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2103 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2104 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002105 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2106 -c "ignoring unexpected CID" \
2107 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002108
Hanno Beckera5a2b082019-05-15 14:03:01 +01002109requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002110requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2111run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Becker96870292019-05-03 17:30:59 +01002112 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2113 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2114 0 \
2115 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2116 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2117 -s "(initial handshake) Use of Connection ID has been negotiated" \
2118 -c "(initial handshake) Use of Connection ID has been negotiated" \
2119 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2120 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2121 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2122 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2123 -s "(after renegotiation) Use of Connection ID was not offered by client"
2124
Hanno Beckera5a2b082019-05-15 14:03:01 +01002125requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker96870292019-05-03 17:30:59 +01002126requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker04ca04c2019-05-08 13:31:15 +01002127run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002128 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker04ca04c2019-05-08 13:31:15 +01002129 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2130 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2131 0 \
2132 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2133 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2134 -s "(initial handshake) Use of Connection ID has been negotiated" \
2135 -c "(initial handshake) Use of Connection ID has been negotiated" \
2136 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2137 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2138 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2139 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002140 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2141 -c "ignoring unexpected CID" \
2142 -s "ignoring unexpected CID"
Hanno Becker04ca04c2019-05-08 13:31:15 +01002143
Hanno Beckera5a2b082019-05-15 14:03:01 +01002144requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002145requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2146run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2147 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2148 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2149 0 \
2150 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2151 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2152 -s "(initial handshake) Use of Connection ID has been negotiated" \
2153 -c "(initial handshake) Use of Connection ID has been negotiated" \
2154 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2155 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2156 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2157 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2158 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2159
Hanno Beckera5a2b082019-05-15 14:03:01 +01002160requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker04ca04c2019-05-08 13:31:15 +01002161requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2162run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002163 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker96870292019-05-03 17:30:59 +01002164 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2165 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2166 0 \
2167 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2168 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2169 -s "(initial handshake) Use of Connection ID has been negotiated" \
2170 -c "(initial handshake) Use of Connection ID has been negotiated" \
2171 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2172 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2173 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2174 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerf6fb4ea2019-05-24 10:11:23 +01002175 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2176 -c "ignoring unexpected CID" \
2177 -s "ignoring unexpected CID"
Hanno Becker2dcdc922019-04-09 18:08:47 +01002178
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002179# Tests for Encrypt-then-MAC extension
2180
2181run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002182 "$P_SRV debug_level=3 \
2183 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002184 "$P_CLI debug_level=3" \
2185 0 \
2186 -c "client hello, adding encrypt_then_mac extension" \
2187 -s "found encrypt then mac extension" \
2188 -s "server hello, adding encrypt then mac extension" \
2189 -c "found encrypt_then_mac extension" \
2190 -c "using encrypt then mac" \
2191 -s "using encrypt then mac"
2192
2193run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002194 "$P_SRV debug_level=3 etm=0 \
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 etm=1" \
2197 0 \
2198 -c "client hello, adding encrypt_then_mac extension" \
2199 -s "found encrypt then mac extension" \
2200 -S "server hello, adding encrypt then mac extension" \
2201 -C "found encrypt_then_mac extension" \
2202 -C "using encrypt then mac" \
2203 -S "using encrypt then mac"
2204
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002205run_test "Encrypt then MAC: client enabled, aead cipher" \
2206 "$P_SRV debug_level=3 etm=1 \
2207 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2208 "$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
2217run_test "Encrypt then MAC: client enabled, stream cipher" \
2218 "$P_SRV debug_level=3 etm=1 \
2219 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002220 "$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 +01002221 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
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002229run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002230 "$P_SRV debug_level=3 etm=1 \
2231 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002232 "$P_CLI debug_level=3 etm=0" \
2233 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
Janos Follathe2681a42016-03-07 15:57:05 +00002241requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002242run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002243 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002244 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002245 "$P_CLI debug_level=3 force_version=ssl3" \
2246 0 \
2247 -C "client hello, adding encrypt_then_mac extension" \
2248 -S "found encrypt then mac extension" \
2249 -S "server hello, adding encrypt then mac extension" \
2250 -C "found encrypt_then_mac extension" \
2251 -C "using encrypt then mac" \
2252 -S "using encrypt then mac"
2253
Janos Follathe2681a42016-03-07 15:57:05 +00002254requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002255run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002256 "$P_SRV debug_level=3 force_version=ssl3 \
2257 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002258 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002259 0 \
2260 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002261 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002262 -S "server hello, adding encrypt then mac extension" \
2263 -C "found encrypt_then_mac extension" \
2264 -C "using encrypt then mac" \
2265 -S "using encrypt then mac"
2266
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002267# Tests for Extended Master Secret extension
2268
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002269run_test "Extended Master Secret: default (not enforcing)" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002270 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0 " \
2271 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa31d940b2019-06-12 10:21:33 +03002272 0 \
2273 -c "client hello, adding extended_master_secret extension" \
2274 -s "found extended master secret extension" \
2275 -s "server hello, adding extended master secret extension" \
2276 -c "found extended_master_secret extension" \
2277 -c "session hash for extended master secret" \
2278 -s "session hash for extended master secret"
2279
2280run_test "Extended Master Secret: both enabled, both enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002281 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2282 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002283 0 \
2284 -c "client hello, adding extended_master_secret extension" \
2285 -s "found extended master secret extension" \
2286 -s "server hello, adding extended master secret extension" \
2287 -c "found extended_master_secret extension" \
2288 -c "session hash for extended master secret" \
2289 -s "session hash for extended master secret"
2290
Jarno Lamsa20095af2019-06-11 17:16:58 +03002291run_test "Extended Master Secret: both enabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002292 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2293 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002294 0 \
2295 -c "client hello, adding extended_master_secret extension" \
2296 -s "found extended master secret extension" \
2297 -s "server hello, adding extended master secret extension" \
2298 -c "found extended_master_secret extension" \
2299 -c "session hash for extended master secret" \
2300 -s "session hash for extended master secret"
2301
2302run_test "Extended Master Secret: both enabled, server enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002303 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2304 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002305 0 \
2306 -c "client hello, adding extended_master_secret extension" \
2307 -s "found extended master secret extension" \
2308 -s "server hello, adding extended master secret extension" \
2309 -c "found extended_master_secret extension" \
2310 -c "session hash for extended master secret" \
2311 -s "session hash for extended master secret"
2312
2313run_test "Extended Master Secret: client enabled, server disabled, client enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002314 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002315 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2316 1 \
2317 -c "client hello, adding extended_master_secret extension" \
2318 -s "found extended master secret extension" \
2319 -S "server hello, adding extended master secret extension" \
2320 -C "found extended_master_secret extension" \
2321 -c "Peer not offering extended master secret, while it is enforced"
2322
Jarno Lamsa20095af2019-06-11 17:16:58 +03002323run_test "Extended Master Secret enforced: client disabled, server enabled, server enforcing" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002324 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002325 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa41b35912019-06-10 15:51:11 +03002326 1 \
2327 -C "client hello, adding extended_master_secret extension" \
2328 -S "found extended master secret extension" \
2329 -S "server hello, adding extended master secret extension" \
2330 -C "found extended_master_secret extension" \
2331 -s "Peer not offering extended master secret, while it is enforced"
2332
Jarno Lamsa20095af2019-06-11 17:16:58 +03002333run_test "Extended Master Secret: client enabled, server disabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002334 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2335 "$P_CLI debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002336 0 \
2337 -c "client hello, adding extended_master_secret extension" \
2338 -s "found extended master secret extension" \
2339 -S "server hello, adding extended master secret extension" \
2340 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002341 -C "session hash for extended master secret" \
2342 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002343
Jarno Lamsa20095af2019-06-11 17:16:58 +03002344run_test "Extended Master Secret: client disabled, server enabled, not enforcing" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002345 "$P_SRV debug_level=3 extended_ms=1 enforce_extended_master_secret=0" \
2346 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002347 0 \
2348 -C "client hello, adding extended_master_secret extension" \
2349 -S "found extended master secret extension" \
2350 -S "server hello, adding extended master secret extension" \
2351 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002352 -C "session hash for extended master secret" \
2353 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002354
Jarno Lamsa20095af2019-06-11 17:16:58 +03002355run_test "Extended Master Secret: client disabled, server disabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002356 "$P_SRV debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
2357 "$P_CLI debug_level=3 extended_ms=0 enforce_extended_master_secret=0" \
Jarno Lamsa20095af2019-06-11 17:16:58 +03002358 0 \
2359 -C "client hello, adding extended_master_secret extension" \
2360 -S "found extended master secret extension" \
2361 -S "server hello, adding extended master secret extension" \
2362 -C "found extended_master_secret extension" \
2363 -C "session hash for extended master secret" \
2364 -S "session hash for extended master secret"
2365
Janos Follathe2681a42016-03-07 15:57:05 +00002366requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002367run_test "Extended Master Secret: client SSLv3, server enabled" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002368 "$P_SRV debug_level=3 min_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2369 "$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 +02002370 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" \
Manuel Pégourié-Gonnard9c5bcc92019-05-20 12:09:50 +02002375 -C "session hash for extended master secret" \
2376 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002377
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 enabled, server SSLv3" \
Hanno Beckeraf5ab912019-06-21 12:59:46 +01002380 "$P_SRV debug_level=3 force_version=ssl3 extended_ms=1 enforce_extended_master_secret=0" \
2381 "$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 +02002382 0 \
2383 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002384 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002385 -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
Jarno Lamsaff434c22019-10-25 12:21:54 +03002390run_test "Extended Master Secret: both enabled, both enforcing, DTLS" \
2391 "$P_SRV dtls=1 debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2392 "$P_CLI dtls=1 debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \
2393 0 \
2394 -c "client hello, adding extended_master_secret extension" \
2395 -s "found extended master secret extension" \
2396 -s "server hello, adding extended master secret extension" \
2397 -c "found extended_master_secret extension" \
2398 -c "session hash for extended master secret" \
2399 -s "session hash for extended master secret"
2400
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002401# Tests for FALLBACK_SCSV
2402
2403run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002404 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002405 "$P_CLI debug_level=3 force_version=tls1_1" \
2406 0 \
2407 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002408 -S "received FALLBACK_SCSV" \
2409 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002410 -C "is a fatal alert message (msg 86)"
2411
2412run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002413 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002414 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2415 0 \
2416 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002417 -S "received FALLBACK_SCSV" \
2418 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002419 -C "is a fatal alert message (msg 86)"
2420
2421run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002422 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002423 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002424 1 \
2425 -c "adding FALLBACK_SCSV" \
2426 -s "received FALLBACK_SCSV" \
2427 -s "inapropriate fallback" \
2428 -c "is a fatal alert message (msg 86)"
2429
2430run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002431 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002432 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002433 0 \
2434 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002435 -s "received FALLBACK_SCSV" \
2436 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002437 -C "is a fatal alert message (msg 86)"
2438
2439requires_openssl_with_fallback_scsv
2440run_test "Fallback SCSV: default, openssl server" \
2441 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002442 "$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 +02002443 0 \
2444 -C "adding FALLBACK_SCSV" \
2445 -C "is a fatal alert message (msg 86)"
2446
2447requires_openssl_with_fallback_scsv
2448run_test "Fallback SCSV: enabled, openssl server" \
2449 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002450 "$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 +02002451 1 \
2452 -c "adding FALLBACK_SCSV" \
2453 -c "is a fatal alert message (msg 86)"
2454
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002455requires_openssl_with_fallback_scsv
2456run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002457 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002458 "$O_CLI -tls1_1" \
2459 0 \
2460 -S "received FALLBACK_SCSV" \
2461 -S "inapropriate fallback"
2462
2463requires_openssl_with_fallback_scsv
2464run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002465 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002466 "$O_CLI -tls1_1 -fallback_scsv" \
2467 1 \
2468 -s "received FALLBACK_SCSV" \
2469 -s "inapropriate fallback"
2470
2471requires_openssl_with_fallback_scsv
2472run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002473 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002474 "$O_CLI -fallback_scsv" \
2475 0 \
2476 -s "received FALLBACK_SCSV" \
2477 -S "inapropriate fallback"
2478
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002479# Test sending and receiving empty application data records
2480
2481run_test "Encrypt then MAC: empty application data record" \
2482 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2483 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2484 0 \
2485 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2486 -s "dumping 'input payload after decrypt' (0 bytes)" \
2487 -c "0 bytes written in 1 fragments"
2488
Andrzej Kurek825ebd42020-05-18 11:47:25 -04002489run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002490 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2491 "$P_CLI auth_mode=none etm=0 request_size=0" \
2492 0 \
2493 -s "dumping 'input payload after decrypt' (0 bytes)" \
2494 -c "0 bytes written in 1 fragments"
2495
2496run_test "Encrypt then MAC, DTLS: empty application data record" \
2497 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2498 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2499 0 \
2500 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2501 -s "dumping 'input payload after decrypt' (0 bytes)" \
2502 -c "0 bytes written in 1 fragments"
2503
Andrzej Kurek825ebd42020-05-18 11:47:25 -04002504run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002505 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2506 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2507 0 \
2508 -s "dumping 'input payload after decrypt' (0 bytes)" \
2509 -c "0 bytes written in 1 fragments"
2510
Gilles Peskined50177f2017-05-16 17:53:03 +02002511## ClientHello generated with
2512## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2513## then manually twiddling the ciphersuite list.
2514## The ClientHello content is spelled out below as a hex string as
2515## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2516## The expected response is an inappropriate_fallback alert.
2517requires_openssl_with_fallback_scsv
2518run_test "Fallback SCSV: beginning of list" \
2519 "$P_SRV debug_level=2" \
2520 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2521 0 \
2522 -s "received FALLBACK_SCSV" \
2523 -s "inapropriate fallback"
2524
2525requires_openssl_with_fallback_scsv
2526run_test "Fallback SCSV: end of list" \
2527 "$P_SRV debug_level=2" \
2528 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2529 0 \
2530 -s "received FALLBACK_SCSV" \
2531 -s "inapropriate fallback"
2532
2533## Here the expected response is a valid ServerHello prefix, up to the random.
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02002534## Due to the way the clienthello was generated, this currently needs the
2535## server to have support for session tickets.
2536requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Gilles Peskined50177f2017-05-16 17:53:03 +02002537requires_openssl_with_fallback_scsv
2538run_test "Fallback SCSV: not in list" \
2539 "$P_SRV debug_level=2" \
2540 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2541 0 \
2542 -S "received FALLBACK_SCSV" \
2543 -S "inapropriate fallback"
2544
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002545# Tests for CBC 1/n-1 record splitting
2546
2547run_test "CBC Record splitting: TLS 1.2, no splitting" \
2548 "$P_SRV" \
2549 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2550 request_size=123 force_version=tls1_2" \
2551 0 \
2552 -s "Read from client: 123 bytes read" \
2553 -S "Read from client: 1 bytes read" \
2554 -S "122 bytes read"
2555
2556run_test "CBC Record splitting: TLS 1.1, no splitting" \
2557 "$P_SRV" \
2558 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2559 request_size=123 force_version=tls1_1" \
2560 0 \
2561 -s "Read from client: 123 bytes read" \
2562 -S "Read from client: 1 bytes read" \
2563 -S "122 bytes read"
2564
2565run_test "CBC Record splitting: TLS 1.0, splitting" \
2566 "$P_SRV" \
2567 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2568 request_size=123 force_version=tls1" \
2569 0 \
2570 -S "Read from client: 123 bytes read" \
2571 -s "Read from client: 1 bytes read" \
2572 -s "122 bytes read"
2573
Janos Follathe2681a42016-03-07 15:57:05 +00002574requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002575run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002576 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002577 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2578 request_size=123 force_version=ssl3" \
2579 0 \
2580 -S "Read from client: 123 bytes read" \
2581 -s "Read from client: 1 bytes read" \
2582 -s "122 bytes read"
2583
2584run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002585 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002586 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2587 request_size=123 force_version=tls1" \
2588 0 \
2589 -s "Read from client: 123 bytes read" \
2590 -S "Read from client: 1 bytes read" \
2591 -S "122 bytes read"
2592
2593run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2594 "$P_SRV" \
2595 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2596 request_size=123 force_version=tls1 recsplit=0" \
2597 0 \
2598 -s "Read from client: 123 bytes read" \
2599 -S "Read from client: 1 bytes read" \
2600 -S "122 bytes read"
2601
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002602run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2603 "$P_SRV nbio=2" \
2604 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2605 request_size=123 force_version=tls1" \
2606 0 \
2607 -S "Read from client: 123 bytes read" \
2608 -s "Read from client: 1 bytes read" \
2609 -s "122 bytes read"
2610
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002611# Tests for Session Tickets
2612
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002613requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002614requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002615run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002616 "$P_SRV debug_level=3 tickets=1" \
2617 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002618 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002619 -c "client hello, adding session ticket extension" \
2620 -s "found session ticket extension" \
2621 -s "server hello, adding session ticket extension" \
2622 -c "found session_ticket extension" \
2623 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002624 -S "session successfully restored from cache" \
2625 -s "session successfully restored from ticket" \
2626 -s "a session has been resumed" \
2627 -c "a session has been resumed"
2628
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002629requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002630requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002631run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002632 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2633 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002634 0 \
2635 -c "client hello, adding session ticket extension" \
2636 -s "found session ticket extension" \
2637 -s "server hello, adding session ticket extension" \
2638 -c "found session_ticket extension" \
2639 -c "parse new session ticket" \
2640 -S "session successfully restored from cache" \
2641 -s "session successfully restored from ticket" \
2642 -s "a session has been resumed" \
2643 -c "a session has been resumed"
2644
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002645requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002646requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002647run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002648 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2649 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002650 0 \
2651 -c "client hello, adding session ticket extension" \
2652 -s "found session ticket extension" \
2653 -s "server hello, adding session ticket extension" \
2654 -c "found session_ticket extension" \
2655 -c "parse new session ticket" \
2656 -S "session successfully restored from cache" \
2657 -S "session successfully restored from ticket" \
2658 -S "a session has been resumed" \
2659 -C "a session has been resumed"
2660
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002661requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002662requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002663run_test "Session resume using tickets: session copy" \
2664 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2665 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2666 0 \
2667 -c "client hello, adding session ticket extension" \
2668 -s "found session ticket extension" \
2669 -s "server hello, adding session ticket extension" \
2670 -c "found session_ticket extension" \
2671 -c "parse new session ticket" \
2672 -S "session successfully restored from cache" \
2673 -s "session successfully restored from ticket" \
2674 -s "a session has been resumed" \
2675 -c "a session has been resumed"
2676
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002677requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002678requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002679run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002680 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002681 "$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 +01002682 0 \
2683 -c "client hello, adding session ticket extension" \
2684 -c "found session_ticket extension" \
2685 -c "parse new session ticket" \
2686 -c "a session has been resumed"
2687
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002688requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002689requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002690run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002691 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002692 "( $O_CLI -sess_out $SESSION; \
2693 $O_CLI -sess_in $SESSION; \
2694 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002695 0 \
2696 -s "found session ticket extension" \
2697 -s "server hello, adding session ticket extension" \
2698 -S "session successfully restored from cache" \
2699 -s "session successfully restored from ticket" \
2700 -s "a session has been resumed"
2701
Hanno Becker1d739932018-08-21 13:55:22 +01002702# Tests for Session Tickets with DTLS
2703
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002704requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002705requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002706run_test "Session resume using tickets, DTLS: basic" \
2707 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04002708 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002709 0 \
2710 -c "client hello, adding session ticket extension" \
2711 -s "found session ticket extension" \
2712 -s "server hello, adding session ticket extension" \
2713 -c "found session_ticket extension" \
2714 -c "parse new session ticket" \
2715 -S "session successfully restored from cache" \
2716 -s "session successfully restored from ticket" \
2717 -s "a session has been resumed" \
2718 -c "a session has been resumed"
2719
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002720requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002721requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002722run_test "Session resume using tickets, DTLS: cache disabled" \
2723 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04002724 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002725 0 \
2726 -c "client hello, adding session ticket extension" \
2727 -s "found session ticket extension" \
2728 -s "server hello, adding session ticket extension" \
2729 -c "found session_ticket extension" \
2730 -c "parse new session ticket" \
2731 -S "session successfully restored from cache" \
2732 -s "session successfully restored from ticket" \
2733 -s "a session has been resumed" \
2734 -c "a session has been resumed"
2735
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002736requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002737requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002738run_test "Session resume using tickets, DTLS: timeout" \
2739 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04002740 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Becker1d739932018-08-21 13:55:22 +01002741 0 \
2742 -c "client hello, adding session ticket extension" \
2743 -s "found session ticket extension" \
2744 -s "server hello, adding session ticket extension" \
2745 -c "found session_ticket extension" \
2746 -c "parse new session ticket" \
2747 -S "session successfully restored from cache" \
2748 -S "session successfully restored from ticket" \
2749 -S "a session has been resumed" \
2750 -C "a session has been resumed"
2751
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002752requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002753requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002754run_test "Session resume using tickets, DTLS: session copy" \
2755 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
2756 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_mode=0" \
2757 0 \
2758 -c "client hello, adding session ticket extension" \
2759 -s "found session ticket extension" \
2760 -s "server hello, adding session ticket extension" \
2761 -c "found session_ticket extension" \
2762 -c "parse new session ticket" \
2763 -S "session successfully restored from cache" \
2764 -s "session successfully restored from ticket" \
2765 -s "a session has been resumed" \
2766 -c "a session has been resumed"
2767
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002768requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002769requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002770run_test "Session resume using tickets, DTLS: openssl server" \
2771 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002772 "$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 +01002773 0 \
2774 -c "client hello, adding session ticket extension" \
2775 -c "found session_ticket extension" \
2776 -c "parse new session ticket" \
2777 -c "a session has been resumed"
2778
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002779requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002780requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker1d739932018-08-21 13:55:22 +01002781run_test "Session resume using tickets, DTLS: openssl client" \
2782 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2783 "( $O_CLI -dtls1 -sess_out $SESSION; \
2784 $O_CLI -dtls1 -sess_in $SESSION; \
2785 rm -f $SESSION )" \
2786 0 \
2787 -s "found session ticket extension" \
2788 -s "server hello, adding session ticket extension" \
2789 -S "session successfully restored from cache" \
2790 -s "session successfully restored from ticket" \
2791 -s "a session has been resumed"
2792
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002793# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002794
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002795requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002796requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002797requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002798run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002799 "$P_SRV debug_level=3 tickets=0" \
2800 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002801 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002802 -c "client hello, adding session ticket extension" \
2803 -s "found session ticket extension" \
2804 -S "server hello, adding session ticket extension" \
2805 -C "found session_ticket extension" \
2806 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002807 -s "session successfully restored from cache" \
2808 -S "session successfully restored from ticket" \
2809 -s "a session has been resumed" \
2810 -c "a session has been resumed"
2811
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002812requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002813requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002814requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002815run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002816 "$P_SRV debug_level=3 tickets=1" \
2817 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002818 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002819 -C "client hello, adding session ticket extension" \
2820 -S "found session ticket extension" \
2821 -S "server hello, adding session ticket extension" \
2822 -C "found session_ticket extension" \
2823 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002824 -s "session successfully restored from cache" \
2825 -S "session successfully restored from ticket" \
2826 -s "a session has been resumed" \
2827 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002828
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002829requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2830requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002831run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002832 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2833 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002834 0 \
2835 -S "session successfully restored from cache" \
2836 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002837 -S "a session has been resumed" \
2838 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002839
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002840requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2841requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002842run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002843 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2844 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002845 0 \
2846 -s "session successfully restored from cache" \
2847 -S "session successfully restored from ticket" \
2848 -s "a session has been resumed" \
2849 -c "a session has been resumed"
2850
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002851requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2852requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002853run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002854 "$P_SRV debug_level=3 tickets=0" \
2855 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002856 0 \
2857 -s "session successfully restored from cache" \
2858 -S "session successfully restored from ticket" \
2859 -s "a session has been resumed" \
2860 -c "a session has been resumed"
2861
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002862requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2863requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002864run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002865 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2866 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002867 0 \
2868 -S "session successfully restored from cache" \
2869 -S "session successfully restored from ticket" \
2870 -S "a session has been resumed" \
2871 -C "a session has been resumed"
2872
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002873requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2874requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002875run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002876 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2877 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002878 0 \
2879 -s "session successfully restored from cache" \
2880 -S "session successfully restored from ticket" \
2881 -s "a session has been resumed" \
2882 -c "a session has been resumed"
2883
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002884requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2885requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02002886run_test "Session resume using cache: session copy" \
2887 "$P_SRV debug_level=3 tickets=0" \
2888 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2889 0 \
2890 -s "session successfully restored from cache" \
2891 -S "session successfully restored from ticket" \
2892 -s "a session has been resumed" \
2893 -c "a session has been resumed"
2894
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002895requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2896requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002897run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002898 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002899 "( $O_CLI -sess_out $SESSION; \
2900 $O_CLI -sess_in $SESSION; \
2901 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002902 0 \
2903 -s "found session ticket extension" \
2904 -S "server hello, adding session ticket extension" \
2905 -s "session successfully restored from cache" \
2906 -S "session successfully restored from ticket" \
2907 -s "a session has been resumed"
2908
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002909requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2910requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002911run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002912 "$O_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01002913 "$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 +01002914 0 \
2915 -C "found session_ticket extension" \
2916 -C "parse new session ticket" \
2917 -c "a session has been resumed"
2918
Hanno Becker1d739932018-08-21 13:55:22 +01002919# Tests for Session Resume based on session-ID and cache, DTLS
2920
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002921requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002922requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002923requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002924run_test "Session resume using cache, DTLS: tickets enabled on client" \
2925 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04002926 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002927 0 \
2928 -c "client hello, adding session ticket extension" \
2929 -s "found session ticket extension" \
2930 -S "server hello, adding session ticket extension" \
2931 -C "found session_ticket extension" \
2932 -C "parse new session ticket" \
2933 -s "session successfully restored from cache" \
2934 -S "session successfully restored from ticket" \
2935 -s "a session has been resumed" \
2936 -c "a session has been resumed"
2937
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002938requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03002939requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002940requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002941run_test "Session resume using cache, DTLS: tickets enabled on server" \
2942 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04002943 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002944 0 \
2945 -C "client hello, adding session ticket extension" \
2946 -S "found session ticket extension" \
2947 -S "server hello, adding session ticket extension" \
2948 -C "found session_ticket extension" \
2949 -C "parse new session ticket" \
2950 -s "session successfully restored from cache" \
2951 -S "session successfully restored from ticket" \
2952 -s "a session has been resumed" \
2953 -c "a session has been resumed"
2954
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002955requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2956requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002957run_test "Session resume using cache, DTLS: cache_max=0" \
2958 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04002959 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002960 0 \
2961 -S "session successfully restored from cache" \
2962 -S "session successfully restored from ticket" \
2963 -S "a session has been resumed" \
2964 -C "a session has been resumed"
2965
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002966requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2967requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002968run_test "Session resume using cache, DTLS: cache_max=1" \
2969 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04002970 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002971 0 \
2972 -s "session successfully restored from cache" \
2973 -S "session successfully restored from ticket" \
2974 -s "a session has been resumed" \
2975 -c "a session has been resumed"
2976
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002977requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2978requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002979run_test "Session resume using cache, DTLS: timeout > delay" \
2980 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04002981 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=0" \
Hanno Becker1d739932018-08-21 13:55:22 +01002982 0 \
2983 -s "session successfully restored from cache" \
2984 -S "session successfully restored from ticket" \
2985 -s "a session has been resumed" \
2986 -c "a session has been resumed"
2987
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002988requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
2989requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01002990run_test "Session resume using cache, DTLS: timeout < delay" \
2991 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04002992 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Becker1d739932018-08-21 13:55:22 +01002993 0 \
2994 -S "session successfully restored from cache" \
2995 -S "session successfully restored from ticket" \
2996 -S "a session has been resumed" \
2997 -C "a session has been resumed"
2998
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03002999requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3000requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01003001run_test "Session resume using cache, DTLS: no timeout" \
3002 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04003003 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Becker1d739932018-08-21 13:55:22 +01003004 0 \
3005 -s "session successfully restored from cache" \
3006 -S "session successfully restored from ticket" \
3007 -s "a session has been resumed" \
3008 -c "a session has been resumed"
3009
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03003010requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3011requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard57a348b2019-05-20 12:46:26 +02003012run_test "Session resume using cache, DTLS: session copy" \
3013 "$P_SRV dtls=1 debug_level=3 tickets=0" \
3014 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
3015 0 \
3016 -s "session successfully restored from cache" \
3017 -S "session successfully restored from ticket" \
3018 -s "a session has been resumed" \
3019 -c "a session has been resumed"
3020
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03003021requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3022requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01003023run_test "Session resume using cache, DTLS: openssl client" \
3024 "$P_SRV dtls=1 debug_level=3 tickets=0" \
3025 "( $O_CLI -dtls1 -sess_out $SESSION; \
3026 $O_CLI -dtls1 -sess_in $SESSION; \
3027 rm -f $SESSION )" \
3028 0 \
3029 -s "found session ticket extension" \
3030 -S "server hello, adding session ticket extension" \
3031 -s "session successfully restored from cache" \
3032 -S "session successfully restored from ticket" \
3033 -s "a session has been resumed"
3034
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03003035requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
3036requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Hanno Becker1d739932018-08-21 13:55:22 +01003037run_test "Session resume using cache, DTLS: openssl server" \
3038 "$O_SRV -dtls1" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003039 "$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 +01003040 0 \
3041 -C "found session_ticket extension" \
3042 -C "parse new session ticket" \
3043 -c "a session has been resumed"
3044
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003045# Tests for Max Fragment Length extension
3046
Angus Grattonc4dd0732018-04-11 16:28:39 +10003047if [ $MAX_CONTENT_LEN -ne 16384 ]; then
3048 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
3049fi
3050
Hanno Becker4aed27e2017-09-18 15:00:34 +01003051requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003052run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003053 "$P_SRV debug_level=3" \
3054 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003055 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003056 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3057 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003058 -C "client hello, adding max_fragment_length extension" \
3059 -S "found max fragment length extension" \
3060 -S "server hello, max_fragment_length extension" \
3061 -C "found max_fragment_length extension"
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, larger message" \
3065 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003066 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +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" \
Hanno Beckerc5266962017-09-18 15:01:50 +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" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003074 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3075 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003076 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003077
3078requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003079requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Hanno Beckerc5266962017-09-18 15:01:50 +01003080run_test "Max fragment length, DTLS: enabled, default, larger message" \
3081 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003082 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003083 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003084 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
3085 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003086 -C "client hello, adding max_fragment_length extension" \
3087 -S "found max fragment length extension" \
3088 -S "server hello, max_fragment_length extension" \
3089 -C "found max_fragment_length extension" \
3090 -c "fragment larger than.*maximum "
3091
Angus Grattonc4dd0732018-04-11 16:28:39 +10003092# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3093# (session fragment length will be 16384 regardless of mbedtls
3094# content length configuration.)
3095
Hanno Beckerc5266962017-09-18 15:01:50 +01003096requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003097requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 16384
Hanno Beckerc5266962017-09-18 15:01:50 +01003098run_test "Max fragment length: disabled, larger message" \
3099 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003100 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003101 0 \
3102 -C "Maximum fragment length is 16384" \
3103 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003104 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3105 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003106 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003107
3108requires_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 DTLS: disabled, larger message" \
3111 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003112 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003113 1 \
3114 -C "Maximum fragment length is 16384" \
3115 -S "Maximum fragment length is 16384" \
3116 -c "fragment larger than.*maximum "
3117
3118requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003119requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003120run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003121 "$P_SRV debug_level=3" \
3122 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003123 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003124 -c "Maximum fragment length is 4096" \
3125 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003126 -c "client hello, adding max_fragment_length extension" \
3127 -s "found max fragment length extension" \
3128 -s "server hello, max_fragment_length extension" \
3129 -c "found max_fragment_length extension"
3130
Hanno Becker4aed27e2017-09-18 15:00:34 +01003131requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003132requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003133run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003134 "$P_SRV debug_level=3 max_frag_len=4096" \
3135 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003136 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003137 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003138 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003139 -C "client hello, adding max_fragment_length extension" \
3140 -S "found max fragment length extension" \
3141 -S "server hello, max_fragment_length extension" \
3142 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003143
Hanno Becker4aed27e2017-09-18 15:00:34 +01003144requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunen3f1190d2019-09-26 17:18:57 +03003145requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003146requires_gnutls
3147run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003148 "$G_SRV" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003149 "$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 +02003150 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003151 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003152 -c "client hello, adding max_fragment_length extension" \
3153 -c "found max_fragment_length extension"
3154
Hanno Becker4aed27e2017-09-18 15:00:34 +01003155requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003156requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003157run_test "Max fragment length: client, message just fits" \
3158 "$P_SRV debug_level=3" \
3159 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3160 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003161 -c "Maximum fragment length is 2048" \
3162 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003163 -c "client hello, adding max_fragment_length extension" \
3164 -s "found max fragment length extension" \
3165 -s "server hello, max_fragment_length extension" \
3166 -c "found max_fragment_length extension" \
3167 -c "2048 bytes written in 1 fragments" \
3168 -s "2048 bytes read"
3169
Hanno Becker4aed27e2017-09-18 15:00:34 +01003170requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003171requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003172run_test "Max fragment length: client, larger message" \
3173 "$P_SRV debug_level=3" \
3174 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3175 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003176 -c "Maximum fragment length is 2048" \
3177 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003178 -c "client hello, adding max_fragment_length extension" \
3179 -s "found max fragment length extension" \
3180 -s "server hello, max_fragment_length extension" \
3181 -c "found max_fragment_length extension" \
3182 -c "2345 bytes written in 2 fragments" \
3183 -s "2048 bytes read" \
3184 -s "297 bytes read"
3185
Hanno Becker4aed27e2017-09-18 15:00:34 +01003186requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Arto Kinnunena1e98062019-09-26 19:35:16 +03003187requires_config_value_at_least "MBEDTLS_SSL_MAX_CONTENT_LEN" 2048
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003188run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003189 "$P_SRV debug_level=3 dtls=1" \
3190 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3191 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02003192 -c "Maximum fragment length is 2048" \
3193 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003194 -c "client hello, adding max_fragment_length extension" \
3195 -s "found max fragment length extension" \
3196 -s "server hello, max_fragment_length extension" \
3197 -c "found max_fragment_length extension" \
3198 -c "fragment larger than.*maximum"
3199
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003200# Tests for renegotiation
3201
Hanno Becker6a243642017-10-12 15:18:45 +01003202# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003203run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003204 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003205 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003206 0 \
3207 -C "client hello, adding renegotiation extension" \
3208 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3209 -S "found renegotiation extension" \
3210 -s "server hello, secure renegotiation extension" \
3211 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003212 -C "=> renegotiate" \
3213 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003214 -S "write hello request"
3215
Hanno Becker6a243642017-10-12 15:18:45 +01003216requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003217run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003218 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003219 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003220 0 \
3221 -c "client hello, adding renegotiation extension" \
3222 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3223 -s "found renegotiation extension" \
3224 -s "server hello, secure renegotiation extension" \
3225 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003226 -c "=> renegotiate" \
3227 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003228 -S "write hello request"
3229
Hanno Becker6a243642017-10-12 15:18:45 +01003230requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003231run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003232 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003233 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003234 0 \
3235 -c "client hello, adding renegotiation extension" \
3236 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3237 -s "found renegotiation extension" \
3238 -s "server hello, secure renegotiation extension" \
3239 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003240 -c "=> renegotiate" \
3241 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003242 -s "write hello request"
3243
Janos Follathb0f148c2017-10-05 12:29:42 +01003244# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3245# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3246# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003247requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003248run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3249 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3250 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3251 0 \
3252 -c "client hello, adding renegotiation extension" \
3253 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3254 -s "found renegotiation extension" \
3255 -s "server hello, secure renegotiation extension" \
3256 -c "found renegotiation extension" \
3257 -c "=> renegotiate" \
3258 -s "=> renegotiate" \
3259 -S "write hello request" \
3260 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3261
3262# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3263# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3264# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003265requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003266run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3267 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3268 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3269 0 \
3270 -c "client hello, adding renegotiation extension" \
3271 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3272 -s "found renegotiation extension" \
3273 -s "server hello, secure renegotiation extension" \
3274 -c "found renegotiation extension" \
3275 -c "=> renegotiate" \
3276 -s "=> renegotiate" \
3277 -s "write hello request" \
3278 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3279
Hanno Becker6a243642017-10-12 15:18:45 +01003280requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003281run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003282 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003283 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003284 0 \
3285 -c "client hello, adding renegotiation extension" \
3286 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3287 -s "found renegotiation extension" \
3288 -s "server hello, secure renegotiation extension" \
3289 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003290 -c "=> renegotiate" \
3291 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003292 -s "write hello request"
3293
Hanno Becker6a243642017-10-12 15:18:45 +01003294requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003295run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003296 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003297 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003298 1 \
3299 -c "client hello, adding renegotiation extension" \
3300 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3301 -S "found renegotiation extension" \
3302 -s "server hello, secure renegotiation extension" \
3303 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003304 -c "=> renegotiate" \
3305 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003306 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003307 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003308 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003309
Hanno Becker6a243642017-10-12 15:18:45 +01003310requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003311run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003312 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003313 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003314 0 \
3315 -C "client hello, adding renegotiation extension" \
3316 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3317 -S "found renegotiation extension" \
3318 -s "server hello, secure renegotiation extension" \
3319 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003320 -C "=> renegotiate" \
3321 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003322 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003323 -S "SSL - An unexpected message was received from our peer" \
3324 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003325
Hanno Becker6a243642017-10-12 15:18:45 +01003326requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003327run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003328 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003329 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003330 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003331 0 \
3332 -C "client hello, adding renegotiation extension" \
3333 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3334 -S "found renegotiation extension" \
3335 -s "server hello, secure renegotiation extension" \
3336 -c "found renegotiation extension" \
3337 -C "=> renegotiate" \
3338 -S "=> renegotiate" \
3339 -s "write hello request" \
3340 -S "SSL - An unexpected message was received from our peer" \
3341 -S "failed"
3342
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003343# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003344requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003345run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003346 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003347 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003348 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003349 0 \
3350 -C "client hello, adding renegotiation extension" \
3351 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3352 -S "found renegotiation extension" \
3353 -s "server hello, secure renegotiation extension" \
3354 -c "found renegotiation extension" \
3355 -C "=> renegotiate" \
3356 -S "=> renegotiate" \
3357 -s "write hello request" \
3358 -S "SSL - An unexpected message was received from our peer" \
3359 -S "failed"
3360
Hanno Becker6a243642017-10-12 15:18:45 +01003361requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003362run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003363 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003364 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003365 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003366 0 \
3367 -C "client hello, adding renegotiation extension" \
3368 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3369 -S "found renegotiation extension" \
3370 -s "server hello, secure renegotiation extension" \
3371 -c "found renegotiation extension" \
3372 -C "=> renegotiate" \
3373 -S "=> renegotiate" \
3374 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003375 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003376
Hanno Becker6a243642017-10-12 15:18:45 +01003377requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003378run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003379 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003380 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003381 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003382 0 \
3383 -c "client hello, adding renegotiation extension" \
3384 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3385 -s "found renegotiation extension" \
3386 -s "server hello, secure renegotiation extension" \
3387 -c "found renegotiation extension" \
3388 -c "=> renegotiate" \
3389 -s "=> renegotiate" \
3390 -s "write hello request" \
3391 -S "SSL - An unexpected message was received from our peer" \
3392 -S "failed"
3393
Hanno Becker6a243642017-10-12 15:18:45 +01003394requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003395run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003396 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003397 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3398 0 \
3399 -C "client hello, adding renegotiation extension" \
3400 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3401 -S "found renegotiation extension" \
3402 -s "server hello, secure renegotiation extension" \
3403 -c "found renegotiation extension" \
3404 -S "record counter limit reached: renegotiate" \
3405 -C "=> renegotiate" \
3406 -S "=> renegotiate" \
3407 -S "write hello request" \
3408 -S "SSL - An unexpected message was received from our peer" \
3409 -S "failed"
3410
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003411# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003412requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003413run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003414 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003415 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003416 0 \
3417 -c "client hello, adding renegotiation extension" \
3418 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3419 -s "found renegotiation extension" \
3420 -s "server hello, secure renegotiation extension" \
3421 -c "found renegotiation extension" \
3422 -s "record counter limit reached: renegotiate" \
3423 -c "=> renegotiate" \
3424 -s "=> renegotiate" \
3425 -s "write hello request" \
3426 -S "SSL - An unexpected message was received from our peer" \
3427 -S "failed"
3428
Hanno Becker6a243642017-10-12 15:18:45 +01003429requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003430run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003431 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003432 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003433 0 \
3434 -c "client hello, adding renegotiation extension" \
3435 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3436 -s "found renegotiation extension" \
3437 -s "server hello, secure renegotiation extension" \
3438 -c "found renegotiation extension" \
3439 -s "record counter limit reached: renegotiate" \
3440 -c "=> renegotiate" \
3441 -s "=> renegotiate" \
3442 -s "write hello request" \
3443 -S "SSL - An unexpected message was received from our peer" \
3444 -S "failed"
3445
Hanno Becker6a243642017-10-12 15:18:45 +01003446requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003447run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003448 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003449 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3450 0 \
3451 -C "client hello, adding renegotiation extension" \
3452 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3453 -S "found renegotiation extension" \
3454 -s "server hello, secure renegotiation extension" \
3455 -c "found renegotiation extension" \
3456 -S "record counter limit reached: renegotiate" \
3457 -C "=> renegotiate" \
3458 -S "=> renegotiate" \
3459 -S "write hello request" \
3460 -S "SSL - An unexpected message was received from our peer" \
3461 -S "failed"
3462
Hanno Becker6a243642017-10-12 15:18:45 +01003463requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003464run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003465 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003466 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003467 0 \
3468 -c "client hello, adding renegotiation extension" \
3469 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3470 -s "found renegotiation extension" \
3471 -s "server hello, secure renegotiation extension" \
3472 -c "found renegotiation extension" \
3473 -c "=> renegotiate" \
3474 -s "=> renegotiate" \
3475 -S "write hello request"
3476
Hanno Becker6a243642017-10-12 15:18:45 +01003477requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003478run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003479 "$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 +02003480 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003481 0 \
3482 -c "client hello, adding renegotiation extension" \
3483 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3484 -s "found renegotiation extension" \
3485 -s "server hello, secure renegotiation extension" \
3486 -c "found renegotiation extension" \
3487 -c "=> renegotiate" \
3488 -s "=> renegotiate" \
3489 -s "write hello request"
3490
Hanno Becker6a243642017-10-12 15:18:45 +01003491requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003492run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003493 "$O_SRV -www" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003494 "$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 +02003495 0 \
3496 -c "client hello, adding renegotiation extension" \
3497 -c "found renegotiation extension" \
3498 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003499 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003500 -C "error" \
3501 -c "HTTP/1.0 200 [Oo][Kk]"
3502
Paul Bakker539d9722015-02-08 16:18:35 +01003503requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003504requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003505run_test "Renegotiation: gnutls server strict, client-initiated" \
3506 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003507 "$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 +02003508 0 \
3509 -c "client hello, adding renegotiation extension" \
3510 -c "found renegotiation extension" \
3511 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003512 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003513 -C "error" \
3514 -c "HTTP/1.0 200 [Oo][Kk]"
3515
Paul Bakker539d9722015-02-08 16:18:35 +01003516requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003517requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003518run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3519 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003520 "$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 +01003521 1 \
3522 -c "client hello, adding renegotiation extension" \
3523 -C "found renegotiation extension" \
3524 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003525 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003526 -c "error" \
3527 -C "HTTP/1.0 200 [Oo][Kk]"
3528
Paul Bakker539d9722015-02-08 16:18:35 +01003529requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003530requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003531run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3532 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003533 "$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 +01003534 allow_legacy=0" \
3535 1 \
3536 -c "client hello, adding renegotiation extension" \
3537 -C "found renegotiation extension" \
3538 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003539 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003540 -c "error" \
3541 -C "HTTP/1.0 200 [Oo][Kk]"
3542
Paul Bakker539d9722015-02-08 16:18:35 +01003543requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003544requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003545run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3546 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003547 "$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 +01003548 allow_legacy=1" \
3549 0 \
3550 -c "client hello, adding renegotiation extension" \
3551 -C "found renegotiation extension" \
3552 -c "=> renegotiate" \
3553 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003554 -C "error" \
3555 -c "HTTP/1.0 200 [Oo][Kk]"
3556
Hanno Becker6a243642017-10-12 15:18:45 +01003557requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003558run_test "Renegotiation: DTLS, client-initiated" \
3559 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3560 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3561 0 \
3562 -c "client hello, adding renegotiation extension" \
3563 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3564 -s "found renegotiation extension" \
3565 -s "server hello, secure renegotiation extension" \
3566 -c "found renegotiation extension" \
3567 -c "=> renegotiate" \
3568 -s "=> renegotiate" \
3569 -S "write hello request"
3570
Hanno Becker6a243642017-10-12 15:18:45 +01003571requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003572run_test "Renegotiation: DTLS, server-initiated" \
3573 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003574 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3575 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003576 0 \
3577 -c "client hello, adding renegotiation extension" \
3578 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3579 -s "found renegotiation extension" \
3580 -s "server hello, secure renegotiation extension" \
3581 -c "found renegotiation extension" \
3582 -c "=> renegotiate" \
3583 -s "=> renegotiate" \
3584 -s "write hello request"
3585
Hanno Becker6a243642017-10-12 15:18:45 +01003586requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003587run_test "Renegotiation: DTLS, renego_period overflow" \
3588 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3589 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3590 0 \
3591 -c "client hello, adding renegotiation extension" \
3592 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3593 -s "found renegotiation extension" \
3594 -s "server hello, secure renegotiation extension" \
3595 -s "record counter limit reached: renegotiate" \
3596 -c "=> renegotiate" \
3597 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003598 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003599
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003600requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003601requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003602run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3603 "$G_SRV -u --mtu 4096" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003604 "$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 +02003605 0 \
3606 -c "client hello, adding renegotiation extension" \
3607 -c "found renegotiation extension" \
3608 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003609 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003610 -C "error" \
3611 -s "Extra-header:"
3612
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003613# Test for the "secure renegotation" extension only (no actual renegotiation)
3614
Paul Bakker539d9722015-02-08 16:18:35 +01003615requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003616run_test "Renego ext: gnutls server strict, client default" \
3617 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003618 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003619 0 \
3620 -c "found renegotiation extension" \
3621 -C "error" \
3622 -c "HTTP/1.0 200 [Oo][Kk]"
3623
Paul Bakker539d9722015-02-08 16:18:35 +01003624requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003625run_test "Renego ext: gnutls server unsafe, client default" \
3626 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003627 "$P_CLI debug_level=3 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003628 0 \
3629 -C "found renegotiation extension" \
3630 -C "error" \
3631 -c "HTTP/1.0 200 [Oo][Kk]"
3632
Paul Bakker539d9722015-02-08 16:18:35 +01003633requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003634run_test "Renego ext: gnutls server unsafe, client break legacy" \
3635 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3636 "$P_CLI debug_level=3 allow_legacy=-1" \
3637 1 \
3638 -C "found renegotiation extension" \
3639 -c "error" \
3640 -C "HTTP/1.0 200 [Oo][Kk]"
3641
Paul Bakker539d9722015-02-08 16:18:35 +01003642requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003643run_test "Renego ext: gnutls client strict, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003644 "$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 +02003645 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003646 0 \
3647 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3648 -s "server hello, secure renegotiation extension"
3649
Paul Bakker539d9722015-02-08 16:18:35 +01003650requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003651run_test "Renego ext: gnutls client unsafe, server default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003652 "$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 +02003653 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003654 0 \
3655 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3656 -S "server hello, secure renegotiation extension"
3657
Paul Bakker539d9722015-02-08 16:18:35 +01003658requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003659run_test "Renego ext: gnutls client unsafe, server break legacy" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003660 "$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 +02003661 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003662 1 \
3663 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3664 -S "server hello, secure renegotiation extension"
3665
Janos Follath0b242342016-02-17 10:11:21 +00003666# Tests for silently dropping trailing extra bytes in .der certificates
3667
3668requires_gnutls
3669run_test "DER format: no trailing bytes" \
3670 "$P_SRV crt_file=data_files/server5-der0.crt \
3671 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003672 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003673 0 \
3674 -c "Handshake was completed" \
3675
3676requires_gnutls
3677run_test "DER format: with a trailing zero byte" \
3678 "$P_SRV crt_file=data_files/server5-der1a.crt \
3679 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003680 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003681 0 \
3682 -c "Handshake was completed" \
3683
3684requires_gnutls
3685run_test "DER format: with a trailing random byte" \
3686 "$P_SRV crt_file=data_files/server5-der1b.crt \
3687 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003688 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003689 0 \
3690 -c "Handshake was completed" \
3691
3692requires_gnutls
3693run_test "DER format: with 2 trailing random bytes" \
3694 "$P_SRV crt_file=data_files/server5-der2.crt \
3695 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003696 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003697 0 \
3698 -c "Handshake was completed" \
3699
3700requires_gnutls
3701run_test "DER format: with 4 trailing random bytes" \
3702 "$P_SRV crt_file=data_files/server5-der4.crt \
3703 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003704 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003705 0 \
3706 -c "Handshake was completed" \
3707
3708requires_gnutls
3709run_test "DER format: with 8 trailing random bytes" \
3710 "$P_SRV crt_file=data_files/server5-der8.crt \
3711 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003712 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003713 0 \
3714 -c "Handshake was completed" \
3715
3716requires_gnutls
3717run_test "DER format: with 9 trailing random bytes" \
3718 "$P_SRV crt_file=data_files/server5-der9.crt \
3719 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003720 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003721 0 \
3722 -c "Handshake was completed" \
3723
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003724# Tests for auth_mode
3725
Hanno Becker4a156fc2019-06-14 17:07:06 +01003726requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003727requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003728run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003729 "$P_SRV crt_file=data_files/server5-badsign.crt \
3730 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003731 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003732 1 \
3733 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003734 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003735 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003736 -c "X509 - Certificate verification failed"
3737
Hanno Becker4a156fc2019-06-14 17:07:06 +01003738requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003739requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003740run_test "Authentication: server badcert, client optional" \
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=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003744 0 \
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
Hanno Beckere6706e62017-05-15 16:05:15 +01003752run_test "Authentication: server goodcert, client optional, no trusted CA" \
3753 "$P_SRV" \
3754 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3755 0 \
3756 -c "x509_verify_cert() returned" \
3757 -c "! The certificate is not correctly signed by the trusted CA" \
3758 -c "! Certificate verification flags"\
3759 -C "! mbedtls_ssl_handshake returned" \
3760 -C "X509 - Certificate verification failed" \
3761 -C "SSL - No CA Chain is set, but required to operate"
3762
Hanno Becker4a156fc2019-06-14 17:07:06 +01003763requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003764requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Hanno Beckere6706e62017-05-15 16:05:15 +01003765run_test "Authentication: server goodcert, client required, no trusted CA" \
3766 "$P_SRV" \
3767 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3768 1 \
3769 -c "x509_verify_cert() returned" \
3770 -c "! The certificate is not correctly signed by the trusted CA" \
3771 -c "! Certificate verification flags"\
3772 -c "! mbedtls_ssl_handshake returned" \
3773 -c "SSL - No CA Chain is set, but required to operate"
3774
3775# The purpose of the next two tests is to test the client's behaviour when receiving a server
3776# certificate with an unsupported elliptic curve. This should usually not happen because
3777# the client informs the server about the supported curves - it does, though, in the
3778# corner case of a static ECDH suite, because the server doesn't check the curve on that
3779# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3780# different means to have the server ignoring the client's supported curve list.
3781
3782requires_config_enabled MBEDTLS_ECP_C
3783run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3784 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3785 crt_file=data_files/server5.ku-ka.crt" \
3786 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3787 1 \
3788 -c "bad certificate (EC key curve)"\
3789 -c "! Certificate verification flags"\
3790 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3791
3792requires_config_enabled MBEDTLS_ECP_C
3793run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3794 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3795 crt_file=data_files/server5.ku-ka.crt" \
3796 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3797 1 \
3798 -c "bad certificate (EC key curve)"\
3799 -c "! Certificate verification flags"\
3800 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3801
Jarno Lamsa6ba32ca2019-10-29 15:16:40 +02003802requires_config_enabled MBEDTLS_USE_TINYCRYPT
Jarno Lamsa2e2fa5e2019-10-30 15:08:26 +02003803run_test "Authentication: DTLS server ECDH p256, client required, server goodcert" \
Jarno Lamsa6ba32ca2019-10-29 15:16:40 +02003804 "$P_SRV dtls=1 debug_level=1 key_file=data_files/server11.key.der \
3805 crt_file=data_files/server11.crt.der" \
3806 "$P_CLI dtls=1 debug_level=3 auth_mode=required" \
3807 0 \
3808 -C "bad certificate (EC key curve)"\
3809 -C "! Certificate verification flags"\
3810 -C "! mbedtls_ssl_handshake returned"
3811
3812requires_config_enabled MBEDTLS_USE_TINYCRYPT
Jarno Lamsa2e2fa5e2019-10-30 15:08:26 +02003813run_test "Authentication: DTLS server ECDH p256, client required, server badcert" \
Jarno Lamsa6ba32ca2019-10-29 15:16:40 +02003814 "$P_SRV dtls=1 debug_level=1 key_file=data_files/server11.key.der \
3815 crt_file=data_files/server11-bad.crt.der" \
3816 "$P_CLI dtls=1 debug_level=3 auth_mode=required" \
3817 1 \
3818 -c "! Certificate verification flags"\
3819 -c "! mbedtls_ssl_handshake returned"
3820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003821run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003822 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003823 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003824 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003825 0 \
3826 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003827 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003828 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003829 -C "X509 - Certificate verification failed"
3830
Simon Butcher99000142016-10-13 17:21:01 +01003831run_test "Authentication: client SHA256, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003832 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003833 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3834 key_file=data_files/server6.key \
3835 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3836 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003837 -c "Supported Signature Algorithm found: 5,"
3838
3839run_test "Authentication: client SHA384, server required" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003840 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Simon Butcher99000142016-10-13 17:21:01 +01003841 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3842 key_file=data_files/server6.key \
3843 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3844 0 \
Simon Butcher99000142016-10-13 17:21:01 +01003845 -c "Supported Signature Algorithm found: 5,"
3846
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003847requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3848run_test "Authentication: client has no cert, server required (SSLv3)" \
3849 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
3850 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
3851 key_file=data_files/server5.key" \
3852 1 \
3853 -S "skip write certificate request" \
3854 -C "skip parse certificate request" \
3855 -c "got a certificate request" \
3856 -c "got no certificate to send" \
3857 -S "x509_verify_cert() returned" \
3858 -s "client has no certificate" \
3859 -s "! mbedtls_ssl_handshake returned" \
3860 -c "! mbedtls_ssl_handshake returned" \
3861 -s "No client certification received from the client, but required by the authentication mode"
3862
3863run_test "Authentication: client has no cert, server required (TLS)" \
3864 "$P_SRV debug_level=3 auth_mode=required" \
3865 "$P_CLI debug_level=3 crt_file=none \
3866 key_file=data_files/server5.key" \
3867 1 \
3868 -S "skip write certificate request" \
3869 -C "skip parse certificate request" \
3870 -c "got a certificate request" \
3871 -c "= write certificate$" \
3872 -C "skip write certificate$" \
3873 -S "x509_verify_cert() returned" \
3874 -s "client has no certificate" \
3875 -s "! mbedtls_ssl_handshake returned" \
3876 -c "! mbedtls_ssl_handshake returned" \
3877 -s "No client certification received from the client, but required by the authentication mode"
3878
Hanno Becker4a156fc2019-06-14 17:07:06 +01003879requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003880requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003881run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003882 "$P_SRV debug_level=3 auth_mode=required" \
3883 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003884 key_file=data_files/server5.key" \
3885 1 \
3886 -S "skip write certificate request" \
3887 -C "skip parse certificate request" \
3888 -c "got a certificate request" \
3889 -C "skip write certificate" \
3890 -C "skip write certificate verify" \
3891 -S "skip parse certificate verify" \
3892 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003893 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003894 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003895 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003896 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003897 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003898# We don't check that the client receives the alert because it might
3899# detect that its write end of the connection is closed and abort
3900# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003901
Hanno Becker4a156fc2019-06-14 17:07:06 +01003902requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003903requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01003904run_test "Authentication: client cert not trusted, server required" \
3905 "$P_SRV debug_level=3 auth_mode=required" \
3906 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3907 key_file=data_files/server5.key" \
3908 1 \
3909 -S "skip write certificate request" \
3910 -C "skip parse certificate request" \
3911 -c "got a certificate request" \
3912 -C "skip write certificate" \
3913 -C "skip write certificate verify" \
3914 -S "skip parse certificate verify" \
3915 -s "x509_verify_cert() returned" \
3916 -s "! The certificate is not correctly signed by the trusted CA" \
3917 -s "! mbedtls_ssl_handshake returned" \
3918 -c "! mbedtls_ssl_handshake returned" \
3919 -s "X509 - Certificate verification failed"
3920
Hanno Becker4a156fc2019-06-14 17:07:06 +01003921requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003922requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003923run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003924 "$P_SRV debug_level=3 auth_mode=optional" \
3925 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003926 key_file=data_files/server5.key" \
3927 0 \
3928 -S "skip write certificate request" \
3929 -C "skip parse certificate request" \
3930 -c "got a certificate request" \
3931 -C "skip write certificate" \
3932 -C "skip write certificate verify" \
3933 -S "skip parse certificate verify" \
3934 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003935 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003936 -S "! mbedtls_ssl_handshake returned" \
3937 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003938 -S "X509 - Certificate verification failed"
3939
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003940run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003941 "$P_SRV debug_level=3 auth_mode=none" \
3942 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003943 key_file=data_files/server5.key" \
3944 0 \
3945 -s "skip write certificate request" \
3946 -C "skip parse certificate request" \
3947 -c "got no certificate request" \
3948 -c "skip write certificate" \
3949 -c "skip write certificate verify" \
3950 -s "skip parse certificate verify" \
3951 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003952 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003953 -S "! mbedtls_ssl_handshake returned" \
3954 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003955 -S "X509 - Certificate verification failed"
3956
Hanno Becker4a156fc2019-06-14 17:07:06 +01003957requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003958requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003959run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003960 "$P_SRV debug_level=3 auth_mode=optional" \
3961 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003962 0 \
3963 -S "skip write certificate request" \
3964 -C "skip parse certificate request" \
3965 -c "got a certificate request" \
3966 -C "skip write certificate$" \
3967 -C "got no certificate to send" \
3968 -S "SSLv3 client has no certificate" \
3969 -c "skip write certificate verify" \
3970 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003971 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003972 -S "! mbedtls_ssl_handshake returned" \
3973 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003974 -S "X509 - Certificate verification failed"
3975
Hanno Becker4a156fc2019-06-14 17:07:06 +01003976requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01003977requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003978run_test "Authentication: openssl client no cert, server optional" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003979 "$P_SRV debug_level=3 auth_mode=optional ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003980 "$O_CLI" \
3981 0 \
3982 -S "skip write certificate request" \
3983 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003984 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003985 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003986 -S "X509 - Certificate verification failed"
3987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003988run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003989 "$O_SRV -verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01003990 "$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 +01003991 0 \
3992 -C "skip parse certificate request" \
3993 -c "got a certificate request" \
3994 -C "skip write certificate$" \
3995 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003996 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003997
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003998run_test "Authentication: client no cert, openssl server required" \
3999 "$O_SRV -Verify 10" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004000 "$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 +02004001 1 \
4002 -C "skip parse certificate request" \
4003 -c "got a certificate request" \
4004 -C "skip write certificate$" \
4005 -c "skip write certificate verify" \
4006 -c "! mbedtls_ssl_handshake returned"
4007
Janos Follathe2681a42016-03-07 15:57:05 +00004008requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Hanno Beckerb2c63832019-06-17 08:35:16 +01004009requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004010requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004011run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004012 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004013 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004014 0 \
4015 -S "skip write certificate request" \
4016 -C "skip parse certificate request" \
4017 -c "got a certificate request" \
4018 -C "skip write certificate$" \
4019 -c "skip write certificate verify" \
4020 -c "got no certificate to send" \
4021 -s "SSLv3 client has no certificate" \
4022 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004023 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004024 -S "! mbedtls_ssl_handshake returned" \
4025 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004026 -S "X509 - Certificate verification failed"
4027
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02004028# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
4029# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004030
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004031MAX_IM_CA='8'
Arto Kinnunen78213522019-09-26 11:06:39 +03004032MAX_IM_CA_CONFIG="$( get_config_value_or_default MBEDTLS_X509_MAX_INTERMEDIATE_CA )"
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004033
Angus Grattonc4dd0732018-04-11 16:28:39 +10004034requires_full_size_output_buffer
Arto Kinnunenc457ab12019-09-27 12:00:51 +03004035requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004036run_test "Authentication: server max_int chain, client default" \
4037 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4038 key_file=data_files/dir-maxpath/09.key" \
4039 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4040 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004041 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004042
Angus Grattonc4dd0732018-04-11 16:28:39 +10004043requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004044requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004045run_test "Authentication: server max_int+1 chain, client default" \
4046 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4047 key_file=data_files/dir-maxpath/10.key" \
4048 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4049 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004050 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004051
Angus Grattonc4dd0732018-04-11 16:28:39 +10004052requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004053requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004054run_test "Authentication: server max_int+1 chain, client optional" \
4055 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4056 key_file=data_files/dir-maxpath/10.key" \
4057 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4058 auth_mode=optional" \
4059 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004060 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004061
Angus Grattonc4dd0732018-04-11 16:28:39 +10004062requires_full_size_output_buffer
Arto Kinnunencfbeb762019-09-27 13:43:05 +03004063requires_config_value_exactly "MBEDTLS_X509_MAX_INTERMEDIATE_CA" 8
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004064run_test "Authentication: server max_int+1 chain, client none" \
4065 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4066 key_file=data_files/dir-maxpath/10.key" \
4067 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4068 auth_mode=none" \
4069 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004070 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004071
Angus Grattonc4dd0732018-04-11 16:28:39 +10004072requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004073run_test "Authentication: client max_int+1 chain, server default" \
4074 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4075 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4076 key_file=data_files/dir-maxpath/10.key" \
4077 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004078 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004079
Angus Grattonc4dd0732018-04-11 16:28:39 +10004080requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004081run_test "Authentication: client max_int+1 chain, server optional" \
4082 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4083 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4084 key_file=data_files/dir-maxpath/10.key" \
4085 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004086 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004087
Angus Grattonc4dd0732018-04-11 16:28:39 +10004088requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004089run_test "Authentication: client max_int+1 chain, server required" \
4090 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4091 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4092 key_file=data_files/dir-maxpath/10.key" \
4093 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004094 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004095
Angus Grattonc4dd0732018-04-11 16:28:39 +10004096requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004097run_test "Authentication: client max_int chain, server required" \
4098 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4099 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4100 key_file=data_files/dir-maxpath/09.key" \
4101 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01004102 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004103
Janos Follath89baba22017-04-10 14:34:35 +01004104# Tests for CA list in CertificateRequest messages
4105
4106run_test "Authentication: send CA list in CertificateRequest (default)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004107 "$P_SRV debug_level=3 auth_mode=required ca_file=data_files/test-ca2.crt" \
Janos Follath89baba22017-04-10 14:34:35 +01004108 "$P_CLI crt_file=data_files/server6.crt \
4109 key_file=data_files/server6.key" \
4110 0 \
4111 -s "requested DN"
4112
4113run_test "Authentication: do not send CA list in CertificateRequest" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004114 "$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 +01004115 "$P_CLI crt_file=data_files/server6.crt \
4116 key_file=data_files/server6.key" \
4117 0 \
4118 -S "requested DN"
4119
Hanno Becker4a156fc2019-06-14 17:07:06 +01004120requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004121requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Janos Follath89baba22017-04-10 14:34:35 +01004122run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4123 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4124 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4125 key_file=data_files/server5.key" \
4126 1 \
4127 -S "requested DN" \
4128 -s "x509_verify_cert() returned" \
4129 -s "! The certificate is not correctly signed by the trusted CA" \
4130 -s "! mbedtls_ssl_handshake returned" \
4131 -c "! mbedtls_ssl_handshake returned" \
4132 -s "X509 - Certificate verification failed"
4133
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004134# Tests for certificate selection based on SHA verson
4135
Hanno Becker4a156fc2019-06-14 17:07:06 +01004136requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004137requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004138run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4139 "$P_SRV crt_file=data_files/server5.crt \
4140 key_file=data_files/server5.key \
4141 crt_file2=data_files/server5-sha1.crt \
4142 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004143 "$P_CLI force_version=tls1_2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004144 0 \
4145 -c "signed using.*ECDSA with SHA256" \
4146 -C "signed using.*ECDSA with SHA1"
4147
Hanno Becker4a156fc2019-06-14 17:07:06 +01004148requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004149requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004150run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4151 "$P_SRV crt_file=data_files/server5.crt \
4152 key_file=data_files/server5.key \
4153 crt_file2=data_files/server5-sha1.crt \
4154 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004155 "$P_CLI force_version=tls1_1 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.0 -> 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 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.1, no SHA-1 -> SHA-2 (order 1)" \
4175 "$P_SRV crt_file=data_files/server5.crt \
4176 key_file=data_files/server5.key \
4177 crt_file2=data_files/server6.crt \
4178 key_file2=data_files/server6.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004179 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004180 0 \
4181 -c "serial number.*09" \
4182 -c "signed using.*ECDSA with SHA256" \
4183 -C "signed using.*ECDSA with SHA1"
4184
Hanno Becker4a156fc2019-06-14 17:07:06 +01004185requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004186requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004187run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4188 "$P_SRV crt_file=data_files/server6.crt \
4189 key_file=data_files/server6.key \
4190 crt_file2=data_files/server5.crt \
4191 key_file2=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004192 "$P_CLI force_version=tls1_1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004193 0 \
4194 -c "serial number.*0A" \
4195 -c "signed using.*ECDSA with SHA256" \
4196 -C "signed using.*ECDSA with SHA1"
4197
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004198# tests for SNI
4199
Hanno Becker4a156fc2019-06-14 17:07:06 +01004200requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004201requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004202run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004203 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004204 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004205 "$P_CLI server_name=localhost ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004206 0 \
4207 -S "parse ServerName extension" \
4208 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4209 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004210
Hanno Becker4a156fc2019-06-14 17:07:06 +01004211requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004212requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
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: matching cert 1" \
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 \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004217 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 +01004218 "$P_CLI server_name=localhost ca_file=data_files/test-ca.crt" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004219 0 \
4220 -s "parse ServerName extension" \
4221 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4222 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004223
Hanno Becker4a156fc2019-06-14 17:07:06 +01004224requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004225requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004226requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004227run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004228 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004229 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004230 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 +02004231 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004232 0 \
4233 -s "parse ServerName extension" \
4234 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4235 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004236
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004237requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004238run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004239 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004240 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004241 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 +02004242 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004243 1 \
4244 -s "parse ServerName extension" \
4245 -s "ssl_sni_wrapper() returned" \
4246 -s "mbedtls_ssl_handshake returned" \
4247 -c "mbedtls_ssl_handshake returned" \
4248 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004249
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004250run_test "SNI: client auth no override: optional" \
4251 "$P_SRV debug_level=3 auth_mode=optional \
4252 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4253 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4254 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004255 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004256 -S "skip write certificate request" \
4257 -C "skip parse certificate request" \
4258 -c "got a certificate request" \
4259 -C "skip write certificate" \
4260 -C "skip write certificate verify" \
4261 -S "skip parse certificate verify"
4262
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004263requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004264run_test "SNI: client auth override: none -> optional" \
4265 "$P_SRV debug_level=3 auth_mode=none \
4266 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4267 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4268 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004269 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004270 -S "skip write certificate request" \
4271 -C "skip parse certificate request" \
4272 -c "got a certificate request" \
4273 -C "skip write certificate" \
4274 -C "skip write certificate verify" \
4275 -S "skip parse certificate verify"
4276
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004277requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004278run_test "SNI: client auth override: optional -> none" \
4279 "$P_SRV debug_level=3 auth_mode=optional \
4280 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4281 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4282 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004283 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004284 -s "skip write certificate request" \
4285 -C "skip parse certificate request" \
4286 -c "got no certificate request" \
4287 -c "skip write certificate" \
4288 -c "skip write certificate verify" \
4289 -s "skip parse certificate verify"
4290
Hanno Becker4a156fc2019-06-14 17:07:06 +01004291requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004292requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004293requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004294run_test "SNI: CA no override" \
4295 "$P_SRV debug_level=3 auth_mode=optional \
4296 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4297 ca_file=data_files/test-ca.crt \
4298 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4299 "$P_CLI debug_level=3 server_name=localhost \
4300 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4301 1 \
4302 -S "skip write certificate request" \
4303 -C "skip parse certificate request" \
4304 -c "got a certificate request" \
4305 -C "skip write certificate" \
4306 -C "skip write certificate verify" \
4307 -S "skip parse certificate verify" \
4308 -s "x509_verify_cert() returned" \
4309 -s "! The certificate is not correctly signed by the trusted CA" \
4310 -S "The certificate has been revoked (is on a CRL)"
4311
Hanno Becker4a156fc2019-06-14 17:07:06 +01004312requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004313requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004314requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004315run_test "SNI: CA override" \
4316 "$P_SRV debug_level=3 auth_mode=optional \
4317 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4318 ca_file=data_files/test-ca.crt \
4319 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4320 "$P_CLI debug_level=3 server_name=localhost \
4321 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4322 0 \
4323 -S "skip write certificate request" \
4324 -C "skip parse certificate request" \
4325 -c "got a certificate request" \
4326 -C "skip write certificate" \
4327 -C "skip write certificate verify" \
4328 -S "skip parse certificate verify" \
4329 -S "x509_verify_cert() returned" \
4330 -S "! The certificate is not correctly signed by the trusted CA" \
4331 -S "The certificate has been revoked (is on a CRL)"
4332
Hanno Becker4a156fc2019-06-14 17:07:06 +01004333requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004334requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004335requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004336run_test "SNI: CA override with CRL" \
4337 "$P_SRV debug_level=3 auth_mode=optional \
4338 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4339 ca_file=data_files/test-ca.crt \
4340 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4341 "$P_CLI debug_level=3 server_name=localhost \
4342 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4343 1 \
4344 -S "skip write certificate request" \
4345 -C "skip parse certificate request" \
4346 -c "got a certificate request" \
4347 -C "skip write certificate" \
4348 -C "skip write certificate verify" \
4349 -S "skip parse certificate verify" \
4350 -s "x509_verify_cert() returned" \
4351 -S "! The certificate is not correctly signed by the trusted CA" \
4352 -s "The certificate has been revoked (is on a CRL)"
4353
Andres AG1a834452016-12-07 10:01:30 +00004354# Tests for SNI and DTLS
4355
Hanno Becker4a156fc2019-06-14 17:07:06 +01004356requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004357requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004358run_test "SNI: DTLS, no SNI callback" \
4359 "$P_SRV debug_level=3 dtls=1 \
4360 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004361 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca2.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004362 0 \
4363 -S "parse ServerName extension" \
4364 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4365 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4366
Hanno Becker4a156fc2019-06-14 17:07:06 +01004367requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004368requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004369requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004370run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004371 "$P_SRV debug_level=3 dtls=1 \
4372 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4373 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 +01004374 "$P_CLI server_name=localhost dtls=1 ca_file=data_files/test-ca.crt" \
Andres AG1a834452016-12-07 10:01:30 +00004375 0 \
4376 -s "parse ServerName extension" \
4377 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4378 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4379
Hanno Becker4a156fc2019-06-14 17:07:06 +01004380requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004381requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004382requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004383run_test "SNI: DTLS, matching cert 2" \
4384 "$P_SRV debug_level=3 dtls=1 \
4385 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4386 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 +01004387 "$P_CLI server_name=polarssl.example dtls=1 ca_file=data_files/test-ca.crt" \
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004388 0 \
4389 -s "parse ServerName extension" \
4390 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4391 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4392
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004393requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004394run_test "SNI: DTLS, no matching cert" \
4395 "$P_SRV debug_level=3 dtls=1 \
4396 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4397 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4398 "$P_CLI server_name=nonesuch.example dtls=1" \
4399 1 \
4400 -s "parse ServerName extension" \
4401 -s "ssl_sni_wrapper() returned" \
4402 -s "mbedtls_ssl_handshake returned" \
4403 -c "mbedtls_ssl_handshake returned" \
4404 -c "SSL - A fatal alert message was received from our peer"
4405
4406run_test "SNI: DTLS, client auth no override: optional" \
4407 "$P_SRV debug_level=3 auth_mode=optional 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,-,-,-" \
4410 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4411 0 \
4412 -S "skip write certificate request" \
4413 -C "skip parse certificate request" \
4414 -c "got a certificate request" \
4415 -C "skip write certificate" \
4416 -C "skip write certificate verify" \
4417 -S "skip parse certificate verify"
4418
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004419requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004420run_test "SNI: DTLS, client auth override: none -> optional" \
4421 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4422 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4423 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4424 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4425 0 \
4426 -S "skip write certificate request" \
4427 -C "skip parse certificate request" \
4428 -c "got a certificate request" \
4429 -C "skip write certificate" \
4430 -C "skip write certificate verify" \
4431 -S "skip parse certificate verify"
4432
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004433requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004434run_test "SNI: DTLS, client auth override: optional -> none" \
4435 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4436 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4437 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4438 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4439 0 \
4440 -s "skip write certificate request" \
4441 -C "skip parse certificate request" \
4442 -c "got no certificate request" \
4443 -c "skip write certificate" \
4444 -c "skip write certificate verify" \
4445 -s "skip parse certificate verify"
4446
Hanno Becker4a156fc2019-06-14 17:07:06 +01004447requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004448requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004449requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004450run_test "SNI: DTLS, CA no override" \
4451 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4452 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4453 ca_file=data_files/test-ca.crt \
4454 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4455 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4456 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4457 1 \
4458 -S "skip write certificate request" \
4459 -C "skip parse certificate request" \
4460 -c "got a certificate request" \
4461 -C "skip write certificate" \
4462 -C "skip write certificate verify" \
4463 -S "skip parse certificate verify" \
4464 -s "x509_verify_cert() returned" \
4465 -s "! The certificate is not correctly signed by the trusted CA" \
4466 -S "The certificate has been revoked (is on a CRL)"
4467
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004468requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004469run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004470 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4471 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4472 ca_file=data_files/test-ca.crt \
4473 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4474 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4475 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4476 0 \
4477 -S "skip write certificate request" \
4478 -C "skip parse certificate request" \
4479 -c "got a certificate request" \
4480 -C "skip write certificate" \
4481 -C "skip write certificate verify" \
4482 -S "skip parse certificate verify" \
4483 -S "x509_verify_cert() returned" \
4484 -S "! The certificate is not correctly signed by the trusted CA" \
4485 -S "The certificate has been revoked (is on a CRL)"
4486
Hanno Becker4a156fc2019-06-14 17:07:06 +01004487requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03004488requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004489requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004490run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004491 "$P_SRV debug_level=3 auth_mode=optional \
4492 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4493 ca_file=data_files/test-ca.crt \
4494 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4495 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4496 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4497 1 \
4498 -S "skip write certificate request" \
4499 -C "skip parse certificate request" \
4500 -c "got a certificate request" \
4501 -C "skip write certificate" \
4502 -C "skip write certificate verify" \
4503 -S "skip parse certificate verify" \
4504 -s "x509_verify_cert() returned" \
4505 -S "! The certificate is not correctly signed by the trusted CA" \
4506 -s "The certificate has been revoked (is on a CRL)"
4507
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004508# Tests for non-blocking I/O: exercise a variety of handshake flows
4509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004510run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004511 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4512 "$P_CLI nbio=2 tickets=0" \
4513 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004514 -S "mbedtls_ssl_handshake returned" \
4515 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004516 -c "Read from server: .* bytes read"
4517
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004518run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004519 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4520 "$P_CLI nbio=2 tickets=0" \
4521 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004522 -S "mbedtls_ssl_handshake returned" \
4523 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004524 -c "Read from server: .* bytes read"
4525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004526run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004527 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4528 "$P_CLI nbio=2 tickets=1" \
4529 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004530 -S "mbedtls_ssl_handshake returned" \
4531 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004532 -c "Read from server: .* bytes read"
4533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004534run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004535 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4536 "$P_CLI nbio=2 tickets=1" \
4537 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004538 -S "mbedtls_ssl_handshake returned" \
4539 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004540 -c "Read from server: .* bytes read"
4541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004542run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004543 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4544 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4545 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004546 -S "mbedtls_ssl_handshake returned" \
4547 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004548 -c "Read from server: .* bytes read"
4549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004550run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004551 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4552 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4553 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004554 -S "mbedtls_ssl_handshake returned" \
4555 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004556 -c "Read from server: .* bytes read"
4557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004558run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004559 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4560 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4561 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004562 -S "mbedtls_ssl_handshake returned" \
4563 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004564 -c "Read from server: .* bytes read"
4565
Hanno Becker00076712017-11-15 16:39:08 +00004566# Tests for event-driven I/O: exercise a variety of handshake flows
4567
4568run_test "Event-driven I/O: basic handshake" \
4569 "$P_SRV event=1 tickets=0 auth_mode=none" \
4570 "$P_CLI event=1 tickets=0" \
4571 0 \
4572 -S "mbedtls_ssl_handshake returned" \
4573 -C "mbedtls_ssl_handshake returned" \
4574 -c "Read from server: .* bytes read"
4575
4576run_test "Event-driven I/O: client auth" \
4577 "$P_SRV event=1 tickets=0 auth_mode=required" \
4578 "$P_CLI event=1 tickets=0" \
4579 0 \
4580 -S "mbedtls_ssl_handshake returned" \
4581 -C "mbedtls_ssl_handshake returned" \
4582 -c "Read from server: .* bytes read"
4583
4584run_test "Event-driven I/O: ticket" \
4585 "$P_SRV event=1 tickets=1 auth_mode=none" \
4586 "$P_CLI event=1 tickets=1" \
4587 0 \
4588 -S "mbedtls_ssl_handshake returned" \
4589 -C "mbedtls_ssl_handshake returned" \
4590 -c "Read from server: .* bytes read"
4591
4592run_test "Event-driven I/O: ticket + client auth" \
4593 "$P_SRV event=1 tickets=1 auth_mode=required" \
4594 "$P_CLI event=1 tickets=1" \
4595 0 \
4596 -S "mbedtls_ssl_handshake returned" \
4597 -C "mbedtls_ssl_handshake returned" \
4598 -c "Read from server: .* bytes read"
4599
4600run_test "Event-driven I/O: ticket + client auth + resume" \
4601 "$P_SRV event=1 tickets=1 auth_mode=required" \
4602 "$P_CLI event=1 tickets=1 reconnect=1" \
4603 0 \
4604 -S "mbedtls_ssl_handshake returned" \
4605 -C "mbedtls_ssl_handshake returned" \
4606 -c "Read from server: .* bytes read"
4607
4608run_test "Event-driven I/O: ticket + resume" \
4609 "$P_SRV event=1 tickets=1 auth_mode=none" \
4610 "$P_CLI event=1 tickets=1 reconnect=1" \
4611 0 \
4612 -S "mbedtls_ssl_handshake returned" \
4613 -C "mbedtls_ssl_handshake returned" \
4614 -c "Read from server: .* bytes read"
4615
4616run_test "Event-driven I/O: session-id resume" \
4617 "$P_SRV event=1 tickets=0 auth_mode=none" \
4618 "$P_CLI event=1 tickets=0 reconnect=1" \
4619 0 \
4620 -S "mbedtls_ssl_handshake returned" \
4621 -C "mbedtls_ssl_handshake returned" \
4622 -c "Read from server: .* bytes read"
4623
Hanno Becker6a33f592018-03-13 11:38:46 +00004624run_test "Event-driven I/O, DTLS: basic handshake" \
4625 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4626 "$P_CLI dtls=1 event=1 tickets=0" \
4627 0 \
4628 -c "Read from server: .* bytes read"
4629
4630run_test "Event-driven I/O, DTLS: client auth" \
4631 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4632 "$P_CLI dtls=1 event=1 tickets=0" \
4633 0 \
4634 -c "Read from server: .* bytes read"
4635
4636run_test "Event-driven I/O, DTLS: ticket" \
4637 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4638 "$P_CLI dtls=1 event=1 tickets=1" \
4639 0 \
4640 -c "Read from server: .* bytes read"
4641
4642run_test "Event-driven I/O, DTLS: ticket + client auth" \
4643 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4644 "$P_CLI dtls=1 event=1 tickets=1" \
4645 0 \
4646 -c "Read from server: .* bytes read"
4647
4648run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4649 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04004650 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004651 0 \
4652 -c "Read from server: .* bytes read"
4653
4654run_test "Event-driven I/O, DTLS: ticket + resume" \
4655 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04004656 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004657 0 \
4658 -c "Read from server: .* bytes read"
4659
4660run_test "Event-driven I/O, DTLS: session-id resume" \
4661 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04004662 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004663 0 \
4664 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004665
4666# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4667# During session resumption, the client will send its ApplicationData record
4668# within the same datagram as the Finished messages. In this situation, the
4669# server MUST NOT idle on the underlying transport after handshake completion,
4670# because the ApplicationData request has already been queued internally.
4671run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004672 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004673 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04004674 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004675 0 \
4676 -c "Read from server: .* bytes read"
4677
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004678# Tests for version negotiation
4679
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004680run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004681 "$P_SRV" \
4682 "$P_CLI" \
4683 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004684 -S "mbedtls_ssl_handshake returned" \
4685 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004686 -s "Protocol is TLSv1.2" \
4687 -c "Protocol is TLSv1.2"
4688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004689run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004690 "$P_SRV" \
4691 "$P_CLI max_version=tls1_1" \
4692 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004693 -S "mbedtls_ssl_handshake returned" \
4694 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004695 -s "Protocol is TLSv1.1" \
4696 -c "Protocol is TLSv1.1"
4697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004698run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004699 "$P_SRV max_version=tls1_1" \
4700 "$P_CLI" \
4701 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004702 -S "mbedtls_ssl_handshake returned" \
4703 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004704 -s "Protocol is TLSv1.1" \
4705 -c "Protocol is TLSv1.1"
4706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004707run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004708 "$P_SRV max_version=tls1_1" \
4709 "$P_CLI max_version=tls1_1" \
4710 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004711 -S "mbedtls_ssl_handshake returned" \
4712 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004713 -s "Protocol is TLSv1.1" \
4714 -c "Protocol is TLSv1.1"
4715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004716run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004717 "$P_SRV min_version=tls1_1" \
4718 "$P_CLI max_version=tls1_1" \
4719 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004720 -S "mbedtls_ssl_handshake returned" \
4721 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004722 -s "Protocol is TLSv1.1" \
4723 -c "Protocol is TLSv1.1"
4724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004725run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004726 "$P_SRV max_version=tls1_1" \
4727 "$P_CLI min_version=tls1_1" \
4728 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004729 -S "mbedtls_ssl_handshake returned" \
4730 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004731 -s "Protocol is TLSv1.1" \
4732 -c "Protocol is TLSv1.1"
4733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004734run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004735 "$P_SRV max_version=tls1_1" \
4736 "$P_CLI min_version=tls1_2" \
4737 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004738 -s "mbedtls_ssl_handshake returned" \
4739 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004740 -c "SSL - Handshake protocol not within min/max boundaries"
4741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004742run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004743 "$P_SRV min_version=tls1_2" \
4744 "$P_CLI max_version=tls1_1" \
4745 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004746 -s "mbedtls_ssl_handshake returned" \
4747 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004748 -s "SSL - Handshake protocol not within min/max boundaries"
4749
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004750# Tests for ALPN extension
4751
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004752run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004753 "$P_SRV debug_level=3" \
4754 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004755 0 \
4756 -C "client hello, adding alpn extension" \
4757 -S "found alpn extension" \
4758 -C "got an alert message, type: \\[2:120]" \
4759 -S "server hello, adding alpn extension" \
4760 -C "found alpn extension " \
4761 -C "Application Layer Protocol is" \
4762 -S "Application Layer Protocol is"
4763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004764run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004765 "$P_SRV debug_level=3" \
4766 "$P_CLI debug_level=3 alpn=abc,1234" \
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 (none)" \
4774 -S "Application Layer Protocol is"
4775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004776run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004777 "$P_SRV debug_level=3 alpn=abc,1234" \
4778 "$P_CLI debug_level=3" \
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" \
4786 -s "Application Layer Protocol is (none)"
4787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004788run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004789 "$P_SRV debug_level=3 alpn=abc,1234" \
4790 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004791 0 \
4792 -c "client hello, adding alpn extension" \
4793 -s "found alpn extension" \
4794 -C "got an alert message, type: \\[2:120]" \
4795 -s "server hello, adding alpn extension" \
4796 -c "found alpn extension" \
4797 -c "Application Layer Protocol is abc" \
4798 -s "Application Layer Protocol is abc"
4799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004800run_test "ALPN: both, common cli2-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=1234,abc" \
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 cli1-srv2" \
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,abcde" \
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 1234" \
4822 -s "Application Layer Protocol is 1234"
4823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004824run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004825 "$P_SRV debug_level=3 alpn=abc,123" \
4826 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004827 1 \
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é-Gonnard83d8c732014-04-07 13:24:21 +02004836
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004837# Tests for keyUsage in leaf certificates, part 1:
4838# server-side certificate/suite selection
4839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004840run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004841 "$P_SRV key_file=data_files/server2.key \
4842 crt_file=data_files/server2.ku-ds.crt" \
4843 "$P_CLI" \
4844 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02004845 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004846
4847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004848run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004849 "$P_SRV key_file=data_files/server2.key \
4850 crt_file=data_files/server2.ku-ke.crt" \
4851 "$P_CLI" \
4852 0 \
4853 -c "Ciphersuite is TLS-RSA-WITH-"
4854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004855run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004856 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004857 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004858 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004859 1 \
4860 -C "Ciphersuite is "
4861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004862run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004863 "$P_SRV key_file=data_files/server5.key \
4864 crt_file=data_files/server5.ku-ds.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004865 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004866 0 \
4867 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
4868
Jarno Lamsac5118b72019-10-28 10:30:58 +02004869run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA p256" \
4870 "$P_SRV dtls=1 key_file=data_files/server11.key.der \
4871 crt_file=data_files/server11.crt.der" \
4872 "$P_CLI dtls=1 ca_file=data_files/test-ca3.crt.der" \
4873 0 \
4874 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004876run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004877 "$P_SRV key_file=data_files/server5.key \
4878 crt_file=data_files/server5.ku-ka.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004879 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004880 0 \
4881 -c "Ciphersuite is TLS-ECDH-"
4882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004883run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004884 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004885 crt_file=data_files/server5.ku-ke.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01004886 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004887 1 \
4888 -C "Ciphersuite is "
4889
4890# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004891# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004893run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004894 "$O_SRV -key data_files/server2.key \
4895 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004896 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004897 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4898 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004899 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004900 -C "Processing of the Certificate handshake message failed" \
4901 -c "Ciphersuite is TLS-"
4902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004903run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004904 "$O_SRV -key data_files/server2.key \
4905 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004906 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004907 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4908 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004909 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004910 -C "Processing of the Certificate handshake message failed" \
4911 -c "Ciphersuite is TLS-"
4912
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004913run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004914 "$O_SRV -key data_files/server2.key \
4915 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004916 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004917 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4918 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004919 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004920 -C "Processing of the Certificate handshake message failed" \
4921 -c "Ciphersuite is TLS-"
4922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004923run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004924 "$O_SRV -key data_files/server2.key \
4925 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004926 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004927 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4928 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004929 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004930 -c "Processing of the Certificate handshake message failed" \
4931 -C "Ciphersuite is TLS-"
4932
Hanno Becker4a156fc2019-06-14 17:07:06 +01004933requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004934requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004935run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
4936 "$O_SRV -key data_files/server2.key \
4937 -cert data_files/server2.ku-ke.crt" \
4938 "$P_CLI debug_level=1 auth_mode=optional \
4939 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4940 0 \
4941 -c "bad certificate (usage extensions)" \
4942 -C "Processing of the Certificate handshake message failed" \
4943 -c "Ciphersuite is TLS-" \
4944 -c "! Usage does not match the keyUsage extension"
4945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004946run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004947 "$O_SRV -key data_files/server2.key \
4948 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004949 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004950 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4951 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004952 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004953 -C "Processing of the Certificate handshake message failed" \
4954 -c "Ciphersuite is TLS-"
4955
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004956run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004957 "$O_SRV -key data_files/server2.key \
4958 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004959 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004960 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4961 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004962 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004963 -c "Processing of the Certificate handshake message failed" \
4964 -C "Ciphersuite is TLS-"
4965
Hanno Becker4a156fc2019-06-14 17:07:06 +01004966requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01004967requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004968run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
4969 "$O_SRV -key data_files/server2.key \
4970 -cert data_files/server2.ku-ds.crt" \
4971 "$P_CLI debug_level=1 auth_mode=optional \
4972 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4973 0 \
4974 -c "bad certificate (usage extensions)" \
4975 -C "Processing of the Certificate handshake message failed" \
4976 -c "Ciphersuite is TLS-" \
4977 -c "! Usage does not match the keyUsage extension"
4978
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004979# Tests for keyUsage in leaf certificates, part 3:
4980# server-side checking of client cert
4981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004982run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004983 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004984 "$O_CLI -key data_files/server2.key \
4985 -cert data_files/server2.ku-ds.crt" \
4986 0 \
4987 -S "bad certificate (usage extensions)" \
4988 -S "Processing of the Certificate handshake message failed"
4989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004990run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004991 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004992 "$O_CLI -key data_files/server2.key \
4993 -cert data_files/server2.ku-ke.crt" \
4994 0 \
4995 -s "bad certificate (usage extensions)" \
4996 -S "Processing of the Certificate handshake message failed"
4997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004998run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004999 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005000 "$O_CLI -key data_files/server2.key \
5001 -cert data_files/server2.ku-ke.crt" \
5002 1 \
5003 -s "bad certificate (usage extensions)" \
5004 -s "Processing of the Certificate handshake message failed"
5005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005006run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005007 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005008 "$O_CLI -key data_files/server5.key \
5009 -cert data_files/server5.ku-ds.crt" \
5010 0 \
5011 -S "bad certificate (usage extensions)" \
5012 -S "Processing of the Certificate handshake message failed"
5013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005014run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005015 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005016 "$O_CLI -key data_files/server5.key \
5017 -cert data_files/server5.ku-ka.crt" \
5018 0 \
5019 -s "bad certificate (usage extensions)" \
5020 -S "Processing of the Certificate handshake message failed"
5021
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005022# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
5023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005024run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005025 "$P_SRV key_file=data_files/server5.key \
5026 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005027 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005028 0
5029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005030run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005031 "$P_SRV key_file=data_files/server5.key \
5032 crt_file=data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005033 "$P_CLI ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005034 0
5035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005036run_test "extKeyUsage srv: codeSign,anyEKU -> 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-cs_any.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: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005043 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005044 crt_file=data_files/server5.eku-cli.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 1
5047
5048# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005050run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005051 "$O_SRV -key data_files/server5.key \
5052 -cert data_files/server5.eku-srv.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005053 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005054 0 \
5055 -C "bad certificate (usage extensions)" \
5056 -C "Processing of the Certificate handshake message failed" \
5057 -c "Ciphersuite is TLS-"
5058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005059run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005060 "$O_SRV -key data_files/server5.key \
5061 -cert data_files/server5.eku-srv_cli.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005062 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005063 0 \
5064 -C "bad certificate (usage extensions)" \
5065 -C "Processing of the Certificate handshake message failed" \
5066 -c "Ciphersuite is TLS-"
5067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005068run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005069 "$O_SRV -key data_files/server5.key \
5070 -cert data_files/server5.eku-cs_any.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005071 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005072 0 \
5073 -C "bad certificate (usage extensions)" \
5074 -C "Processing of the Certificate handshake message failed" \
5075 -c "Ciphersuite is TLS-"
5076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005077run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005078 "$O_SRV -key data_files/server5.key \
5079 -cert data_files/server5.eku-cs.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005080 "$P_CLI debug_level=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005081 1 \
5082 -c "bad certificate (usage extensions)" \
5083 -c "Processing of the Certificate handshake message failed" \
5084 -C "Ciphersuite is TLS-"
5085
5086# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5087
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005088run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005089 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005090 "$O_CLI -key data_files/server5.key \
5091 -cert data_files/server5.eku-cli.crt" \
5092 0 \
5093 -S "bad certificate (usage extensions)" \
5094 -S "Processing of the Certificate handshake message failed"
5095
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005096run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005097 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005098 "$O_CLI -key data_files/server5.key \
5099 -cert data_files/server5.eku-srv_cli.crt" \
5100 0 \
5101 -S "bad certificate (usage extensions)" \
5102 -S "Processing of the Certificate handshake message failed"
5103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005104run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005105 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005106 "$O_CLI -key data_files/server5.key \
5107 -cert data_files/server5.eku-cs_any.crt" \
5108 0 \
5109 -S "bad certificate (usage extensions)" \
5110 -S "Processing of the Certificate handshake message failed"
5111
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005112run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005113 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005114 "$O_CLI -key data_files/server5.key \
5115 -cert data_files/server5.eku-cs.crt" \
5116 0 \
5117 -s "bad certificate (usage extensions)" \
5118 -S "Processing of the Certificate handshake message failed"
5119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005120run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01005121 "$P_SRV debug_level=1 auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005122 "$O_CLI -key data_files/server5.key \
5123 -cert data_files/server5.eku-cs.crt" \
5124 1 \
5125 -s "bad certificate (usage extensions)" \
5126 -s "Processing of the Certificate handshake message failed"
5127
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005128# Tests for DHM parameters loading
5129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005130run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005131 "$P_SRV" \
5132 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5133 debug_level=3" \
5134 0 \
5135 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005136 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005138run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005139 "$P_SRV dhm_file=data_files/dhparams.pem" \
5140 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5141 debug_level=3" \
5142 0 \
5143 -c "value of 'DHM: P ' (1024 bits)" \
5144 -c "value of 'DHM: G ' (2 bits)"
5145
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005146# Tests for DHM client-side size checking
5147
5148run_test "DHM size: server default, client default, OK" \
5149 "$P_SRV" \
5150 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5151 debug_level=1" \
5152 0 \
5153 -C "DHM prime too short:"
5154
5155run_test "DHM size: server default, client 2048, OK" \
5156 "$P_SRV" \
5157 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5158 debug_level=1 dhmlen=2048" \
5159 0 \
5160 -C "DHM prime too short:"
5161
5162run_test "DHM size: server 1024, client default, OK" \
5163 "$P_SRV dhm_file=data_files/dhparams.pem" \
5164 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5165 debug_level=1" \
5166 0 \
5167 -C "DHM prime too short:"
5168
5169run_test "DHM size: server 1000, client default, rejected" \
5170 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5171 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5172 debug_level=1" \
5173 1 \
5174 -c "DHM prime too short:"
5175
5176run_test "DHM size: server default, client 2049, rejected" \
5177 "$P_SRV" \
5178 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5179 debug_level=1 dhmlen=2049" \
5180 1 \
5181 -c "DHM prime too short:"
5182
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005183# Tests for PSK callback
5184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005185run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005186 "$P_SRV psk=abc123 psk_identity=foo" \
5187 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5188 psk_identity=foo psk=abc123" \
5189 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005190 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005191 -S "SSL - Unknown identity received" \
5192 -S "SSL - Verification of the message MAC failed"
5193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005194run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005195 "$P_SRV" \
5196 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5197 psk_identity=foo psk=abc123" \
5198 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005199 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005200 -S "SSL - Unknown identity received" \
5201 -S "SSL - Verification of the message MAC failed"
5202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005203run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005204 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5205 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5206 psk_identity=foo psk=abc123" \
5207 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005208 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005209 -s "SSL - Unknown identity received" \
5210 -S "SSL - Verification of the message MAC failed"
5211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005212run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005213 "$P_SRV psk_list=abc,dead,def,beef" \
5214 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5215 psk_identity=abc psk=dead" \
5216 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005217 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005218 -S "SSL - Unknown identity received" \
5219 -S "SSL - Verification of the message MAC failed"
5220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005221run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005222 "$P_SRV psk_list=abc,dead,def,beef" \
5223 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5224 psk_identity=def psk=beef" \
5225 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005226 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005227 -S "SSL - Unknown identity received" \
5228 -S "SSL - Verification of the message MAC failed"
5229
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005230run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005231 "$P_SRV psk_list=abc,dead,def,beef" \
5232 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5233 psk_identity=ghi psk=beef" \
5234 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005235 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005236 -s "SSL - Unknown identity received" \
5237 -S "SSL - Verification of the message MAC failed"
5238
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005239run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005240 "$P_SRV psk_list=abc,dead,def,beef" \
5241 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5242 psk_identity=abc psk=beef" \
5243 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005244 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005245 -S "SSL - Unknown identity received" \
5246 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005247
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005248# Tests for EC J-PAKE
5249
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005250requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005251run_test "ECJPAKE: client not configured" \
5252 "$P_SRV debug_level=3" \
5253 "$P_CLI debug_level=3" \
5254 0 \
5255 -C "add ciphersuite: c0ff" \
5256 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005257 -S "found ecjpake kkpp extension" \
5258 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005259 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005260 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005261 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005262 -S "None of the common ciphersuites is usable"
5263
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005264requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005265run_test "ECJPAKE: server not configured" \
5266 "$P_SRV debug_level=3" \
5267 "$P_CLI debug_level=3 ecjpake_pw=bla \
5268 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5269 1 \
5270 -c "add ciphersuite: c0ff" \
5271 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005272 -s "found ecjpake kkpp extension" \
5273 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005274 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005275 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005276 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005277 -s "None of the common ciphersuites is usable"
5278
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005279requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005280run_test "ECJPAKE: working, TLS" \
5281 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5282 "$P_CLI debug_level=3 ecjpake_pw=bla \
5283 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005284 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005285 -c "add ciphersuite: c0ff" \
5286 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005287 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005288 -s "found ecjpake kkpp extension" \
5289 -S "skip ecjpake kkpp extension" \
5290 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005291 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005292 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005293 -S "None of the common ciphersuites is usable" \
5294 -S "SSL - Verification of the message MAC failed"
5295
Janos Follath74537a62016-09-02 13:45:28 +01005296server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005297requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005298run_test "ECJPAKE: password mismatch, TLS" \
5299 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5300 "$P_CLI debug_level=3 ecjpake_pw=bad \
5301 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5302 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005303 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005304 -s "SSL - Verification of the message MAC failed"
5305
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005306requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005307run_test "ECJPAKE: working, DTLS" \
5308 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5309 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5310 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5311 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005312 -c "re-using cached ecjpake parameters" \
5313 -S "SSL - Verification of the message MAC failed"
5314
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005315requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005316run_test "ECJPAKE: working, DTLS, no cookie" \
5317 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5318 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5319 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5320 0 \
5321 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005322 -S "SSL - Verification of the message MAC failed"
5323
Janos Follath74537a62016-09-02 13:45:28 +01005324server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005325requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005326run_test "ECJPAKE: password mismatch, DTLS" \
5327 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5328 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5329 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5330 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005331 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005332 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005333
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005334# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005335requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005336run_test "ECJPAKE: working, DTLS, nolog" \
5337 "$P_SRV dtls=1 ecjpake_pw=bla" \
5338 "$P_CLI dtls=1 ecjpake_pw=bla \
5339 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5340 0
5341
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005342# Tests for ciphersuites per version
5343
Janos Follathe2681a42016-03-07 15:57:05 +00005344requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005345requires_config_enabled MBEDTLS_CAMELLIA_C
5346requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005347run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005348 "$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 +02005349 "$P_CLI force_version=ssl3" \
5350 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005351 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005352
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005353requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5354requires_config_enabled MBEDTLS_CAMELLIA_C
5355requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005356run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005357 "$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 +01005358 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005359 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005360 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005361
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005362requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5363requires_config_enabled MBEDTLS_CAMELLIA_C
5364requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005365run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005366 "$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 +02005367 "$P_CLI force_version=tls1_1" \
5368 0 \
5369 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5370
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005371requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5372requires_config_enabled MBEDTLS_CAMELLIA_C
5373requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005374run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01005375 "$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 +02005376 "$P_CLI force_version=tls1_2" \
5377 0 \
5378 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5379
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005380# Test for ClientHello without extensions
5381
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005382requires_gnutls
Manuel Pégourié-Gonnardd817f542020-01-30 12:45:14 +01005383run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7006ca12020-01-30 10:58:57 +01005384 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005385 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005386 0 \
5387 -s "dumping 'client hello extensions' (0 bytes)"
5388
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005389# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005390
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005391run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005392 "$P_SRV" \
5393 "$P_CLI request_size=100" \
5394 0 \
5395 -s "Read from client: 100 bytes read$"
5396
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005397run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005398 "$P_SRV" \
5399 "$P_CLI request_size=500" \
5400 0 \
5401 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005402
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005403# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005404
Janos Follathe2681a42016-03-07 15:57:05 +00005405requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005406run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005407 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005408 "$P_CLI request_size=1 force_version=ssl3 \
5409 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5410 0 \
5411 -s "Read from client: 1 bytes read"
5412
Janos Follathe2681a42016-03-07 15:57:05 +00005413requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005414run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005415 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005416 "$P_CLI request_size=1 force_version=ssl3 \
5417 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5418 0 \
5419 -s "Read from client: 1 bytes read"
5420
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005421run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005422 "$P_SRV" \
5423 "$P_CLI request_size=1 force_version=tls1 \
5424 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5425 0 \
5426 -s "Read from client: 1 bytes read"
5427
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005428run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005429 "$P_SRV" \
5430 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5431 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5432 0 \
5433 -s "Read from client: 1 bytes read"
5434
Hanno Becker32c55012017-11-10 08:42:54 +00005435requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005436run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005437 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005438 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005439 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005440 0 \
5441 -s "Read from client: 1 bytes read"
5442
Hanno Becker32c55012017-11-10 08:42:54 +00005443requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005444run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005445 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005446 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005447 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005448 0 \
5449 -s "Read from client: 1 bytes read"
5450
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005451run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005452 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005453 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00005454 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5455 0 \
5456 -s "Read from client: 1 bytes read"
5457
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005458run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005459 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5460 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005461 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005462 0 \
5463 -s "Read from client: 1 bytes read"
5464
5465requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005466run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005467 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005468 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005469 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005470 0 \
5471 -s "Read from client: 1 bytes read"
5472
Hanno Becker8501f982017-11-10 08:59:04 +00005473requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005474run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005475 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5476 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5477 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005478 0 \
5479 -s "Read from client: 1 bytes read"
5480
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005481run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005482 "$P_SRV" \
5483 "$P_CLI request_size=1 force_version=tls1_1 \
5484 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5485 0 \
5486 -s "Read from client: 1 bytes read"
5487
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005488run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005489 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005490 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005491 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005492 0 \
5493 -s "Read from client: 1 bytes read"
5494
5495requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005496run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005497 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005498 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005499 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005500 0 \
5501 -s "Read from client: 1 bytes read"
5502
5503requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005504run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005505 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005506 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005507 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005508 0 \
5509 -s "Read from client: 1 bytes read"
5510
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005511run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005512 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005513 "$P_CLI request_size=1 force_version=tls1_1 \
5514 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5515 0 \
5516 -s "Read from client: 1 bytes read"
5517
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005518run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00005519 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005520 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005521 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005522 0 \
5523 -s "Read from client: 1 bytes read"
5524
Hanno Becker8501f982017-11-10 08:59:04 +00005525requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005526run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005527 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005528 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005529 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005530 0 \
5531 -s "Read from client: 1 bytes read"
5532
Hanno Becker32c55012017-11-10 08:42:54 +00005533requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005534run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005535 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005536 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005537 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005538 0 \
5539 -s "Read from client: 1 bytes read"
5540
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005541run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005542 "$P_SRV" \
5543 "$P_CLI request_size=1 force_version=tls1_2 \
5544 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5545 0 \
5546 -s "Read from client: 1 bytes read"
5547
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005548run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005549 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005550 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005551 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005552 0 \
5553 -s "Read from client: 1 bytes read"
5554
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005555run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005556 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005557 "$P_CLI request_size=1 force_version=tls1_2 \
5558 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005559 0 \
5560 -s "Read from client: 1 bytes read"
5561
Hanno Becker32c55012017-11-10 08:42:54 +00005562requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005563run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005564 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005565 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005566 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005567 0 \
5568 -s "Read from client: 1 bytes read"
5569
Hanno Becker8501f982017-11-10 08:59:04 +00005570requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005571run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005572 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005573 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005574 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005575 0 \
5576 -s "Read from client: 1 bytes read"
5577
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005578run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005579 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005580 "$P_CLI request_size=1 force_version=tls1_2 \
5581 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5582 0 \
5583 -s "Read from client: 1 bytes read"
5584
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005585run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005586 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005587 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005588 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00005589 0 \
5590 -s "Read from client: 1 bytes read"
5591
Hanno Becker32c55012017-11-10 08:42:54 +00005592requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005593run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005594 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005595 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005596 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005597 0 \
5598 -s "Read from client: 1 bytes read"
5599
Hanno Becker8501f982017-11-10 08:59:04 +00005600requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005601run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005602 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005603 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005604 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005605 0 \
5606 -s "Read from client: 1 bytes read"
5607
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005608run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005609 "$P_SRV" \
5610 "$P_CLI request_size=1 force_version=tls1_2 \
5611 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5612 0 \
5613 -s "Read from client: 1 bytes read"
5614
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005615run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005616 "$P_SRV" \
5617 "$P_CLI request_size=1 force_version=tls1_2 \
5618 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5619 0 \
5620 -s "Read from client: 1 bytes read"
5621
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005622# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005623
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005624run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005625 "$P_SRV dtls=1 force_version=dtls1" \
5626 "$P_CLI dtls=1 request_size=1 \
5627 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5628 0 \
5629 -s "Read from client: 1 bytes read"
5630
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005631run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00005632 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
5633 "$P_CLI dtls=1 request_size=1 \
5634 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5635 0 \
5636 -s "Read from client: 1 bytes read"
5637
Hanno Beckere2148042017-11-10 08:59:18 +00005638requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005639run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005640 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
5641 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00005642 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5643 0 \
5644 -s "Read from client: 1 bytes read"
5645
Hanno Beckere2148042017-11-10 08:59:18 +00005646requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005647run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005648 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005649 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005650 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005651 0 \
5652 -s "Read from client: 1 bytes read"
5653
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005654run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00005655 "$P_SRV dtls=1 force_version=dtls1_2" \
5656 "$P_CLI dtls=1 request_size=1 \
5657 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5658 0 \
5659 -s "Read from client: 1 bytes read"
5660
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005661run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005662 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005663 "$P_CLI dtls=1 request_size=1 \
5664 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5665 0 \
5666 -s "Read from client: 1 bytes read"
5667
Hanno Beckere2148042017-11-10 08:59:18 +00005668requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005669run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005670 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005671 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005672 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005673 0 \
5674 -s "Read from client: 1 bytes read"
5675
Hanno Beckere2148042017-11-10 08:59:18 +00005676requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005677run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005678 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005679 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005680 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005681 0 \
5682 -s "Read from client: 1 bytes read"
5683
Jarno Lamsa0ed68082019-10-28 14:10:59 +02005684run_test "Small client packet DTLS, ECDHE-ECDSA" \
5685 "$P_SRV dtls=1" \
5686 "$P_CLI dtls=1 request_size=1 \
5687 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
5688 0 \
5689 -s "Read from client: 1 bytes read"
5690
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005691# Tests for small server packets
5692
5693requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5694run_test "Small server packet SSLv3 BlockCipher" \
5695 "$P_SRV response_size=1 min_version=ssl3" \
5696 "$P_CLI force_version=ssl3 \
5697 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5698 0 \
5699 -c "Read from server: 1 bytes read"
5700
5701requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5702run_test "Small server packet SSLv3 StreamCipher" \
5703 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5704 "$P_CLI force_version=ssl3 \
5705 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5706 0 \
5707 -c "Read from server: 1 bytes read"
5708
5709run_test "Small server packet TLS 1.0 BlockCipher" \
5710 "$P_SRV response_size=1" \
5711 "$P_CLI force_version=tls1 \
5712 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5713 0 \
5714 -c "Read from server: 1 bytes read"
5715
5716run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
5717 "$P_SRV response_size=1" \
5718 "$P_CLI force_version=tls1 etm=0 \
5719 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5720 0 \
5721 -c "Read from server: 1 bytes read"
5722
5723requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5724run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
5725 "$P_SRV response_size=1 trunc_hmac=1" \
5726 "$P_CLI force_version=tls1 \
5727 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5728 0 \
5729 -c "Read from server: 1 bytes read"
5730
5731requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5732run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
5733 "$P_SRV response_size=1 trunc_hmac=1" \
5734 "$P_CLI force_version=tls1 \
5735 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5736 0 \
5737 -c "Read from server: 1 bytes read"
5738
5739run_test "Small server packet TLS 1.0 StreamCipher" \
5740 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5741 "$P_CLI force_version=tls1 \
5742 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5743 0 \
5744 -c "Read from server: 1 bytes read"
5745
5746run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
5747 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5748 "$P_CLI force_version=tls1 \
5749 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5750 0 \
5751 -c "Read from server: 1 bytes read"
5752
5753requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5754run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
5755 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5756 "$P_CLI force_version=tls1 \
5757 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5758 0 \
5759 -c "Read from server: 1 bytes read"
5760
5761requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5762run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5763 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5764 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5765 trunc_hmac=1 etm=0" \
5766 0 \
5767 -c "Read from server: 1 bytes read"
5768
5769run_test "Small server packet TLS 1.1 BlockCipher" \
5770 "$P_SRV response_size=1" \
5771 "$P_CLI force_version=tls1_1 \
5772 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5773 0 \
5774 -c "Read from server: 1 bytes read"
5775
5776run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
5777 "$P_SRV response_size=1" \
5778 "$P_CLI force_version=tls1_1 \
5779 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5780 0 \
5781 -c "Read from server: 1 bytes read"
5782
5783requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5784run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
5785 "$P_SRV response_size=1 trunc_hmac=1" \
5786 "$P_CLI force_version=tls1_1 \
5787 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5788 0 \
5789 -c "Read from server: 1 bytes read"
5790
5791requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5792run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5793 "$P_SRV response_size=1 trunc_hmac=1" \
5794 "$P_CLI force_version=tls1_1 \
5795 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5796 0 \
5797 -c "Read from server: 1 bytes read"
5798
5799run_test "Small server packet TLS 1.1 StreamCipher" \
5800 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5801 "$P_CLI force_version=tls1_1 \
5802 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5803 0 \
5804 -c "Read from server: 1 bytes read"
5805
5806run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
5807 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5808 "$P_CLI force_version=tls1_1 \
5809 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5810 0 \
5811 -c "Read from server: 1 bytes read"
5812
5813requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5814run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
5815 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5816 "$P_CLI force_version=tls1_1 \
5817 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5818 0 \
5819 -c "Read from server: 1 bytes read"
5820
5821requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5822run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5823 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5824 "$P_CLI force_version=tls1_1 \
5825 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5826 0 \
5827 -c "Read from server: 1 bytes read"
5828
5829run_test "Small server packet TLS 1.2 BlockCipher" \
5830 "$P_SRV response_size=1" \
5831 "$P_CLI force_version=tls1_2 \
5832 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5833 0 \
5834 -c "Read from server: 1 bytes read"
5835
5836run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5837 "$P_SRV response_size=1" \
5838 "$P_CLI force_version=tls1_2 \
5839 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5840 0 \
5841 -c "Read from server: 1 bytes read"
5842
5843run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5844 "$P_SRV response_size=1" \
5845 "$P_CLI force_version=tls1_2 \
5846 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5847 0 \
5848 -c "Read from server: 1 bytes read"
5849
5850requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5851run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5852 "$P_SRV response_size=1 trunc_hmac=1" \
5853 "$P_CLI force_version=tls1_2 \
5854 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5855 0 \
5856 -c "Read from server: 1 bytes read"
5857
5858requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5859run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5860 "$P_SRV response_size=1 trunc_hmac=1" \
5861 "$P_CLI force_version=tls1_2 \
5862 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5863 0 \
5864 -c "Read from server: 1 bytes read"
5865
5866run_test "Small server packet TLS 1.2 StreamCipher" \
5867 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5868 "$P_CLI force_version=tls1_2 \
5869 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5870 0 \
5871 -c "Read from server: 1 bytes read"
5872
5873run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
5874 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5875 "$P_CLI force_version=tls1_2 \
5876 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5877 0 \
5878 -c "Read from server: 1 bytes read"
5879
5880requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5881run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
5882 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5883 "$P_CLI force_version=tls1_2 \
5884 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5885 0 \
5886 -c "Read from server: 1 bytes read"
5887
5888requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5889run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5890 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5891 "$P_CLI force_version=tls1_2 \
5892 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5893 0 \
5894 -c "Read from server: 1 bytes read"
5895
5896run_test "Small server packet TLS 1.2 AEAD" \
5897 "$P_SRV response_size=1" \
5898 "$P_CLI force_version=tls1_2 \
5899 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5900 0 \
5901 -c "Read from server: 1 bytes read"
5902
5903run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5904 "$P_SRV response_size=1" \
5905 "$P_CLI force_version=tls1_2 \
5906 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5907 0 \
5908 -c "Read from server: 1 bytes read"
5909
5910# Tests for small server packets in DTLS
5911
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005912run_test "Small server packet DTLS 1.0" \
5913 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
5914 "$P_CLI dtls=1 \
5915 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5916 0 \
5917 -c "Read from server: 1 bytes read"
5918
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005919run_test "Small server packet DTLS 1.0, without EtM" \
5920 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
5921 "$P_CLI dtls=1 \
5922 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5923 0 \
5924 -c "Read from server: 1 bytes read"
5925
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005926requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5927run_test "Small server packet DTLS 1.0, truncated hmac" \
5928 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
5929 "$P_CLI dtls=1 trunc_hmac=1 \
5930 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5931 0 \
5932 -c "Read from server: 1 bytes read"
5933
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005934requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5935run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
5936 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
5937 "$P_CLI dtls=1 \
5938 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5939 0 \
5940 -c "Read from server: 1 bytes read"
5941
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005942run_test "Small server packet DTLS 1.2" \
5943 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
5944 "$P_CLI dtls=1 \
5945 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5946 0 \
5947 -c "Read from server: 1 bytes read"
5948
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005949run_test "Small server packet DTLS 1.2, without EtM" \
5950 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5951 "$P_CLI dtls=1 \
5952 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5953 0 \
5954 -c "Read from server: 1 bytes read"
5955
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005956requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5957run_test "Small server packet DTLS 1.2, truncated hmac" \
5958 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5959 "$P_CLI dtls=1 \
5960 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5961 0 \
5962 -c "Read from server: 1 bytes read"
5963
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005964requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5965run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5966 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5967 "$P_CLI dtls=1 \
5968 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5969 0 \
5970 -c "Read from server: 1 bytes read"
5971
Jarno Lamsac40184b2019-10-28 14:16:12 +02005972run_test "Small server packet DTLS, ECDHE-ECDSA" \
5973 "$P_SRV dtls=1 response_size=1" \
5974 "$P_CLI dtls=1 \
5975 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
5976 0 \
5977 -c "Read from server: 1 bytes read"
5978
Janos Follath00efff72016-05-06 13:48:23 +01005979# A test for extensions in SSLv3
5980
5981requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5982run_test "SSLv3 with extensions, server side" \
5983 "$P_SRV min_version=ssl3 debug_level=3" \
5984 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
5985 0 \
5986 -S "dumping 'client hello extensions'" \
5987 -S "server hello, total extension length:"
5988
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005989# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005990
Angus Grattonc4dd0732018-04-11 16:28:39 +10005991# How many fragments do we expect to write $1 bytes?
5992fragments_for_write() {
5993 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
5994}
5995
Janos Follathe2681a42016-03-07 15:57:05 +00005996requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005997run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005998 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005999 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006000 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6001 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006002 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6003 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006004
Janos Follathe2681a42016-03-07 15:57:05 +00006005requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006006run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006007 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006008 "$P_CLI request_size=16384 force_version=ssl3 \
6009 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6010 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006011 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6012 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006013
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006014run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006015 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006016 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006017 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6018 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006019 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6020 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006021
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006022run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006023 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006024 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
6025 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6026 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006027 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006028
Hanno Becker32c55012017-11-10 08:42:54 +00006029requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006030run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006031 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006032 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006033 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006034 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006035 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6036 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006037
Hanno Becker32c55012017-11-10 08:42:54 +00006038requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006039run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006040 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006041 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006042 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006043 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006044 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006045
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006046run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006047 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006048 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006049 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6050 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006051 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006052
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006053run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006054 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6055 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006056 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006057 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006058 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006059
6060requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006061run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006062 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006063 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006064 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006065 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006066 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006067
Hanno Becker278fc7a2017-11-10 09:16:28 +00006068requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006069run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006070 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006071 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006072 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006073 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006074 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6075 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006076
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006077run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006078 "$P_SRV" \
6079 "$P_CLI request_size=16384 force_version=tls1_1 \
6080 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6081 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006082 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6083 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006084
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006085run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006086 "$P_SRV" \
6087 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6088 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006089 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006090 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006091
Hanno Becker32c55012017-11-10 08:42:54 +00006092requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006093run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006094 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006095 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006096 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006097 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006098 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006099
Hanno Becker32c55012017-11-10 08:42:54 +00006100requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006101run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006102 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006103 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006104 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006105 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006106 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006107
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006108run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006109 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6110 "$P_CLI request_size=16384 force_version=tls1_1 \
6111 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6112 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006113 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6114 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006115
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006116run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006117 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006118 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006119 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006120 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006121 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6122 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006123
Hanno Becker278fc7a2017-11-10 09:16:28 +00006124requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006125run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006126 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006127 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006128 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006129 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006130 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006131
Hanno Becker278fc7a2017-11-10 09:16:28 +00006132requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006133run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006134 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006135 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006136 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006137 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006138 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6139 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006140
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006141run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006142 "$P_SRV" \
6143 "$P_CLI request_size=16384 force_version=tls1_2 \
6144 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6145 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006146 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6147 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006148
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006149run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006150 "$P_SRV" \
6151 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6152 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6153 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006154 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006155
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006156run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006157 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006158 "$P_CLI request_size=16384 force_version=tls1_2 \
6159 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006160 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006161 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6162 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006163
Hanno Becker32c55012017-11-10 08:42:54 +00006164requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006165run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006166 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006167 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006168 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006169 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006170 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006171
Hanno Becker278fc7a2017-11-10 09:16:28 +00006172requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006173run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006174 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006175 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006176 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006177 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006178 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6179 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006180
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006181run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006182 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006183 "$P_CLI request_size=16384 force_version=tls1_2 \
6184 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6185 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006186 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6187 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006188
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006189run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006190 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006191 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006192 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6193 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006194 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006195
Hanno Becker32c55012017-11-10 08:42:54 +00006196requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006197run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006198 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006199 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006200 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006201 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006202 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006203
Hanno Becker278fc7a2017-11-10 09:16:28 +00006204requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006205run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006206 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006207 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006208 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006209 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006210 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6211 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006212
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006213run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006214 "$P_SRV" \
6215 "$P_CLI request_size=16384 force_version=tls1_2 \
6216 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6217 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006218 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6219 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006220
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006221run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006222 "$P_SRV" \
6223 "$P_CLI request_size=16384 force_version=tls1_2 \
6224 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6225 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006226 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6227 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006228
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006229# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006230requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6231run_test "Large server packet SSLv3 StreamCipher" \
6232 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6233 "$P_CLI force_version=ssl3 \
6234 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6235 0 \
6236 -c "Read from server: 16384 bytes read"
6237
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006238# Checking next 4 tests logs for 1n-1 split against BEAST too
6239requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6240run_test "Large server packet SSLv3 BlockCipher" \
6241 "$P_SRV response_size=16384 min_version=ssl3" \
6242 "$P_CLI force_version=ssl3 recsplit=0 \
6243 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6244 0 \
6245 -c "Read from server: 1 bytes read"\
6246 -c "16383 bytes read"\
6247 -C "Read from server: 16384 bytes read"
6248
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006249run_test "Large server packet TLS 1.0 BlockCipher" \
6250 "$P_SRV response_size=16384" \
6251 "$P_CLI force_version=tls1 recsplit=0 \
6252 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6253 0 \
6254 -c "Read from server: 1 bytes read"\
6255 -c "16383 bytes read"\
6256 -C "Read from server: 16384 bytes read"
6257
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006258run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6259 "$P_SRV response_size=16384" \
6260 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6261 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6262 0 \
6263 -c "Read from server: 1 bytes read"\
6264 -c "16383 bytes read"\
6265 -C "Read from server: 16384 bytes read"
6266
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006267requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6268run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
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 trunc_hmac=1" \
6273 0 \
6274 -c "Read from server: 1 bytes read"\
6275 -c "16383 bytes read"\
6276 -C "Read from server: 16384 bytes read"
6277
6278requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6279run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6280 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6281 "$P_CLI force_version=tls1 \
6282 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6283 trunc_hmac=1" \
6284 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006285 -s "16384 bytes written in 1 fragments" \
6286 -c "Read from server: 16384 bytes read"
6287
6288run_test "Large server packet TLS 1.0 StreamCipher" \
6289 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6290 "$P_CLI force_version=tls1 \
6291 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6292 0 \
6293 -s "16384 bytes written in 1 fragments" \
6294 -c "Read from server: 16384 bytes read"
6295
6296run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6297 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6298 "$P_CLI force_version=tls1 \
6299 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6300 0 \
6301 -s "16384 bytes written in 1 fragments" \
6302 -c "Read from server: 16384 bytes read"
6303
6304requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6305run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6306 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6307 "$P_CLI force_version=tls1 \
6308 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6309 0 \
6310 -s "16384 bytes written in 1 fragments" \
6311 -c "Read from server: 16384 bytes read"
6312
6313requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6314run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6315 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6316 "$P_CLI force_version=tls1 \
6317 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6318 0 \
6319 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006320 -c "Read from server: 16384 bytes read"
6321
6322run_test "Large server packet TLS 1.1 BlockCipher" \
6323 "$P_SRV response_size=16384" \
6324 "$P_CLI force_version=tls1_1 \
6325 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6326 0 \
6327 -c "Read from server: 16384 bytes read"
6328
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006329run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6330 "$P_SRV response_size=16384" \
6331 "$P_CLI force_version=tls1_1 etm=0 \
6332 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006333 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006334 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006335 -c "Read from server: 16384 bytes read"
6336
6337requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6338run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6339 "$P_SRV response_size=16384" \
6340 "$P_CLI force_version=tls1_1 \
6341 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6342 trunc_hmac=1" \
6343 0 \
6344 -c "Read from server: 16384 bytes read"
6345
6346requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006347run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6348 "$P_SRV response_size=16384 trunc_hmac=1" \
6349 "$P_CLI force_version=tls1_1 \
6350 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6351 0 \
6352 -s "16384 bytes written in 1 fragments" \
6353 -c "Read from server: 16384 bytes read"
6354
6355run_test "Large server packet TLS 1.1 StreamCipher" \
6356 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6357 "$P_CLI force_version=tls1_1 \
6358 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6359 0 \
6360 -c "Read from server: 16384 bytes read"
6361
6362run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6363 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6364 "$P_CLI force_version=tls1_1 \
6365 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6366 0 \
6367 -s "16384 bytes written in 1 fragments" \
6368 -c "Read from server: 16384 bytes read"
6369
6370requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006371run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6372 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6373 "$P_CLI force_version=tls1_1 \
6374 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6375 trunc_hmac=1" \
6376 0 \
6377 -c "Read from server: 16384 bytes read"
6378
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006379run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6380 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6381 "$P_CLI force_version=tls1_1 \
6382 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6383 0 \
6384 -s "16384 bytes written in 1 fragments" \
6385 -c "Read from server: 16384 bytes read"
6386
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006387run_test "Large server packet TLS 1.2 BlockCipher" \
6388 "$P_SRV response_size=16384" \
6389 "$P_CLI force_version=tls1_2 \
6390 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6391 0 \
6392 -c "Read from server: 16384 bytes read"
6393
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006394run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6395 "$P_SRV response_size=16384" \
6396 "$P_CLI force_version=tls1_2 etm=0 \
6397 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6398 0 \
6399 -s "16384 bytes written in 1 fragments" \
6400 -c "Read from server: 16384 bytes read"
6401
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006402run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6403 "$P_SRV response_size=16384" \
6404 "$P_CLI force_version=tls1_2 \
6405 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6406 0 \
6407 -c "Read from server: 16384 bytes read"
6408
6409requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6410run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6411 "$P_SRV response_size=16384" \
6412 "$P_CLI force_version=tls1_2 \
6413 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6414 trunc_hmac=1" \
6415 0 \
6416 -c "Read from server: 16384 bytes read"
6417
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006418run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6419 "$P_SRV response_size=16384 trunc_hmac=1" \
6420 "$P_CLI force_version=tls1_2 \
6421 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6422 0 \
6423 -s "16384 bytes written in 1 fragments" \
6424 -c "Read from server: 16384 bytes read"
6425
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006426run_test "Large server packet TLS 1.2 StreamCipher" \
6427 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6428 "$P_CLI force_version=tls1_2 \
6429 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6430 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006431 -s "16384 bytes written in 1 fragments" \
6432 -c "Read from server: 16384 bytes read"
6433
6434run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6435 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6436 "$P_CLI force_version=tls1_2 \
6437 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6438 0 \
6439 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006440 -c "Read from server: 16384 bytes read"
6441
6442requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6443run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6444 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6445 "$P_CLI force_version=tls1_2 \
6446 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6447 trunc_hmac=1" \
6448 0 \
6449 -c "Read from server: 16384 bytes read"
6450
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006451requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6452run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6453 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6454 "$P_CLI force_version=tls1_2 \
6455 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6456 0 \
6457 -s "16384 bytes written in 1 fragments" \
6458 -c "Read from server: 16384 bytes read"
6459
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006460run_test "Large server packet TLS 1.2 AEAD" \
6461 "$P_SRV response_size=16384" \
6462 "$P_CLI force_version=tls1_2 \
6463 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6464 0 \
6465 -c "Read from server: 16384 bytes read"
6466
6467run_test "Large server packet TLS 1.2 AEAD shorter tag" \
6468 "$P_SRV response_size=16384" \
6469 "$P_CLI force_version=tls1_2 \
6470 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6471 0 \
6472 -c "Read from server: 16384 bytes read"
6473
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006474# Tests for restartable ECC
6475
6476requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6477run_test "EC restart: TLS, default" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006478 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006479 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006480 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006481 debug_level=1" \
6482 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006483 -C "x509_verify_cert.*4b00" \
6484 -C "mbedtls_pk_verify.*4b00" \
6485 -C "mbedtls_ecdh_make_public.*4b00" \
6486 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006487
6488requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6489run_test "EC restart: TLS, max_ops=0" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006490 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006491 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006492 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006493 debug_level=1 ec_max_ops=0" \
6494 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006495 -C "x509_verify_cert.*4b00" \
6496 -C "mbedtls_pk_verify.*4b00" \
6497 -C "mbedtls_ecdh_make_public.*4b00" \
6498 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006499
6500requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6501run_test "EC restart: TLS, max_ops=65535" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006502 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006503 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006504 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006505 debug_level=1 ec_max_ops=65535" \
6506 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006507 -C "x509_verify_cert.*4b00" \
6508 -C "mbedtls_pk_verify.*4b00" \
6509 -C "mbedtls_ecdh_make_public.*4b00" \
6510 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006511
6512requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6513run_test "EC restart: TLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006514 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006515 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006516 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006517 debug_level=1 ec_max_ops=1000" \
6518 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006519 -c "x509_verify_cert.*4b00" \
6520 -c "mbedtls_pk_verify.*4b00" \
6521 -c "mbedtls_ecdh_make_public.*4b00" \
6522 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006523
6524requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Hanno Becker4a156fc2019-06-14 17:07:06 +01006525requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006526run_test "EC restart: TLS, max_ops=1000, badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006527 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006528 crt_file=data_files/server5-badsign.crt \
6529 key_file=data_files/server5.key" \
6530 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker03d77462019-08-27 16:24:56 +01006531 key_file=data_files/server5.key crt_file=data_files/server5.crt ca_file=data_files/test-ca2.crt \
6532 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6533 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006534 -c "x509_verify_cert.*4b00" \
Hanno Becker03d77462019-08-27 16:24:56 +01006535 -c "mbedtls_pk_verify.*4b00" \
6536 -c "mbedtls_ecdh_make_public.*4b00" \
6537 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006538 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006539
Hanno Becker4a156fc2019-06-14 17:07:06 +01006540requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006541requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6542run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006543 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006544 crt_file=data_files/server5-badsign.crt \
6545 key_file=data_files/server5.key" \
6546 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6547 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006548 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006549 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6550 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006551 -c "x509_verify_cert.*4b00" \
6552 -c "mbedtls_pk_verify.*4b00" \
6553 -c "mbedtls_ecdh_make_public.*4b00" \
6554 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006555 -c "! The certificate is not correctly signed by the trusted CA" \
6556 -C "! mbedtls_ssl_handshake returned" \
6557 -C "X509 - Certificate verification failed"
6558
Hanno Becker4a156fc2019-06-14 17:07:06 +01006559requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006560requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006561requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6562run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006563 "$P_SRV auth_mode=required ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006564 crt_file=data_files/server5-badsign.crt \
6565 key_file=data_files/server5.key" \
6566 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
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 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6569 debug_level=1 ec_max_ops=1000 auth_mode=none" \
6570 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006571 -C "x509_verify_cert.*4b00" \
6572 -c "mbedtls_pk_verify.*4b00" \
6573 -c "mbedtls_ecdh_make_public.*4b00" \
6574 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006575 -C "! The certificate is not correctly signed by the trusted CA" \
6576 -C "! mbedtls_ssl_handshake returned" \
6577 -C "X509 - Certificate verification failed"
6578
6579requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006580run_test "EC restart: DTLS, max_ops=1000" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006581 "$P_SRV auth_mode=required dtls=1 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006582 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006583 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006584 dtls=1 debug_level=1 ec_max_ops=1000" \
6585 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006586 -c "x509_verify_cert.*4b00" \
6587 -c "mbedtls_pk_verify.*4b00" \
6588 -c "mbedtls_ecdh_make_public.*4b00" \
6589 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006590
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006591requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6592run_test "EC restart: TLS, max_ops=1000 no client auth" \
6593 "$P_SRV" \
6594 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6595 debug_level=1 ec_max_ops=1000" \
6596 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006597 -c "x509_verify_cert.*4b00" \
6598 -c "mbedtls_pk_verify.*4b00" \
6599 -c "mbedtls_ecdh_make_public.*4b00" \
6600 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006601
6602requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6603run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6604 "$P_SRV psk=abc123" \
6605 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6606 psk=abc123 debug_level=1 ec_max_ops=1000" \
6607 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006608 -C "x509_verify_cert.*4b00" \
6609 -C "mbedtls_pk_verify.*4b00" \
6610 -C "mbedtls_ecdh_make_public.*4b00" \
6611 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006612
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006613# Tests of asynchronous private key support in SSL
6614
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006615requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006616run_test "SSL async private: sign, delay=0" \
6617 "$P_SRV \
6618 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006619 "$P_CLI" \
6620 0 \
6621 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006622 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006623
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006624requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006625run_test "SSL async private: sign, delay=1" \
6626 "$P_SRV \
6627 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006628 "$P_CLI" \
6629 0 \
6630 -s "Async sign callback: using key slot " \
6631 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006632 -s "Async resume (slot [0-9]): sign done, status=0"
6633
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006634requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6635run_test "SSL async private: sign, delay=2" \
6636 "$P_SRV \
6637 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6638 "$P_CLI" \
6639 0 \
6640 -s "Async sign callback: using key slot " \
6641 -U "Async sign callback: using key slot " \
6642 -s "Async resume (slot [0-9]): call 1 more times." \
6643 -s "Async resume (slot [0-9]): call 0 more times." \
6644 -s "Async resume (slot [0-9]): sign done, status=0"
6645
Gilles Peskined3268832018-04-26 06:23:59 +02006646# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
6647# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
6648requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6649requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6650run_test "SSL async private: sign, RSA, TLS 1.1" \
6651 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
6652 async_operations=s async_private_delay1=0 async_private_delay2=0" \
6653 "$P_CLI force_version=tls1_1" \
6654 0 \
6655 -s "Async sign callback: using key slot " \
6656 -s "Async resume (slot [0-9]): sign done, status=0"
6657
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006658requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerb2c63832019-06-17 08:35:16 +01006659requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Teppo Järvelin4009d8f2019-08-19 14:48:09 +03006660requires_config_disabled MBEDTLS_X509_REMOVE_HOSTNAME_VERIFICATION
Hanno Becker9ec3fe02019-07-01 17:36:12 +01006661requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Gilles Peskine807d74a2018-04-30 10:30:49 +02006662run_test "SSL async private: sign, SNI" \
6663 "$P_SRV debug_level=3 \
6664 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6665 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6666 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6667 "$P_CLI server_name=polarssl.example" \
6668 0 \
6669 -s "Async sign callback: using key slot " \
6670 -s "Async resume (slot [0-9]): sign done, status=0" \
6671 -s "parse ServerName extension" \
6672 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6673 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6674
6675requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006676run_test "SSL async private: decrypt, delay=0" \
6677 "$P_SRV \
6678 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6679 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6680 0 \
6681 -s "Async decrypt callback: using key slot " \
6682 -s "Async resume (slot [0-9]): decrypt done, status=0"
6683
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006684requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006685run_test "SSL async private: decrypt, delay=1" \
6686 "$P_SRV \
6687 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6688 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6689 0 \
6690 -s "Async decrypt callback: using key slot " \
6691 -s "Async resume (slot [0-9]): call 0 more times." \
6692 -s "Async resume (slot [0-9]): decrypt done, status=0"
6693
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006694requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006695run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6696 "$P_SRV psk=abc123 \
6697 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6698 "$P_CLI psk=abc123 \
6699 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6700 0 \
6701 -s "Async decrypt callback: using key slot " \
6702 -s "Async resume (slot [0-9]): decrypt done, status=0"
6703
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006704requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006705run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6706 "$P_SRV psk=abc123 \
6707 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6708 "$P_CLI psk=abc123 \
6709 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6710 0 \
6711 -s "Async decrypt callback: using key slot " \
6712 -s "Async resume (slot [0-9]): call 0 more times." \
6713 -s "Async resume (slot [0-9]): decrypt done, status=0"
6714
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006715requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006716run_test "SSL async private: sign callback not present" \
6717 "$P_SRV \
6718 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6719 "$P_CLI; [ \$? -eq 1 ] &&
6720 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6721 0 \
6722 -S "Async sign callback" \
6723 -s "! mbedtls_ssl_handshake returned" \
6724 -s "The own private key or pre-shared key is not set, but needed" \
6725 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6726 -s "Successful connection"
6727
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006728requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006729run_test "SSL async private: decrypt callback not present" \
6730 "$P_SRV debug_level=1 \
6731 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6732 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6733 [ \$? -eq 1 ] && $P_CLI" \
6734 0 \
6735 -S "Async decrypt callback" \
6736 -s "! mbedtls_ssl_handshake returned" \
6737 -s "got no RSA private key" \
6738 -s "Async resume (slot [0-9]): sign done, status=0" \
6739 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006740
6741# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006742requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006743run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006744 "$P_SRV \
6745 async_operations=s async_private_delay1=1 \
6746 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6747 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01006748 "$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 +01006749 0 \
6750 -s "Async sign callback: using key slot 0," \
6751 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006752 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006753
6754# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006755requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006756run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006757 "$P_SRV \
6758 async_operations=s async_private_delay2=1 \
6759 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6760 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006761 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6762 0 \
6763 -s "Async sign callback: using key slot 0," \
6764 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006765 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006766
6767# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006768requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006769run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006770 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006771 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006772 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6773 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006774 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6775 0 \
6776 -s "Async sign callback: using key slot 1," \
6777 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006778 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006779
6780# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006781requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006782run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006783 "$P_SRV \
6784 async_operations=s async_private_delay1=1 \
6785 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6786 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006787 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6788 0 \
6789 -s "Async sign callback: no key matches this certificate."
6790
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006791requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006792run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006793 "$P_SRV \
6794 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6795 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006796 "$P_CLI" \
6797 1 \
6798 -s "Async sign callback: injected error" \
6799 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006800 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006801 -s "! mbedtls_ssl_handshake returned"
6802
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006803requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006804run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006805 "$P_SRV \
6806 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6807 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006808 "$P_CLI" \
6809 1 \
6810 -s "Async sign callback: using key slot " \
6811 -S "Async resume" \
6812 -s "Async cancel"
6813
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006814requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006815run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006816 "$P_SRV \
6817 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6818 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006819 "$P_CLI" \
6820 1 \
6821 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006822 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006823 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006824 -s "! mbedtls_ssl_handshake returned"
6825
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006826requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006827run_test "SSL async private: decrypt, error in start" \
6828 "$P_SRV \
6829 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6830 async_private_error=1" \
6831 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6832 1 \
6833 -s "Async decrypt callback: injected error" \
6834 -S "Async resume" \
6835 -S "Async cancel" \
6836 -s "! mbedtls_ssl_handshake returned"
6837
6838requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6839run_test "SSL async private: decrypt, cancel after start" \
6840 "$P_SRV \
6841 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6842 async_private_error=2" \
6843 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6844 1 \
6845 -s "Async decrypt callback: using key slot " \
6846 -S "Async resume" \
6847 -s "Async cancel"
6848
6849requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6850run_test "SSL async private: decrypt, error in resume" \
6851 "$P_SRV \
6852 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6853 async_private_error=3" \
6854 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6855 1 \
6856 -s "Async decrypt callback: using key slot " \
6857 -s "Async resume callback: decrypt done but injected error" \
6858 -S "Async cancel" \
6859 -s "! mbedtls_ssl_handshake returned"
6860
6861requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006862run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006863 "$P_SRV \
6864 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6865 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006866 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6867 0 \
6868 -s "Async cancel" \
6869 -s "! mbedtls_ssl_handshake returned" \
6870 -s "Async resume" \
6871 -s "Successful connection"
6872
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006873requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006874run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006875 "$P_SRV \
6876 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6877 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006878 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6879 0 \
6880 -s "! mbedtls_ssl_handshake returned" \
6881 -s "Async resume" \
6882 -s "Successful connection"
6883
6884# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006885requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006886run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006887 "$P_SRV \
6888 async_operations=s async_private_delay1=1 async_private_error=-2 \
6889 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6890 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006891 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6892 [ \$? -eq 1 ] &&
6893 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6894 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006895 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006896 -S "Async resume" \
6897 -s "Async cancel" \
6898 -s "! mbedtls_ssl_handshake returned" \
6899 -s "Async sign callback: no key matches this certificate." \
6900 -s "Successful connection"
6901
6902# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006903requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006904run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006905 "$P_SRV \
6906 async_operations=s async_private_delay1=1 async_private_error=-3 \
6907 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6908 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006909 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6910 [ \$? -eq 1 ] &&
6911 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6912 0 \
6913 -s "Async resume" \
6914 -s "! mbedtls_ssl_handshake returned" \
6915 -s "Async sign callback: no key matches this certificate." \
6916 -s "Successful connection"
6917
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006918requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006919requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006920run_test "SSL async private: renegotiation: client-initiated; sign" \
6921 "$P_SRV \
6922 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006923 exchanges=2 renegotiation=1" \
6924 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6925 0 \
6926 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006927 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006928
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006929requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006930requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006931run_test "SSL async private: renegotiation: server-initiated; sign" \
6932 "$P_SRV \
6933 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006934 exchanges=2 renegotiation=1 renegotiate=1" \
6935 "$P_CLI exchanges=2 renegotiation=1" \
6936 0 \
6937 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006938 -s "Async resume (slot [0-9]): sign done, status=0"
6939
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006940requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006941requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6942run_test "SSL async private: renegotiation: client-initiated; decrypt" \
6943 "$P_SRV \
6944 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6945 exchanges=2 renegotiation=1" \
6946 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6947 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6948 0 \
6949 -s "Async decrypt callback: using key slot " \
6950 -s "Async resume (slot [0-9]): decrypt done, status=0"
6951
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006952requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006953requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6954run_test "SSL async private: renegotiation: server-initiated; decrypt" \
6955 "$P_SRV \
6956 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6957 exchanges=2 renegotiation=1 renegotiate=1" \
6958 "$P_CLI exchanges=2 renegotiation=1 \
6959 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6960 0 \
6961 -s "Async decrypt callback: using key slot " \
6962 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006963
Ron Eldor58093c82018-06-28 13:22:05 +03006964# Tests for ECC extensions (rfc 4492)
6965
Ron Eldor643df7c2018-06-28 16:17:00 +03006966requires_config_enabled MBEDTLS_AES_C
6967requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6968requires_config_enabled MBEDTLS_SHA256_C
6969requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006970run_test "Force a non ECC ciphersuite in the client side" \
6971 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006972 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006973 0 \
6974 -C "client hello, adding supported_elliptic_curves extension" \
6975 -C "client hello, adding supported_point_formats extension" \
6976 -S "found supported elliptic curves extension" \
6977 -S "found supported point formats extension"
6978
Ron Eldor643df7c2018-06-28 16:17:00 +03006979requires_config_enabled MBEDTLS_AES_C
6980requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6981requires_config_enabled MBEDTLS_SHA256_C
6982requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006983run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006984 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006985 "$P_CLI debug_level=3" \
6986 0 \
6987 -C "found supported_point_formats extension" \
6988 -S "server hello, supported_point_formats extension"
6989
Ron Eldor643df7c2018-06-28 16:17:00 +03006990requires_config_enabled MBEDTLS_AES_C
6991requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6992requires_config_enabled MBEDTLS_SHA256_C
6993requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006994run_test "Force an ECC ciphersuite in the client side" \
6995 "$P_SRV debug_level=3" \
6996 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6997 0 \
6998 -c "client hello, adding supported_elliptic_curves extension" \
6999 -c "client hello, adding supported_point_formats extension" \
7000 -s "found supported elliptic curves extension" \
7001 -s "found supported point formats extension"
7002
Ron Eldor643df7c2018-06-28 16:17:00 +03007003requires_config_enabled MBEDTLS_AES_C
7004requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7005requires_config_enabled MBEDTLS_SHA256_C
7006requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007007run_test "Force an ECC ciphersuite in the server side" \
7008 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7009 "$P_CLI debug_level=3" \
7010 0 \
7011 -c "found supported_point_formats extension" \
7012 -s "server hello, supported_point_formats extension"
7013
Jarno Lamsa2e2fa5e2019-10-30 15:08:26 +02007014requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
Jarno Lamsad3428052019-10-28 14:36:37 +02007015run_test "Force an ECC ciphersuite with CCM in the client side" \
7016 "$P_SRV dtls=1 debug_level=3" \
7017 "$P_CLI dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
7018 0 \
7019 -c "client hello, adding supported_elliptic_curves extension" \
7020 -c "client hello, adding supported_point_formats extension" \
7021 -s "found supported elliptic curves extension" \
7022 -s "found supported point formats extension"
7023
Jarno Lamsa2e2fa5e2019-10-30 15:08:26 +02007024requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
Jarno Lamsad3428052019-10-28 14:36:37 +02007025run_test "Force an ECC ciphersuite with CCM in the server side" \
7026 "$P_SRV dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
7027 "$P_CLI dtls=1 debug_level=3" \
7028 0 \
7029 -c "found supported_point_formats extension" \
7030 -s "server hello, supported_point_formats extension"
7031
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007032# Tests for DTLS HelloVerifyRequest
7033
7034run_test "DTLS cookie: enabled" \
7035 "$P_SRV dtls=1 debug_level=2" \
7036 "$P_CLI dtls=1 debug_level=2" \
7037 0 \
7038 -s "cookie verification failed" \
7039 -s "cookie verification passed" \
7040 -S "cookie verification skipped" \
7041 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007042 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007043 -S "SSL - The requested feature is not available"
7044
7045run_test "DTLS cookie: disabled" \
7046 "$P_SRV dtls=1 debug_level=2 cookies=0" \
7047 "$P_CLI dtls=1 debug_level=2" \
7048 0 \
7049 -S "cookie verification failed" \
7050 -S "cookie verification passed" \
7051 -s "cookie verification skipped" \
7052 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007053 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007054 -S "SSL - The requested feature is not available"
7055
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007056run_test "DTLS cookie: default (failing)" \
7057 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
7058 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
7059 1 \
7060 -s "cookie verification failed" \
7061 -S "cookie verification passed" \
7062 -S "cookie verification skipped" \
7063 -C "received hello verify request" \
Jarno Lamsab514cd32019-10-28 14:37:51 +02007064 -S "hello verification requested"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007065
7066requires_ipv6
7067run_test "DTLS cookie: enabled, IPv6" \
7068 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
7069 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
7070 0 \
7071 -s "cookie verification failed" \
7072 -s "cookie verification passed" \
7073 -S "cookie verification skipped" \
7074 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007075 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007076 -S "SSL - The requested feature is not available"
7077
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007078run_test "DTLS cookie: enabled, nbio" \
7079 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7080 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7081 0 \
7082 -s "cookie verification failed" \
7083 -s "cookie verification passed" \
7084 -S "cookie verification skipped" \
7085 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007086 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007087 -S "SSL - The requested feature is not available"
7088
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007089# Tests for client reconnecting from the same port with DTLS
7090
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007091not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007092requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard731d7c02020-04-01 09:58:39 +02007093requires_config_enabled MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007094run_test "DTLS client reconnect from same port: reference" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04007095 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7096 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007097 0 \
7098 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007099 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007100 -S "Client initiated reconnection from same port"
7101
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007102not_with_valgrind # spurious resend
Jarno Lamsa33281d52019-10-18 10:54:35 +03007103requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard731d7c02020-04-01 09:58:39 +02007104requires_config_enabled MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007105run_test "DTLS client reconnect from same port: reconnect" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04007106 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7107 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007108 0 \
7109 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007110 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007111 -s "Client initiated reconnection from same port"
7112
Paul Bakker362689d2016-05-13 10:33:25 +01007113not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
Jarno Lamsa33281d52019-10-18 10:54:35 +03007114requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard731d7c02020-04-01 09:58:39 +02007115requires_config_enabled MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE
Paul Bakker362689d2016-05-13 10:33:25 +01007116run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007117 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7118 "$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 +02007119 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007120 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007121 -s "Client initiated reconnection from same port"
7122
Paul Bakker362689d2016-05-13 10:33:25 +01007123only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
Jarno Lamsa33281d52019-10-18 10:54:35 +03007124requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard731d7c02020-04-01 09:58:39 +02007125requires_config_enabled MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE
Paul Bakker362689d2016-05-13 10:33:25 +01007126run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7127 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7128 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7129 0 \
7130 -S "The operation timed out" \
7131 -s "Client initiated reconnection from same port"
7132
Jarno Lamsa33281d52019-10-18 10:54:35 +03007133requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard731d7c02020-04-01 09:58:39 +02007134requires_config_enabled MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007135run_test "DTLS client reconnect from same port: no cookies" \
7136 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007137 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7138 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007139 -s "The operation timed out" \
7140 -S "Client initiated reconnection from same port"
7141
Manuel Pégourié-Gonnard731d7c02020-04-01 09:58:39 +02007142requires_config_enabled MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE
Andrzej Kurek825ebd42020-05-18 11:47:25 -04007143run_test "DTLS client reconnect from same port: attacker-injected" \
7144 -p "$P_PXY inject_clihlo=1" \
7145 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
7146 "$P_CLI dtls=1 exchanges=2" \
7147 0 \
7148 -s "possible client reconnect from the same port" \
7149 -S "Client initiated reconnection from same port"
7150
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007151# Tests for various cases of client authentication with DTLS
7152# (focused on handshake flows and message parsing)
7153
7154run_test "DTLS client auth: required" \
7155 "$P_SRV dtls=1 auth_mode=required" \
7156 "$P_CLI dtls=1" \
7157 0 \
7158 -s "Verifying peer X.509 certificate... ok"
7159
Hanno Becker4a156fc2019-06-14 17:07:06 +01007160requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007161requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007162run_test "DTLS client auth: optional, client has no cert" \
7163 "$P_SRV dtls=1 auth_mode=optional" \
7164 "$P_CLI dtls=1 crt_file=none key_file=none" \
7165 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007166 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007167
Hanno Becker4a156fc2019-06-14 17:07:06 +01007168requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Hanno Becker9ec3fe02019-07-01 17:36:12 +01007169requires_config_disabled MBEDTLS_X509_REMOVE_VERIFY_CALLBACK
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007170run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007171 "$P_SRV dtls=1 auth_mode=none" \
7172 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7173 0 \
7174 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007175 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007176
Jarno Lamsa33281d52019-10-18 10:54:35 +03007177requires_ciphersuite_enabled TLS-PSK-WITH-AES-128-GCM-SHA256
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007178run_test "DTLS wrong PSK: badmac alert" \
7179 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7180 "$P_CLI dtls=1 psk=abc124" \
7181 1 \
7182 -s "SSL - Verification of the message MAC failed" \
7183 -c "SSL - A fatal alert message was received from our peer"
7184
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007185# Tests for receiving fragmented handshake messages with DTLS
7186
7187requires_gnutls
7188run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7189 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007190 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007191 0 \
7192 -C "found fragmented DTLS handshake message" \
7193 -C "error"
7194
7195requires_gnutls
7196run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7197 "$G_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007198 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007199 0 \
7200 -c "found fragmented DTLS handshake message" \
7201 -C "error"
7202
7203requires_gnutls
7204run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7205 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007206 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007207 0 \
7208 -c "found fragmented DTLS handshake message" \
7209 -C "error"
7210
7211requires_gnutls
7212run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7213 "$G_SRV -u --mtu 128" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007214 "$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 +02007215 0 \
7216 -c "found fragmented DTLS handshake message" \
7217 -C "error"
7218
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007219requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007220requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007221run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7222 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007223 "$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 +02007224 0 \
7225 -c "found fragmented DTLS handshake message" \
7226 -c "client hello, adding renegotiation extension" \
7227 -c "found renegotiation extension" \
7228 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007229 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007230 -C "error" \
7231 -s "Extra-header:"
7232
7233requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007234requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007235run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7236 "$G_SRV -u --mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007237 "$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 +02007238 0 \
7239 -c "found fragmented DTLS handshake message" \
7240 -c "client hello, adding renegotiation extension" \
7241 -c "found renegotiation extension" \
7242 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007243 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007244 -C "error" \
7245 -s "Extra-header:"
7246
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007247run_test "DTLS reassembly: no fragmentation (openssl server)" \
7248 "$O_SRV -dtls1 -mtu 2048" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007249 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007250 0 \
7251 -C "found fragmented DTLS handshake message" \
7252 -C "error"
7253
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007254run_test "DTLS reassembly: some fragmentation (openssl server)" \
7255 "$O_SRV -dtls1 -mtu 768" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007256 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007257 0 \
7258 -c "found fragmented DTLS handshake message" \
7259 -C "error"
7260
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007261run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007262 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007263 "$P_CLI dtls=1 debug_level=2 ca_file=data_files/test-ca2.crt" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007264 0 \
7265 -c "found fragmented DTLS handshake message" \
7266 -C "error"
7267
7268run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7269 "$O_SRV -dtls1 -mtu 256" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007270 "$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 +02007271 0 \
7272 -c "found fragmented DTLS handshake message" \
7273 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007274
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007275# Tests for sending fragmented handshake messages with DTLS
7276#
7277# Use client auth when we need the client to send large messages,
7278# and use large cert chains on both sides too (the long chains we have all use
7279# both RSA and ECDSA, but ideally we should have long chains with either).
7280# Sizes reached (UDP payload):
7281# - 2037B for server certificate
7282# - 1542B for client certificate
7283# - 1013B for newsessionticket
7284# - all others below 512B
7285# All those tests assume MAX_CONTENT_LEN is at least 2048
7286
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007287requires_config_enabled MBEDTLS_RSA_C
7288requires_config_enabled MBEDTLS_ECDSA_C
7289requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7290run_test "DTLS fragmenting: none (for reference)" \
7291 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7292 crt_file=data_files/server7_int-ca.crt \
7293 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007294 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007295 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007296 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007297 "$P_CLI dtls=1 debug_level=2 \
7298 crt_file=data_files/server8_int-ca2.crt \
7299 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007300 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007301 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007302 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007303 0 \
7304 -S "found fragmented DTLS handshake message" \
7305 -C "found fragmented DTLS handshake message" \
7306 -C "error"
7307
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007308requires_config_enabled MBEDTLS_RSA_C
7309requires_config_enabled MBEDTLS_ECDSA_C
7310requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007311run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007312 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7313 crt_file=data_files/server7_int-ca.crt \
7314 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007315 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007316 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007317 max_frag_len=1024" \
7318 "$P_CLI dtls=1 debug_level=2 \
7319 crt_file=data_files/server8_int-ca2.crt \
7320 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007321 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007322 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007323 max_frag_len=2048" \
7324 0 \
7325 -S "found fragmented DTLS handshake message" \
7326 -c "found fragmented DTLS handshake message" \
7327 -C "error"
7328
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007329# With the MFL extension, the server has no way of forcing
7330# the client to not exceed a certain MTU; hence, the following
7331# test can't be replicated with an MTU proxy such as the one
7332# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007333requires_config_enabled MBEDTLS_RSA_C
7334requires_config_enabled MBEDTLS_ECDSA_C
7335requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007336run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007337 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7338 crt_file=data_files/server7_int-ca.crt \
7339 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007340 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007341 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007342 max_frag_len=512" \
7343 "$P_CLI dtls=1 debug_level=2 \
7344 crt_file=data_files/server8_int-ca2.crt \
7345 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007346 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007347 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007348 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007349 0 \
7350 -S "found fragmented DTLS handshake message" \
7351 -c "found fragmented DTLS handshake message" \
7352 -C "error"
7353
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007354requires_config_enabled MBEDTLS_RSA_C
7355requires_config_enabled MBEDTLS_ECDSA_C
7356requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007357run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007358 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7359 crt_file=data_files/server7_int-ca.crt \
7360 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007361 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007362 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007363 max_frag_len=2048" \
7364 "$P_CLI dtls=1 debug_level=2 \
7365 crt_file=data_files/server8_int-ca2.crt \
7366 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007367 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007368 hs_timeout=2500-60000 \
7369 max_frag_len=1024" \
7370 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007371 -S "found fragmented DTLS handshake message" \
7372 -c "found fragmented DTLS handshake message" \
7373 -C "error"
7374
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007375# While not required by the standard defining the MFL extension
7376# (according to which it only applies to records, not to datagrams),
7377# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7378# as otherwise there wouldn't be any means to communicate MTU restrictions
7379# to the peer.
7380# The next test checks that no datagrams significantly larger than the
7381# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007382requires_config_enabled MBEDTLS_RSA_C
7383requires_config_enabled MBEDTLS_ECDSA_C
7384requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7385run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007386 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007387 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7388 crt_file=data_files/server7_int-ca.crt \
7389 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007390 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007391 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007392 max_frag_len=2048" \
7393 "$P_CLI dtls=1 debug_level=2 \
7394 crt_file=data_files/server8_int-ca2.crt \
7395 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007396 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007397 hs_timeout=2500-60000 \
7398 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007399 0 \
7400 -S "found fragmented DTLS handshake message" \
7401 -c "found fragmented DTLS handshake message" \
7402 -C "error"
7403
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007404requires_config_enabled MBEDTLS_RSA_C
7405requires_config_enabled MBEDTLS_ECDSA_C
7406requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007407run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007408 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7409 crt_file=data_files/server7_int-ca.crt \
7410 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007411 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007412 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007413 max_frag_len=2048" \
7414 "$P_CLI dtls=1 debug_level=2 \
7415 crt_file=data_files/server8_int-ca2.crt \
7416 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007417 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007418 hs_timeout=2500-60000 \
7419 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007420 0 \
7421 -s "found fragmented DTLS handshake message" \
7422 -c "found fragmented DTLS handshake message" \
7423 -C "error"
7424
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007425# While not required by the standard defining the MFL extension
7426# (according to which it only applies to records, not to datagrams),
7427# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7428# as otherwise there wouldn't be any means to communicate MTU restrictions
7429# to the peer.
7430# The next test checks that no datagrams significantly larger than the
7431# negotiated MFL are sent.
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007432requires_config_enabled MBEDTLS_RSA_C
7433requires_config_enabled MBEDTLS_ECDSA_C
7434requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7435run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007436 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007437 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7438 crt_file=data_files/server7_int-ca.crt \
7439 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007440 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007441 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007442 max_frag_len=2048" \
7443 "$P_CLI dtls=1 debug_level=2 \
7444 crt_file=data_files/server8_int-ca2.crt \
7445 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007446 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007447 hs_timeout=2500-60000 \
7448 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007449 0 \
7450 -s "found fragmented DTLS handshake message" \
7451 -c "found fragmented DTLS handshake message" \
7452 -C "error"
7453
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007454requires_config_enabled MBEDTLS_RSA_C
7455requires_config_enabled MBEDTLS_ECDSA_C
7456run_test "DTLS fragmenting: none (for reference) (MTU)" \
7457 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7458 crt_file=data_files/server7_int-ca.crt \
7459 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007460 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007461 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007462 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007463 "$P_CLI dtls=1 debug_level=2 \
7464 crt_file=data_files/server8_int-ca2.crt \
7465 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007466 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007467 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007468 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007469 0 \
7470 -S "found fragmented DTLS handshake message" \
7471 -C "found fragmented DTLS handshake message" \
7472 -C "error"
7473
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007474requires_config_enabled MBEDTLS_RSA_C
7475requires_config_enabled MBEDTLS_ECDSA_C
7476run_test "DTLS fragmenting: client (MTU)" \
7477 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7478 crt_file=data_files/server7_int-ca.crt \
7479 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007480 ca_file=data_files/test-ca.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007481 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007482 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007483 "$P_CLI dtls=1 debug_level=2 \
7484 crt_file=data_files/server8_int-ca2.crt \
7485 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007486 ca_file=data_files/test-ca2.crt \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007487 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007488 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007489 0 \
7490 -s "found fragmented DTLS handshake message" \
7491 -C "found fragmented DTLS handshake message" \
7492 -C "error"
7493
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007494requires_config_enabled MBEDTLS_RSA_C
7495requires_config_enabled MBEDTLS_ECDSA_C
7496run_test "DTLS fragmenting: server (MTU)" \
7497 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7498 crt_file=data_files/server7_int-ca.crt \
7499 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007500 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007501 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007502 mtu=512" \
7503 "$P_CLI dtls=1 debug_level=2 \
7504 crt_file=data_files/server8_int-ca2.crt \
7505 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007506 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007507 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007508 mtu=2048" \
7509 0 \
7510 -S "found fragmented DTLS handshake message" \
7511 -c "found fragmented DTLS handshake message" \
7512 -C "error"
7513
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007514requires_config_enabled MBEDTLS_RSA_C
7515requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007516run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007517 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007518 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7519 crt_file=data_files/server7_int-ca.crt \
7520 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007521 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007522 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04007523 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007524 "$P_CLI dtls=1 debug_level=2 \
7525 crt_file=data_files/server8_int-ca2.crt \
7526 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007527 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007528 hs_timeout=2500-60000 \
7529 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007530 0 \
7531 -s "found fragmented DTLS handshake message" \
7532 -c "found fragmented DTLS handshake message" \
7533 -C "error"
7534
Andrzej Kurek77826052018-10-11 07:34:08 -04007535# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007536requires_config_enabled MBEDTLS_RSA_C
7537requires_config_enabled MBEDTLS_ECDSA_C
7538requires_config_enabled MBEDTLS_SHA256_C
7539requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7540requires_config_enabled MBEDTLS_AES_C
7541requires_config_enabled MBEDTLS_GCM_C
7542run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00007543 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00007544 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7545 crt_file=data_files/server7_int-ca.crt \
7546 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007547 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007548 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00007549 mtu=512" \
7550 "$P_CLI dtls=1 debug_level=2 \
7551 crt_file=data_files/server8_int-ca2.crt \
7552 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007553 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007554 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7555 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007556 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007557 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007558 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007559 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007560 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007561
Andrzej Kurek7311c782018-10-11 06:49:41 -04007562# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04007563# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007564# The ratio of max/min timeout should ideally equal 4 to accept two
7565# retransmissions, but in some cases (like both the server and client using
7566# fragmentation and auto-reduction) an extra retransmission might occur,
7567# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01007568not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007569requires_config_enabled MBEDTLS_RSA_C
7570requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007571requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7572requires_config_enabled MBEDTLS_AES_C
7573requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007574run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7575 -p "$P_PXY mtu=508" \
7576 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7577 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007578 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007579 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007580 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007581 "$P_CLI dtls=1 debug_level=2 \
7582 crt_file=data_files/server8_int-ca2.crt \
7583 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007584 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007585 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7586 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02007587 0 \
7588 -s "found fragmented DTLS handshake message" \
7589 -c "found fragmented DTLS handshake message" \
7590 -C "error"
7591
Andrzej Kurek77826052018-10-11 07:34:08 -04007592# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01007593only_with_valgrind
Hanno Becker108992e2018-08-29 17:04:18 +01007594requires_config_enabled MBEDTLS_RSA_C
7595requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007596requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7597requires_config_enabled MBEDTLS_AES_C
7598requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01007599run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
7600 -p "$P_PXY mtu=508" \
7601 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7602 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007603 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007604 ca_file=data_files/test-ca.crt \
Hanno Becker108992e2018-08-29 17:04:18 +01007605 hs_timeout=250-10000" \
7606 "$P_CLI dtls=1 debug_level=2 \
7607 crt_file=data_files/server8_int-ca2.crt \
7608 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007609 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007610 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007611 hs_timeout=250-10000" \
7612 0 \
7613 -s "found fragmented DTLS handshake message" \
7614 -c "found fragmented DTLS handshake message" \
7615 -C "error"
7616
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007617# 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 +02007618# OTOH the client might resend if the server is to slow to reset after sending
7619# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007620not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007621requires_config_enabled MBEDTLS_RSA_C
7622requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007623run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007624 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007625 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7626 crt_file=data_files/server7_int-ca.crt \
7627 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007628 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007629 hs_timeout=10000-60000 \
7630 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007631 "$P_CLI dtls=1 debug_level=2 \
7632 crt_file=data_files/server8_int-ca2.crt \
7633 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007634 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007635 hs_timeout=10000-60000 \
7636 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007637 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007638 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007639 -s "found fragmented DTLS handshake message" \
7640 -c "found fragmented DTLS handshake message" \
7641 -C "error"
7642
Andrzej Kurek77826052018-10-11 07:34:08 -04007643# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007644# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7645# OTOH the client might resend if the server is to slow to reset after sending
7646# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007647not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007648requires_config_enabled MBEDTLS_RSA_C
7649requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007650requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7651requires_config_enabled MBEDTLS_AES_C
7652requires_config_enabled MBEDTLS_GCM_C
7653run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007654 -p "$P_PXY mtu=512" \
7655 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7656 crt_file=data_files/server7_int-ca.crt \
7657 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007658 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007659 hs_timeout=10000-60000 \
7660 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007661 "$P_CLI dtls=1 debug_level=2 \
7662 crt_file=data_files/server8_int-ca2.crt \
7663 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007664 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007665 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7666 hs_timeout=10000-60000 \
7667 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007668 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007669 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007670 -s "found fragmented DTLS handshake message" \
7671 -c "found fragmented DTLS handshake message" \
7672 -C "error"
7673
Andrzej Kurek7311c782018-10-11 06:49:41 -04007674not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007675requires_config_enabled MBEDTLS_RSA_C
7676requires_config_enabled MBEDTLS_ECDSA_C
7677run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007678 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007679 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7680 crt_file=data_files/server7_int-ca.crt \
7681 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007682 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007683 hs_timeout=10000-60000 \
7684 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007685 "$P_CLI dtls=1 debug_level=2 \
7686 crt_file=data_files/server8_int-ca2.crt \
7687 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007688 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007689 hs_timeout=10000-60000 \
7690 mtu=1024 nbio=2" \
7691 0 \
7692 -S "autoreduction" \
7693 -s "found fragmented DTLS handshake message" \
7694 -c "found fragmented DTLS handshake message" \
7695 -C "error"
7696
Andrzej Kurek77826052018-10-11 07:34:08 -04007697# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007698not_with_valgrind # spurious autoreduction due to timeout
Andrzej Kurek7311c782018-10-11 06:49:41 -04007699requires_config_enabled MBEDTLS_RSA_C
7700requires_config_enabled MBEDTLS_ECDSA_C
7701requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7702requires_config_enabled MBEDTLS_AES_C
7703requires_config_enabled MBEDTLS_GCM_C
7704run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7705 -p "$P_PXY mtu=512" \
7706 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7707 crt_file=data_files/server7_int-ca.crt \
7708 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007709 ca_file=data_files/test-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007710 hs_timeout=10000-60000 \
7711 mtu=512 nbio=2" \
7712 "$P_CLI dtls=1 debug_level=2 \
7713 crt_file=data_files/server8_int-ca2.crt \
7714 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007715 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007716 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7717 hs_timeout=10000-60000 \
7718 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007719 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007720 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007721 -s "found fragmented DTLS handshake message" \
7722 -c "found fragmented DTLS handshake message" \
7723 -C "error"
7724
Andrzej Kurek77826052018-10-11 07:34:08 -04007725# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007726# This ensures things still work after session_reset().
7727# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007728# Since we don't support reading fragmented ClientHello yet,
7729# up the MTU to 1450 (larger than ClientHello with session ticket,
7730# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007731# An autoreduction on the client-side might happen if the server is
7732# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007733# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007734# resumed listening, which would result in a spurious autoreduction.
7735not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007736requires_config_enabled MBEDTLS_RSA_C
7737requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007738requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7739requires_config_enabled MBEDTLS_AES_C
7740requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007741run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7742 -p "$P_PXY mtu=1450" \
7743 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7744 crt_file=data_files/server7_int-ca.crt \
7745 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007746 ca_file=data_files/test-ca.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007747 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007748 mtu=1450" \
7749 "$P_CLI dtls=1 debug_level=2 \
7750 crt_file=data_files/server8_int-ca2.crt \
7751 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007752 ca_file=data_files/test-ca2.crt \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007753 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007754 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04007755 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007756 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007757 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007758 -s "found fragmented DTLS handshake message" \
7759 -c "found fragmented DTLS handshake message" \
7760 -C "error"
7761
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007762# An autoreduction on the client-side might happen if the server is
7763# slow to reset, therefore omitting '-C "autoreduction"' below.
7764not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007765requires_config_enabled MBEDTLS_RSA_C
7766requires_config_enabled MBEDTLS_ECDSA_C
7767requires_config_enabled MBEDTLS_SHA256_C
7768requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7769requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7770requires_config_enabled MBEDTLS_CHACHAPOLY_C
7771run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7772 -p "$P_PXY mtu=512" \
7773 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7774 crt_file=data_files/server7_int-ca.crt \
7775 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007776 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007777 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007778 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007779 mtu=512" \
7780 "$P_CLI dtls=1 debug_level=2 \
7781 crt_file=data_files/server8_int-ca2.crt \
7782 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007783 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007784 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007785 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007786 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007787 mtu=512" \
7788 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007789 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007790 -s "found fragmented DTLS handshake message" \
7791 -c "found fragmented DTLS handshake message" \
7792 -C "error"
7793
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007794# An autoreduction on the client-side might happen if the server is
7795# slow to reset, therefore omitting '-C "autoreduction"' below.
7796not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007797requires_config_enabled MBEDTLS_RSA_C
7798requires_config_enabled MBEDTLS_ECDSA_C
7799requires_config_enabled MBEDTLS_SHA256_C
7800requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7801requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7802requires_config_enabled MBEDTLS_AES_C
7803requires_config_enabled MBEDTLS_GCM_C
7804run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7805 -p "$P_PXY mtu=512" \
7806 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7807 crt_file=data_files/server7_int-ca.crt \
7808 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007809 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007810 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007811 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007812 mtu=512" \
7813 "$P_CLI dtls=1 debug_level=2 \
7814 crt_file=data_files/server8_int-ca2.crt \
7815 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007816 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007817 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007818 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007819 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007820 mtu=512" \
7821 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007822 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007823 -s "found fragmented DTLS handshake message" \
7824 -c "found fragmented DTLS handshake message" \
7825 -C "error"
7826
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007827# An autoreduction on the client-side might happen if the server is
7828# slow to reset, therefore omitting '-C "autoreduction"' below.
7829not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007830requires_config_enabled MBEDTLS_RSA_C
7831requires_config_enabled MBEDTLS_ECDSA_C
7832requires_config_enabled MBEDTLS_SHA256_C
7833requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7834requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7835requires_config_enabled MBEDTLS_AES_C
7836requires_config_enabled MBEDTLS_CCM_C
7837run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007838 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007839 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7840 crt_file=data_files/server7_int-ca.crt \
7841 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007842 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007843 exchanges=2 renegotiation=1 \
7844 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007845 hs_timeout=10000-60000 \
7846 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007847 "$P_CLI dtls=1 debug_level=2 \
7848 crt_file=data_files/server8_int-ca2.crt \
7849 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007850 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007851 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007852 hs_timeout=10000-60000 \
7853 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007854 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007855 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007856 -s "found fragmented DTLS handshake message" \
7857 -c "found fragmented DTLS handshake message" \
7858 -C "error"
7859
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007860# An autoreduction on the client-side might happen if the server is
7861# slow to reset, therefore omitting '-C "autoreduction"' below.
7862not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007863requires_config_enabled MBEDTLS_RSA_C
7864requires_config_enabled MBEDTLS_ECDSA_C
7865requires_config_enabled MBEDTLS_SHA256_C
7866requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7867requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7868requires_config_enabled MBEDTLS_AES_C
7869requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7870requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7871run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007872 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007873 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7874 crt_file=data_files/server7_int-ca.crt \
7875 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007876 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007877 exchanges=2 renegotiation=1 \
7878 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007879 hs_timeout=10000-60000 \
7880 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007881 "$P_CLI dtls=1 debug_level=2 \
7882 crt_file=data_files/server8_int-ca2.crt \
7883 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007884 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007885 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007886 hs_timeout=10000-60000 \
7887 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007888 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007889 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007890 -s "found fragmented DTLS handshake message" \
7891 -c "found fragmented DTLS handshake message" \
7892 -C "error"
7893
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007894# An autoreduction on the client-side might happen if the server is
7895# slow to reset, therefore omitting '-C "autoreduction"' below.
7896not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007897requires_config_enabled MBEDTLS_RSA_C
7898requires_config_enabled MBEDTLS_ECDSA_C
7899requires_config_enabled MBEDTLS_SHA256_C
7900requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7901requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7902requires_config_enabled MBEDTLS_AES_C
7903requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7904run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007905 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007906 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7907 crt_file=data_files/server7_int-ca.crt \
7908 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007909 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007910 exchanges=2 renegotiation=1 \
7911 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007912 hs_timeout=10000-60000 \
7913 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007914 "$P_CLI dtls=1 debug_level=2 \
7915 crt_file=data_files/server8_int-ca2.crt \
7916 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007917 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007918 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007919 hs_timeout=10000-60000 \
7920 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007921 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007922 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007923 -s "found fragmented DTLS handshake message" \
7924 -c "found fragmented DTLS handshake message" \
7925 -C "error"
7926
Andrzej Kurek77826052018-10-11 07:34:08 -04007927# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007928requires_config_enabled MBEDTLS_RSA_C
7929requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007930requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7931requires_config_enabled MBEDTLS_AES_C
7932requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007933client_needs_more_time 2
7934run_test "DTLS fragmenting: proxy MTU + 3d" \
7935 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007936 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007937 crt_file=data_files/server7_int-ca.crt \
7938 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007939 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007940 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007941 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007942 crt_file=data_files/server8_int-ca2.crt \
7943 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007944 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007945 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007946 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007947 0 \
7948 -s "found fragmented DTLS handshake message" \
7949 -c "found fragmented DTLS handshake message" \
7950 -C "error"
7951
Andrzej Kurek77826052018-10-11 07:34:08 -04007952# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007953requires_config_enabled MBEDTLS_RSA_C
7954requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007955requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7956requires_config_enabled MBEDTLS_AES_C
7957requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007958client_needs_more_time 2
7959run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7960 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7961 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7962 crt_file=data_files/server7_int-ca.crt \
7963 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007964 ca_file=data_files/test-ca.crt \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007965 hs_timeout=250-10000 mtu=512 nbio=2" \
7966 "$P_CLI dtls=1 debug_level=2 \
7967 crt_file=data_files/server8_int-ca2.crt \
7968 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007969 ca_file=data_files/test-ca2.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007970 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007971 hs_timeout=250-10000 mtu=512 nbio=2" \
7972 0 \
7973 -s "found fragmented DTLS handshake message" \
7974 -c "found fragmented DTLS handshake message" \
7975 -C "error"
7976
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007977# interop tests for DTLS fragmentating with reliable connection
7978#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007979# here and below we just want to test that the we fragment in a way that
7980# pleases other implementations, so we don't need the peer to fragment
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007981requires_config_enabled MBEDTLS_RSA_C
7982requires_config_enabled MBEDTLS_ECDSA_C
7983requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007984requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007985run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7986 "$G_SRV -u" \
7987 "$P_CLI dtls=1 debug_level=2 \
7988 crt_file=data_files/server8_int-ca2.crt \
7989 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01007990 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007991 mtu=512 force_version=dtls1_2" \
7992 0 \
7993 -c "fragmenting handshake message" \
7994 -C "error"
7995
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007996requires_config_enabled MBEDTLS_RSA_C
7997requires_config_enabled MBEDTLS_ECDSA_C
7998requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007999requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008000run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
8001 "$G_SRV -u" \
8002 "$P_CLI dtls=1 debug_level=2 \
8003 crt_file=data_files/server8_int-ca2.crt \
8004 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008005 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008006 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008007 0 \
8008 -c "fragmenting handshake message" \
8009 -C "error"
8010
Hanno Beckerb9a00862018-08-28 10:20:22 +01008011# We use --insecure for the GnuTLS client because it expects
8012# the hostname / IP it connects to to be the name used in the
8013# certificate obtained from the server. Here, however, it
8014# connects to 127.0.0.1 while our test certificates use 'localhost'
8015# as the server name in the certificate. This will make the
8016# certifiate validation fail, but passing --insecure makes
8017# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008018requires_config_enabled MBEDTLS_RSA_C
8019requires_config_enabled MBEDTLS_ECDSA_C
8020requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008021requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008022requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008023run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008024 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008025 crt_file=data_files/server7_int-ca.crt \
8026 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008027 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008028 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008029 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008030 0 \
8031 -s "fragmenting handshake message"
8032
Hanno Beckerb9a00862018-08-28 10:20:22 +01008033# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008034requires_config_enabled MBEDTLS_RSA_C
8035requires_config_enabled MBEDTLS_ECDSA_C
8036requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008037requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008038requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008039run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008040 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008041 crt_file=data_files/server7_int-ca.crt \
8042 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008043 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008044 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008045 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008046 0 \
8047 -s "fragmenting handshake message"
8048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008049requires_config_enabled MBEDTLS_RSA_C
8050requires_config_enabled MBEDTLS_ECDSA_C
8051requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8052run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
8053 "$O_SRV -dtls1_2 -verify 10" \
8054 "$P_CLI dtls=1 debug_level=2 \
8055 crt_file=data_files/server8_int-ca2.crt \
8056 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008057 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008058 mtu=512 force_version=dtls1_2" \
8059 0 \
8060 -c "fragmenting handshake message" \
8061 -C "error"
8062
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008063requires_config_enabled MBEDTLS_RSA_C
8064requires_config_enabled MBEDTLS_ECDSA_C
8065requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8066run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
8067 "$O_SRV -dtls1 -verify 10" \
8068 "$P_CLI dtls=1 debug_level=2 \
8069 crt_file=data_files/server8_int-ca2.crt \
8070 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008071 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008072 mtu=512 force_version=dtls1" \
8073 0 \
8074 -c "fragmenting handshake message" \
8075 -C "error"
8076
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008077requires_config_enabled MBEDTLS_RSA_C
8078requires_config_enabled MBEDTLS_ECDSA_C
8079requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8080run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
8081 "$P_SRV dtls=1 debug_level=2 \
8082 crt_file=data_files/server7_int-ca.crt \
8083 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008084 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008085 mtu=512 force_version=dtls1_2" \
8086 "$O_CLI -dtls1_2" \
8087 0 \
8088 -s "fragmenting handshake message"
8089
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008090requires_config_enabled MBEDTLS_RSA_C
8091requires_config_enabled MBEDTLS_ECDSA_C
8092requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8093run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8094 "$P_SRV dtls=1 debug_level=2 \
8095 crt_file=data_files/server7_int-ca.crt \
8096 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008097 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008098 mtu=512 force_version=dtls1" \
8099 "$O_CLI -dtls1" \
8100 0 \
8101 -s "fragmenting handshake message"
8102
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008103# interop tests for DTLS fragmentating with unreliable connection
8104#
8105# again we just want to test that the we fragment in a way that
8106# pleases other implementations, so we don't need the peer to fragment
8107requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008108requires_config_enabled MBEDTLS_RSA_C
8109requires_config_enabled MBEDTLS_ECDSA_C
8110requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008111client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008112run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8113 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8114 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008115 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008116 crt_file=data_files/server8_int-ca2.crt \
8117 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008118 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008119 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008120 0 \
8121 -c "fragmenting handshake message" \
8122 -C "error"
8123
8124requires_gnutls_next
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008125requires_config_enabled MBEDTLS_RSA_C
8126requires_config_enabled MBEDTLS_ECDSA_C
8127requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008128client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008129run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8130 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8131 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008132 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008133 crt_file=data_files/server8_int-ca2.crt \
8134 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008135 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008136 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008137 0 \
8138 -c "fragmenting handshake message" \
8139 -C "error"
8140
k-stachowiakabb843e2019-02-18 16:14:03 +01008141requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008142requires_config_enabled MBEDTLS_RSA_C
8143requires_config_enabled MBEDTLS_ECDSA_C
8144requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8145client_needs_more_time 4
8146run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8147 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8148 "$P_SRV dtls=1 debug_level=2 \
8149 crt_file=data_files/server7_int-ca.crt \
8150 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008151 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008152 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008153 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008154 0 \
8155 -s "fragmenting handshake message"
8156
k-stachowiakabb843e2019-02-18 16:14:03 +01008157requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008158requires_config_enabled MBEDTLS_RSA_C
8159requires_config_enabled MBEDTLS_ECDSA_C
8160requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8161client_needs_more_time 4
8162run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8163 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8164 "$P_SRV dtls=1 debug_level=2 \
8165 crt_file=data_files/server7_int-ca.crt \
8166 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008167 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008168 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008169 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008170 0 \
8171 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008172
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008173## Interop test with OpenSSL might trigger a bug in recent versions (including
8174## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008175## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008176## They should be re-enabled once a fixed version of OpenSSL is available
8177## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008178skip_next_test
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008179requires_config_enabled MBEDTLS_RSA_C
8180requires_config_enabled MBEDTLS_ECDSA_C
8181requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8182client_needs_more_time 4
8183run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8184 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8185 "$O_SRV -dtls1_2 -verify 10" \
8186 "$P_CLI dtls=1 debug_level=2 \
8187 crt_file=data_files/server8_int-ca2.crt \
8188 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008189 ca_file=data_files/test-ca2.crt \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008190 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8191 0 \
8192 -c "fragmenting handshake message" \
8193 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008194
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008195skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008196requires_config_enabled MBEDTLS_RSA_C
8197requires_config_enabled MBEDTLS_ECDSA_C
8198requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008199client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008200run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8201 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008202 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008203 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008204 crt_file=data_files/server8_int-ca2.crt \
8205 key_file=data_files/server8.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008206 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008207 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008208 0 \
8209 -c "fragmenting handshake message" \
8210 -C "error"
8211
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008212skip_next_test
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008213requires_config_enabled MBEDTLS_RSA_C
8214requires_config_enabled MBEDTLS_ECDSA_C
8215requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8216client_needs_more_time 4
8217run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8218 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8219 "$P_SRV dtls=1 debug_level=2 \
8220 crt_file=data_files/server7_int-ca.crt \
8221 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008222 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008223 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8224 "$O_CLI -dtls1_2" \
8225 0 \
8226 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008227
8228# -nbio is added to prevent s_client from blocking in case of duplicated
8229# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008230skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008231requires_config_enabled MBEDTLS_RSA_C
8232requires_config_enabled MBEDTLS_ECDSA_C
8233requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008234client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008235run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8236 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008237 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008238 crt_file=data_files/server7_int-ca.crt \
8239 key_file=data_files/server7.key \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008240 ca_file=data_files/test-ca2.crt \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008241 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008242 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008243 0 \
8244 -s "fragmenting handshake message"
8245
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008246# Tests for specific things with "unreliable" UDP connection
8247
8248not_with_valgrind # spurious resend due to timeout
8249run_test "DTLS proxy: reference" \
8250 -p "$P_PXY" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04008251 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
8252 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008253 0 \
8254 -C "replayed record" \
8255 -S "replayed record" \
Hanno Beckere03eb7b2019-07-19 15:43:09 +01008256 -C "Buffer record from epoch" \
8257 -S "Buffer record from epoch" \
8258 -C "ssl_buffer_message" \
8259 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008260 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008261 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008262 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008263 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008264 -c "HTTP/1.0 200 OK"
8265
8266not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008267run_test "DTLS proxy: duplicate every packet" \
8268 -p "$P_PXY duplicate=1" \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04008269 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=1 hs_timeout=10000-20000" \
8270 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008271 0 \
8272 -c "replayed record" \
8273 -s "replayed record" \
8274 -c "record from another epoch" \
8275 -s "record from another epoch" \
8276 -S "resend" \
8277 -s "Extra-header:" \
8278 -c "HTTP/1.0 200 OK"
8279
8280run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8281 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008282 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8283 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008284 0 \
8285 -c "replayed record" \
8286 -S "replayed record" \
8287 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008288 -s "record from another epoch" \
8289 -c "resend" \
8290 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008291 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008292 -c "HTTP/1.0 200 OK"
8293
8294run_test "DTLS proxy: multiple records in same datagram" \
8295 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008296 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8297 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008298 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008299 -c "next record in same datagram" \
8300 -s "next record in same datagram"
8301
8302run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8303 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008304 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8305 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008306 0 \
8307 -c "next record in same datagram" \
8308 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008309
Jarno Lamsa33281d52019-10-18 10:54:35 +03008310requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008311run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8312 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008313 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8314 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008315 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008316 -c "discarding invalid record (mac)" \
8317 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008318 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008319 -c "HTTP/1.0 200 OK" \
8320 -S "too many records with bad MAC" \
8321 -S "Verification of the message MAC failed"
8322
Jarno Lamsa33281d52019-10-18 10:54:35 +03008323requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008324run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8325 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008326 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8327 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008328 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008329 -C "discarding invalid record (mac)" \
8330 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008331 -S "Extra-header:" \
8332 -C "HTTP/1.0 200 OK" \
8333 -s "too many records with bad MAC" \
8334 -s "Verification of the message MAC failed"
8335
Jarno Lamsa33281d52019-10-18 10:54:35 +03008336requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008337run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8338 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008339 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8340 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008341 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008342 -c "discarding invalid record (mac)" \
8343 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008344 -s "Extra-header:" \
8345 -c "HTTP/1.0 200 OK" \
8346 -S "too many records with bad MAC" \
8347 -S "Verification of the message MAC failed"
8348
Jarno Lamsa33281d52019-10-18 10:54:35 +03008349requires_config_disabled MBEDTLS_SSL_CONF_READ_TIMEOUT
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008350run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8351 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008352 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8353 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008354 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008355 -c "discarding invalid record (mac)" \
8356 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008357 -s "Extra-header:" \
8358 -c "HTTP/1.0 200 OK" \
8359 -s "too many records with bad MAC" \
8360 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008361
8362run_test "DTLS proxy: delay ChangeCipherSpec" \
8363 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008364 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8365 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008366 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008367 -c "record from another epoch" \
8368 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008369 -s "Extra-header:" \
8370 -c "HTTP/1.0 200 OK"
8371
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008372# Tests for reordering support with DTLS
8373
Hanno Becker56cdfd12018-08-17 13:42:15 +01008374run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8375 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008376 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8377 hs_timeout=2500-60000" \
8378 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8379 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008380 0 \
8381 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008382 -c "Next handshake message has been buffered - load"\
8383 -S "Buffering HS message" \
8384 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008385 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008386 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008387 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008388 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008389
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008390run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8391 -p "$P_PXY delay_srv=ServerHello" \
Jarno Lamsa33281d52019-10-18 10:54:35 +03008392 "$P_SRV mtu=256 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008393 hs_timeout=2500-60000" \
8394 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8395 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008396 0 \
8397 -c "Buffering HS message" \
8398 -c "found fragmented DTLS handshake message"\
8399 -c "Next handshake message 1 not or only partially bufffered" \
8400 -c "Next handshake message has been buffered - load"\
8401 -S "Buffering HS message" \
8402 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008403 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008404 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008405 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008406 -S "Remember CCS message"
8407
Hanno Beckera1adcca2018-08-24 14:41:07 +01008408# The client buffers the ServerKeyExchange before receiving the fragmented
8409# Certificate message; at the time of writing, together these are aroudn 1200b
8410# in size, so that the bound below ensures that the certificate can be reassembled
8411# while keeping the ServerKeyExchange.
8412requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8413run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008414 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008415 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8416 hs_timeout=2500-60000" \
8417 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8418 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008419 0 \
8420 -c "Buffering HS message" \
8421 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008422 -C "attempt to make space by freeing buffered messages" \
8423 -S "Buffering HS message" \
8424 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008425 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008426 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008427 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008428 -S "Remember CCS message"
8429
8430# The size constraints ensure that the delayed certificate message can't
8431# be reassembled while keeping the ServerKeyExchange message, but it can
8432# when dropping it first.
8433requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8434requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8435run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8436 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008437 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8438 hs_timeout=2500-60000" \
8439 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8440 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008441 0 \
8442 -c "Buffering HS message" \
8443 -c "attempt to make space by freeing buffered future messages" \
8444 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008445 -S "Buffering HS message" \
8446 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008447 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008448 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008449 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008450 -S "Remember CCS message"
8451
Hanno Becker56cdfd12018-08-17 13:42:15 +01008452run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8453 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008454 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8455 hs_timeout=2500-60000" \
8456 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8457 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008458 0 \
8459 -C "Buffering HS message" \
8460 -C "Next handshake message has been buffered - load"\
8461 -s "Buffering HS message" \
8462 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008463 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008464 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008465 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008466 -S "Remember CCS message"
8467
Manuel Pégourié-Gonnardf1c6ad42019-07-01 10:13:04 +02008468# This needs session tickets; otherwise CCS is the first message in its flight
8469requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008470run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8471 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008472 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8473 hs_timeout=2500-60000" \
8474 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8475 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008476 0 \
8477 -C "Buffering HS message" \
8478 -C "Next handshake message has been buffered - load"\
8479 -S "Buffering HS message" \
8480 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008481 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008482 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008483 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008484 -S "Remember CCS message"
8485
Jarno Lamsa33281d52019-10-18 10:54:35 +03008486# This needs session tickets; otherwise CCS is the first message in its flight
8487requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Hanno Becker56cdfd12018-08-17 13:42:15 +01008488run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8489 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008490 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8491 hs_timeout=2500-60000" \
8492 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8493 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008494 0 \
8495 -C "Buffering HS message" \
8496 -C "Next handshake message has been buffered - load"\
8497 -S "Buffering HS message" \
8498 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008499 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008500 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008501 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008502 -s "Remember CCS message"
8503
Hanno Beckera1adcca2018-08-24 14:41:07 +01008504run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008505 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008506 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8507 hs_timeout=2500-60000" \
8508 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8509 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008510 0 \
8511 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008512 -s "Found buffered record from current epoch - load" \
8513 -c "Buffer record from epoch 1" \
8514 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008515
Hanno Beckera1adcca2018-08-24 14:41:07 +01008516# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8517# from the server are delayed, so that the encrypted Finished message
8518# is received and buffered. When the fragmented NewSessionTicket comes
8519# in afterwards, the encrypted Finished message must be freed in order
8520# to make space for the NewSessionTicket to be reassembled.
8521# This works only in very particular circumstances:
8522# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8523# of the NewSessionTicket, but small enough to also allow buffering of
8524# the encrypted Finished message.
8525# - The MTU setting on the server must be so small that the NewSessionTicket
8526# needs to be fragmented.
8527# - All messages sent by the server must be small enough to be either sent
8528# without fragmentation or be reassembled within the bounds of
8529# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8530# handshake, omitting CRTs.
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008531requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8532requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008533run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8534 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardf8c355a2019-05-28 10:21:30 +02008535 "$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 +01008536 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8537 0 \
8538 -s "Buffer record from epoch 1" \
8539 -s "Found buffered record from current epoch - load" \
8540 -c "Buffer record from epoch 1" \
8541 -C "Found buffered record from current epoch - load" \
8542 -c "Enough space available after freeing future epoch record"
8543
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008544# Tests for "randomly unreliable connection": try a variety of flows and peers
8545
8546client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008547run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8548 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008549 "$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 +02008550 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008551 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008552 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8553 0 \
8554 -s "Extra-header:" \
8555 -c "HTTP/1.0 200 OK"
8556
Janos Follath74537a62016-09-02 13:45:28 +01008557client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008558run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8559 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008560 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8561 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008562 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8563 0 \
8564 -s "Extra-header:" \
8565 -c "HTTP/1.0 200 OK"
8566
Janos Follath74537a62016-09-02 13:45:28 +01008567client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008568run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8569 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008570 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8571 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008572 0 \
8573 -s "Extra-header:" \
8574 -c "HTTP/1.0 200 OK"
8575
Janos Follath74537a62016-09-02 13:45:28 +01008576client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008577run_test "DTLS proxy: 3d, FS, client auth" \
8578 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008579 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8580 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008581 0 \
8582 -s "Extra-header:" \
8583 -c "HTTP/1.0 200 OK"
8584
Janos Follath74537a62016-09-02 13:45:28 +01008585client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008586run_test "DTLS proxy: 3d, FS, ticket" \
8587 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008588 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8589 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008590 0 \
8591 -s "Extra-header:" \
8592 -c "HTTP/1.0 200 OK"
8593
Janos Follath74537a62016-09-02 13:45:28 +01008594client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008595run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8596 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008597 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8598 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008599 0 \
8600 -s "Extra-header:" \
8601 -c "HTTP/1.0 200 OK"
8602
Janos Follath74537a62016-09-02 13:45:28 +01008603client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008604run_test "DTLS proxy: 3d, max handshake, nbio" \
8605 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008606 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008607 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008608 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008609 0 \
8610 -s "Extra-header:" \
8611 -c "HTTP/1.0 200 OK"
8612
Janos Follath74537a62016-09-02 13:45:28 +01008613client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008614requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008615requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008616requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008617run_test "DTLS proxy: 3d, min handshake, resumption" \
8618 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008619 "$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 +02008620 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008621 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04008622 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008623 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8624 0 \
8625 -s "a session has been resumed" \
8626 -c "a session has been resumed" \
8627 -s "Extra-header:" \
8628 -c "HTTP/1.0 200 OK"
8629
Janos Follath74537a62016-09-02 13:45:28 +01008630client_needs_more_time 4
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008631requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION
Jarno Lamsa5b52b272019-06-19 10:21:37 +03008632requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS
Jarno Lamsa29f2dd02019-06-20 15:31:52 +03008633requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008634run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8635 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008636 "$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 +02008637 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008638 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Andrzej Kurek825ebd42020-05-18 11:47:25 -04008639 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008640 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8641 0 \
8642 -s "a session has been resumed" \
8643 -c "a session has been resumed" \
8644 -s "Extra-header:" \
8645 -c "HTTP/1.0 200 OK"
8646
Janos Follath74537a62016-09-02 13:45:28 +01008647client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008648requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008649run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008650 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008651 "$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 +02008652 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008653 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008654 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008655 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8656 0 \
8657 -c "=> renegotiate" \
8658 -s "=> renegotiate" \
8659 -s "Extra-header:" \
8660 -c "HTTP/1.0 200 OK"
8661
Janos Follath74537a62016-09-02 13:45:28 +01008662client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008663requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008664run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8665 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008666 "$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 +02008667 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008668 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008669 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008670 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8671 0 \
8672 -c "=> renegotiate" \
8673 -s "=> renegotiate" \
8674 -s "Extra-header:" \
8675 -c "HTTP/1.0 200 OK"
8676
Janos Follath74537a62016-09-02 13:45:28 +01008677client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008678requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008679run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008680 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008681 "$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 +02008682 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008683 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008684 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008685 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008686 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8687 0 \
8688 -c "=> renegotiate" \
8689 -s "=> renegotiate" \
8690 -s "Extra-header:" \
8691 -c "HTTP/1.0 200 OK"
8692
Janos Follath74537a62016-09-02 13:45:28 +01008693client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008694requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008695run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008696 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008697 "$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 +02008698 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008699 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008700 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008701 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008702 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8703 0 \
8704 -c "=> renegotiate" \
8705 -s "=> renegotiate" \
8706 -s "Extra-header:" \
8707 -c "HTTP/1.0 200 OK"
8708
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008709## Interop tests with OpenSSL might trigger a bug in recent versions (including
8710## all versions installed on the CI machines), reported here:
8711## Bug report: https://github.com/openssl/openssl/issues/6902
8712## They should be re-enabled once a fixed version of OpenSSL is available
8713## (this should happen in some 1.1.1_ release according to the ticket).
8714skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008715client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008716not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008717run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008718 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8719 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008720 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008721 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008722 -c "HTTP/1.0 200 OK"
8723
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008724skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008725client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008726not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008727run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8728 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8729 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008730 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008731 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008732 -c "HTTP/1.0 200 OK"
8733
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008734skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008735client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008736not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008737run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8738 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8739 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008740 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008741 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008742 -c "HTTP/1.0 200 OK"
8743
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008744requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008745client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008746not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008747run_test "DTLS proxy: 3d, gnutls server" \
8748 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8749 "$G_SRV -u --mtu 2048 -a" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008750 "$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 +02008751 0 \
8752 -s "Extra-header:" \
8753 -c "Extra-header:"
8754
k-stachowiakabb843e2019-02-18 16:14:03 +01008755requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008756client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008757not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008758run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8759 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008760 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008761 "$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 +02008762 0 \
8763 -s "Extra-header:" \
8764 -c "Extra-header:"
8765
k-stachowiakabb843e2019-02-18 16:14:03 +01008766requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008767client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008768not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008769run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8770 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01008771 "$G_NEXT_SRV -u --mtu 512" \
Hanno Becker843f5bb2019-08-23 17:17:09 +01008772 "$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 +02008773 0 \
8774 -s "Extra-header:" \
8775 -c "Extra-header:"
8776
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008777# Final report
8778
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008779echo "------------------------------------------------------------------------"
8780
8781if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008782 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008783else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008784 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008785fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008786PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008787echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008788
8789exit $FAILS