blob: 41fbf7c287df572f246b4fc0d5713d540b35045d [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
Angus Grattonc4dd0732018-04-11 16:28:39 +100024if cd $( dirname $0 ); then :; else
25 echo "cd $( dirname $0 ) failed" >&2
26 exit 1
27fi
28
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010029# default values, can be overriden by the environment
30: ${P_SRV:=../programs/ssl/ssl_server2}
31: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020032: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010033: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020034: ${GNUTLS_CLI:=gnutls-cli}
35: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020036: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010037
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020038O_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 +010039O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020040G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010041G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020042TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010043
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020044# alternative versions of OpenSSL and GnuTLS (no default path)
45
46if [ -n "${OPENSSL_LEGACY:-}" ]; then
47 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
48 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
49else
50 O_LEGACY_SRV=false
51 O_LEGACY_CLI=false
52fi
53
Hanno Becker58e9dc32018-08-17 15:53:21 +010054if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020055 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
56else
57 G_NEXT_SRV=false
58fi
59
Hanno Becker58e9dc32018-08-17 15:53:21 +010060if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020061 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
62else
63 G_NEXT_CLI=false
64fi
65
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010066TESTS=0
67FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020068SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010069
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000070CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020071
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010073FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020074EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010075
Paul Bakkere20310a2016-05-10 11:18:17 +010076SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010077RUN_TEST_NUMBER=''
78
Paul Bakkeracaac852016-05-10 11:47:13 +010079PRESERVE_LOGS=0
80
Gilles Peskinef93c7d32017-04-14 17:55:28 +020081# Pick a "unique" server port in the range 10000-19999, and a proxy
82# port which is this plus 10000. Each port number may be independently
83# overridden by a command line option.
84SRV_PORT=$(($$ % 10000 + 10000))
85PXY_PORT=$((SRV_PORT + 10000))
86
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010087print_usage() {
88 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010089 printf " -h|--help\tPrint this help.\n"
90 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020091 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
92 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010093 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010094 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010095 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020096 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
97 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010098 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010099}
100
101get_options() {
102 while [ $# -gt 0 ]; do
103 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100104 -f|--filter)
105 shift; FILTER=$1
106 ;;
107 -e|--exclude)
108 shift; EXCLUDE=$1
109 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 -m|--memcheck)
111 MEMCHECK=1
112 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100113 -n|--number)
114 shift; RUN_TEST_NUMBER=$1
115 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100116 -s|--show-numbers)
117 SHOW_TEST_NUMBER=1
118 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100119 -p|--preserve-logs)
120 PRESERVE_LOGS=1
121 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200122 --port)
123 shift; SRV_PORT=$1
124 ;;
125 --proxy-port)
126 shift; PXY_PORT=$1
127 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100128 --seed)
129 shift; SEED="$1"
130 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100131 -h|--help)
132 print_usage
133 exit 0
134 ;;
135 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200136 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100137 print_usage
138 exit 1
139 ;;
140 esac
141 shift
142 done
143}
144
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100145# Skip next test; use this macro to skip tests which are legitimate
146# in theory and expected to be re-introduced at some point, but
147# aren't expected to succeed at the moment due to problems outside
148# our control (such as bugs in other TLS implementations).
149skip_next_test() {
150 SKIP_NEXT="YES"
151}
152
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100153# skip next test if the flag is not enabled in config.h
154requires_config_enabled() {
155 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
156 SKIP_NEXT="YES"
157 fi
158}
159
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200160# skip next test if the flag is enabled in config.h
161requires_config_disabled() {
162 if grep "^#define $1" $CONFIG_H > /dev/null; then
163 SKIP_NEXT="YES"
164 fi
165}
166
Hanno Becker7c48dd12018-08-28 16:09:22 +0100167get_config_value_or_default() {
Hanno Becker5cd017f2018-08-24 14:40:12 +0100168 NAME="$1"
Hanno Beckere6045562018-08-28 11:24:55 +0100169 DEF_VAL=$( grep ".*#define.*${NAME}" ../include/mbedtls/config.h |
Hanno Becker5cd017f2018-08-24 14:40:12 +0100170 sed 's/^.*\s\([0-9]*\)$/\1/' )
Hanno Becker7c48dd12018-08-28 16:09:22 +0100171 ../scripts/config.pl get $NAME || echo "$DEF_VAL"
172}
173
174requires_config_value_at_least() {
175 VAL=$( get_config_value_or_default "$1" )
Hanno Becker5cd017f2018-08-24 14:40:12 +0100176 if [ "$VAL" -lt "$2" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
181requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100182 VAL=$( get_config_value_or_default "$1" )
Hanno Becker5cd017f2018-08-24 14:40:12 +0100183 if [ "$VAL" -gt "$2" ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200188# skip next test if OpenSSL doesn't support FALLBACK_SCSV
189requires_openssl_with_fallback_scsv() {
190 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
191 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
192 then
193 OPENSSL_HAS_FBSCSV="YES"
194 else
195 OPENSSL_HAS_FBSCSV="NO"
196 fi
197 fi
198 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
199 SKIP_NEXT="YES"
200 fi
201}
202
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200203# skip next test if GnuTLS isn't available
204requires_gnutls() {
205 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200206 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200207 GNUTLS_AVAILABLE="YES"
208 else
209 GNUTLS_AVAILABLE="NO"
210 fi
211 fi
212 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
213 SKIP_NEXT="YES"
214 fi
215}
216
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200217# skip next test if GnuTLS-next isn't available
218requires_gnutls_next() {
219 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
220 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
221 GNUTLS_NEXT_AVAILABLE="YES"
222 else
223 GNUTLS_NEXT_AVAILABLE="NO"
224 fi
225 fi
226 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
227 SKIP_NEXT="YES"
228 fi
229}
230
231# skip next test if OpenSSL-legacy isn't available
232requires_openssl_legacy() {
233 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
234 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
235 OPENSSL_LEGACY_AVAILABLE="YES"
236 else
237 OPENSSL_LEGACY_AVAILABLE="NO"
238 fi
239 fi
240 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
241 SKIP_NEXT="YES"
242 fi
243}
244
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200245# skip next test if IPv6 isn't available on this host
246requires_ipv6() {
247 if [ -z "${HAS_IPV6:-}" ]; then
248 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
249 SRV_PID=$!
250 sleep 1
251 kill $SRV_PID >/dev/null 2>&1
252 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
253 HAS_IPV6="NO"
254 else
255 HAS_IPV6="YES"
256 fi
257 rm -r $SRV_OUT
258 fi
259
260 if [ "$HAS_IPV6" = "NO" ]; then
261 SKIP_NEXT="YES"
262 fi
263}
264
Andrzej Kurekb4593462018-10-11 08:43:30 -0400265# skip next test if it's i686 or uname is not available
266requires_not_i686() {
267 if [ -z "${IS_I686:-}" ]; then
268 IS_I686="YES"
269 if which "uname" >/dev/null 2>&1; then
270 if [ -z "$(uname -a | grep i686)" ]; then
271 IS_I686="NO"
272 fi
273 fi
274 fi
275 if [ "$IS_I686" = "YES" ]; then
276 SKIP_NEXT="YES"
277 fi
278}
279
Angus Grattonc4dd0732018-04-11 16:28:39 +1000280# Calculate the input & output maximum content lengths set in the config
281MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
282MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
283MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
284
285if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
286 MAX_CONTENT_LEN="$MAX_IN_LEN"
287fi
288if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
289 MAX_CONTENT_LEN="$MAX_OUT_LEN"
290fi
291
292# skip the next test if the SSL output buffer is less than 16KB
293requires_full_size_output_buffer() {
294 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
295 SKIP_NEXT="YES"
296 fi
297}
298
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200299# skip the next test if valgrind is in use
300not_with_valgrind() {
301 if [ "$MEMCHECK" -gt 0 ]; then
302 SKIP_NEXT="YES"
303 fi
304}
305
Paul Bakker362689d2016-05-13 10:33:25 +0100306# skip the next test if valgrind is NOT in use
307only_with_valgrind() {
308 if [ "$MEMCHECK" -eq 0 ]; then
309 SKIP_NEXT="YES"
310 fi
311}
312
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200313# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100314client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200315 CLI_DELAY_FACTOR=$1
316}
317
Janos Follath74537a62016-09-02 13:45:28 +0100318# wait for the given seconds after the client finished in the next test
319server_needs_more_time() {
320 SRV_DELAY_SECONDS=$1
321}
322
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100323# print_name <name>
324print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100325 TESTS=$(( $TESTS + 1 ))
326 LINE=""
327
328 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
329 LINE="$TESTS "
330 fi
331
332 LINE="$LINE$1"
333 printf "$LINE "
334 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100335 for i in `seq 1 $LEN`; do printf '.'; done
336 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100337
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100338}
339
340# fail <message>
341fail() {
342 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100343 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100344
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200345 mv $SRV_OUT o-srv-${TESTS}.log
346 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200347 if [ -n "$PXY_CMD" ]; then
348 mv $PXY_OUT o-pxy-${TESTS}.log
349 fi
350 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100351
Azim Khan19d13732018-03-29 11:04:20 +0100352 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 +0200353 echo " ! server output:"
354 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200355 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200356 echo " ! client output:"
357 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200358 if [ -n "$PXY_CMD" ]; then
359 echo " ! ========================================================"
360 echo " ! proxy output:"
361 cat o-pxy-${TESTS}.log
362 fi
363 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200364 fi
365
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200366 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100367}
368
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100369# is_polar <cmd_line>
370is_polar() {
371 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
372}
373
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200374# openssl s_server doesn't have -www with DTLS
375check_osrv_dtls() {
376 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
377 NEEDS_INPUT=1
378 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
379 else
380 NEEDS_INPUT=0
381 fi
382}
383
384# provide input to commands that need it
385provide_input() {
386 if [ $NEEDS_INPUT -eq 0 ]; then
387 return
388 fi
389
390 while true; do
391 echo "HTTP/1.0 200 OK"
392 sleep 1
393 done
394}
395
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100396# has_mem_err <log_file_name>
397has_mem_err() {
398 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
399 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
400 then
401 return 1 # false: does not have errors
402 else
403 return 0 # true: has errors
404 fi
405}
406
Gilles Peskine418b5362017-12-14 18:58:42 +0100407# Wait for process $2 to be listening on port $1
408if type lsof >/dev/null 2>/dev/null; then
409 wait_server_start() {
410 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200411 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100412 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200413 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100414 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200415 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100416 # Make a tight loop, server normally takes less than 1s to start.
417 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
418 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
419 echo "SERVERSTART TIMEOUT"
420 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
421 break
422 fi
423 # Linux and *BSD support decimal arguments to sleep. On other
424 # OSes this may be a tight loop.
425 sleep 0.1 2>/dev/null || true
426 done
427 }
428else
Gilles Peskinea9312652018-06-29 15:48:13 +0200429 echo "Warning: lsof not available, wait_server_start = sleep"
Gilles Peskine418b5362017-12-14 18:58:42 +0100430 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200431 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100432 }
433fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200434
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100435# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100436# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100437# acceptable bounds
438check_server_hello_time() {
439 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100440 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100441 # Get the Unix timestamp for now
442 CUR_TIME=$(date +'%s')
443 THRESHOLD_IN_SECS=300
444
445 # Check if the ServerHello time was printed
446 if [ -z "$SERVER_HELLO_TIME" ]; then
447 return 1
448 fi
449
450 # Check the time in ServerHello is within acceptable bounds
451 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
452 # The time in ServerHello is at least 5 minutes before now
453 return 1
454 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100455 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100456 return 1
457 else
458 return 0
459 fi
460}
461
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200462# wait for client to terminate and set CLI_EXIT
463# must be called right after starting the client
464wait_client_done() {
465 CLI_PID=$!
466
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200467 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
468 CLI_DELAY_FACTOR=1
469
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200470 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200471 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200472
473 wait $CLI_PID
474 CLI_EXIT=$?
475
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200476 kill $DOG_PID >/dev/null 2>&1
477 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200478
479 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100480
481 sleep $SRV_DELAY_SECONDS
482 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200483}
484
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200485# check if the given command uses dtls and sets global variable DTLS
486detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200487 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200488 DTLS=1
489 else
490 DTLS=0
491 fi
492}
493
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200494# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100495# Options: -s pattern pattern that must be present in server output
496# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100497# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100498# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100499# -S pattern pattern that must be absent in server output
500# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100501# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100502# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100503run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100504 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200505 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100506
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100507 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
508 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200509 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100510 return
511 fi
512
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100513 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100514
Paul Bakkerb7584a52016-05-10 10:50:43 +0100515 # Do we only run numbered tests?
516 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
517 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
518 else
519 SKIP_NEXT="YES"
520 fi
521
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200522 # should we skip?
523 if [ "X$SKIP_NEXT" = "XYES" ]; then
524 SKIP_NEXT="NO"
525 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200526 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200527 return
528 fi
529
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200530 # does this test use a proxy?
531 if [ "X$1" = "X-p" ]; then
532 PXY_CMD="$2"
533 shift 2
534 else
535 PXY_CMD=""
536 fi
537
538 # get commands and client output
539 SRV_CMD="$1"
540 CLI_CMD="$2"
541 CLI_EXPECT="$3"
542 shift 3
543
544 # fix client port
545 if [ -n "$PXY_CMD" ]; then
546 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
547 else
548 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
549 fi
550
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200551 # update DTLS variable
552 detect_dtls "$SRV_CMD"
553
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100554 # prepend valgrind to our commands if active
555 if [ "$MEMCHECK" -gt 0 ]; then
556 if is_polar "$SRV_CMD"; then
557 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
558 fi
559 if is_polar "$CLI_CMD"; then
560 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
561 fi
562 fi
563
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200564 TIMES_LEFT=2
565 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200566 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200567
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200568 # run the commands
569 if [ -n "$PXY_CMD" ]; then
570 echo "$PXY_CMD" > $PXY_OUT
571 $PXY_CMD >> $PXY_OUT 2>&1 &
572 PXY_PID=$!
573 # assume proxy starts faster than server
574 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200575
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200576 check_osrv_dtls
577 echo "$SRV_CMD" > $SRV_OUT
578 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
579 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100580 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200581
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200582 echo "$CLI_CMD" > $CLI_OUT
583 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
584 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100585
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100586 sleep 0.05
587
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200588 # terminate the server (and the proxy)
589 kill $SRV_PID
590 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100591
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200592 if [ -n "$PXY_CMD" ]; then
593 kill $PXY_PID >/dev/null 2>&1
594 wait $PXY_PID
595 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100596
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200597 # retry only on timeouts
598 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
599 printf "RETRY "
600 else
601 TIMES_LEFT=0
602 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200603 done
604
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100605 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200606 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100607 # expected client exit to incorrectly succeed in case of catastrophic
608 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100609 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200610 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100611 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100612 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100613 return
614 fi
615 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100616 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200617 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100618 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100619 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100620 return
621 fi
622 fi
623
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100624 # check server exit code
625 if [ $? != 0 ]; then
626 fail "server fail"
627 return
628 fi
629
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100630 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100631 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
632 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100633 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200634 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100635 return
636 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100637
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100638 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200639 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100640 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100641 while [ $# -gt 0 ]
642 do
643 case $1 in
644 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100645 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 +0100646 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100647 return
648 fi
649 ;;
650
651 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100652 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 +0100653 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100654 return
655 fi
656 ;;
657
658 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100659 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 +0100660 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100661 return
662 fi
663 ;;
664
665 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100666 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 +0100667 fail "pattern '$2' MUST NOT be present in the Client output"
668 return
669 fi
670 ;;
671
672 # The filtering in the following two options (-u and -U) do the following
673 # - ignore valgrind output
674 # - filter out everything but lines right after the pattern occurances
675 # - keep one of each non-unique line
676 # - count how many lines remain
677 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
678 # if there were no duplicates.
679 "-U")
680 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
681 fail "lines following pattern '$2' must be unique in Server output"
682 return
683 fi
684 ;;
685
686 "-u")
687 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
688 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100689 return
690 fi
691 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100692 "-F")
693 if ! $2 "$SRV_OUT"; then
694 fail "function call to '$2' failed on Server output"
695 return
696 fi
697 ;;
698 "-f")
699 if ! $2 "$CLI_OUT"; then
700 fail "function call to '$2' failed on Client output"
701 return
702 fi
703 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100704
705 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200706 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100707 exit 1
708 esac
709 shift 2
710 done
711
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100712 # check valgrind's results
713 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200714 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100715 fail "Server has memory errors"
716 return
717 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200718 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100719 fail "Client has memory errors"
720 return
721 fi
722 fi
723
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100724 # if we're here, everything is ok
725 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100726 if [ "$PRESERVE_LOGS" -gt 0 ]; then
727 mv $SRV_OUT o-srv-${TESTS}.log
728 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100729 if [ -n "$PXY_CMD" ]; then
730 mv $PXY_OUT o-pxy-${TESTS}.log
731 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100732 fi
733
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200734 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100735}
736
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100737cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200738 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200739 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
740 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
741 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
742 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100743 exit 1
744}
745
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100746#
747# MAIN
748#
749
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100750get_options "$@"
751
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100752# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100753P_SRV_BIN="${P_SRV%%[ ]*}"
754P_CLI_BIN="${P_CLI%%[ ]*}"
755P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100756if [ ! -x "$P_SRV_BIN" ]; then
757 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100758 exit 1
759fi
Hanno Becker17c04932017-10-10 14:44:53 +0100760if [ ! -x "$P_CLI_BIN" ]; then
761 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100762 exit 1
763fi
Hanno Becker17c04932017-10-10 14:44:53 +0100764if [ ! -x "$P_PXY_BIN" ]; then
765 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200766 exit 1
767fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100768if [ "$MEMCHECK" -gt 0 ]; then
769 if which valgrind >/dev/null 2>&1; then :; else
770 echo "Memcheck not possible. Valgrind not found"
771 exit 1
772 fi
773fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100774if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
775 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100776 exit 1
777fi
778
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200779# used by watchdog
780MAIN_PID="$$"
781
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100782# We use somewhat arbitrary delays for tests:
783# - how long do we wait for the server to start (when lsof not available)?
784# - how long do we allow for the client to finish?
785# (not to check performance, just to avoid waiting indefinitely)
786# Things are slower with valgrind, so give extra time here.
787#
788# Note: without lsof, there is a trade-off between the running time of this
789# script and the risk of spurious errors because we didn't wait long enough.
790# The watchdog delay on the other hand doesn't affect normal running time of
791# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200792if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100793 START_DELAY=6
794 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200795else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100796 START_DELAY=2
797 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200798fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100799
800# some particular tests need more time:
801# - for the client, we multiply the usual watchdog limit by a factor
802# - for the server, we sleep for a number of seconds after the client exits
803# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200804CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100805SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200806
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200807# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000808# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200809P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
810P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100811P_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 +0200812O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200813O_CLI="$O_CLI -connect localhost:+SRV_PORT"
814G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200815G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200816
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200817if [ -n "${OPENSSL_LEGACY:-}" ]; then
818 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
819 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
820fi
821
Hanno Becker58e9dc32018-08-17 15:53:21 +0100822if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200823 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
824fi
825
Hanno Becker58e9dc32018-08-17 15:53:21 +0100826if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200827 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200828fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100829
Gilles Peskine62469d92017-05-10 10:13:59 +0200830# Allow SHA-1, because many of our test certificates use it
831P_SRV="$P_SRV allow_sha1=1"
832P_CLI="$P_CLI allow_sha1=1"
833
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200834# Also pick a unique name for intermediate files
835SRV_OUT="srv_out.$$"
836CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200837PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200838SESSION="session.$$"
839
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200840SKIP_NEXT="NO"
841
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100842trap cleanup INT TERM HUP
843
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200844# Basic test
845
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200846# Checks that:
847# - things work with all ciphersuites active (used with config-full in all.sh)
848# - the expected (highest security) parameters are selected
849# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200850run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200851 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200852 "$P_CLI" \
853 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200854 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200855 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200856 -s "client hello v3, signature_algorithm ext: 6" \
857 -s "ECDHE curve: secp521r1" \
858 -S "error" \
859 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200860
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000861run_test "Default, DTLS" \
862 "$P_SRV dtls=1" \
863 "$P_CLI dtls=1" \
864 0 \
865 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200866 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000867
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100868# Test current time in ServerHello
869requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200870run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100871 "$P_SRV debug_level=3" \
872 "$P_CLI debug_level=3" \
873 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100874 -f "check_server_hello_time" \
875 -F "check_server_hello_time"
876
Simon Butcher8e004102016-10-14 00:48:33 +0100877# Test for uniqueness of IVs in AEAD ciphersuites
878run_test "Unique IV in GCM" \
879 "$P_SRV exchanges=20 debug_level=4" \
880 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
881 0 \
882 -u "IV used" \
883 -U "IV used"
884
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100885# Tests for rc4 option
886
Simon Butchera410af52016-05-19 22:12:18 +0100887requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100888run_test "RC4: server disabled, client enabled" \
889 "$P_SRV" \
890 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
891 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100892 -s "SSL - The server has no ciphersuites in common"
893
Simon Butchera410af52016-05-19 22:12:18 +0100894requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100895run_test "RC4: server half, client enabled" \
896 "$P_SRV arc4=1" \
897 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
898 1 \
899 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100900
901run_test "RC4: server enabled, client disabled" \
902 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
903 "$P_CLI" \
904 1 \
905 -s "SSL - The server has no ciphersuites in common"
906
907run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100908 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100909 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
910 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100911 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100912 -S "SSL - The server has no ciphersuites in common"
913
Hanno Beckerd26bb202018-08-17 09:54:10 +0100914# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
915
916requires_gnutls
917requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
918run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
919 "$G_SRV"\
920 "$P_CLI force_version=tls1_1" \
921 0
922
923requires_gnutls
924requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
925run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
926 "$G_SRV"\
927 "$P_CLI force_version=tls1" \
928 0
929
Gilles Peskinebc70a182017-05-09 15:59:24 +0200930# Tests for SHA-1 support
931
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200932requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200933run_test "SHA-1 forbidden by default in server certificate" \
934 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
935 "$P_CLI debug_level=2 allow_sha1=0" \
936 1 \
937 -c "The certificate is signed with an unacceptable hash"
938
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200939requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
940run_test "SHA-1 forbidden by default in server certificate" \
941 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
942 "$P_CLI debug_level=2 allow_sha1=0" \
943 0
944
Gilles Peskinebc70a182017-05-09 15:59:24 +0200945run_test "SHA-1 explicitly allowed in server certificate" \
946 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
947 "$P_CLI allow_sha1=1" \
948 0
949
950run_test "SHA-256 allowed by default in server certificate" \
951 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
952 "$P_CLI allow_sha1=0" \
953 0
954
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200955requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200956run_test "SHA-1 forbidden by default in client certificate" \
957 "$P_SRV auth_mode=required allow_sha1=0" \
958 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
959 1 \
960 -s "The certificate is signed with an unacceptable hash"
961
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200962requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
963run_test "SHA-1 forbidden by default in client certificate" \
964 "$P_SRV auth_mode=required allow_sha1=0" \
965 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
966 0
967
Gilles Peskinebc70a182017-05-09 15:59:24 +0200968run_test "SHA-1 explicitly allowed in client certificate" \
969 "$P_SRV auth_mode=required allow_sha1=1" \
970 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
971 0
972
973run_test "SHA-256 allowed by default in client certificate" \
974 "$P_SRV auth_mode=required allow_sha1=0" \
975 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
976 0
977
Hanno Becker7ae8a762018-08-14 15:43:35 +0100978# Tests for datagram packing
979run_test "DTLS: multiple records in same datagram, client and server" \
980 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
981 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
982 0 \
983 -c "next record in same datagram" \
984 -s "next record in same datagram"
985
986run_test "DTLS: multiple records in same datagram, client only" \
987 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
988 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
989 0 \
990 -s "next record in same datagram" \
991 -C "next record in same datagram"
992
993run_test "DTLS: multiple records in same datagram, server only" \
994 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
995 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
996 0 \
997 -S "next record in same datagram" \
998 -c "next record in same datagram"
999
1000run_test "DTLS: multiple records in same datagram, neither client nor server" \
1001 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1002 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1003 0 \
1004 -S "next record in same datagram" \
1005 -C "next record in same datagram"
1006
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001007# Tests for Truncated HMAC extension
1008
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001009run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001010 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001011 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001012 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001013 -s "dumping 'expected mac' (20 bytes)" \
1014 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001015
Hanno Becker32c55012017-11-10 08:42:54 +00001016requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001017run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001018 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001019 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001020 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001021 -s "dumping 'expected mac' (20 bytes)" \
1022 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001023
Hanno Becker32c55012017-11-10 08:42:54 +00001024requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001025run_test "Truncated HMAC: client enabled, server default" \
1026 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001027 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001028 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001029 -s "dumping 'expected mac' (20 bytes)" \
1030 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001031
Hanno Becker32c55012017-11-10 08:42:54 +00001032requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001033run_test "Truncated HMAC: client enabled, server disabled" \
1034 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001035 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001036 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001037 -s "dumping 'expected mac' (20 bytes)" \
1038 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001039
Hanno Becker32c55012017-11-10 08:42:54 +00001040requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001041run_test "Truncated HMAC: client disabled, server enabled" \
1042 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001043 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001044 0 \
1045 -s "dumping 'expected mac' (20 bytes)" \
1046 -S "dumping 'expected mac' (10 bytes)"
1047
1048requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001049run_test "Truncated HMAC: client enabled, server enabled" \
1050 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001051 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001052 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001053 -S "dumping 'expected mac' (20 bytes)" \
1054 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001055
Hanno Becker4c4f4102017-11-10 09:16:05 +00001056run_test "Truncated HMAC, DTLS: client default, server default" \
1057 "$P_SRV dtls=1 debug_level=4" \
1058 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1059 0 \
1060 -s "dumping 'expected mac' (20 bytes)" \
1061 -S "dumping 'expected mac' (10 bytes)"
1062
1063requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1064run_test "Truncated HMAC, DTLS: client disabled, server default" \
1065 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001066 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001067 0 \
1068 -s "dumping 'expected mac' (20 bytes)" \
1069 -S "dumping 'expected mac' (10 bytes)"
1070
1071requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1072run_test "Truncated HMAC, DTLS: client enabled, server default" \
1073 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001074 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001075 0 \
1076 -s "dumping 'expected mac' (20 bytes)" \
1077 -S "dumping 'expected mac' (10 bytes)"
1078
1079requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1080run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1081 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001082 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001083 0 \
1084 -s "dumping 'expected mac' (20 bytes)" \
1085 -S "dumping 'expected mac' (10 bytes)"
1086
1087requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1088run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1089 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001090 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001091 0 \
1092 -s "dumping 'expected mac' (20 bytes)" \
1093 -S "dumping 'expected mac' (10 bytes)"
1094
1095requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1096run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1097 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001098 "$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 +01001099 0 \
1100 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001101 -s "dumping 'expected mac' (10 bytes)"
1102
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001103# Tests for Encrypt-then-MAC extension
1104
1105run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001106 "$P_SRV debug_level=3 \
1107 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001108 "$P_CLI debug_level=3" \
1109 0 \
1110 -c "client hello, adding encrypt_then_mac extension" \
1111 -s "found encrypt then mac extension" \
1112 -s "server hello, adding encrypt then mac extension" \
1113 -c "found encrypt_then_mac extension" \
1114 -c "using encrypt then mac" \
1115 -s "using encrypt then mac"
1116
1117run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001118 "$P_SRV debug_level=3 etm=0 \
1119 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001120 "$P_CLI debug_level=3 etm=1" \
1121 0 \
1122 -c "client hello, adding encrypt_then_mac extension" \
1123 -s "found encrypt then mac extension" \
1124 -S "server hello, adding encrypt then mac extension" \
1125 -C "found encrypt_then_mac extension" \
1126 -C "using encrypt then mac" \
1127 -S "using encrypt then mac"
1128
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001129run_test "Encrypt then MAC: client enabled, aead cipher" \
1130 "$P_SRV debug_level=3 etm=1 \
1131 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1132 "$P_CLI debug_level=3 etm=1" \
1133 0 \
1134 -c "client hello, adding encrypt_then_mac extension" \
1135 -s "found encrypt then mac extension" \
1136 -S "server hello, adding encrypt then mac extension" \
1137 -C "found encrypt_then_mac extension" \
1138 -C "using encrypt then mac" \
1139 -S "using encrypt then mac"
1140
1141run_test "Encrypt then MAC: client enabled, stream cipher" \
1142 "$P_SRV debug_level=3 etm=1 \
1143 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001144 "$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 +01001145 0 \
1146 -c "client hello, adding encrypt_then_mac extension" \
1147 -s "found encrypt then mac extension" \
1148 -S "server hello, adding encrypt then mac extension" \
1149 -C "found encrypt_then_mac extension" \
1150 -C "using encrypt then mac" \
1151 -S "using encrypt then mac"
1152
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001153run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001154 "$P_SRV debug_level=3 etm=1 \
1155 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001156 "$P_CLI debug_level=3 etm=0" \
1157 0 \
1158 -C "client hello, adding encrypt_then_mac extension" \
1159 -S "found encrypt then mac extension" \
1160 -S "server hello, adding encrypt then mac extension" \
1161 -C "found encrypt_then_mac extension" \
1162 -C "using encrypt then mac" \
1163 -S "using encrypt then mac"
1164
Janos Follathe2681a42016-03-07 15:57:05 +00001165requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001166run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001167 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001168 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001169 "$P_CLI debug_level=3 force_version=ssl3" \
1170 0 \
1171 -C "client hello, adding encrypt_then_mac extension" \
1172 -S "found encrypt then mac extension" \
1173 -S "server hello, adding encrypt then mac extension" \
1174 -C "found encrypt_then_mac extension" \
1175 -C "using encrypt then mac" \
1176 -S "using encrypt then mac"
1177
Janos Follathe2681a42016-03-07 15:57:05 +00001178requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001179run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001180 "$P_SRV debug_level=3 force_version=ssl3 \
1181 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001182 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001183 0 \
1184 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001185 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001186 -S "server hello, adding encrypt then mac extension" \
1187 -C "found encrypt_then_mac extension" \
1188 -C "using encrypt then mac" \
1189 -S "using encrypt then mac"
1190
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001191# Tests for Extended Master Secret extension
1192
1193run_test "Extended Master Secret: default" \
1194 "$P_SRV debug_level=3" \
1195 "$P_CLI debug_level=3" \
1196 0 \
1197 -c "client hello, adding extended_master_secret extension" \
1198 -s "found extended master secret extension" \
1199 -s "server hello, adding extended master secret extension" \
1200 -c "found extended_master_secret extension" \
1201 -c "using extended master secret" \
1202 -s "using extended master secret"
1203
1204run_test "Extended Master Secret: client enabled, server disabled" \
1205 "$P_SRV debug_level=3 extended_ms=0" \
1206 "$P_CLI debug_level=3 extended_ms=1" \
1207 0 \
1208 -c "client hello, adding extended_master_secret extension" \
1209 -s "found extended master secret extension" \
1210 -S "server hello, adding extended master secret extension" \
1211 -C "found extended_master_secret extension" \
1212 -C "using extended master secret" \
1213 -S "using extended master secret"
1214
1215run_test "Extended Master Secret: client disabled, server enabled" \
1216 "$P_SRV debug_level=3 extended_ms=1" \
1217 "$P_CLI debug_level=3 extended_ms=0" \
1218 0 \
1219 -C "client hello, adding extended_master_secret extension" \
1220 -S "found extended master secret extension" \
1221 -S "server hello, adding extended master secret extension" \
1222 -C "found extended_master_secret extension" \
1223 -C "using extended master secret" \
1224 -S "using extended master secret"
1225
Janos Follathe2681a42016-03-07 15:57:05 +00001226requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001227run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001228 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001229 "$P_CLI debug_level=3 force_version=ssl3" \
1230 0 \
1231 -C "client hello, adding extended_master_secret extension" \
1232 -S "found extended master secret extension" \
1233 -S "server hello, adding extended master secret extension" \
1234 -C "found extended_master_secret extension" \
1235 -C "using extended master secret" \
1236 -S "using extended master secret"
1237
Janos Follathe2681a42016-03-07 15:57:05 +00001238requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001239run_test "Extended Master Secret: client enabled, server SSLv3" \
1240 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001241 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001242 0 \
1243 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001244 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001245 -S "server hello, adding extended master secret extension" \
1246 -C "found extended_master_secret extension" \
1247 -C "using extended master secret" \
1248 -S "using extended master secret"
1249
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001250# Tests for FALLBACK_SCSV
1251
1252run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001253 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001254 "$P_CLI debug_level=3 force_version=tls1_1" \
1255 0 \
1256 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001257 -S "received FALLBACK_SCSV" \
1258 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001259 -C "is a fatal alert message (msg 86)"
1260
1261run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001262 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001263 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1264 0 \
1265 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001266 -S "received FALLBACK_SCSV" \
1267 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001268 -C "is a fatal alert message (msg 86)"
1269
1270run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001271 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001272 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001273 1 \
1274 -c "adding FALLBACK_SCSV" \
1275 -s "received FALLBACK_SCSV" \
1276 -s "inapropriate fallback" \
1277 -c "is a fatal alert message (msg 86)"
1278
1279run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001280 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001281 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001282 0 \
1283 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001284 -s "received FALLBACK_SCSV" \
1285 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001286 -C "is a fatal alert message (msg 86)"
1287
1288requires_openssl_with_fallback_scsv
1289run_test "Fallback SCSV: default, openssl server" \
1290 "$O_SRV" \
1291 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1292 0 \
1293 -C "adding FALLBACK_SCSV" \
1294 -C "is a fatal alert message (msg 86)"
1295
1296requires_openssl_with_fallback_scsv
1297run_test "Fallback SCSV: enabled, openssl server" \
1298 "$O_SRV" \
1299 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1300 1 \
1301 -c "adding FALLBACK_SCSV" \
1302 -c "is a fatal alert message (msg 86)"
1303
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001304requires_openssl_with_fallback_scsv
1305run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001306 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001307 "$O_CLI -tls1_1" \
1308 0 \
1309 -S "received FALLBACK_SCSV" \
1310 -S "inapropriate fallback"
1311
1312requires_openssl_with_fallback_scsv
1313run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001314 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001315 "$O_CLI -tls1_1 -fallback_scsv" \
1316 1 \
1317 -s "received FALLBACK_SCSV" \
1318 -s "inapropriate fallback"
1319
1320requires_openssl_with_fallback_scsv
1321run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001322 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001323 "$O_CLI -fallback_scsv" \
1324 0 \
1325 -s "received FALLBACK_SCSV" \
1326 -S "inapropriate fallback"
1327
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001328# Test sending and receiving empty application data records
1329
1330run_test "Encrypt then MAC: empty application data record" \
1331 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1332 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1333 0 \
1334 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1335 -s "dumping 'input payload after decrypt' (0 bytes)" \
1336 -c "0 bytes written in 1 fragments"
1337
1338run_test "Default, no Encrypt then MAC: empty application data record" \
1339 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1340 "$P_CLI auth_mode=none etm=0 request_size=0" \
1341 0 \
1342 -s "dumping 'input payload after decrypt' (0 bytes)" \
1343 -c "0 bytes written in 1 fragments"
1344
1345run_test "Encrypt then MAC, DTLS: empty application data record" \
1346 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1347 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1348 0 \
1349 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1350 -s "dumping 'input payload after decrypt' (0 bytes)" \
1351 -c "0 bytes written in 1 fragments"
1352
1353run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
1354 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1355 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1356 0 \
1357 -s "dumping 'input payload after decrypt' (0 bytes)" \
1358 -c "0 bytes written in 1 fragments"
1359
Gilles Peskined50177f2017-05-16 17:53:03 +02001360## ClientHello generated with
1361## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1362## then manually twiddling the ciphersuite list.
1363## The ClientHello content is spelled out below as a hex string as
1364## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1365## The expected response is an inappropriate_fallback alert.
1366requires_openssl_with_fallback_scsv
1367run_test "Fallback SCSV: beginning of list" \
1368 "$P_SRV debug_level=2" \
1369 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1370 0 \
1371 -s "received FALLBACK_SCSV" \
1372 -s "inapropriate fallback"
1373
1374requires_openssl_with_fallback_scsv
1375run_test "Fallback SCSV: end of list" \
1376 "$P_SRV debug_level=2" \
1377 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1378 0 \
1379 -s "received FALLBACK_SCSV" \
1380 -s "inapropriate fallback"
1381
1382## Here the expected response is a valid ServerHello prefix, up to the random.
1383requires_openssl_with_fallback_scsv
1384run_test "Fallback SCSV: not in list" \
1385 "$P_SRV debug_level=2" \
1386 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1387 0 \
1388 -S "received FALLBACK_SCSV" \
1389 -S "inapropriate fallback"
1390
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001391# Tests for CBC 1/n-1 record splitting
1392
1393run_test "CBC Record splitting: TLS 1.2, no splitting" \
1394 "$P_SRV" \
1395 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1396 request_size=123 force_version=tls1_2" \
1397 0 \
1398 -s "Read from client: 123 bytes read" \
1399 -S "Read from client: 1 bytes read" \
1400 -S "122 bytes read"
1401
1402run_test "CBC Record splitting: TLS 1.1, no splitting" \
1403 "$P_SRV" \
1404 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1405 request_size=123 force_version=tls1_1" \
1406 0 \
1407 -s "Read from client: 123 bytes read" \
1408 -S "Read from client: 1 bytes read" \
1409 -S "122 bytes read"
1410
1411run_test "CBC Record splitting: TLS 1.0, splitting" \
1412 "$P_SRV" \
1413 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1414 request_size=123 force_version=tls1" \
1415 0 \
1416 -S "Read from client: 123 bytes read" \
1417 -s "Read from client: 1 bytes read" \
1418 -s "122 bytes read"
1419
Janos Follathe2681a42016-03-07 15:57:05 +00001420requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001421run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001422 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001423 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1424 request_size=123 force_version=ssl3" \
1425 0 \
1426 -S "Read from client: 123 bytes read" \
1427 -s "Read from client: 1 bytes read" \
1428 -s "122 bytes read"
1429
1430run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001431 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001432 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1433 request_size=123 force_version=tls1" \
1434 0 \
1435 -s "Read from client: 123 bytes read" \
1436 -S "Read from client: 1 bytes read" \
1437 -S "122 bytes read"
1438
1439run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1440 "$P_SRV" \
1441 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1442 request_size=123 force_version=tls1 recsplit=0" \
1443 0 \
1444 -s "Read from client: 123 bytes read" \
1445 -S "Read from client: 1 bytes read" \
1446 -S "122 bytes read"
1447
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001448run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1449 "$P_SRV nbio=2" \
1450 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1451 request_size=123 force_version=tls1" \
1452 0 \
1453 -S "Read from client: 123 bytes read" \
1454 -s "Read from client: 1 bytes read" \
1455 -s "122 bytes read"
1456
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001457# Tests for Session Tickets
1458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001459run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001460 "$P_SRV debug_level=3 tickets=1" \
1461 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001462 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001463 -c "client hello, adding session ticket extension" \
1464 -s "found session ticket extension" \
1465 -s "server hello, adding session ticket extension" \
1466 -c "found session_ticket extension" \
1467 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001468 -S "session successfully restored from cache" \
1469 -s "session successfully restored from ticket" \
1470 -s "a session has been resumed" \
1471 -c "a session has been resumed"
1472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001473run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001474 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1475 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001476 0 \
1477 -c "client hello, adding session ticket extension" \
1478 -s "found session ticket extension" \
1479 -s "server hello, adding session ticket extension" \
1480 -c "found session_ticket extension" \
1481 -c "parse new session ticket" \
1482 -S "session successfully restored from cache" \
1483 -s "session successfully restored from ticket" \
1484 -s "a session has been resumed" \
1485 -c "a session has been resumed"
1486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001487run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001488 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1489 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001490 0 \
1491 -c "client hello, adding session ticket extension" \
1492 -s "found session ticket extension" \
1493 -s "server hello, adding session ticket extension" \
1494 -c "found session_ticket extension" \
1495 -c "parse new session ticket" \
1496 -S "session successfully restored from cache" \
1497 -S "session successfully restored from ticket" \
1498 -S "a session has been resumed" \
1499 -C "a session has been resumed"
1500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001501run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001502 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001503 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001504 0 \
1505 -c "client hello, adding session ticket extension" \
1506 -c "found session_ticket extension" \
1507 -c "parse new session ticket" \
1508 -c "a session has been resumed"
1509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001510run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001511 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001512 "( $O_CLI -sess_out $SESSION; \
1513 $O_CLI -sess_in $SESSION; \
1514 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001515 0 \
1516 -s "found session ticket extension" \
1517 -s "server hello, adding session ticket extension" \
1518 -S "session successfully restored from cache" \
1519 -s "session successfully restored from ticket" \
1520 -s "a session has been resumed"
1521
Hanno Becker1d739932018-08-21 13:55:22 +01001522# Tests for Session Tickets with DTLS
1523
1524run_test "Session resume using tickets, DTLS: basic" \
1525 "$P_SRV debug_level=3 dtls=1 tickets=1" \
1526 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
1527 0 \
1528 -c "client hello, adding session ticket extension" \
1529 -s "found session ticket extension" \
1530 -s "server hello, adding session ticket extension" \
1531 -c "found session_ticket extension" \
1532 -c "parse new session ticket" \
1533 -S "session successfully restored from cache" \
1534 -s "session successfully restored from ticket" \
1535 -s "a session has been resumed" \
1536 -c "a session has been resumed"
1537
1538run_test "Session resume using tickets, DTLS: cache disabled" \
1539 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
1540 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \
1541 0 \
1542 -c "client hello, adding session ticket extension" \
1543 -s "found session ticket extension" \
1544 -s "server hello, adding session ticket extension" \
1545 -c "found session_ticket extension" \
1546 -c "parse new session ticket" \
1547 -S "session successfully restored from cache" \
1548 -s "session successfully restored from ticket" \
1549 -s "a session has been resumed" \
1550 -c "a session has been resumed"
1551
1552run_test "Session resume using tickets, DTLS: timeout" \
1553 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
1554 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \
1555 0 \
1556 -c "client hello, adding session ticket extension" \
1557 -s "found session ticket extension" \
1558 -s "server hello, adding session ticket extension" \
1559 -c "found session_ticket extension" \
1560 -c "parse new session ticket" \
1561 -S "session successfully restored from cache" \
1562 -S "session successfully restored from ticket" \
1563 -S "a session has been resumed" \
1564 -C "a session has been resumed"
1565
1566run_test "Session resume using tickets, DTLS: openssl server" \
1567 "$O_SRV -dtls1" \
1568 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1569 0 \
1570 -c "client hello, adding session ticket extension" \
1571 -c "found session_ticket extension" \
1572 -c "parse new session ticket" \
1573 -c "a session has been resumed"
1574
1575run_test "Session resume using tickets, DTLS: openssl client" \
1576 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1577 "( $O_CLI -dtls1 -sess_out $SESSION; \
1578 $O_CLI -dtls1 -sess_in $SESSION; \
1579 rm -f $SESSION )" \
1580 0 \
1581 -s "found session ticket extension" \
1582 -s "server hello, adding session ticket extension" \
1583 -S "session successfully restored from cache" \
1584 -s "session successfully restored from ticket" \
1585 -s "a session has been resumed"
1586
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001587# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001589run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001590 "$P_SRV debug_level=3 tickets=0" \
1591 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001592 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001593 -c "client hello, adding session ticket extension" \
1594 -s "found session ticket extension" \
1595 -S "server hello, adding session ticket extension" \
1596 -C "found session_ticket extension" \
1597 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001598 -s "session successfully restored from cache" \
1599 -S "session successfully restored from ticket" \
1600 -s "a session has been resumed" \
1601 -c "a session has been resumed"
1602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001603run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001604 "$P_SRV debug_level=3 tickets=1" \
1605 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001606 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001607 -C "client hello, adding session ticket extension" \
1608 -S "found session ticket extension" \
1609 -S "server hello, adding session ticket extension" \
1610 -C "found session_ticket extension" \
1611 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001612 -s "session successfully restored from cache" \
1613 -S "session successfully restored from ticket" \
1614 -s "a session has been resumed" \
1615 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001617run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001618 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1619 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001620 0 \
1621 -S "session successfully restored from cache" \
1622 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001623 -S "a session has been resumed" \
1624 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001625
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001626run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001627 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1628 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001629 0 \
1630 -s "session successfully restored from cache" \
1631 -S "session successfully restored from ticket" \
1632 -s "a session has been resumed" \
1633 -c "a session has been resumed"
1634
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001635run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001636 "$P_SRV debug_level=3 tickets=0" \
1637 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001638 0 \
1639 -s "session successfully restored from cache" \
1640 -S "session successfully restored from ticket" \
1641 -s "a session has been resumed" \
1642 -c "a session has been resumed"
1643
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001644run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001645 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1646 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001647 0 \
1648 -S "session successfully restored from cache" \
1649 -S "session successfully restored from ticket" \
1650 -S "a session has been resumed" \
1651 -C "a session has been resumed"
1652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001653run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001654 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1655 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001656 0 \
1657 -s "session successfully restored from cache" \
1658 -S "session successfully restored from ticket" \
1659 -s "a session has been resumed" \
1660 -c "a session has been resumed"
1661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001662run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001663 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001664 "( $O_CLI -sess_out $SESSION; \
1665 $O_CLI -sess_in $SESSION; \
1666 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001667 0 \
1668 -s "found session ticket extension" \
1669 -S "server hello, adding session ticket extension" \
1670 -s "session successfully restored from cache" \
1671 -S "session successfully restored from ticket" \
1672 -s "a session has been resumed"
1673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001674run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001675 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001676 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001677 0 \
1678 -C "found session_ticket extension" \
1679 -C "parse new session ticket" \
1680 -c "a session has been resumed"
1681
Hanno Becker1d739932018-08-21 13:55:22 +01001682# Tests for Session Resume based on session-ID and cache, DTLS
1683
1684run_test "Session resume using cache, DTLS: tickets enabled on client" \
1685 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1686 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1687 0 \
1688 -c "client hello, adding session ticket extension" \
1689 -s "found session ticket extension" \
1690 -S "server hello, adding session ticket extension" \
1691 -C "found session_ticket extension" \
1692 -C "parse new session ticket" \
1693 -s "session successfully restored from cache" \
1694 -S "session successfully restored from ticket" \
1695 -s "a session has been resumed" \
1696 -c "a session has been resumed"
1697
1698run_test "Session resume using cache, DTLS: tickets enabled on server" \
1699 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1700 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1701 0 \
1702 -C "client hello, adding session ticket extension" \
1703 -S "found session ticket extension" \
1704 -S "server hello, adding session ticket extension" \
1705 -C "found session_ticket extension" \
1706 -C "parse new session ticket" \
1707 -s "session successfully restored from cache" \
1708 -S "session successfully restored from ticket" \
1709 -s "a session has been resumed" \
1710 -c "a session has been resumed"
1711
1712run_test "Session resume using cache, DTLS: cache_max=0" \
1713 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
1714 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1715 0 \
1716 -S "session successfully restored from cache" \
1717 -S "session successfully restored from ticket" \
1718 -S "a session has been resumed" \
1719 -C "a session has been resumed"
1720
1721run_test "Session resume using cache, DTLS: cache_max=1" \
1722 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
1723 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1724 0 \
1725 -s "session successfully restored from cache" \
1726 -S "session successfully restored from ticket" \
1727 -s "a session has been resumed" \
1728 -c "a session has been resumed"
1729
1730run_test "Session resume using cache, DTLS: timeout > delay" \
1731 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1732 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
1733 0 \
1734 -s "session successfully restored from cache" \
1735 -S "session successfully restored from ticket" \
1736 -s "a session has been resumed" \
1737 -c "a session has been resumed"
1738
1739run_test "Session resume using cache, DTLS: timeout < delay" \
1740 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
1741 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
1742 0 \
1743 -S "session successfully restored from cache" \
1744 -S "session successfully restored from ticket" \
1745 -S "a session has been resumed" \
1746 -C "a session has been resumed"
1747
1748run_test "Session resume using cache, DTLS: no timeout" \
1749 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
1750 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
1751 0 \
1752 -s "session successfully restored from cache" \
1753 -S "session successfully restored from ticket" \
1754 -s "a session has been resumed" \
1755 -c "a session has been resumed"
1756
1757run_test "Session resume using cache, DTLS: openssl client" \
1758 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1759 "( $O_CLI -dtls1 -sess_out $SESSION; \
1760 $O_CLI -dtls1 -sess_in $SESSION; \
1761 rm -f $SESSION )" \
1762 0 \
1763 -s "found session ticket extension" \
1764 -S "server hello, adding session ticket extension" \
1765 -s "session successfully restored from cache" \
1766 -S "session successfully restored from ticket" \
1767 -s "a session has been resumed"
1768
1769run_test "Session resume using cache, DTLS: openssl server" \
1770 "$O_SRV -dtls1" \
1771 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1772 0 \
1773 -C "found session_ticket extension" \
1774 -C "parse new session ticket" \
1775 -c "a session has been resumed"
1776
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001777# Tests for Max Fragment Length extension
1778
Angus Grattonc4dd0732018-04-11 16:28:39 +10001779if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
1780 printf "${CONFIG_H} defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n"
Hanno Becker6428f8d2017-09-22 16:58:50 +01001781 exit 1
1782fi
1783
Angus Grattonc4dd0732018-04-11 16:28:39 +10001784if [ $MAX_CONTENT_LEN -ne 16384 ]; then
1785 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
1786fi
1787
Hanno Becker4aed27e2017-09-18 15:00:34 +01001788requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001789run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001790 "$P_SRV debug_level=3" \
1791 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001792 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001793 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1794 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001795 -C "client hello, adding max_fragment_length extension" \
1796 -S "found max fragment length extension" \
1797 -S "server hello, max_fragment_length extension" \
1798 -C "found max_fragment_length extension"
1799
Hanno Becker4aed27e2017-09-18 15:00:34 +01001800requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001801run_test "Max fragment length: enabled, default, larger message" \
1802 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001803 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001804 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001805 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1806 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001807 -C "client hello, adding max_fragment_length extension" \
1808 -S "found max fragment length extension" \
1809 -S "server hello, max_fragment_length extension" \
1810 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001811 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1812 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001813 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001814
1815requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1816run_test "Max fragment length, DTLS: enabled, default, larger message" \
1817 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001818 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001819 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001820 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1821 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001822 -C "client hello, adding max_fragment_length extension" \
1823 -S "found max fragment length extension" \
1824 -S "server hello, max_fragment_length extension" \
1825 -C "found max_fragment_length extension" \
1826 -c "fragment larger than.*maximum "
1827
Angus Grattonc4dd0732018-04-11 16:28:39 +10001828# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1829# (session fragment length will be 16384 regardless of mbedtls
1830# content length configuration.)
1831
Hanno Beckerc5266962017-09-18 15:01:50 +01001832requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1833run_test "Max fragment length: disabled, larger message" \
1834 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001835 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001836 0 \
1837 -C "Maximum fragment length is 16384" \
1838 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001839 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1840 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001841 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001842
1843requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1844run_test "Max fragment length DTLS: disabled, larger message" \
1845 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001846 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001847 1 \
1848 -C "Maximum fragment length is 16384" \
1849 -S "Maximum fragment length is 16384" \
1850 -c "fragment larger than.*maximum "
1851
1852requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001853run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001854 "$P_SRV debug_level=3" \
1855 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001856 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001857 -c "Maximum fragment length is 4096" \
1858 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001859 -c "client hello, adding max_fragment_length extension" \
1860 -s "found max fragment length extension" \
1861 -s "server hello, max_fragment_length extension" \
1862 -c "found max_fragment_length extension"
1863
Hanno Becker4aed27e2017-09-18 15:00:34 +01001864requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001865run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001866 "$P_SRV debug_level=3 max_frag_len=4096" \
1867 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001868 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001869 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001870 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001871 -C "client hello, adding max_fragment_length extension" \
1872 -S "found max fragment length extension" \
1873 -S "server hello, max_fragment_length extension" \
1874 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001875
Hanno Becker4aed27e2017-09-18 15:00:34 +01001876requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001877requires_gnutls
1878run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001879 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001880 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001881 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001882 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001883 -c "client hello, adding max_fragment_length extension" \
1884 -c "found max_fragment_length extension"
1885
Hanno Becker4aed27e2017-09-18 15:00:34 +01001886requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001887run_test "Max fragment length: client, message just fits" \
1888 "$P_SRV debug_level=3" \
1889 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1890 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001891 -c "Maximum fragment length is 2048" \
1892 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001893 -c "client hello, adding max_fragment_length extension" \
1894 -s "found max fragment length extension" \
1895 -s "server hello, max_fragment_length extension" \
1896 -c "found max_fragment_length extension" \
1897 -c "2048 bytes written in 1 fragments" \
1898 -s "2048 bytes read"
1899
Hanno Becker4aed27e2017-09-18 15:00:34 +01001900requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001901run_test "Max fragment length: client, larger message" \
1902 "$P_SRV debug_level=3" \
1903 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1904 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001905 -c "Maximum fragment length is 2048" \
1906 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001907 -c "client hello, adding max_fragment_length extension" \
1908 -s "found max fragment length extension" \
1909 -s "server hello, max_fragment_length extension" \
1910 -c "found max_fragment_length extension" \
1911 -c "2345 bytes written in 2 fragments" \
1912 -s "2048 bytes read" \
1913 -s "297 bytes read"
1914
Hanno Becker4aed27e2017-09-18 15:00:34 +01001915requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001916run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001917 "$P_SRV debug_level=3 dtls=1" \
1918 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1919 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001920 -c "Maximum fragment length is 2048" \
1921 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001922 -c "client hello, adding max_fragment_length extension" \
1923 -s "found max fragment length extension" \
1924 -s "server hello, max_fragment_length extension" \
1925 -c "found max_fragment_length extension" \
1926 -c "fragment larger than.*maximum"
1927
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001928# Tests for renegotiation
1929
Hanno Becker6a243642017-10-12 15:18:45 +01001930# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001931run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001932 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001933 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001934 0 \
1935 -C "client hello, adding renegotiation extension" \
1936 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1937 -S "found renegotiation extension" \
1938 -s "server hello, secure renegotiation extension" \
1939 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001940 -C "=> renegotiate" \
1941 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001942 -S "write hello request"
1943
Hanno Becker6a243642017-10-12 15:18:45 +01001944requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001945run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001946 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001947 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001948 0 \
1949 -c "client hello, adding renegotiation extension" \
1950 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1951 -s "found renegotiation extension" \
1952 -s "server hello, secure renegotiation extension" \
1953 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001954 -c "=> renegotiate" \
1955 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001956 -S "write hello request"
1957
Hanno Becker6a243642017-10-12 15:18:45 +01001958requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001959run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001960 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001961 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001962 0 \
1963 -c "client hello, adding renegotiation extension" \
1964 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1965 -s "found renegotiation extension" \
1966 -s "server hello, secure renegotiation extension" \
1967 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001968 -c "=> renegotiate" \
1969 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001970 -s "write hello request"
1971
Janos Follathb0f148c2017-10-05 12:29:42 +01001972# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1973# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1974# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001975requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001976run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1977 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1978 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1979 0 \
1980 -c "client hello, adding renegotiation extension" \
1981 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1982 -s "found renegotiation extension" \
1983 -s "server hello, secure renegotiation extension" \
1984 -c "found renegotiation extension" \
1985 -c "=> renegotiate" \
1986 -s "=> renegotiate" \
1987 -S "write hello request" \
1988 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1989
1990# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1991# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1992# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001993requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001994run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1995 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1996 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1997 0 \
1998 -c "client hello, adding renegotiation extension" \
1999 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2000 -s "found renegotiation extension" \
2001 -s "server hello, secure renegotiation extension" \
2002 -c "found renegotiation extension" \
2003 -c "=> renegotiate" \
2004 -s "=> renegotiate" \
2005 -s "write hello request" \
2006 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2007
Hanno Becker6a243642017-10-12 15:18:45 +01002008requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002009run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002010 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002011 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002012 0 \
2013 -c "client hello, adding renegotiation extension" \
2014 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2015 -s "found renegotiation extension" \
2016 -s "server hello, secure renegotiation extension" \
2017 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002018 -c "=> renegotiate" \
2019 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002020 -s "write hello request"
2021
Hanno Becker6a243642017-10-12 15:18:45 +01002022requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002023run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002024 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002025 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002026 1 \
2027 -c "client hello, adding renegotiation extension" \
2028 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2029 -S "found renegotiation extension" \
2030 -s "server hello, secure renegotiation extension" \
2031 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002032 -c "=> renegotiate" \
2033 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002034 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002035 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002036 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002037
Hanno Becker6a243642017-10-12 15:18:45 +01002038requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002039run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002040 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002041 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002042 0 \
2043 -C "client hello, adding renegotiation extension" \
2044 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2045 -S "found renegotiation extension" \
2046 -s "server hello, secure renegotiation extension" \
2047 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002048 -C "=> renegotiate" \
2049 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002050 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002051 -S "SSL - An unexpected message was received from our peer" \
2052 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002053
Hanno Becker6a243642017-10-12 15:18:45 +01002054requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002055run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002056 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002057 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002058 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002059 0 \
2060 -C "client hello, adding renegotiation extension" \
2061 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2062 -S "found renegotiation extension" \
2063 -s "server hello, secure renegotiation extension" \
2064 -c "found renegotiation extension" \
2065 -C "=> renegotiate" \
2066 -S "=> renegotiate" \
2067 -s "write hello request" \
2068 -S "SSL - An unexpected message was received from our peer" \
2069 -S "failed"
2070
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002071# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002072requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002073run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002074 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002075 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002076 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002077 0 \
2078 -C "client hello, adding renegotiation extension" \
2079 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2080 -S "found renegotiation extension" \
2081 -s "server hello, secure renegotiation extension" \
2082 -c "found renegotiation extension" \
2083 -C "=> renegotiate" \
2084 -S "=> renegotiate" \
2085 -s "write hello request" \
2086 -S "SSL - An unexpected message was received from our peer" \
2087 -S "failed"
2088
Hanno Becker6a243642017-10-12 15:18:45 +01002089requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002090run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002091 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002092 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002093 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002094 0 \
2095 -C "client hello, adding renegotiation extension" \
2096 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2097 -S "found renegotiation extension" \
2098 -s "server hello, secure renegotiation extension" \
2099 -c "found renegotiation extension" \
2100 -C "=> renegotiate" \
2101 -S "=> renegotiate" \
2102 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002103 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002104
Hanno Becker6a243642017-10-12 15:18:45 +01002105requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002106run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002107 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002108 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002109 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002110 0 \
2111 -c "client hello, adding renegotiation extension" \
2112 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2113 -s "found renegotiation extension" \
2114 -s "server hello, secure renegotiation extension" \
2115 -c "found renegotiation extension" \
2116 -c "=> renegotiate" \
2117 -s "=> renegotiate" \
2118 -s "write hello request" \
2119 -S "SSL - An unexpected message was received from our peer" \
2120 -S "failed"
2121
Hanno Becker6a243642017-10-12 15:18:45 +01002122requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002123run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002124 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002125 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2126 0 \
2127 -C "client hello, adding renegotiation extension" \
2128 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2129 -S "found renegotiation extension" \
2130 -s "server hello, secure renegotiation extension" \
2131 -c "found renegotiation extension" \
2132 -S "record counter limit reached: renegotiate" \
2133 -C "=> renegotiate" \
2134 -S "=> renegotiate" \
2135 -S "write hello request" \
2136 -S "SSL - An unexpected message was received from our peer" \
2137 -S "failed"
2138
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002139# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002140requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002141run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002142 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002143 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002144 0 \
2145 -c "client hello, adding renegotiation extension" \
2146 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2147 -s "found renegotiation extension" \
2148 -s "server hello, secure renegotiation extension" \
2149 -c "found renegotiation extension" \
2150 -s "record counter limit reached: renegotiate" \
2151 -c "=> renegotiate" \
2152 -s "=> renegotiate" \
2153 -s "write hello request" \
2154 -S "SSL - An unexpected message was received from our peer" \
2155 -S "failed"
2156
Hanno Becker6a243642017-10-12 15:18:45 +01002157requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002158run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002159 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002160 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002161 0 \
2162 -c "client hello, adding renegotiation extension" \
2163 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2164 -s "found renegotiation extension" \
2165 -s "server hello, secure renegotiation extension" \
2166 -c "found renegotiation extension" \
2167 -s "record counter limit reached: renegotiate" \
2168 -c "=> renegotiate" \
2169 -s "=> renegotiate" \
2170 -s "write hello request" \
2171 -S "SSL - An unexpected message was received from our peer" \
2172 -S "failed"
2173
Hanno Becker6a243642017-10-12 15:18:45 +01002174requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002175run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002176 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002177 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2178 0 \
2179 -C "client hello, adding renegotiation extension" \
2180 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2181 -S "found renegotiation extension" \
2182 -s "server hello, secure renegotiation extension" \
2183 -c "found renegotiation extension" \
2184 -S "record counter limit reached: renegotiate" \
2185 -C "=> renegotiate" \
2186 -S "=> renegotiate" \
2187 -S "write hello request" \
2188 -S "SSL - An unexpected message was received from our peer" \
2189 -S "failed"
2190
Hanno Becker6a243642017-10-12 15:18:45 +01002191requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002192run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002193 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002194 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002195 0 \
2196 -c "client hello, adding renegotiation extension" \
2197 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2198 -s "found renegotiation extension" \
2199 -s "server hello, secure renegotiation extension" \
2200 -c "found renegotiation extension" \
2201 -c "=> renegotiate" \
2202 -s "=> renegotiate" \
2203 -S "write hello request"
2204
Hanno Becker6a243642017-10-12 15:18:45 +01002205requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002206run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002207 "$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 +02002208 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002209 0 \
2210 -c "client hello, adding renegotiation extension" \
2211 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2212 -s "found renegotiation extension" \
2213 -s "server hello, secure renegotiation extension" \
2214 -c "found renegotiation extension" \
2215 -c "=> renegotiate" \
2216 -s "=> renegotiate" \
2217 -s "write hello request"
2218
Hanno Becker6a243642017-10-12 15:18:45 +01002219requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002220run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002221 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002222 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002223 0 \
2224 -c "client hello, adding renegotiation extension" \
2225 -c "found renegotiation extension" \
2226 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002227 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002228 -C "error" \
2229 -c "HTTP/1.0 200 [Oo][Kk]"
2230
Paul Bakker539d9722015-02-08 16:18:35 +01002231requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002232requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002233run_test "Renegotiation: gnutls server strict, client-initiated" \
2234 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002235 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002236 0 \
2237 -c "client hello, adding renegotiation extension" \
2238 -c "found renegotiation extension" \
2239 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002240 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002241 -C "error" \
2242 -c "HTTP/1.0 200 [Oo][Kk]"
2243
Paul Bakker539d9722015-02-08 16:18:35 +01002244requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002245requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002246run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2247 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2248 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2249 1 \
2250 -c "client hello, adding renegotiation extension" \
2251 -C "found renegotiation extension" \
2252 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002253 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002254 -c "error" \
2255 -C "HTTP/1.0 200 [Oo][Kk]"
2256
Paul Bakker539d9722015-02-08 16:18:35 +01002257requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002258requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002259run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2260 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2261 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2262 allow_legacy=0" \
2263 1 \
2264 -c "client hello, adding renegotiation extension" \
2265 -C "found renegotiation extension" \
2266 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002267 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002268 -c "error" \
2269 -C "HTTP/1.0 200 [Oo][Kk]"
2270
Paul Bakker539d9722015-02-08 16:18:35 +01002271requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002272requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002273run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2274 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2275 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2276 allow_legacy=1" \
2277 0 \
2278 -c "client hello, adding renegotiation extension" \
2279 -C "found renegotiation extension" \
2280 -c "=> renegotiate" \
2281 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002282 -C "error" \
2283 -c "HTTP/1.0 200 [Oo][Kk]"
2284
Hanno Becker6a243642017-10-12 15:18:45 +01002285requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002286run_test "Renegotiation: DTLS, client-initiated" \
2287 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2288 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2289 0 \
2290 -c "client hello, adding renegotiation extension" \
2291 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2292 -s "found renegotiation extension" \
2293 -s "server hello, secure renegotiation extension" \
2294 -c "found renegotiation extension" \
2295 -c "=> renegotiate" \
2296 -s "=> renegotiate" \
2297 -S "write hello request"
2298
Hanno Becker6a243642017-10-12 15:18:45 +01002299requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002300run_test "Renegotiation: DTLS, server-initiated" \
2301 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002302 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2303 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002304 0 \
2305 -c "client hello, adding renegotiation extension" \
2306 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2307 -s "found renegotiation extension" \
2308 -s "server hello, secure renegotiation extension" \
2309 -c "found renegotiation extension" \
2310 -c "=> renegotiate" \
2311 -s "=> renegotiate" \
2312 -s "write hello request"
2313
Hanno Becker6a243642017-10-12 15:18:45 +01002314requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002315run_test "Renegotiation: DTLS, renego_period overflow" \
2316 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2317 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2318 0 \
2319 -c "client hello, adding renegotiation extension" \
2320 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2321 -s "found renegotiation extension" \
2322 -s "server hello, secure renegotiation extension" \
2323 -s "record counter limit reached: renegotiate" \
2324 -c "=> renegotiate" \
2325 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002326 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002327
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002328requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002329requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002330run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2331 "$G_SRV -u --mtu 4096" \
2332 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2333 0 \
2334 -c "client hello, adding renegotiation extension" \
2335 -c "found renegotiation extension" \
2336 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002337 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002338 -C "error" \
2339 -s "Extra-header:"
2340
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002341# Test for the "secure renegotation" extension only (no actual renegotiation)
2342
Paul Bakker539d9722015-02-08 16:18:35 +01002343requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002344run_test "Renego ext: gnutls server strict, client default" \
2345 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2346 "$P_CLI debug_level=3" \
2347 0 \
2348 -c "found renegotiation extension" \
2349 -C "error" \
2350 -c "HTTP/1.0 200 [Oo][Kk]"
2351
Paul Bakker539d9722015-02-08 16:18:35 +01002352requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002353run_test "Renego ext: gnutls server unsafe, client default" \
2354 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2355 "$P_CLI debug_level=3" \
2356 0 \
2357 -C "found renegotiation extension" \
2358 -C "error" \
2359 -c "HTTP/1.0 200 [Oo][Kk]"
2360
Paul Bakker539d9722015-02-08 16:18:35 +01002361requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002362run_test "Renego ext: gnutls server unsafe, client break legacy" \
2363 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2364 "$P_CLI debug_level=3 allow_legacy=-1" \
2365 1 \
2366 -C "found renegotiation extension" \
2367 -c "error" \
2368 -C "HTTP/1.0 200 [Oo][Kk]"
2369
Paul Bakker539d9722015-02-08 16:18:35 +01002370requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002371run_test "Renego ext: gnutls client strict, server default" \
2372 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002373 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002374 0 \
2375 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2376 -s "server hello, secure renegotiation extension"
2377
Paul Bakker539d9722015-02-08 16:18:35 +01002378requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002379run_test "Renego ext: gnutls client unsafe, server default" \
2380 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002381 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002382 0 \
2383 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2384 -S "server hello, secure renegotiation extension"
2385
Paul Bakker539d9722015-02-08 16:18:35 +01002386requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002387run_test "Renego ext: gnutls client unsafe, server break legacy" \
2388 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002389 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002390 1 \
2391 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2392 -S "server hello, secure renegotiation extension"
2393
Janos Follath0b242342016-02-17 10:11:21 +00002394# Tests for silently dropping trailing extra bytes in .der certificates
2395
2396requires_gnutls
2397run_test "DER format: no trailing bytes" \
2398 "$P_SRV crt_file=data_files/server5-der0.crt \
2399 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002400 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002401 0 \
2402 -c "Handshake was completed" \
2403
2404requires_gnutls
2405run_test "DER format: with a trailing zero byte" \
2406 "$P_SRV crt_file=data_files/server5-der1a.crt \
2407 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002408 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002409 0 \
2410 -c "Handshake was completed" \
2411
2412requires_gnutls
2413run_test "DER format: with a trailing random byte" \
2414 "$P_SRV crt_file=data_files/server5-der1b.crt \
2415 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002416 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002417 0 \
2418 -c "Handshake was completed" \
2419
2420requires_gnutls
2421run_test "DER format: with 2 trailing random bytes" \
2422 "$P_SRV crt_file=data_files/server5-der2.crt \
2423 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002424 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002425 0 \
2426 -c "Handshake was completed" \
2427
2428requires_gnutls
2429run_test "DER format: with 4 trailing random bytes" \
2430 "$P_SRV crt_file=data_files/server5-der4.crt \
2431 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002432 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002433 0 \
2434 -c "Handshake was completed" \
2435
2436requires_gnutls
2437run_test "DER format: with 8 trailing random bytes" \
2438 "$P_SRV crt_file=data_files/server5-der8.crt \
2439 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002440 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002441 0 \
2442 -c "Handshake was completed" \
2443
2444requires_gnutls
2445run_test "DER format: with 9 trailing random bytes" \
2446 "$P_SRV crt_file=data_files/server5-der9.crt \
2447 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002448 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002449 0 \
2450 -c "Handshake was completed" \
2451
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002452# Tests for auth_mode
2453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002454run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002455 "$P_SRV crt_file=data_files/server5-badsign.crt \
2456 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002457 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002458 1 \
2459 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002460 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002461 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002462 -c "X509 - Certificate verification failed"
2463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002464run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002465 "$P_SRV crt_file=data_files/server5-badsign.crt \
2466 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002467 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002468 0 \
2469 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002470 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002471 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002472 -C "X509 - Certificate verification failed"
2473
Hanno Beckere6706e62017-05-15 16:05:15 +01002474run_test "Authentication: server goodcert, client optional, no trusted CA" \
2475 "$P_SRV" \
2476 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2477 0 \
2478 -c "x509_verify_cert() returned" \
2479 -c "! The certificate is not correctly signed by the trusted CA" \
2480 -c "! Certificate verification flags"\
2481 -C "! mbedtls_ssl_handshake returned" \
2482 -C "X509 - Certificate verification failed" \
2483 -C "SSL - No CA Chain is set, but required to operate"
2484
2485run_test "Authentication: server goodcert, client required, no trusted CA" \
2486 "$P_SRV" \
2487 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2488 1 \
2489 -c "x509_verify_cert() returned" \
2490 -c "! The certificate is not correctly signed by the trusted CA" \
2491 -c "! Certificate verification flags"\
2492 -c "! mbedtls_ssl_handshake returned" \
2493 -c "SSL - No CA Chain is set, but required to operate"
2494
2495# The purpose of the next two tests is to test the client's behaviour when receiving a server
2496# certificate with an unsupported elliptic curve. This should usually not happen because
2497# the client informs the server about the supported curves - it does, though, in the
2498# corner case of a static ECDH suite, because the server doesn't check the curve on that
2499# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2500# different means to have the server ignoring the client's supported curve list.
2501
2502requires_config_enabled MBEDTLS_ECP_C
2503run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2504 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2505 crt_file=data_files/server5.ku-ka.crt" \
2506 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2507 1 \
2508 -c "bad certificate (EC key curve)"\
2509 -c "! Certificate verification flags"\
2510 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2511
2512requires_config_enabled MBEDTLS_ECP_C
2513run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2514 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2515 crt_file=data_files/server5.ku-ka.crt" \
2516 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2517 1 \
2518 -c "bad certificate (EC key curve)"\
2519 -c "! Certificate verification flags"\
2520 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002522run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002523 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002524 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002525 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002526 0 \
2527 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002528 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002529 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002530 -C "X509 - Certificate verification failed"
2531
Simon Butcher99000142016-10-13 17:21:01 +01002532run_test "Authentication: client SHA256, server required" \
2533 "$P_SRV auth_mode=required" \
2534 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2535 key_file=data_files/server6.key \
2536 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2537 0 \
2538 -c "Supported Signature Algorithm found: 4," \
2539 -c "Supported Signature Algorithm found: 5,"
2540
2541run_test "Authentication: client SHA384, server required" \
2542 "$P_SRV auth_mode=required" \
2543 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2544 key_file=data_files/server6.key \
2545 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2546 0 \
2547 -c "Supported Signature Algorithm found: 4," \
2548 -c "Supported Signature Algorithm found: 5,"
2549
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002550requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2551run_test "Authentication: client has no cert, server required (SSLv3)" \
2552 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2553 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2554 key_file=data_files/server5.key" \
2555 1 \
2556 -S "skip write certificate request" \
2557 -C "skip parse certificate request" \
2558 -c "got a certificate request" \
2559 -c "got no certificate to send" \
2560 -S "x509_verify_cert() returned" \
2561 -s "client has no certificate" \
2562 -s "! mbedtls_ssl_handshake returned" \
2563 -c "! mbedtls_ssl_handshake returned" \
2564 -s "No client certification received from the client, but required by the authentication mode"
2565
2566run_test "Authentication: client has no cert, server required (TLS)" \
2567 "$P_SRV debug_level=3 auth_mode=required" \
2568 "$P_CLI debug_level=3 crt_file=none \
2569 key_file=data_files/server5.key" \
2570 1 \
2571 -S "skip write certificate request" \
2572 -C "skip parse certificate request" \
2573 -c "got a certificate request" \
2574 -c "= write certificate$" \
2575 -C "skip write certificate$" \
2576 -S "x509_verify_cert() returned" \
2577 -s "client has no certificate" \
2578 -s "! mbedtls_ssl_handshake returned" \
2579 -c "! mbedtls_ssl_handshake returned" \
2580 -s "No client certification received from the client, but required by the authentication mode"
2581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002582run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002583 "$P_SRV debug_level=3 auth_mode=required" \
2584 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002585 key_file=data_files/server5.key" \
2586 1 \
2587 -S "skip write certificate request" \
2588 -C "skip parse certificate request" \
2589 -c "got a certificate request" \
2590 -C "skip write certificate" \
2591 -C "skip write certificate verify" \
2592 -S "skip parse certificate verify" \
2593 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002594 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002595 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002596 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002597 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002598 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002599# We don't check that the client receives the alert because it might
2600# detect that its write end of the connection is closed and abort
2601# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002602
Janos Follath89baba22017-04-10 14:34:35 +01002603run_test "Authentication: client cert not trusted, server required" \
2604 "$P_SRV debug_level=3 auth_mode=required" \
2605 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2606 key_file=data_files/server5.key" \
2607 1 \
2608 -S "skip write certificate request" \
2609 -C "skip parse certificate request" \
2610 -c "got a certificate request" \
2611 -C "skip write certificate" \
2612 -C "skip write certificate verify" \
2613 -S "skip parse certificate verify" \
2614 -s "x509_verify_cert() returned" \
2615 -s "! The certificate is not correctly signed by the trusted CA" \
2616 -s "! mbedtls_ssl_handshake returned" \
2617 -c "! mbedtls_ssl_handshake returned" \
2618 -s "X509 - Certificate verification failed"
2619
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002620run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002621 "$P_SRV debug_level=3 auth_mode=optional" \
2622 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002623 key_file=data_files/server5.key" \
2624 0 \
2625 -S "skip write certificate request" \
2626 -C "skip parse certificate request" \
2627 -c "got a certificate request" \
2628 -C "skip write certificate" \
2629 -C "skip write certificate verify" \
2630 -S "skip parse certificate verify" \
2631 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002632 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002633 -S "! mbedtls_ssl_handshake returned" \
2634 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002635 -S "X509 - Certificate verification failed"
2636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002637run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002638 "$P_SRV debug_level=3 auth_mode=none" \
2639 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002640 key_file=data_files/server5.key" \
2641 0 \
2642 -s "skip write certificate request" \
2643 -C "skip parse certificate request" \
2644 -c "got no certificate request" \
2645 -c "skip write certificate" \
2646 -c "skip write certificate verify" \
2647 -s "skip parse certificate verify" \
2648 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002649 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002650 -S "! mbedtls_ssl_handshake returned" \
2651 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002652 -S "X509 - Certificate verification failed"
2653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002654run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002655 "$P_SRV debug_level=3 auth_mode=optional" \
2656 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002657 0 \
2658 -S "skip write certificate request" \
2659 -C "skip parse certificate request" \
2660 -c "got a certificate request" \
2661 -C "skip write certificate$" \
2662 -C "got no certificate to send" \
2663 -S "SSLv3 client has no certificate" \
2664 -c "skip write certificate verify" \
2665 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002666 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002667 -S "! mbedtls_ssl_handshake returned" \
2668 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002669 -S "X509 - Certificate verification failed"
2670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002671run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002672 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002673 "$O_CLI" \
2674 0 \
2675 -S "skip write certificate request" \
2676 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002677 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002678 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002679 -S "X509 - Certificate verification failed"
2680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002681run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002682 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002683 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002684 0 \
2685 -C "skip parse certificate request" \
2686 -c "got a certificate request" \
2687 -C "skip write certificate$" \
2688 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002689 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002690
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002691run_test "Authentication: client no cert, openssl server required" \
2692 "$O_SRV -Verify 10" \
2693 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2694 1 \
2695 -C "skip parse certificate request" \
2696 -c "got a certificate request" \
2697 -C "skip write certificate$" \
2698 -c "skip write certificate verify" \
2699 -c "! mbedtls_ssl_handshake returned"
2700
Janos Follathe2681a42016-03-07 15:57:05 +00002701requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002702run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002703 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002704 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002705 0 \
2706 -S "skip write certificate request" \
2707 -C "skip parse certificate request" \
2708 -c "got a certificate request" \
2709 -C "skip write certificate$" \
2710 -c "skip write certificate verify" \
2711 -c "got no certificate to send" \
2712 -s "SSLv3 client has no certificate" \
2713 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002714 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002715 -S "! mbedtls_ssl_handshake returned" \
2716 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002717 -S "X509 - Certificate verification failed"
2718
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002719# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2720# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002721
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002722MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002723MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002724
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002725if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002726 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002727 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002728 printf "test value of ${MAX_IM_CA}. \n"
2729 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002730 printf "The tests assume this value and if it changes, the tests in this\n"
2731 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002732 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002733
2734 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002735fi
2736
Angus Grattonc4dd0732018-04-11 16:28:39 +10002737requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002738run_test "Authentication: server max_int chain, client default" \
2739 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2740 key_file=data_files/dir-maxpath/09.key" \
2741 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2742 0 \
2743 -C "X509 - A fatal error occured"
2744
Angus Grattonc4dd0732018-04-11 16:28:39 +10002745requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002746run_test "Authentication: server max_int+1 chain, client default" \
2747 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2748 key_file=data_files/dir-maxpath/10.key" \
2749 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2750 1 \
2751 -c "X509 - A fatal error occured"
2752
Angus Grattonc4dd0732018-04-11 16:28:39 +10002753requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002754run_test "Authentication: server max_int+1 chain, client optional" \
2755 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2756 key_file=data_files/dir-maxpath/10.key" \
2757 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2758 auth_mode=optional" \
2759 1 \
2760 -c "X509 - A fatal error occured"
2761
Angus Grattonc4dd0732018-04-11 16:28:39 +10002762requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002763run_test "Authentication: server max_int+1 chain, client none" \
2764 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2765 key_file=data_files/dir-maxpath/10.key" \
2766 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2767 auth_mode=none" \
2768 0 \
2769 -C "X509 - A fatal error occured"
2770
Angus Grattonc4dd0732018-04-11 16:28:39 +10002771requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002772run_test "Authentication: client max_int+1 chain, server default" \
2773 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2774 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2775 key_file=data_files/dir-maxpath/10.key" \
2776 0 \
2777 -S "X509 - A fatal error occured"
2778
Angus Grattonc4dd0732018-04-11 16:28:39 +10002779requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002780run_test "Authentication: client max_int+1 chain, server optional" \
2781 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2782 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2783 key_file=data_files/dir-maxpath/10.key" \
2784 1 \
2785 -s "X509 - A fatal error occured"
2786
Angus Grattonc4dd0732018-04-11 16:28:39 +10002787requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002788run_test "Authentication: client max_int+1 chain, server required" \
2789 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2790 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2791 key_file=data_files/dir-maxpath/10.key" \
2792 1 \
2793 -s "X509 - A fatal error occured"
2794
Angus Grattonc4dd0732018-04-11 16:28:39 +10002795requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002796run_test "Authentication: client max_int chain, server required" \
2797 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2798 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2799 key_file=data_files/dir-maxpath/09.key" \
2800 0 \
2801 -S "X509 - A fatal error occured"
2802
Janos Follath89baba22017-04-10 14:34:35 +01002803# Tests for CA list in CertificateRequest messages
2804
2805run_test "Authentication: send CA list in CertificateRequest (default)" \
2806 "$P_SRV debug_level=3 auth_mode=required" \
2807 "$P_CLI crt_file=data_files/server6.crt \
2808 key_file=data_files/server6.key" \
2809 0 \
2810 -s "requested DN"
2811
2812run_test "Authentication: do not send CA list in CertificateRequest" \
2813 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2814 "$P_CLI crt_file=data_files/server6.crt \
2815 key_file=data_files/server6.key" \
2816 0 \
2817 -S "requested DN"
2818
2819run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2820 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2821 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2822 key_file=data_files/server5.key" \
2823 1 \
2824 -S "requested DN" \
2825 -s "x509_verify_cert() returned" \
2826 -s "! The certificate is not correctly signed by the trusted CA" \
2827 -s "! mbedtls_ssl_handshake returned" \
2828 -c "! mbedtls_ssl_handshake returned" \
2829 -s "X509 - Certificate verification failed"
2830
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002831# Tests for certificate selection based on SHA verson
2832
2833run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2834 "$P_SRV crt_file=data_files/server5.crt \
2835 key_file=data_files/server5.key \
2836 crt_file2=data_files/server5-sha1.crt \
2837 key_file2=data_files/server5.key" \
2838 "$P_CLI force_version=tls1_2" \
2839 0 \
2840 -c "signed using.*ECDSA with SHA256" \
2841 -C "signed using.*ECDSA with SHA1"
2842
2843run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2844 "$P_SRV crt_file=data_files/server5.crt \
2845 key_file=data_files/server5.key \
2846 crt_file2=data_files/server5-sha1.crt \
2847 key_file2=data_files/server5.key" \
2848 "$P_CLI force_version=tls1_1" \
2849 0 \
2850 -C "signed using.*ECDSA with SHA256" \
2851 -c "signed using.*ECDSA with SHA1"
2852
2853run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2854 "$P_SRV crt_file=data_files/server5.crt \
2855 key_file=data_files/server5.key \
2856 crt_file2=data_files/server5-sha1.crt \
2857 key_file2=data_files/server5.key" \
2858 "$P_CLI force_version=tls1" \
2859 0 \
2860 -C "signed using.*ECDSA with SHA256" \
2861 -c "signed using.*ECDSA with SHA1"
2862
2863run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2864 "$P_SRV crt_file=data_files/server5.crt \
2865 key_file=data_files/server5.key \
2866 crt_file2=data_files/server6.crt \
2867 key_file2=data_files/server6.key" \
2868 "$P_CLI force_version=tls1_1" \
2869 0 \
2870 -c "serial number.*09" \
2871 -c "signed using.*ECDSA with SHA256" \
2872 -C "signed using.*ECDSA with SHA1"
2873
2874run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2875 "$P_SRV crt_file=data_files/server6.crt \
2876 key_file=data_files/server6.key \
2877 crt_file2=data_files/server5.crt \
2878 key_file2=data_files/server5.key" \
2879 "$P_CLI force_version=tls1_1" \
2880 0 \
2881 -c "serial number.*0A" \
2882 -c "signed using.*ECDSA with SHA256" \
2883 -C "signed using.*ECDSA with SHA1"
2884
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002885# tests for SNI
2886
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002887run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002888 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002889 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002890 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002891 0 \
2892 -S "parse ServerName extension" \
2893 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2894 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002896run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002897 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002898 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002899 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 +02002900 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002901 0 \
2902 -s "parse ServerName extension" \
2903 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2904 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002905
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002906run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002907 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002908 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002909 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 +02002910 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002911 0 \
2912 -s "parse ServerName extension" \
2913 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2914 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002916run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002917 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002918 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002919 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 +02002920 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002921 1 \
2922 -s "parse ServerName extension" \
2923 -s "ssl_sni_wrapper() returned" \
2924 -s "mbedtls_ssl_handshake returned" \
2925 -c "mbedtls_ssl_handshake returned" \
2926 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002927
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002928run_test "SNI: client auth no override: optional" \
2929 "$P_SRV debug_level=3 auth_mode=optional \
2930 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2931 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2932 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002933 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002934 -S "skip write certificate request" \
2935 -C "skip parse certificate request" \
2936 -c "got a certificate request" \
2937 -C "skip write certificate" \
2938 -C "skip write certificate verify" \
2939 -S "skip parse certificate verify"
2940
2941run_test "SNI: client auth override: none -> optional" \
2942 "$P_SRV debug_level=3 auth_mode=none \
2943 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2944 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2945 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002946 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002947 -S "skip write certificate request" \
2948 -C "skip parse certificate request" \
2949 -c "got a certificate request" \
2950 -C "skip write certificate" \
2951 -C "skip write certificate verify" \
2952 -S "skip parse certificate verify"
2953
2954run_test "SNI: client auth override: optional -> none" \
2955 "$P_SRV debug_level=3 auth_mode=optional \
2956 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2957 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2958 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002959 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002960 -s "skip write certificate request" \
2961 -C "skip parse certificate request" \
2962 -c "got no certificate request" \
2963 -c "skip write certificate" \
2964 -c "skip write certificate verify" \
2965 -s "skip parse certificate verify"
2966
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002967run_test "SNI: CA no override" \
2968 "$P_SRV debug_level=3 auth_mode=optional \
2969 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2970 ca_file=data_files/test-ca.crt \
2971 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2972 "$P_CLI debug_level=3 server_name=localhost \
2973 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2974 1 \
2975 -S "skip write certificate request" \
2976 -C "skip parse certificate request" \
2977 -c "got a certificate request" \
2978 -C "skip write certificate" \
2979 -C "skip write certificate verify" \
2980 -S "skip parse certificate verify" \
2981 -s "x509_verify_cert() returned" \
2982 -s "! The certificate is not correctly signed by the trusted CA" \
2983 -S "The certificate has been revoked (is on a CRL)"
2984
2985run_test "SNI: CA override" \
2986 "$P_SRV debug_level=3 auth_mode=optional \
2987 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2988 ca_file=data_files/test-ca.crt \
2989 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2990 "$P_CLI debug_level=3 server_name=localhost \
2991 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2992 0 \
2993 -S "skip write certificate request" \
2994 -C "skip parse certificate request" \
2995 -c "got a certificate request" \
2996 -C "skip write certificate" \
2997 -C "skip write certificate verify" \
2998 -S "skip parse certificate verify" \
2999 -S "x509_verify_cert() returned" \
3000 -S "! The certificate is not correctly signed by the trusted CA" \
3001 -S "The certificate has been revoked (is on a CRL)"
3002
3003run_test "SNI: CA override with CRL" \
3004 "$P_SRV debug_level=3 auth_mode=optional \
3005 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3006 ca_file=data_files/test-ca.crt \
3007 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3008 "$P_CLI debug_level=3 server_name=localhost \
3009 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3010 1 \
3011 -S "skip write certificate request" \
3012 -C "skip parse certificate request" \
3013 -c "got a certificate request" \
3014 -C "skip write certificate" \
3015 -C "skip write certificate verify" \
3016 -S "skip parse certificate verify" \
3017 -s "x509_verify_cert() returned" \
3018 -S "! The certificate is not correctly signed by the trusted CA" \
3019 -s "The certificate has been revoked (is on a CRL)"
3020
Andres AG1a834452016-12-07 10:01:30 +00003021# Tests for SNI and DTLS
3022
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003023run_test "SNI: DTLS, no SNI callback" \
3024 "$P_SRV debug_level=3 dtls=1 \
3025 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3026 "$P_CLI server_name=localhost dtls=1" \
3027 0 \
3028 -S "parse ServerName extension" \
3029 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3030 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3031
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003032run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003033 "$P_SRV debug_level=3 dtls=1 \
3034 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3035 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3036 "$P_CLI server_name=localhost dtls=1" \
3037 0 \
3038 -s "parse ServerName extension" \
3039 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3040 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3041
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003042run_test "SNI: DTLS, matching cert 2" \
3043 "$P_SRV debug_level=3 dtls=1 \
3044 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3045 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3046 "$P_CLI server_name=polarssl.example dtls=1" \
3047 0 \
3048 -s "parse ServerName extension" \
3049 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3050 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3051
3052run_test "SNI: DTLS, no matching cert" \
3053 "$P_SRV debug_level=3 dtls=1 \
3054 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3055 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3056 "$P_CLI server_name=nonesuch.example dtls=1" \
3057 1 \
3058 -s "parse ServerName extension" \
3059 -s "ssl_sni_wrapper() returned" \
3060 -s "mbedtls_ssl_handshake returned" \
3061 -c "mbedtls_ssl_handshake returned" \
3062 -c "SSL - A fatal alert message was received from our peer"
3063
3064run_test "SNI: DTLS, client auth no override: optional" \
3065 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3066 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3067 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3068 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3069 0 \
3070 -S "skip write certificate request" \
3071 -C "skip parse certificate request" \
3072 -c "got a certificate request" \
3073 -C "skip write certificate" \
3074 -C "skip write certificate verify" \
3075 -S "skip parse certificate verify"
3076
3077run_test "SNI: DTLS, client auth override: none -> optional" \
3078 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3079 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3080 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3081 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3082 0 \
3083 -S "skip write certificate request" \
3084 -C "skip parse certificate request" \
3085 -c "got a certificate request" \
3086 -C "skip write certificate" \
3087 -C "skip write certificate verify" \
3088 -S "skip parse certificate verify"
3089
3090run_test "SNI: DTLS, client auth override: optional -> none" \
3091 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3092 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3093 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3094 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3095 0 \
3096 -s "skip write certificate request" \
3097 -C "skip parse certificate request" \
3098 -c "got no certificate request" \
3099 -c "skip write certificate" \
3100 -c "skip write certificate verify" \
3101 -s "skip parse certificate verify"
3102
3103run_test "SNI: DTLS, CA no override" \
3104 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3105 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3106 ca_file=data_files/test-ca.crt \
3107 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3108 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3109 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3110 1 \
3111 -S "skip write certificate request" \
3112 -C "skip parse certificate request" \
3113 -c "got a certificate request" \
3114 -C "skip write certificate" \
3115 -C "skip write certificate verify" \
3116 -S "skip parse certificate verify" \
3117 -s "x509_verify_cert() returned" \
3118 -s "! The certificate is not correctly signed by the trusted CA" \
3119 -S "The certificate has been revoked (is on a CRL)"
3120
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003121run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003122 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3123 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3124 ca_file=data_files/test-ca.crt \
3125 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3126 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3127 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3128 0 \
3129 -S "skip write certificate request" \
3130 -C "skip parse certificate request" \
3131 -c "got a certificate request" \
3132 -C "skip write certificate" \
3133 -C "skip write certificate verify" \
3134 -S "skip parse certificate verify" \
3135 -S "x509_verify_cert() returned" \
3136 -S "! The certificate is not correctly signed by the trusted CA" \
3137 -S "The certificate has been revoked (is on a CRL)"
3138
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003139run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003140 "$P_SRV debug_level=3 auth_mode=optional \
3141 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3142 ca_file=data_files/test-ca.crt \
3143 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3144 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3145 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3146 1 \
3147 -S "skip write certificate request" \
3148 -C "skip parse certificate request" \
3149 -c "got a certificate request" \
3150 -C "skip write certificate" \
3151 -C "skip write certificate verify" \
3152 -S "skip parse certificate verify" \
3153 -s "x509_verify_cert() returned" \
3154 -S "! The certificate is not correctly signed by the trusted CA" \
3155 -s "The certificate has been revoked (is on a CRL)"
3156
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003157# Tests for non-blocking I/O: exercise a variety of handshake flows
3158
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003159run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003160 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3161 "$P_CLI nbio=2 tickets=0" \
3162 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003163 -S "mbedtls_ssl_handshake returned" \
3164 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003165 -c "Read from server: .* bytes read"
3166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003167run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003168 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3169 "$P_CLI nbio=2 tickets=0" \
3170 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003171 -S "mbedtls_ssl_handshake returned" \
3172 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003173 -c "Read from server: .* bytes read"
3174
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003175run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003176 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3177 "$P_CLI nbio=2 tickets=1" \
3178 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003179 -S "mbedtls_ssl_handshake returned" \
3180 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003181 -c "Read from server: .* bytes read"
3182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003183run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003184 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3185 "$P_CLI nbio=2 tickets=1" \
3186 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003187 -S "mbedtls_ssl_handshake returned" \
3188 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003189 -c "Read from server: .* bytes read"
3190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003191run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003192 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3193 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3194 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003195 -S "mbedtls_ssl_handshake returned" \
3196 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003197 -c "Read from server: .* bytes read"
3198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003199run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003200 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3201 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3202 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003203 -S "mbedtls_ssl_handshake returned" \
3204 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003205 -c "Read from server: .* bytes read"
3206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003207run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003208 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3209 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3210 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003211 -S "mbedtls_ssl_handshake returned" \
3212 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003213 -c "Read from server: .* bytes read"
3214
Hanno Becker00076712017-11-15 16:39:08 +00003215# Tests for event-driven I/O: exercise a variety of handshake flows
3216
3217run_test "Event-driven I/O: basic handshake" \
3218 "$P_SRV event=1 tickets=0 auth_mode=none" \
3219 "$P_CLI event=1 tickets=0" \
3220 0 \
3221 -S "mbedtls_ssl_handshake returned" \
3222 -C "mbedtls_ssl_handshake returned" \
3223 -c "Read from server: .* bytes read"
3224
3225run_test "Event-driven I/O: client auth" \
3226 "$P_SRV event=1 tickets=0 auth_mode=required" \
3227 "$P_CLI event=1 tickets=0" \
3228 0 \
3229 -S "mbedtls_ssl_handshake returned" \
3230 -C "mbedtls_ssl_handshake returned" \
3231 -c "Read from server: .* bytes read"
3232
3233run_test "Event-driven I/O: ticket" \
3234 "$P_SRV event=1 tickets=1 auth_mode=none" \
3235 "$P_CLI event=1 tickets=1" \
3236 0 \
3237 -S "mbedtls_ssl_handshake returned" \
3238 -C "mbedtls_ssl_handshake returned" \
3239 -c "Read from server: .* bytes read"
3240
3241run_test "Event-driven I/O: ticket + client auth" \
3242 "$P_SRV event=1 tickets=1 auth_mode=required" \
3243 "$P_CLI event=1 tickets=1" \
3244 0 \
3245 -S "mbedtls_ssl_handshake returned" \
3246 -C "mbedtls_ssl_handshake returned" \
3247 -c "Read from server: .* bytes read"
3248
3249run_test "Event-driven I/O: ticket + client auth + resume" \
3250 "$P_SRV event=1 tickets=1 auth_mode=required" \
3251 "$P_CLI event=1 tickets=1 reconnect=1" \
3252 0 \
3253 -S "mbedtls_ssl_handshake returned" \
3254 -C "mbedtls_ssl_handshake returned" \
3255 -c "Read from server: .* bytes read"
3256
3257run_test "Event-driven I/O: ticket + resume" \
3258 "$P_SRV event=1 tickets=1 auth_mode=none" \
3259 "$P_CLI event=1 tickets=1 reconnect=1" \
3260 0 \
3261 -S "mbedtls_ssl_handshake returned" \
3262 -C "mbedtls_ssl_handshake returned" \
3263 -c "Read from server: .* bytes read"
3264
3265run_test "Event-driven I/O: session-id resume" \
3266 "$P_SRV event=1 tickets=0 auth_mode=none" \
3267 "$P_CLI event=1 tickets=0 reconnect=1" \
3268 0 \
3269 -S "mbedtls_ssl_handshake returned" \
3270 -C "mbedtls_ssl_handshake returned" \
3271 -c "Read from server: .* bytes read"
3272
Hanno Becker6a33f592018-03-13 11:38:46 +00003273run_test "Event-driven I/O, DTLS: basic handshake" \
3274 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3275 "$P_CLI dtls=1 event=1 tickets=0" \
3276 0 \
3277 -c "Read from server: .* bytes read"
3278
3279run_test "Event-driven I/O, DTLS: client auth" \
3280 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3281 "$P_CLI dtls=1 event=1 tickets=0" \
3282 0 \
3283 -c "Read from server: .* bytes read"
3284
3285run_test "Event-driven I/O, DTLS: ticket" \
3286 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3287 "$P_CLI dtls=1 event=1 tickets=1" \
3288 0 \
3289 -c "Read from server: .* bytes read"
3290
3291run_test "Event-driven I/O, DTLS: ticket + client auth" \
3292 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3293 "$P_CLI dtls=1 event=1 tickets=1" \
3294 0 \
3295 -c "Read from server: .* bytes read"
3296
3297run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3298 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3299 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
3300 0 \
3301 -c "Read from server: .* bytes read"
3302
3303run_test "Event-driven I/O, DTLS: ticket + resume" \
3304 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3305 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
3306 0 \
3307 -c "Read from server: .* bytes read"
3308
3309run_test "Event-driven I/O, DTLS: session-id resume" \
3310 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3311 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
3312 0 \
3313 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003314
3315# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3316# During session resumption, the client will send its ApplicationData record
3317# within the same datagram as the Finished messages. In this situation, the
3318# server MUST NOT idle on the underlying transport after handshake completion,
3319# because the ApplicationData request has already been queued internally.
3320run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003321 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003322 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3323 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
3324 0 \
3325 -c "Read from server: .* bytes read"
3326
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003327# Tests for version negotiation
3328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003329run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003330 "$P_SRV" \
3331 "$P_CLI" \
3332 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003333 -S "mbedtls_ssl_handshake returned" \
3334 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003335 -s "Protocol is TLSv1.2" \
3336 -c "Protocol is TLSv1.2"
3337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003338run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003339 "$P_SRV" \
3340 "$P_CLI max_version=tls1_1" \
3341 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003342 -S "mbedtls_ssl_handshake returned" \
3343 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003344 -s "Protocol is TLSv1.1" \
3345 -c "Protocol is TLSv1.1"
3346
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003347run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003348 "$P_SRV max_version=tls1_1" \
3349 "$P_CLI" \
3350 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003351 -S "mbedtls_ssl_handshake returned" \
3352 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003353 -s "Protocol is TLSv1.1" \
3354 -c "Protocol is TLSv1.1"
3355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003356run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003357 "$P_SRV max_version=tls1_1" \
3358 "$P_CLI max_version=tls1_1" \
3359 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003360 -S "mbedtls_ssl_handshake returned" \
3361 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003362 -s "Protocol is TLSv1.1" \
3363 -c "Protocol is TLSv1.1"
3364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003365run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003366 "$P_SRV min_version=tls1_1" \
3367 "$P_CLI max_version=tls1_1" \
3368 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003369 -S "mbedtls_ssl_handshake returned" \
3370 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003371 -s "Protocol is TLSv1.1" \
3372 -c "Protocol is TLSv1.1"
3373
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003374run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003375 "$P_SRV max_version=tls1_1" \
3376 "$P_CLI min_version=tls1_1" \
3377 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003378 -S "mbedtls_ssl_handshake returned" \
3379 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003380 -s "Protocol is TLSv1.1" \
3381 -c "Protocol is TLSv1.1"
3382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003383run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003384 "$P_SRV max_version=tls1_1" \
3385 "$P_CLI min_version=tls1_2" \
3386 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003387 -s "mbedtls_ssl_handshake returned" \
3388 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003389 -c "SSL - Handshake protocol not within min/max boundaries"
3390
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003391run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003392 "$P_SRV min_version=tls1_2" \
3393 "$P_CLI max_version=tls1_1" \
3394 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003395 -s "mbedtls_ssl_handshake returned" \
3396 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003397 -s "SSL - Handshake protocol not within min/max boundaries"
3398
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003399# Tests for ALPN extension
3400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003401run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003402 "$P_SRV debug_level=3" \
3403 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003404 0 \
3405 -C "client hello, adding alpn extension" \
3406 -S "found alpn extension" \
3407 -C "got an alert message, type: \\[2:120]" \
3408 -S "server hello, adding alpn extension" \
3409 -C "found alpn extension " \
3410 -C "Application Layer Protocol is" \
3411 -S "Application Layer Protocol is"
3412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003413run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003414 "$P_SRV debug_level=3" \
3415 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003416 0 \
3417 -c "client hello, adding alpn extension" \
3418 -s "found alpn extension" \
3419 -C "got an alert message, type: \\[2:120]" \
3420 -S "server hello, adding alpn extension" \
3421 -C "found alpn extension " \
3422 -c "Application Layer Protocol is (none)" \
3423 -S "Application Layer Protocol is"
3424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003425run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003426 "$P_SRV debug_level=3 alpn=abc,1234" \
3427 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003428 0 \
3429 -C "client hello, adding alpn extension" \
3430 -S "found alpn extension" \
3431 -C "got an alert message, type: \\[2:120]" \
3432 -S "server hello, adding alpn extension" \
3433 -C "found alpn extension " \
3434 -C "Application Layer Protocol is" \
3435 -s "Application Layer Protocol is (none)"
3436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003437run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003438 "$P_SRV debug_level=3 alpn=abc,1234" \
3439 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003440 0 \
3441 -c "client hello, adding alpn extension" \
3442 -s "found alpn extension" \
3443 -C "got an alert message, type: \\[2:120]" \
3444 -s "server hello, adding alpn extension" \
3445 -c "found alpn extension" \
3446 -c "Application Layer Protocol is abc" \
3447 -s "Application Layer Protocol is abc"
3448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003449run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003450 "$P_SRV debug_level=3 alpn=abc,1234" \
3451 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003452 0 \
3453 -c "client hello, adding alpn extension" \
3454 -s "found alpn extension" \
3455 -C "got an alert message, type: \\[2:120]" \
3456 -s "server hello, adding alpn extension" \
3457 -c "found alpn extension" \
3458 -c "Application Layer Protocol is abc" \
3459 -s "Application Layer Protocol is abc"
3460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003461run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003462 "$P_SRV debug_level=3 alpn=abc,1234" \
3463 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003464 0 \
3465 -c "client hello, adding alpn extension" \
3466 -s "found alpn extension" \
3467 -C "got an alert message, type: \\[2:120]" \
3468 -s "server hello, adding alpn extension" \
3469 -c "found alpn extension" \
3470 -c "Application Layer Protocol is 1234" \
3471 -s "Application Layer Protocol is 1234"
3472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003473run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003474 "$P_SRV debug_level=3 alpn=abc,123" \
3475 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003476 1 \
3477 -c "client hello, adding alpn extension" \
3478 -s "found alpn extension" \
3479 -c "got an alert message, type: \\[2:120]" \
3480 -S "server hello, adding alpn extension" \
3481 -C "found alpn extension" \
3482 -C "Application Layer Protocol is 1234" \
3483 -S "Application Layer Protocol is 1234"
3484
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003485
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003486# Tests for keyUsage in leaf certificates, part 1:
3487# server-side certificate/suite selection
3488
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003489run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003490 "$P_SRV key_file=data_files/server2.key \
3491 crt_file=data_files/server2.ku-ds.crt" \
3492 "$P_CLI" \
3493 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003494 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003495
3496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003497run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003498 "$P_SRV key_file=data_files/server2.key \
3499 crt_file=data_files/server2.ku-ke.crt" \
3500 "$P_CLI" \
3501 0 \
3502 -c "Ciphersuite is TLS-RSA-WITH-"
3503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003504run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003505 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003506 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003507 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003508 1 \
3509 -C "Ciphersuite is "
3510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003511run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003512 "$P_SRV key_file=data_files/server5.key \
3513 crt_file=data_files/server5.ku-ds.crt" \
3514 "$P_CLI" \
3515 0 \
3516 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3517
3518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003519run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003520 "$P_SRV key_file=data_files/server5.key \
3521 crt_file=data_files/server5.ku-ka.crt" \
3522 "$P_CLI" \
3523 0 \
3524 -c "Ciphersuite is TLS-ECDH-"
3525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003526run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003527 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003528 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003529 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003530 1 \
3531 -C "Ciphersuite is "
3532
3533# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003534# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003535
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003536run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003537 "$O_SRV -key data_files/server2.key \
3538 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003539 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003540 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3541 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003542 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003543 -C "Processing of the Certificate handshake message failed" \
3544 -c "Ciphersuite is TLS-"
3545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003546run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003547 "$O_SRV -key data_files/server2.key \
3548 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003549 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003550 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3551 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003552 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003553 -C "Processing of the Certificate handshake message failed" \
3554 -c "Ciphersuite is TLS-"
3555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003556run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003557 "$O_SRV -key data_files/server2.key \
3558 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003559 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003560 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3561 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003562 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003563 -C "Processing of the Certificate handshake message failed" \
3564 -c "Ciphersuite is TLS-"
3565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003566run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003567 "$O_SRV -key data_files/server2.key \
3568 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003569 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003570 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3571 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003572 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003573 -c "Processing of the Certificate handshake message failed" \
3574 -C "Ciphersuite is TLS-"
3575
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003576run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3577 "$O_SRV -key data_files/server2.key \
3578 -cert data_files/server2.ku-ke.crt" \
3579 "$P_CLI debug_level=1 auth_mode=optional \
3580 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3581 0 \
3582 -c "bad certificate (usage extensions)" \
3583 -C "Processing of the Certificate handshake message failed" \
3584 -c "Ciphersuite is TLS-" \
3585 -c "! Usage does not match the keyUsage extension"
3586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003587run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003588 "$O_SRV -key data_files/server2.key \
3589 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003590 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003591 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3592 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003593 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003594 -C "Processing of the Certificate handshake message failed" \
3595 -c "Ciphersuite is TLS-"
3596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003597run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003598 "$O_SRV -key data_files/server2.key \
3599 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003600 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003601 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3602 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003603 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003604 -c "Processing of the Certificate handshake message failed" \
3605 -C "Ciphersuite is TLS-"
3606
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003607run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3608 "$O_SRV -key data_files/server2.key \
3609 -cert data_files/server2.ku-ds.crt" \
3610 "$P_CLI debug_level=1 auth_mode=optional \
3611 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3612 0 \
3613 -c "bad certificate (usage extensions)" \
3614 -C "Processing of the Certificate handshake message failed" \
3615 -c "Ciphersuite is TLS-" \
3616 -c "! Usage does not match the keyUsage extension"
3617
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003618# Tests for keyUsage in leaf certificates, part 3:
3619# server-side checking of client cert
3620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003621run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003622 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003623 "$O_CLI -key data_files/server2.key \
3624 -cert data_files/server2.ku-ds.crt" \
3625 0 \
3626 -S "bad certificate (usage extensions)" \
3627 -S "Processing of the Certificate handshake message failed"
3628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003629run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003630 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003631 "$O_CLI -key data_files/server2.key \
3632 -cert data_files/server2.ku-ke.crt" \
3633 0 \
3634 -s "bad certificate (usage extensions)" \
3635 -S "Processing of the Certificate handshake message failed"
3636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003637run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003638 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003639 "$O_CLI -key data_files/server2.key \
3640 -cert data_files/server2.ku-ke.crt" \
3641 1 \
3642 -s "bad certificate (usage extensions)" \
3643 -s "Processing of the Certificate handshake message failed"
3644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003645run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003646 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003647 "$O_CLI -key data_files/server5.key \
3648 -cert data_files/server5.ku-ds.crt" \
3649 0 \
3650 -S "bad certificate (usage extensions)" \
3651 -S "Processing of the Certificate handshake message failed"
3652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003653run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003654 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003655 "$O_CLI -key data_files/server5.key \
3656 -cert data_files/server5.ku-ka.crt" \
3657 0 \
3658 -s "bad certificate (usage extensions)" \
3659 -S "Processing of the Certificate handshake message failed"
3660
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003661# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003663run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003664 "$P_SRV key_file=data_files/server5.key \
3665 crt_file=data_files/server5.eku-srv.crt" \
3666 "$P_CLI" \
3667 0
3668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003669run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003670 "$P_SRV key_file=data_files/server5.key \
3671 crt_file=data_files/server5.eku-srv.crt" \
3672 "$P_CLI" \
3673 0
3674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003675run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003676 "$P_SRV key_file=data_files/server5.key \
3677 crt_file=data_files/server5.eku-cs_any.crt" \
3678 "$P_CLI" \
3679 0
3680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003681run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003682 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003683 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003684 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003685 1
3686
3687# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003689run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003690 "$O_SRV -key data_files/server5.key \
3691 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003692 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003693 0 \
3694 -C "bad certificate (usage extensions)" \
3695 -C "Processing of the Certificate handshake message failed" \
3696 -c "Ciphersuite is TLS-"
3697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003698run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003699 "$O_SRV -key data_files/server5.key \
3700 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003701 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003702 0 \
3703 -C "bad certificate (usage extensions)" \
3704 -C "Processing of the Certificate handshake message failed" \
3705 -c "Ciphersuite is TLS-"
3706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003707run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003708 "$O_SRV -key data_files/server5.key \
3709 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003710 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003711 0 \
3712 -C "bad certificate (usage extensions)" \
3713 -C "Processing of the Certificate handshake message failed" \
3714 -c "Ciphersuite is TLS-"
3715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003716run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003717 "$O_SRV -key data_files/server5.key \
3718 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003719 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003720 1 \
3721 -c "bad certificate (usage extensions)" \
3722 -c "Processing of the Certificate handshake message failed" \
3723 -C "Ciphersuite is TLS-"
3724
3725# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3726
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003727run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003728 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003729 "$O_CLI -key data_files/server5.key \
3730 -cert data_files/server5.eku-cli.crt" \
3731 0 \
3732 -S "bad certificate (usage extensions)" \
3733 -S "Processing of the Certificate handshake message failed"
3734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003735run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003736 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003737 "$O_CLI -key data_files/server5.key \
3738 -cert data_files/server5.eku-srv_cli.crt" \
3739 0 \
3740 -S "bad certificate (usage extensions)" \
3741 -S "Processing of the Certificate handshake message failed"
3742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003743run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003744 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003745 "$O_CLI -key data_files/server5.key \
3746 -cert data_files/server5.eku-cs_any.crt" \
3747 0 \
3748 -S "bad certificate (usage extensions)" \
3749 -S "Processing of the Certificate handshake message failed"
3750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003751run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003752 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003753 "$O_CLI -key data_files/server5.key \
3754 -cert data_files/server5.eku-cs.crt" \
3755 0 \
3756 -s "bad certificate (usage extensions)" \
3757 -S "Processing of the Certificate handshake message failed"
3758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003759run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003760 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003761 "$O_CLI -key data_files/server5.key \
3762 -cert data_files/server5.eku-cs.crt" \
3763 1 \
3764 -s "bad certificate (usage extensions)" \
3765 -s "Processing of the Certificate handshake message failed"
3766
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003767# Tests for DHM parameters loading
3768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003769run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003770 "$P_SRV" \
3771 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3772 debug_level=3" \
3773 0 \
3774 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003775 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003777run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003778 "$P_SRV dhm_file=data_files/dhparams.pem" \
3779 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3780 debug_level=3" \
3781 0 \
3782 -c "value of 'DHM: P ' (1024 bits)" \
3783 -c "value of 'DHM: G ' (2 bits)"
3784
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003785# Tests for DHM client-side size checking
3786
3787run_test "DHM size: server default, client default, OK" \
3788 "$P_SRV" \
3789 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3790 debug_level=1" \
3791 0 \
3792 -C "DHM prime too short:"
3793
3794run_test "DHM size: server default, client 2048, OK" \
3795 "$P_SRV" \
3796 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3797 debug_level=1 dhmlen=2048" \
3798 0 \
3799 -C "DHM prime too short:"
3800
3801run_test "DHM size: server 1024, client default, OK" \
3802 "$P_SRV dhm_file=data_files/dhparams.pem" \
3803 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3804 debug_level=1" \
3805 0 \
3806 -C "DHM prime too short:"
3807
3808run_test "DHM size: server 1000, client default, rejected" \
3809 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3810 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3811 debug_level=1" \
3812 1 \
3813 -c "DHM prime too short:"
3814
3815run_test "DHM size: server default, client 2049, rejected" \
3816 "$P_SRV" \
3817 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3818 debug_level=1 dhmlen=2049" \
3819 1 \
3820 -c "DHM prime too short:"
3821
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003822# Tests for PSK callback
3823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003824run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003825 "$P_SRV psk=abc123 psk_identity=foo" \
3826 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3827 psk_identity=foo psk=abc123" \
3828 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003829 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003830 -S "SSL - Unknown identity received" \
3831 -S "SSL - Verification of the message MAC failed"
3832
Hanno Beckerf7027512018-10-23 15:27:39 +01003833requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
3834run_test "PSK callback: opaque psk on client, no callback" \
3835 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
3836 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3837 psk_identity=foo psk=abc123 psk_slot=1" \
3838 0 \
3839 -c "skip PMS generation for opaque PSK"\
3840 -S "skip PMS generation for opaque PSK"\
3841 -C "using extended master secret"\
3842 -S "using extended master secret"\
3843 -S "SSL - None of the common ciphersuites is usable" \
3844 -S "SSL - Unknown identity received" \
3845 -S "SSL - Verification of the message MAC failed"
3846
3847requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
3848run_test "PSK callback: opaque psk on client, no callback, SHA-384" \
3849 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
3850 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
3851 psk_identity=foo psk=abc123 psk_slot=1" \
3852 0 \
3853 -c "skip PMS generation for opaque PSK"\
3854 -S "skip PMS generation for opaque PSK"\
3855 -C "using extended master secret"\
3856 -S "using extended master secret"\
3857 -S "SSL - None of the common ciphersuites is usable" \
3858 -S "SSL - Unknown identity received" \
3859 -S "SSL - Verification of the message MAC failed"
3860
3861requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
3862run_test "PSK callback: opaque psk on client, no callback, EMS" \
3863 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
3864 "$P_CLI extended_ms=1 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3865 psk_identity=foo psk=abc123 psk_slot=1" \
3866 0 \
3867 -c "skip PMS generation for opaque PSK"\
3868 -S "skip PMS generation for opaque PSK"\
3869 -c "using extended master secret"\
3870 -s "using extended master secret"\
3871 -S "SSL - None of the common ciphersuites is usable" \
3872 -S "SSL - Unknown identity received" \
3873 -S "SSL - Verification of the message MAC failed"
3874
3875requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
3876run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \
3877 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
3878 "$P_CLI extended_ms=1 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
3879 psk_identity=foo psk=abc123 psk_slot=1" \
3880 0 \
3881 -c "skip PMS generation for opaque PSK"\
3882 -S "skip PMS generation for opaque PSK"\
3883 -c "using extended master secret"\
3884 -s "using extended master secret"\
3885 -S "SSL - None of the common ciphersuites is usable" \
3886 -S "SSL - Unknown identity received" \
3887 -S "SSL - Verification of the message MAC failed"
3888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003889run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003890 "$P_SRV" \
3891 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3892 psk_identity=foo psk=abc123" \
3893 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003894 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003895 -S "SSL - Unknown identity received" \
3896 -S "SSL - Verification of the message MAC failed"
3897
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003898run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003899 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3900 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3901 psk_identity=foo psk=abc123" \
3902 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003903 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003904 -s "SSL - Unknown identity received" \
3905 -S "SSL - Verification of the message MAC failed"
3906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003907run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003908 "$P_SRV psk_list=abc,dead,def,beef" \
3909 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3910 psk_identity=abc psk=dead" \
3911 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003912 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003913 -S "SSL - Unknown identity received" \
3914 -S "SSL - Verification of the message MAC failed"
3915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003916run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003917 "$P_SRV psk_list=abc,dead,def,beef" \
3918 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3919 psk_identity=def psk=beef" \
3920 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003921 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003922 -S "SSL - Unknown identity received" \
3923 -S "SSL - Verification of the message MAC failed"
3924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003925run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003926 "$P_SRV psk_list=abc,dead,def,beef" \
3927 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3928 psk_identity=ghi psk=beef" \
3929 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003930 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003931 -s "SSL - Unknown identity received" \
3932 -S "SSL - Verification of the message MAC failed"
3933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003934run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003935 "$P_SRV psk_list=abc,dead,def,beef" \
3936 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3937 psk_identity=abc psk=beef" \
3938 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003939 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003940 -S "SSL - Unknown identity received" \
3941 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003942
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003943# Tests for EC J-PAKE
3944
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003945requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003946run_test "ECJPAKE: client not configured" \
3947 "$P_SRV debug_level=3" \
3948 "$P_CLI debug_level=3" \
3949 0 \
3950 -C "add ciphersuite: c0ff" \
3951 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003952 -S "found ecjpake kkpp extension" \
3953 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003954 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003955 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003956 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003957 -S "None of the common ciphersuites is usable"
3958
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003959requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003960run_test "ECJPAKE: server not configured" \
3961 "$P_SRV debug_level=3" \
3962 "$P_CLI debug_level=3 ecjpake_pw=bla \
3963 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3964 1 \
3965 -c "add ciphersuite: c0ff" \
3966 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003967 -s "found ecjpake kkpp extension" \
3968 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003969 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003970 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003971 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003972 -s "None of the common ciphersuites is usable"
3973
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003974requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003975run_test "ECJPAKE: working, TLS" \
3976 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3977 "$P_CLI debug_level=3 ecjpake_pw=bla \
3978 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003979 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003980 -c "add ciphersuite: c0ff" \
3981 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003982 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003983 -s "found ecjpake kkpp extension" \
3984 -S "skip ecjpake kkpp extension" \
3985 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003986 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003987 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003988 -S "None of the common ciphersuites is usable" \
3989 -S "SSL - Verification of the message MAC failed"
3990
Janos Follath74537a62016-09-02 13:45:28 +01003991server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003992requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003993run_test "ECJPAKE: password mismatch, TLS" \
3994 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3995 "$P_CLI debug_level=3 ecjpake_pw=bad \
3996 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3997 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003998 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003999 -s "SSL - Verification of the message MAC failed"
4000
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004001requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004002run_test "ECJPAKE: working, DTLS" \
4003 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4004 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4005 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4006 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004007 -c "re-using cached ecjpake parameters" \
4008 -S "SSL - Verification of the message MAC failed"
4009
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004010requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004011run_test "ECJPAKE: working, DTLS, no cookie" \
4012 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4013 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4014 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4015 0 \
4016 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004017 -S "SSL - Verification of the message MAC failed"
4018
Janos Follath74537a62016-09-02 13:45:28 +01004019server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004020requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004021run_test "ECJPAKE: password mismatch, DTLS" \
4022 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4023 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4024 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4025 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004026 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004027 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004028
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004029# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004030requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004031run_test "ECJPAKE: working, DTLS, nolog" \
4032 "$P_SRV dtls=1 ecjpake_pw=bla" \
4033 "$P_CLI dtls=1 ecjpake_pw=bla \
4034 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4035 0
4036
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004037# Tests for ciphersuites per version
4038
Janos Follathe2681a42016-03-07 15:57:05 +00004039requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004040run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004041 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-3DES-EDE-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 +02004042 "$P_CLI force_version=ssl3" \
4043 0 \
4044 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
4045
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004046run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004047 "$P_SRV arc4=1 version_suites=TLS-RSA-WITH-3DES-EDE-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 +01004048 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004049 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004050 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004052run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004053 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-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 +02004054 "$P_CLI force_version=tls1_1" \
4055 0 \
4056 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004058run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004059 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-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 +02004060 "$P_CLI force_version=tls1_2" \
4061 0 \
4062 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4063
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004064# Test for ClientHello without extensions
4065
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004066requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004067run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004068 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004069 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004070 0 \
4071 -s "dumping 'client hello extensions' (0 bytes)"
4072
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004073requires_gnutls
4074run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
4075 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004076 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004077 0 \
4078 -s "dumping 'client hello extensions' (0 bytes)"
4079
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004080# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004081
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004082run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004083 "$P_SRV" \
4084 "$P_CLI request_size=100" \
4085 0 \
4086 -s "Read from client: 100 bytes read$"
4087
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004088run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004089 "$P_SRV" \
4090 "$P_CLI request_size=500" \
4091 0 \
4092 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004093
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004094# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004095
Janos Follathe2681a42016-03-07 15:57:05 +00004096requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004097run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004098 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004099 "$P_CLI request_size=1 force_version=ssl3 \
4100 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4101 0 \
4102 -s "Read from client: 1 bytes read"
4103
Janos Follathe2681a42016-03-07 15:57:05 +00004104requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004105run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004106 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004107 "$P_CLI request_size=1 force_version=ssl3 \
4108 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4109 0 \
4110 -s "Read from client: 1 bytes read"
4111
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004112run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004113 "$P_SRV" \
4114 "$P_CLI request_size=1 force_version=tls1 \
4115 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4116 0 \
4117 -s "Read from client: 1 bytes read"
4118
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004119run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004120 "$P_SRV" \
4121 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4122 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4123 0 \
4124 -s "Read from client: 1 bytes read"
4125
Hanno Becker32c55012017-11-10 08:42:54 +00004126requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004127run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004128 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004129 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004130 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004131 0 \
4132 -s "Read from client: 1 bytes read"
4133
Hanno Becker32c55012017-11-10 08:42:54 +00004134requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004135run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004136 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004137 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004138 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004139 0 \
4140 -s "Read from client: 1 bytes read"
4141
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004142run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004143 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004144 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004145 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4146 0 \
4147 -s "Read from client: 1 bytes read"
4148
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004149run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004150 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4151 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004152 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004153 0 \
4154 -s "Read from client: 1 bytes read"
4155
4156requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004157run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004158 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004159 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004160 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004161 0 \
4162 -s "Read from client: 1 bytes read"
4163
Hanno Becker8501f982017-11-10 08:59:04 +00004164requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004165run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004166 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4167 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4168 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004169 0 \
4170 -s "Read from client: 1 bytes read"
4171
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004172run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004173 "$P_SRV" \
4174 "$P_CLI request_size=1 force_version=tls1_1 \
4175 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4176 0 \
4177 -s "Read from client: 1 bytes read"
4178
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004179run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004180 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004181 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004182 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004183 0 \
4184 -s "Read from client: 1 bytes read"
4185
4186requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004187run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004188 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004189 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004190 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004191 0 \
4192 -s "Read from client: 1 bytes read"
4193
4194requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004195run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004196 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004197 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004198 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004199 0 \
4200 -s "Read from client: 1 bytes read"
4201
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004202run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004203 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004204 "$P_CLI request_size=1 force_version=tls1_1 \
4205 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4206 0 \
4207 -s "Read from client: 1 bytes read"
4208
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004209run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004210 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004211 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004212 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004213 0 \
4214 -s "Read from client: 1 bytes read"
4215
Hanno Becker8501f982017-11-10 08:59:04 +00004216requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004217run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004218 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004219 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004220 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004221 0 \
4222 -s "Read from client: 1 bytes read"
4223
Hanno Becker32c55012017-11-10 08:42:54 +00004224requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004225run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004226 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004227 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004228 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004229 0 \
4230 -s "Read from client: 1 bytes read"
4231
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004232run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004233 "$P_SRV" \
4234 "$P_CLI request_size=1 force_version=tls1_2 \
4235 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4236 0 \
4237 -s "Read from client: 1 bytes read"
4238
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004239run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004240 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004241 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004242 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004243 0 \
4244 -s "Read from client: 1 bytes read"
4245
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004246run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004247 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004248 "$P_CLI request_size=1 force_version=tls1_2 \
4249 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004250 0 \
4251 -s "Read from client: 1 bytes read"
4252
Hanno Becker32c55012017-11-10 08:42:54 +00004253requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004254run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004255 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004256 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004257 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004258 0 \
4259 -s "Read from client: 1 bytes read"
4260
Hanno Becker8501f982017-11-10 08:59:04 +00004261requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004262run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004263 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004264 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004265 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004266 0 \
4267 -s "Read from client: 1 bytes read"
4268
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004269run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004270 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004271 "$P_CLI request_size=1 force_version=tls1_2 \
4272 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4273 0 \
4274 -s "Read from client: 1 bytes read"
4275
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004276run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004277 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004278 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004279 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004280 0 \
4281 -s "Read from client: 1 bytes read"
4282
Hanno Becker32c55012017-11-10 08:42:54 +00004283requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004284run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004285 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004286 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004287 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004288 0 \
4289 -s "Read from client: 1 bytes read"
4290
Hanno Becker8501f982017-11-10 08:59:04 +00004291requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004292run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004293 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004294 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004295 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004296 0 \
4297 -s "Read from client: 1 bytes read"
4298
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004299run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004300 "$P_SRV" \
4301 "$P_CLI request_size=1 force_version=tls1_2 \
4302 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4303 0 \
4304 -s "Read from client: 1 bytes read"
4305
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004306run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004307 "$P_SRV" \
4308 "$P_CLI request_size=1 force_version=tls1_2 \
4309 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4310 0 \
4311 -s "Read from client: 1 bytes read"
4312
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004313# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004314
4315requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004316run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004317 "$P_SRV dtls=1 force_version=dtls1" \
4318 "$P_CLI dtls=1 request_size=1 \
4319 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4320 0 \
4321 -s "Read from client: 1 bytes read"
4322
4323requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004324run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004325 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4326 "$P_CLI dtls=1 request_size=1 \
4327 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4328 0 \
4329 -s "Read from client: 1 bytes read"
4330
4331requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4332requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004333run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004334 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4335 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004336 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4337 0 \
4338 -s "Read from client: 1 bytes read"
4339
4340requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4341requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004342run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004343 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004344 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004345 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004346 0 \
4347 -s "Read from client: 1 bytes read"
4348
4349requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004350run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004351 "$P_SRV dtls=1 force_version=dtls1_2" \
4352 "$P_CLI dtls=1 request_size=1 \
4353 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4354 0 \
4355 -s "Read from client: 1 bytes read"
4356
4357requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004358run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004359 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004360 "$P_CLI dtls=1 request_size=1 \
4361 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4362 0 \
4363 -s "Read from client: 1 bytes read"
4364
4365requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4366requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004367run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004368 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004369 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004370 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004371 0 \
4372 -s "Read from client: 1 bytes read"
4373
4374requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4375requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004376run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004377 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004378 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004379 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004380 0 \
4381 -s "Read from client: 1 bytes read"
4382
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004383# Tests for small server packets
4384
4385requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4386run_test "Small server packet SSLv3 BlockCipher" \
4387 "$P_SRV response_size=1 min_version=ssl3" \
4388 "$P_CLI force_version=ssl3 \
4389 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4390 0 \
4391 -c "Read from server: 1 bytes read"
4392
4393requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4394run_test "Small server packet SSLv3 StreamCipher" \
4395 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4396 "$P_CLI force_version=ssl3 \
4397 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4398 0 \
4399 -c "Read from server: 1 bytes read"
4400
4401run_test "Small server packet TLS 1.0 BlockCipher" \
4402 "$P_SRV response_size=1" \
4403 "$P_CLI force_version=tls1 \
4404 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4405 0 \
4406 -c "Read from server: 1 bytes read"
4407
4408run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4409 "$P_SRV response_size=1" \
4410 "$P_CLI force_version=tls1 etm=0 \
4411 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4412 0 \
4413 -c "Read from server: 1 bytes read"
4414
4415requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4416run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4417 "$P_SRV response_size=1 trunc_hmac=1" \
4418 "$P_CLI force_version=tls1 \
4419 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4420 0 \
4421 -c "Read from server: 1 bytes read"
4422
4423requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4424run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4425 "$P_SRV response_size=1 trunc_hmac=1" \
4426 "$P_CLI force_version=tls1 \
4427 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4428 0 \
4429 -c "Read from server: 1 bytes read"
4430
4431run_test "Small server packet TLS 1.0 StreamCipher" \
4432 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4433 "$P_CLI force_version=tls1 \
4434 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4435 0 \
4436 -c "Read from server: 1 bytes read"
4437
4438run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4439 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4440 "$P_CLI force_version=tls1 \
4441 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4442 0 \
4443 -c "Read from server: 1 bytes read"
4444
4445requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4446run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4447 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4448 "$P_CLI force_version=tls1 \
4449 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4450 0 \
4451 -c "Read from server: 1 bytes read"
4452
4453requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4454run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4455 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4456 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4457 trunc_hmac=1 etm=0" \
4458 0 \
4459 -c "Read from server: 1 bytes read"
4460
4461run_test "Small server packet TLS 1.1 BlockCipher" \
4462 "$P_SRV response_size=1" \
4463 "$P_CLI force_version=tls1_1 \
4464 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4465 0 \
4466 -c "Read from server: 1 bytes read"
4467
4468run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4469 "$P_SRV response_size=1" \
4470 "$P_CLI force_version=tls1_1 \
4471 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4472 0 \
4473 -c "Read from server: 1 bytes read"
4474
4475requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4476run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4477 "$P_SRV response_size=1 trunc_hmac=1" \
4478 "$P_CLI force_version=tls1_1 \
4479 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4480 0 \
4481 -c "Read from server: 1 bytes read"
4482
4483requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4484run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4485 "$P_SRV response_size=1 trunc_hmac=1" \
4486 "$P_CLI force_version=tls1_1 \
4487 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4488 0 \
4489 -c "Read from server: 1 bytes read"
4490
4491run_test "Small server packet TLS 1.1 StreamCipher" \
4492 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4493 "$P_CLI force_version=tls1_1 \
4494 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4495 0 \
4496 -c "Read from server: 1 bytes read"
4497
4498run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4499 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4500 "$P_CLI force_version=tls1_1 \
4501 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4502 0 \
4503 -c "Read from server: 1 bytes read"
4504
4505requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4506run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4507 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4508 "$P_CLI force_version=tls1_1 \
4509 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4510 0 \
4511 -c "Read from server: 1 bytes read"
4512
4513requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4514run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4515 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4516 "$P_CLI force_version=tls1_1 \
4517 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4518 0 \
4519 -c "Read from server: 1 bytes read"
4520
4521run_test "Small server packet TLS 1.2 BlockCipher" \
4522 "$P_SRV response_size=1" \
4523 "$P_CLI force_version=tls1_2 \
4524 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4525 0 \
4526 -c "Read from server: 1 bytes read"
4527
4528run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4529 "$P_SRV response_size=1" \
4530 "$P_CLI force_version=tls1_2 \
4531 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4532 0 \
4533 -c "Read from server: 1 bytes read"
4534
4535run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4536 "$P_SRV response_size=1" \
4537 "$P_CLI force_version=tls1_2 \
4538 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4539 0 \
4540 -c "Read from server: 1 bytes read"
4541
4542requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4543run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4544 "$P_SRV response_size=1 trunc_hmac=1" \
4545 "$P_CLI force_version=tls1_2 \
4546 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4547 0 \
4548 -c "Read from server: 1 bytes read"
4549
4550requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4551run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4552 "$P_SRV response_size=1 trunc_hmac=1" \
4553 "$P_CLI force_version=tls1_2 \
4554 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4555 0 \
4556 -c "Read from server: 1 bytes read"
4557
4558run_test "Small server packet TLS 1.2 StreamCipher" \
4559 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4560 "$P_CLI force_version=tls1_2 \
4561 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4562 0 \
4563 -c "Read from server: 1 bytes read"
4564
4565run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4566 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4567 "$P_CLI force_version=tls1_2 \
4568 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4569 0 \
4570 -c "Read from server: 1 bytes read"
4571
4572requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4573run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4574 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4575 "$P_CLI force_version=tls1_2 \
4576 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4577 0 \
4578 -c "Read from server: 1 bytes read"
4579
4580requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4581run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4582 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4583 "$P_CLI force_version=tls1_2 \
4584 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4585 0 \
4586 -c "Read from server: 1 bytes read"
4587
4588run_test "Small server packet TLS 1.2 AEAD" \
4589 "$P_SRV response_size=1" \
4590 "$P_CLI force_version=tls1_2 \
4591 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4592 0 \
4593 -c "Read from server: 1 bytes read"
4594
4595run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4596 "$P_SRV response_size=1" \
4597 "$P_CLI force_version=tls1_2 \
4598 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4599 0 \
4600 -c "Read from server: 1 bytes read"
4601
4602# Tests for small server packets in DTLS
4603
4604requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4605run_test "Small server packet DTLS 1.0" \
4606 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4607 "$P_CLI dtls=1 \
4608 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4609 0 \
4610 -c "Read from server: 1 bytes read"
4611
4612requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4613run_test "Small server packet DTLS 1.0, without EtM" \
4614 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4615 "$P_CLI dtls=1 \
4616 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4617 0 \
4618 -c "Read from server: 1 bytes read"
4619
4620requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4621requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4622run_test "Small server packet DTLS 1.0, truncated hmac" \
4623 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4624 "$P_CLI dtls=1 trunc_hmac=1 \
4625 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4626 0 \
4627 -c "Read from server: 1 bytes read"
4628
4629requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4630requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4631run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4632 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4633 "$P_CLI dtls=1 \
4634 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4635 0 \
4636 -c "Read from server: 1 bytes read"
4637
4638requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4639run_test "Small server packet DTLS 1.2" \
4640 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4641 "$P_CLI dtls=1 \
4642 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4643 0 \
4644 -c "Read from server: 1 bytes read"
4645
4646requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4647run_test "Small server packet DTLS 1.2, without EtM" \
4648 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4649 "$P_CLI dtls=1 \
4650 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4651 0 \
4652 -c "Read from server: 1 bytes read"
4653
4654requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4655requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4656run_test "Small server packet DTLS 1.2, truncated hmac" \
4657 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4658 "$P_CLI dtls=1 \
4659 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4660 0 \
4661 -c "Read from server: 1 bytes read"
4662
4663requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4664requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4665run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4666 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4667 "$P_CLI dtls=1 \
4668 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4669 0 \
4670 -c "Read from server: 1 bytes read"
4671
Janos Follath00efff72016-05-06 13:48:23 +01004672# A test for extensions in SSLv3
4673
4674requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4675run_test "SSLv3 with extensions, server side" \
4676 "$P_SRV min_version=ssl3 debug_level=3" \
4677 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4678 0 \
4679 -S "dumping 'client hello extensions'" \
4680 -S "server hello, total extension length:"
4681
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004682# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004683
Angus Grattonc4dd0732018-04-11 16:28:39 +10004684# How many fragments do we expect to write $1 bytes?
4685fragments_for_write() {
4686 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4687}
4688
Janos Follathe2681a42016-03-07 15:57:05 +00004689requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004690run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004691 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004692 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004693 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4694 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004695 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4696 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004697
Janos Follathe2681a42016-03-07 15:57:05 +00004698requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004699run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004700 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004701 "$P_CLI request_size=16384 force_version=ssl3 \
4702 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4703 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004704 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4705 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004706
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004707run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004708 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004709 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004710 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4711 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004712 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4713 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004714
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004715run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004716 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004717 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4718 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4719 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004720 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004721
Hanno Becker32c55012017-11-10 08:42:54 +00004722requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004723run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004724 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004725 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004726 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004727 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004728 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4729 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004730
Hanno Becker32c55012017-11-10 08:42:54 +00004731requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004732run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004733 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004734 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004735 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004736 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004737 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004738
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004739run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004740 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004741 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004742 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4743 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004744 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004745
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004746run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004747 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4748 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004749 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004750 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004751 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004752
4753requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004754run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004755 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004756 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004757 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004758 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004759 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004760
Hanno Becker278fc7a2017-11-10 09:16:28 +00004761requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004762run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004763 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004764 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004765 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004766 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004767 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4768 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004769
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004770run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004771 "$P_SRV" \
4772 "$P_CLI request_size=16384 force_version=tls1_1 \
4773 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4774 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004775 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4776 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004777
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004778run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004779 "$P_SRV" \
4780 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4781 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004782 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004783 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004784
Hanno Becker32c55012017-11-10 08:42:54 +00004785requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004786run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004787 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004788 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004789 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004790 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004791 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004792
Hanno Becker32c55012017-11-10 08:42:54 +00004793requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004794run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004795 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004796 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004797 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004798 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004799 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004800
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004801run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004802 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4803 "$P_CLI request_size=16384 force_version=tls1_1 \
4804 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4805 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004806 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4807 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004808
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004809run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004810 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004811 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004812 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004813 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004814 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4815 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004816
Hanno Becker278fc7a2017-11-10 09:16:28 +00004817requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004818run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004819 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004820 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004821 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004822 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004823 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004824
Hanno Becker278fc7a2017-11-10 09:16:28 +00004825requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004826run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004827 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004828 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004829 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004830 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004831 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4832 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004833
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004834run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004835 "$P_SRV" \
4836 "$P_CLI request_size=16384 force_version=tls1_2 \
4837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4838 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004839 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4840 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004841
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004842run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004843 "$P_SRV" \
4844 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4845 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4846 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004847 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004848
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004849run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004850 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004851 "$P_CLI request_size=16384 force_version=tls1_2 \
4852 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004853 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004854 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4855 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004856
Hanno Becker32c55012017-11-10 08:42:54 +00004857requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004858run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004859 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004860 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004861 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004862 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004863 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004864
Hanno Becker278fc7a2017-11-10 09:16:28 +00004865requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004866run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004867 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004868 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004869 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004870 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004871 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4872 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004873
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004874run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004875 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004876 "$P_CLI request_size=16384 force_version=tls1_2 \
4877 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4878 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004879 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4880 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004881
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004882run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004883 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004884 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004885 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4886 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004887 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004888
Hanno Becker32c55012017-11-10 08:42:54 +00004889requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004890run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004891 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004892 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004893 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004894 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004895 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004896
Hanno Becker278fc7a2017-11-10 09:16:28 +00004897requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004898run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004899 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004900 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004901 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004902 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004903 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4904 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004905
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004906run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004907 "$P_SRV" \
4908 "$P_CLI request_size=16384 force_version=tls1_2 \
4909 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4910 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004911 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4912 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004913
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004914run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004915 "$P_SRV" \
4916 "$P_CLI request_size=16384 force_version=tls1_2 \
4917 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4918 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004919 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4920 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004921
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004922# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004923requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4924run_test "Large server packet SSLv3 StreamCipher" \
4925 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4926 "$P_CLI force_version=ssl3 \
4927 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4928 0 \
4929 -c "Read from server: 16384 bytes read"
4930
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04004931# Checking next 4 tests logs for 1n-1 split against BEAST too
4932requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4933run_test "Large server packet SSLv3 BlockCipher" \
4934 "$P_SRV response_size=16384 min_version=ssl3" \
4935 "$P_CLI force_version=ssl3 recsplit=0 \
4936 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4937 0 \
4938 -c "Read from server: 1 bytes read"\
4939 -c "16383 bytes read"\
4940 -C "Read from server: 16384 bytes read"
4941
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004942run_test "Large server packet TLS 1.0 BlockCipher" \
4943 "$P_SRV response_size=16384" \
4944 "$P_CLI force_version=tls1 recsplit=0 \
4945 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4946 0 \
4947 -c "Read from server: 1 bytes read"\
4948 -c "16383 bytes read"\
4949 -C "Read from server: 16384 bytes read"
4950
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004951run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
4952 "$P_SRV response_size=16384" \
4953 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
4954 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4955 0 \
4956 -c "Read from server: 1 bytes read"\
4957 -c "16383 bytes read"\
4958 -C "Read from server: 16384 bytes read"
4959
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004960requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4961run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
4962 "$P_SRV response_size=16384" \
4963 "$P_CLI force_version=tls1 recsplit=0 \
4964 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4965 trunc_hmac=1" \
4966 0 \
4967 -c "Read from server: 1 bytes read"\
4968 -c "16383 bytes read"\
4969 -C "Read from server: 16384 bytes read"
4970
4971requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4972run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
4973 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4974 "$P_CLI force_version=tls1 \
4975 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4976 trunc_hmac=1" \
4977 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004978 -s "16384 bytes written in 1 fragments" \
4979 -c "Read from server: 16384 bytes read"
4980
4981run_test "Large server packet TLS 1.0 StreamCipher" \
4982 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4983 "$P_CLI force_version=tls1 \
4984 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4985 0 \
4986 -s "16384 bytes written in 1 fragments" \
4987 -c "Read from server: 16384 bytes read"
4988
4989run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
4990 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4991 "$P_CLI force_version=tls1 \
4992 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4993 0 \
4994 -s "16384 bytes written in 1 fragments" \
4995 -c "Read from server: 16384 bytes read"
4996
4997requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4998run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
4999 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5000 "$P_CLI force_version=tls1 \
5001 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5002 0 \
5003 -s "16384 bytes written in 1 fragments" \
5004 -c "Read from server: 16384 bytes read"
5005
5006requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5007run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5008 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5009 "$P_CLI force_version=tls1 \
5010 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5011 0 \
5012 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005013 -c "Read from server: 16384 bytes read"
5014
5015run_test "Large server packet TLS 1.1 BlockCipher" \
5016 "$P_SRV response_size=16384" \
5017 "$P_CLI force_version=tls1_1 \
5018 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5019 0 \
5020 -c "Read from server: 16384 bytes read"
5021
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005022run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5023 "$P_SRV response_size=16384" \
5024 "$P_CLI force_version=tls1_1 etm=0 \
5025 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005026 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005027 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005028 -c "Read from server: 16384 bytes read"
5029
5030requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5031run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5032 "$P_SRV response_size=16384" \
5033 "$P_CLI force_version=tls1_1 \
5034 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5035 trunc_hmac=1" \
5036 0 \
5037 -c "Read from server: 16384 bytes read"
5038
5039requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005040run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5041 "$P_SRV response_size=16384 trunc_hmac=1" \
5042 "$P_CLI force_version=tls1_1 \
5043 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5044 0 \
5045 -s "16384 bytes written in 1 fragments" \
5046 -c "Read from server: 16384 bytes read"
5047
5048run_test "Large server packet TLS 1.1 StreamCipher" \
5049 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5050 "$P_CLI force_version=tls1_1 \
5051 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5052 0 \
5053 -c "Read from server: 16384 bytes read"
5054
5055run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5056 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5057 "$P_CLI force_version=tls1_1 \
5058 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5059 0 \
5060 -s "16384 bytes written in 1 fragments" \
5061 -c "Read from server: 16384 bytes read"
5062
5063requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005064run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5065 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5066 "$P_CLI force_version=tls1_1 \
5067 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5068 trunc_hmac=1" \
5069 0 \
5070 -c "Read from server: 16384 bytes read"
5071
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005072run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5073 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5074 "$P_CLI force_version=tls1_1 \
5075 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5076 0 \
5077 -s "16384 bytes written in 1 fragments" \
5078 -c "Read from server: 16384 bytes read"
5079
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005080run_test "Large server packet TLS 1.2 BlockCipher" \
5081 "$P_SRV response_size=16384" \
5082 "$P_CLI force_version=tls1_2 \
5083 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5084 0 \
5085 -c "Read from server: 16384 bytes read"
5086
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005087run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5088 "$P_SRV response_size=16384" \
5089 "$P_CLI force_version=tls1_2 etm=0 \
5090 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5091 0 \
5092 -s "16384 bytes written in 1 fragments" \
5093 -c "Read from server: 16384 bytes read"
5094
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005095run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5096 "$P_SRV response_size=16384" \
5097 "$P_CLI force_version=tls1_2 \
5098 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5099 0 \
5100 -c "Read from server: 16384 bytes read"
5101
5102requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5103run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5104 "$P_SRV response_size=16384" \
5105 "$P_CLI force_version=tls1_2 \
5106 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5107 trunc_hmac=1" \
5108 0 \
5109 -c "Read from server: 16384 bytes read"
5110
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005111run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5112 "$P_SRV response_size=16384 trunc_hmac=1" \
5113 "$P_CLI force_version=tls1_2 \
5114 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5115 0 \
5116 -s "16384 bytes written in 1 fragments" \
5117 -c "Read from server: 16384 bytes read"
5118
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005119run_test "Large server packet TLS 1.2 StreamCipher" \
5120 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5121 "$P_CLI force_version=tls1_2 \
5122 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5123 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005124 -s "16384 bytes written in 1 fragments" \
5125 -c "Read from server: 16384 bytes read"
5126
5127run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5128 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5129 "$P_CLI force_version=tls1_2 \
5130 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5131 0 \
5132 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005133 -c "Read from server: 16384 bytes read"
5134
5135requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5136run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5137 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5138 "$P_CLI force_version=tls1_2 \
5139 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5140 trunc_hmac=1" \
5141 0 \
5142 -c "Read from server: 16384 bytes read"
5143
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005144requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5145run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5146 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5147 "$P_CLI force_version=tls1_2 \
5148 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5149 0 \
5150 -s "16384 bytes written in 1 fragments" \
5151 -c "Read from server: 16384 bytes read"
5152
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005153run_test "Large server packet TLS 1.2 AEAD" \
5154 "$P_SRV response_size=16384" \
5155 "$P_CLI force_version=tls1_2 \
5156 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5157 0 \
5158 -c "Read from server: 16384 bytes read"
5159
5160run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5161 "$P_SRV response_size=16384" \
5162 "$P_CLI force_version=tls1_2 \
5163 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5164 0 \
5165 -c "Read from server: 16384 bytes read"
5166
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005167# Tests for restartable ECC
5168
5169requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5170run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005171 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005172 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005173 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005174 debug_level=1" \
5175 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005176 -C "x509_verify_cert.*4b00" \
5177 -C "mbedtls_pk_verify.*4b00" \
5178 -C "mbedtls_ecdh_make_public.*4b00" \
5179 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005180
5181requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5182run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005183 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005184 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005185 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005186 debug_level=1 ec_max_ops=0" \
5187 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005188 -C "x509_verify_cert.*4b00" \
5189 -C "mbedtls_pk_verify.*4b00" \
5190 -C "mbedtls_ecdh_make_public.*4b00" \
5191 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005192
5193requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5194run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005195 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005196 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005197 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005198 debug_level=1 ec_max_ops=65535" \
5199 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005200 -C "x509_verify_cert.*4b00" \
5201 -C "mbedtls_pk_verify.*4b00" \
5202 -C "mbedtls_ecdh_make_public.*4b00" \
5203 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005204
5205requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5206run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005207 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005208 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005209 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005210 debug_level=1 ec_max_ops=1000" \
5211 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005212 -c "x509_verify_cert.*4b00" \
5213 -c "mbedtls_pk_verify.*4b00" \
5214 -c "mbedtls_ecdh_make_public.*4b00" \
5215 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005216
5217requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005218run_test "EC restart: TLS, max_ops=1000, badsign" \
5219 "$P_SRV auth_mode=required \
5220 crt_file=data_files/server5-badsign.crt \
5221 key_file=data_files/server5.key" \
5222 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5223 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5224 debug_level=1 ec_max_ops=1000" \
5225 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005226 -c "x509_verify_cert.*4b00" \
5227 -C "mbedtls_pk_verify.*4b00" \
5228 -C "mbedtls_ecdh_make_public.*4b00" \
5229 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005230 -c "! The certificate is not correctly signed by the trusted CA" \
5231 -c "! mbedtls_ssl_handshake returned" \
5232 -c "X509 - Certificate verification failed"
5233
5234requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5235run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5236 "$P_SRV auth_mode=required \
5237 crt_file=data_files/server5-badsign.crt \
5238 key_file=data_files/server5.key" \
5239 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5240 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5241 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5242 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005243 -c "x509_verify_cert.*4b00" \
5244 -c "mbedtls_pk_verify.*4b00" \
5245 -c "mbedtls_ecdh_make_public.*4b00" \
5246 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005247 -c "! The certificate is not correctly signed by the trusted CA" \
5248 -C "! mbedtls_ssl_handshake returned" \
5249 -C "X509 - Certificate verification failed"
5250
5251requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5252run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5253 "$P_SRV auth_mode=required \
5254 crt_file=data_files/server5-badsign.crt \
5255 key_file=data_files/server5.key" \
5256 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5257 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5258 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5259 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005260 -C "x509_verify_cert.*4b00" \
5261 -c "mbedtls_pk_verify.*4b00" \
5262 -c "mbedtls_ecdh_make_public.*4b00" \
5263 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005264 -C "! The certificate is not correctly signed by the trusted CA" \
5265 -C "! mbedtls_ssl_handshake returned" \
5266 -C "X509 - Certificate verification failed"
5267
5268requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005269run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005270 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005271 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005272 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005273 dtls=1 debug_level=1 ec_max_ops=1000" \
5274 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005275 -c "x509_verify_cert.*4b00" \
5276 -c "mbedtls_pk_verify.*4b00" \
5277 -c "mbedtls_ecdh_make_public.*4b00" \
5278 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005279
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005280requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5281run_test "EC restart: TLS, max_ops=1000 no client auth" \
5282 "$P_SRV" \
5283 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5284 debug_level=1 ec_max_ops=1000" \
5285 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005286 -c "x509_verify_cert.*4b00" \
5287 -c "mbedtls_pk_verify.*4b00" \
5288 -c "mbedtls_ecdh_make_public.*4b00" \
5289 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005290
5291requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5292run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5293 "$P_SRV psk=abc123" \
5294 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5295 psk=abc123 debug_level=1 ec_max_ops=1000" \
5296 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005297 -C "x509_verify_cert.*4b00" \
5298 -C "mbedtls_pk_verify.*4b00" \
5299 -C "mbedtls_ecdh_make_public.*4b00" \
5300 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005301
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005302# Tests of asynchronous private key support in SSL
5303
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005304requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005305run_test "SSL async private: sign, delay=0" \
5306 "$P_SRV \
5307 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005308 "$P_CLI" \
5309 0 \
5310 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005311 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005312
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005313requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005314run_test "SSL async private: sign, delay=1" \
5315 "$P_SRV \
5316 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005317 "$P_CLI" \
5318 0 \
5319 -s "Async sign callback: using key slot " \
5320 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005321 -s "Async resume (slot [0-9]): sign done, status=0"
5322
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005323requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5324run_test "SSL async private: sign, delay=2" \
5325 "$P_SRV \
5326 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5327 "$P_CLI" \
5328 0 \
5329 -s "Async sign callback: using key slot " \
5330 -U "Async sign callback: using key slot " \
5331 -s "Async resume (slot [0-9]): call 1 more times." \
5332 -s "Async resume (slot [0-9]): call 0 more times." \
5333 -s "Async resume (slot [0-9]): sign done, status=0"
5334
Gilles Peskined3268832018-04-26 06:23:59 +02005335# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5336# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5337requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5338requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5339run_test "SSL async private: sign, RSA, TLS 1.1" \
5340 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5341 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5342 "$P_CLI force_version=tls1_1" \
5343 0 \
5344 -s "Async sign callback: using key slot " \
5345 -s "Async resume (slot [0-9]): sign done, status=0"
5346
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005347requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005348run_test "SSL async private: sign, SNI" \
5349 "$P_SRV debug_level=3 \
5350 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5351 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5352 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5353 "$P_CLI server_name=polarssl.example" \
5354 0 \
5355 -s "Async sign callback: using key slot " \
5356 -s "Async resume (slot [0-9]): sign done, status=0" \
5357 -s "parse ServerName extension" \
5358 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5359 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5360
5361requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005362run_test "SSL async private: decrypt, delay=0" \
5363 "$P_SRV \
5364 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5365 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5366 0 \
5367 -s "Async decrypt callback: using key slot " \
5368 -s "Async resume (slot [0-9]): decrypt done, status=0"
5369
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005370requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005371run_test "SSL async private: decrypt, delay=1" \
5372 "$P_SRV \
5373 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5374 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5375 0 \
5376 -s "Async decrypt callback: using key slot " \
5377 -s "Async resume (slot [0-9]): call 0 more times." \
5378 -s "Async resume (slot [0-9]): decrypt done, status=0"
5379
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005380requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005381run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5382 "$P_SRV psk=abc123 \
5383 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5384 "$P_CLI psk=abc123 \
5385 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5386 0 \
5387 -s "Async decrypt callback: using key slot " \
5388 -s "Async resume (slot [0-9]): decrypt done, status=0"
5389
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005390requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005391run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5392 "$P_SRV psk=abc123 \
5393 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5394 "$P_CLI psk=abc123 \
5395 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5396 0 \
5397 -s "Async decrypt callback: using key slot " \
5398 -s "Async resume (slot [0-9]): call 0 more times." \
5399 -s "Async resume (slot [0-9]): decrypt done, status=0"
5400
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005401requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005402run_test "SSL async private: sign callback not present" \
5403 "$P_SRV \
5404 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5405 "$P_CLI; [ \$? -eq 1 ] &&
5406 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5407 0 \
5408 -S "Async sign callback" \
5409 -s "! mbedtls_ssl_handshake returned" \
5410 -s "The own private key or pre-shared key is not set, but needed" \
5411 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5412 -s "Successful connection"
5413
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005414requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005415run_test "SSL async private: decrypt callback not present" \
5416 "$P_SRV debug_level=1 \
5417 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5418 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5419 [ \$? -eq 1 ] && $P_CLI" \
5420 0 \
5421 -S "Async decrypt callback" \
5422 -s "! mbedtls_ssl_handshake returned" \
5423 -s "got no RSA private key" \
5424 -s "Async resume (slot [0-9]): sign done, status=0" \
5425 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005426
5427# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005428requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005429run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005430 "$P_SRV \
5431 async_operations=s async_private_delay1=1 \
5432 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5433 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005434 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5435 0 \
5436 -s "Async sign callback: using key slot 0," \
5437 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005438 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005439
5440# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005441requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005442run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005443 "$P_SRV \
5444 async_operations=s async_private_delay2=1 \
5445 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5446 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005447 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5448 0 \
5449 -s "Async sign callback: using key slot 0," \
5450 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005451 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005452
5453# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005454requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005455run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005456 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005457 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005458 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5459 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005460 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5461 0 \
5462 -s "Async sign callback: using key slot 1," \
5463 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005464 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005465
5466# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005467requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005468run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005469 "$P_SRV \
5470 async_operations=s async_private_delay1=1 \
5471 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5472 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005473 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5474 0 \
5475 -s "Async sign callback: no key matches this certificate."
5476
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005477requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005478run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005479 "$P_SRV \
5480 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5481 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005482 "$P_CLI" \
5483 1 \
5484 -s "Async sign callback: injected error" \
5485 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005486 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005487 -s "! mbedtls_ssl_handshake returned"
5488
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005489requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005490run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005491 "$P_SRV \
5492 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5493 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005494 "$P_CLI" \
5495 1 \
5496 -s "Async sign callback: using key slot " \
5497 -S "Async resume" \
5498 -s "Async cancel"
5499
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005500requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005501run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005502 "$P_SRV \
5503 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5504 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005505 "$P_CLI" \
5506 1 \
5507 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005508 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005509 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005510 -s "! mbedtls_ssl_handshake returned"
5511
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005512requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005513run_test "SSL async private: decrypt, error in start" \
5514 "$P_SRV \
5515 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5516 async_private_error=1" \
5517 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5518 1 \
5519 -s "Async decrypt callback: injected error" \
5520 -S "Async resume" \
5521 -S "Async cancel" \
5522 -s "! mbedtls_ssl_handshake returned"
5523
5524requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5525run_test "SSL async private: decrypt, cancel after start" \
5526 "$P_SRV \
5527 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5528 async_private_error=2" \
5529 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5530 1 \
5531 -s "Async decrypt callback: using key slot " \
5532 -S "Async resume" \
5533 -s "Async cancel"
5534
5535requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5536run_test "SSL async private: decrypt, error in resume" \
5537 "$P_SRV \
5538 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5539 async_private_error=3" \
5540 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5541 1 \
5542 -s "Async decrypt callback: using key slot " \
5543 -s "Async resume callback: decrypt done but injected error" \
5544 -S "Async cancel" \
5545 -s "! mbedtls_ssl_handshake returned"
5546
5547requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005548run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005549 "$P_SRV \
5550 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5551 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005552 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5553 0 \
5554 -s "Async cancel" \
5555 -s "! mbedtls_ssl_handshake returned" \
5556 -s "Async resume" \
5557 -s "Successful connection"
5558
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005559requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005560run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005561 "$P_SRV \
5562 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5563 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005564 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5565 0 \
5566 -s "! mbedtls_ssl_handshake returned" \
5567 -s "Async resume" \
5568 -s "Successful connection"
5569
5570# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005571requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005572run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005573 "$P_SRV \
5574 async_operations=s async_private_delay1=1 async_private_error=-2 \
5575 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5576 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005577 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5578 [ \$? -eq 1 ] &&
5579 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5580 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005581 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005582 -S "Async resume" \
5583 -s "Async cancel" \
5584 -s "! mbedtls_ssl_handshake returned" \
5585 -s "Async sign callback: no key matches this certificate." \
5586 -s "Successful connection"
5587
5588# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005589requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005590run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005591 "$P_SRV \
5592 async_operations=s async_private_delay1=1 async_private_error=-3 \
5593 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5594 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005595 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5596 [ \$? -eq 1 ] &&
5597 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5598 0 \
5599 -s "Async resume" \
5600 -s "! mbedtls_ssl_handshake returned" \
5601 -s "Async sign callback: no key matches this certificate." \
5602 -s "Successful connection"
5603
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005604requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005605requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005606run_test "SSL async private: renegotiation: client-initiated; sign" \
5607 "$P_SRV \
5608 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005609 exchanges=2 renegotiation=1" \
5610 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5611 0 \
5612 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005613 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005614
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005615requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005616requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005617run_test "SSL async private: renegotiation: server-initiated; sign" \
5618 "$P_SRV \
5619 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005620 exchanges=2 renegotiation=1 renegotiate=1" \
5621 "$P_CLI exchanges=2 renegotiation=1" \
5622 0 \
5623 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005624 -s "Async resume (slot [0-9]): sign done, status=0"
5625
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005626requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005627requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5628run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5629 "$P_SRV \
5630 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5631 exchanges=2 renegotiation=1" \
5632 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5633 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5634 0 \
5635 -s "Async decrypt callback: using key slot " \
5636 -s "Async resume (slot [0-9]): decrypt done, status=0"
5637
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005638requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005639requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5640run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5641 "$P_SRV \
5642 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5643 exchanges=2 renegotiation=1 renegotiate=1" \
5644 "$P_CLI exchanges=2 renegotiation=1 \
5645 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5646 0 \
5647 -s "Async decrypt callback: using key slot " \
5648 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005649
Ron Eldor58093c82018-06-28 13:22:05 +03005650# Tests for ECC extensions (rfc 4492)
5651
Ron Eldor643df7c2018-06-28 16:17:00 +03005652requires_config_enabled MBEDTLS_AES_C
5653requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5654requires_config_enabled MBEDTLS_SHA256_C
5655requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005656run_test "Force a non ECC ciphersuite in the client side" \
5657 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005658 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005659 0 \
5660 -C "client hello, adding supported_elliptic_curves extension" \
5661 -C "client hello, adding supported_point_formats extension" \
5662 -S "found supported elliptic curves extension" \
5663 -S "found supported point formats extension"
5664
Ron Eldor643df7c2018-06-28 16:17:00 +03005665requires_config_enabled MBEDTLS_AES_C
5666requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5667requires_config_enabled MBEDTLS_SHA256_C
5668requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005669run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005670 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005671 "$P_CLI debug_level=3" \
5672 0 \
5673 -C "found supported_point_formats extension" \
5674 -S "server hello, supported_point_formats extension"
5675
Ron Eldor643df7c2018-06-28 16:17:00 +03005676requires_config_enabled MBEDTLS_AES_C
5677requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5678requires_config_enabled MBEDTLS_SHA256_C
5679requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005680run_test "Force an ECC ciphersuite in the client side" \
5681 "$P_SRV debug_level=3" \
5682 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5683 0 \
5684 -c "client hello, adding supported_elliptic_curves extension" \
5685 -c "client hello, adding supported_point_formats extension" \
5686 -s "found supported elliptic curves extension" \
5687 -s "found supported point formats extension"
5688
Ron Eldor643df7c2018-06-28 16:17:00 +03005689requires_config_enabled MBEDTLS_AES_C
5690requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5691requires_config_enabled MBEDTLS_SHA256_C
5692requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005693run_test "Force an ECC ciphersuite in the server side" \
5694 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5695 "$P_CLI debug_level=3" \
5696 0 \
5697 -c "found supported_point_formats extension" \
5698 -s "server hello, supported_point_formats extension"
5699
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005700# Tests for DTLS HelloVerifyRequest
5701
5702run_test "DTLS cookie: enabled" \
5703 "$P_SRV dtls=1 debug_level=2" \
5704 "$P_CLI dtls=1 debug_level=2" \
5705 0 \
5706 -s "cookie verification failed" \
5707 -s "cookie verification passed" \
5708 -S "cookie verification skipped" \
5709 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005710 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005711 -S "SSL - The requested feature is not available"
5712
5713run_test "DTLS cookie: disabled" \
5714 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5715 "$P_CLI dtls=1 debug_level=2" \
5716 0 \
5717 -S "cookie verification failed" \
5718 -S "cookie verification passed" \
5719 -s "cookie verification skipped" \
5720 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005721 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005722 -S "SSL - The requested feature is not available"
5723
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005724run_test "DTLS cookie: default (failing)" \
5725 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5726 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5727 1 \
5728 -s "cookie verification failed" \
5729 -S "cookie verification passed" \
5730 -S "cookie verification skipped" \
5731 -C "received hello verify request" \
5732 -S "hello verification requested" \
5733 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005734
5735requires_ipv6
5736run_test "DTLS cookie: enabled, IPv6" \
5737 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5738 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5739 0 \
5740 -s "cookie verification failed" \
5741 -s "cookie verification passed" \
5742 -S "cookie verification skipped" \
5743 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005744 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005745 -S "SSL - The requested feature is not available"
5746
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005747run_test "DTLS cookie: enabled, nbio" \
5748 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5749 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5750 0 \
5751 -s "cookie verification failed" \
5752 -s "cookie verification passed" \
5753 -S "cookie verification skipped" \
5754 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005755 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005756 -S "SSL - The requested feature is not available"
5757
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005758# Tests for client reconnecting from the same port with DTLS
5759
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005760not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005761run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005762 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
5763 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005764 0 \
5765 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005766 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005767 -S "Client initiated reconnection from same port"
5768
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005769not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005770run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005771 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
5772 "$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 +02005773 0 \
5774 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005775 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005776 -s "Client initiated reconnection from same port"
5777
Paul Bakker362689d2016-05-13 10:33:25 +01005778not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5779run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005780 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5781 "$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 +02005782 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005783 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005784 -s "Client initiated reconnection from same port"
5785
Paul Bakker362689d2016-05-13 10:33:25 +01005786only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5787run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5788 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5789 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5790 0 \
5791 -S "The operation timed out" \
5792 -s "Client initiated reconnection from same port"
5793
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005794run_test "DTLS client reconnect from same port: no cookies" \
5795 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005796 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5797 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005798 -s "The operation timed out" \
5799 -S "Client initiated reconnection from same port"
5800
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005801# Tests for various cases of client authentication with DTLS
5802# (focused on handshake flows and message parsing)
5803
5804run_test "DTLS client auth: required" \
5805 "$P_SRV dtls=1 auth_mode=required" \
5806 "$P_CLI dtls=1" \
5807 0 \
5808 -s "Verifying peer X.509 certificate... ok"
5809
5810run_test "DTLS client auth: optional, client has no cert" \
5811 "$P_SRV dtls=1 auth_mode=optional" \
5812 "$P_CLI dtls=1 crt_file=none key_file=none" \
5813 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005814 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005815
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005816run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005817 "$P_SRV dtls=1 auth_mode=none" \
5818 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5819 0 \
5820 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005821 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005822
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005823run_test "DTLS wrong PSK: badmac alert" \
5824 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5825 "$P_CLI dtls=1 psk=abc124" \
5826 1 \
5827 -s "SSL - Verification of the message MAC failed" \
5828 -c "SSL - A fatal alert message was received from our peer"
5829
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005830# Tests for receiving fragmented handshake messages with DTLS
5831
5832requires_gnutls
5833run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5834 "$G_SRV -u --mtu 2048 -a" \
5835 "$P_CLI dtls=1 debug_level=2" \
5836 0 \
5837 -C "found fragmented DTLS handshake message" \
5838 -C "error"
5839
5840requires_gnutls
5841run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5842 "$G_SRV -u --mtu 512" \
5843 "$P_CLI dtls=1 debug_level=2" \
5844 0 \
5845 -c "found fragmented DTLS handshake message" \
5846 -C "error"
5847
5848requires_gnutls
5849run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5850 "$G_SRV -u --mtu 128" \
5851 "$P_CLI dtls=1 debug_level=2" \
5852 0 \
5853 -c "found fragmented DTLS handshake message" \
5854 -C "error"
5855
5856requires_gnutls
5857run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5858 "$G_SRV -u --mtu 128" \
5859 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5860 0 \
5861 -c "found fragmented DTLS handshake message" \
5862 -C "error"
5863
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005864requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005865requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005866run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5867 "$G_SRV -u --mtu 256" \
5868 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5869 0 \
5870 -c "found fragmented DTLS handshake message" \
5871 -c "client hello, adding renegotiation extension" \
5872 -c "found renegotiation extension" \
5873 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005874 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005875 -C "error" \
5876 -s "Extra-header:"
5877
5878requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005879requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005880run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5881 "$G_SRV -u --mtu 256" \
5882 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5883 0 \
5884 -c "found fragmented DTLS handshake message" \
5885 -c "client hello, adding renegotiation extension" \
5886 -c "found renegotiation extension" \
5887 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005888 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005889 -C "error" \
5890 -s "Extra-header:"
5891
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005892run_test "DTLS reassembly: no fragmentation (openssl server)" \
5893 "$O_SRV -dtls1 -mtu 2048" \
5894 "$P_CLI dtls=1 debug_level=2" \
5895 0 \
5896 -C "found fragmented DTLS handshake message" \
5897 -C "error"
5898
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005899run_test "DTLS reassembly: some fragmentation (openssl server)" \
5900 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005901 "$P_CLI dtls=1 debug_level=2" \
5902 0 \
5903 -c "found fragmented DTLS handshake message" \
5904 -C "error"
5905
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005906run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005907 "$O_SRV -dtls1 -mtu 256" \
5908 "$P_CLI dtls=1 debug_level=2" \
5909 0 \
5910 -c "found fragmented DTLS handshake message" \
5911 -C "error"
5912
5913run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5914 "$O_SRV -dtls1 -mtu 256" \
5915 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5916 0 \
5917 -c "found fragmented DTLS handshake message" \
5918 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005919
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005920# Tests for sending fragmented handshake messages with DTLS
5921#
5922# Use client auth when we need the client to send large messages,
5923# and use large cert chains on both sides too (the long chains we have all use
5924# both RSA and ECDSA, but ideally we should have long chains with either).
5925# Sizes reached (UDP payload):
5926# - 2037B for server certificate
5927# - 1542B for client certificate
5928# - 1013B for newsessionticket
5929# - all others below 512B
5930# All those tests assume MAX_CONTENT_LEN is at least 2048
5931
5932requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5933requires_config_enabled MBEDTLS_RSA_C
5934requires_config_enabled MBEDTLS_ECDSA_C
5935requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
5936run_test "DTLS fragmenting: none (for reference)" \
5937 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
5938 crt_file=data_files/server7_int-ca.crt \
5939 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005940 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01005941 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005942 "$P_CLI dtls=1 debug_level=2 \
5943 crt_file=data_files/server8_int-ca2.crt \
5944 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005945 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01005946 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005947 0 \
5948 -S "found fragmented DTLS handshake message" \
5949 -C "found fragmented DTLS handshake message" \
5950 -C "error"
5951
5952requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5953requires_config_enabled MBEDTLS_RSA_C
5954requires_config_enabled MBEDTLS_ECDSA_C
5955requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02005956run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005957 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
5958 crt_file=data_files/server7_int-ca.crt \
5959 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005960 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005961 max_frag_len=1024" \
5962 "$P_CLI dtls=1 debug_level=2 \
5963 crt_file=data_files/server8_int-ca2.crt \
5964 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005965 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005966 max_frag_len=2048" \
5967 0 \
5968 -S "found fragmented DTLS handshake message" \
5969 -c "found fragmented DTLS handshake message" \
5970 -C "error"
5971
Hanno Becker69ca0ad2018-08-24 12:11:35 +01005972# With the MFL extension, the server has no way of forcing
5973# the client to not exceed a certain MTU; hence, the following
5974# test can't be replicated with an MTU proxy such as the one
5975# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005976requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5977requires_config_enabled MBEDTLS_RSA_C
5978requires_config_enabled MBEDTLS_ECDSA_C
5979requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02005980run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005981 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
5982 crt_file=data_files/server7_int-ca.crt \
5983 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005984 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005985 max_frag_len=512" \
5986 "$P_CLI dtls=1 debug_level=2 \
5987 crt_file=data_files/server8_int-ca2.crt \
5988 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005989 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01005990 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005991 0 \
5992 -S "found fragmented DTLS handshake message" \
5993 -c "found fragmented DTLS handshake message" \
5994 -C "error"
5995
5996requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5997requires_config_enabled MBEDTLS_RSA_C
5998requires_config_enabled MBEDTLS_ECDSA_C
5999requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006000run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006001 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6002 crt_file=data_files/server7_int-ca.crt \
6003 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006004 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006005 max_frag_len=2048" \
6006 "$P_CLI dtls=1 debug_level=2 \
6007 crt_file=data_files/server8_int-ca2.crt \
6008 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006009 hs_timeout=2500-60000 \
6010 max_frag_len=1024" \
6011 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006012 -S "found fragmented DTLS handshake message" \
6013 -c "found fragmented DTLS handshake message" \
6014 -C "error"
6015
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006016# While not required by the standard defining the MFL extension
6017# (according to which it only applies to records, not to datagrams),
6018# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6019# as otherwise there wouldn't be any means to communicate MTU restrictions
6020# to the peer.
6021# The next test checks that no datagrams significantly larger than the
6022# negotiated MFL are sent.
6023requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6024requires_config_enabled MBEDTLS_RSA_C
6025requires_config_enabled MBEDTLS_ECDSA_C
6026requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6027run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006028 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006029 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6030 crt_file=data_files/server7_int-ca.crt \
6031 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006032 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006033 max_frag_len=2048" \
6034 "$P_CLI dtls=1 debug_level=2 \
6035 crt_file=data_files/server8_int-ca2.crt \
6036 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006037 hs_timeout=2500-60000 \
6038 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006039 0 \
6040 -S "found fragmented DTLS handshake message" \
6041 -c "found fragmented DTLS handshake message" \
6042 -C "error"
6043
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006044requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6045requires_config_enabled MBEDTLS_RSA_C
6046requires_config_enabled MBEDTLS_ECDSA_C
6047requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006048run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006049 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6050 crt_file=data_files/server7_int-ca.crt \
6051 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006052 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006053 max_frag_len=2048" \
6054 "$P_CLI dtls=1 debug_level=2 \
6055 crt_file=data_files/server8_int-ca2.crt \
6056 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006057 hs_timeout=2500-60000 \
6058 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006059 0 \
6060 -s "found fragmented DTLS handshake message" \
6061 -c "found fragmented DTLS handshake message" \
6062 -C "error"
6063
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006064# While not required by the standard defining the MFL extension
6065# (according to which it only applies to records, not to datagrams),
6066# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6067# as otherwise there wouldn't be any means to communicate MTU restrictions
6068# to the peer.
6069# The next test checks that no datagrams significantly larger than the
6070# negotiated MFL are sent.
6071requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6072requires_config_enabled MBEDTLS_RSA_C
6073requires_config_enabled MBEDTLS_ECDSA_C
6074requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6075run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006076 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006077 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6078 crt_file=data_files/server7_int-ca.crt \
6079 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006080 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006081 max_frag_len=2048" \
6082 "$P_CLI dtls=1 debug_level=2 \
6083 crt_file=data_files/server8_int-ca2.crt \
6084 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006085 hs_timeout=2500-60000 \
6086 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006087 0 \
6088 -s "found fragmented DTLS handshake message" \
6089 -c "found fragmented DTLS handshake message" \
6090 -C "error"
6091
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006092requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6093requires_config_enabled MBEDTLS_RSA_C
6094requires_config_enabled MBEDTLS_ECDSA_C
6095run_test "DTLS fragmenting: none (for reference) (MTU)" \
6096 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6097 crt_file=data_files/server7_int-ca.crt \
6098 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006099 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006100 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006101 "$P_CLI dtls=1 debug_level=2 \
6102 crt_file=data_files/server8_int-ca2.crt \
6103 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006104 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006105 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006106 0 \
6107 -S "found fragmented DTLS handshake message" \
6108 -C "found fragmented DTLS handshake message" \
6109 -C "error"
6110
6111requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6112requires_config_enabled MBEDTLS_RSA_C
6113requires_config_enabled MBEDTLS_ECDSA_C
6114run_test "DTLS fragmenting: client (MTU)" \
6115 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6116 crt_file=data_files/server7_int-ca.crt \
6117 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006118 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006119 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006120 "$P_CLI dtls=1 debug_level=2 \
6121 crt_file=data_files/server8_int-ca2.crt \
6122 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006123 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006124 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006125 0 \
6126 -s "found fragmented DTLS handshake message" \
6127 -C "found fragmented DTLS handshake message" \
6128 -C "error"
6129
6130requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6131requires_config_enabled MBEDTLS_RSA_C
6132requires_config_enabled MBEDTLS_ECDSA_C
6133run_test "DTLS fragmenting: server (MTU)" \
6134 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6135 crt_file=data_files/server7_int-ca.crt \
6136 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006137 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006138 mtu=512" \
6139 "$P_CLI dtls=1 debug_level=2 \
6140 crt_file=data_files/server8_int-ca2.crt \
6141 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006142 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006143 mtu=2048" \
6144 0 \
6145 -S "found fragmented DTLS handshake message" \
6146 -c "found fragmented DTLS handshake message" \
6147 -C "error"
6148
6149requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6150requires_config_enabled MBEDTLS_RSA_C
6151requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006152run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006153 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006154 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6155 crt_file=data_files/server7_int-ca.crt \
6156 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006157 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006158 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006159 "$P_CLI dtls=1 debug_level=2 \
6160 crt_file=data_files/server8_int-ca2.crt \
6161 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006162 hs_timeout=2500-60000 \
6163 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006164 0 \
6165 -s "found fragmented DTLS handshake message" \
6166 -c "found fragmented DTLS handshake message" \
6167 -C "error"
6168
Andrzej Kurek77826052018-10-11 07:34:08 -04006169# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006170requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6171requires_config_enabled MBEDTLS_RSA_C
6172requires_config_enabled MBEDTLS_ECDSA_C
6173requires_config_enabled MBEDTLS_SHA256_C
6174requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6175requires_config_enabled MBEDTLS_AES_C
6176requires_config_enabled MBEDTLS_GCM_C
6177run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006178 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006179 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6180 crt_file=data_files/server7_int-ca.crt \
6181 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006182 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006183 mtu=512" \
6184 "$P_CLI dtls=1 debug_level=2 \
6185 crt_file=data_files/server8_int-ca2.crt \
6186 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006187 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6188 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006189 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006190 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006191 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006192 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006193 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006194
Andrzej Kurek7311c782018-10-11 06:49:41 -04006195# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006196# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006197# The ratio of max/min timeout should ideally equal 4 to accept two
6198# retransmissions, but in some cases (like both the server and client using
6199# fragmentation and auto-reduction) an extra retransmission might occur,
6200# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006201not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006202requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6203requires_config_enabled MBEDTLS_RSA_C
6204requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006205requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6206requires_config_enabled MBEDTLS_AES_C
6207requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006208run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6209 -p "$P_PXY mtu=508" \
6210 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6211 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006212 key_file=data_files/server7.key \
6213 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006214 "$P_CLI dtls=1 debug_level=2 \
6215 crt_file=data_files/server8_int-ca2.crt \
6216 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006217 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6218 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006219 0 \
6220 -s "found fragmented DTLS handshake message" \
6221 -c "found fragmented DTLS handshake message" \
6222 -C "error"
6223
Andrzej Kurek77826052018-10-11 07:34:08 -04006224# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006225only_with_valgrind
6226requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6227requires_config_enabled MBEDTLS_RSA_C
6228requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006229requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6230requires_config_enabled MBEDTLS_AES_C
6231requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006232run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6233 -p "$P_PXY mtu=508" \
6234 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6235 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006236 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006237 hs_timeout=250-10000" \
6238 "$P_CLI dtls=1 debug_level=2 \
6239 crt_file=data_files/server8_int-ca2.crt \
6240 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006241 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006242 hs_timeout=250-10000" \
6243 0 \
6244 -s "found fragmented DTLS handshake message" \
6245 -c "found fragmented DTLS handshake message" \
6246 -C "error"
6247
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006248# 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 +02006249# OTOH the client might resend if the server is to slow to reset after sending
6250# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006251not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006252requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6253requires_config_enabled MBEDTLS_RSA_C
6254requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006255run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006256 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006257 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6258 crt_file=data_files/server7_int-ca.crt \
6259 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006260 hs_timeout=10000-60000 \
6261 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006262 "$P_CLI dtls=1 debug_level=2 \
6263 crt_file=data_files/server8_int-ca2.crt \
6264 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006265 hs_timeout=10000-60000 \
6266 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006267 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006268 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006269 -s "found fragmented DTLS handshake message" \
6270 -c "found fragmented DTLS handshake message" \
6271 -C "error"
6272
Andrzej Kurek77826052018-10-11 07:34:08 -04006273# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006274# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6275# OTOH the client might resend if the server is to slow to reset after sending
6276# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006277not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006278requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6279requires_config_enabled MBEDTLS_RSA_C
6280requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006281requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6282requires_config_enabled MBEDTLS_AES_C
6283requires_config_enabled MBEDTLS_GCM_C
6284run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006285 -p "$P_PXY mtu=512" \
6286 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6287 crt_file=data_files/server7_int-ca.crt \
6288 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006289 hs_timeout=10000-60000 \
6290 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006291 "$P_CLI dtls=1 debug_level=2 \
6292 crt_file=data_files/server8_int-ca2.crt \
6293 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006294 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6295 hs_timeout=10000-60000 \
6296 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006297 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006298 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006299 -s "found fragmented DTLS handshake message" \
6300 -c "found fragmented DTLS handshake message" \
6301 -C "error"
6302
Andrzej Kurek7311c782018-10-11 06:49:41 -04006303not_with_valgrind # spurious autoreduction due to timeout
6304requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6305requires_config_enabled MBEDTLS_RSA_C
6306requires_config_enabled MBEDTLS_ECDSA_C
6307run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006308 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006309 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6310 crt_file=data_files/server7_int-ca.crt \
6311 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006312 hs_timeout=10000-60000 \
6313 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006314 "$P_CLI dtls=1 debug_level=2 \
6315 crt_file=data_files/server8_int-ca2.crt \
6316 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006317 hs_timeout=10000-60000 \
6318 mtu=1024 nbio=2" \
6319 0 \
6320 -S "autoreduction" \
6321 -s "found fragmented DTLS handshake message" \
6322 -c "found fragmented DTLS handshake message" \
6323 -C "error"
6324
Andrzej Kurek77826052018-10-11 07:34:08 -04006325# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006326not_with_valgrind # spurious autoreduction due to timeout
6327requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6328requires_config_enabled MBEDTLS_RSA_C
6329requires_config_enabled MBEDTLS_ECDSA_C
6330requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6331requires_config_enabled MBEDTLS_AES_C
6332requires_config_enabled MBEDTLS_GCM_C
6333run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6334 -p "$P_PXY mtu=512" \
6335 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6336 crt_file=data_files/server7_int-ca.crt \
6337 key_file=data_files/server7.key \
6338 hs_timeout=10000-60000 \
6339 mtu=512 nbio=2" \
6340 "$P_CLI dtls=1 debug_level=2 \
6341 crt_file=data_files/server8_int-ca2.crt \
6342 key_file=data_files/server8.key \
6343 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6344 hs_timeout=10000-60000 \
6345 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006346 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006347 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006348 -s "found fragmented DTLS handshake message" \
6349 -c "found fragmented DTLS handshake message" \
6350 -C "error"
6351
Andrzej Kurek77826052018-10-11 07:34:08 -04006352# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006353# This ensures things still work after session_reset().
6354# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006355# Since we don't support reading fragmented ClientHello yet,
6356# up the MTU to 1450 (larger than ClientHello with session ticket,
6357# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006358# An autoreduction on the client-side might happen if the server is
6359# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006360# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006361# resumed listening, which would result in a spurious autoreduction.
6362not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006363requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6364requires_config_enabled MBEDTLS_RSA_C
6365requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006366requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6367requires_config_enabled MBEDTLS_AES_C
6368requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006369run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6370 -p "$P_PXY mtu=1450" \
6371 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6372 crt_file=data_files/server7_int-ca.crt \
6373 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006374 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006375 mtu=1450" \
6376 "$P_CLI dtls=1 debug_level=2 \
6377 crt_file=data_files/server8_int-ca2.crt \
6378 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006379 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006380 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006381 mtu=1450 reconnect=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006382 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006383 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006384 -s "found fragmented DTLS handshake message" \
6385 -c "found fragmented DTLS handshake message" \
6386 -C "error"
6387
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006388# An autoreduction on the client-side might happen if the server is
6389# slow to reset, therefore omitting '-C "autoreduction"' below.
6390not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006391requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6392requires_config_enabled MBEDTLS_RSA_C
6393requires_config_enabled MBEDTLS_ECDSA_C
6394requires_config_enabled MBEDTLS_SHA256_C
6395requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6396requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6397requires_config_enabled MBEDTLS_CHACHAPOLY_C
6398run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6399 -p "$P_PXY mtu=512" \
6400 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6401 crt_file=data_files/server7_int-ca.crt \
6402 key_file=data_files/server7.key \
6403 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006404 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006405 mtu=512" \
6406 "$P_CLI dtls=1 debug_level=2 \
6407 crt_file=data_files/server8_int-ca2.crt \
6408 key_file=data_files/server8.key \
6409 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006410 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006411 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006412 mtu=512" \
6413 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006414 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006415 -s "found fragmented DTLS handshake message" \
6416 -c "found fragmented DTLS handshake message" \
6417 -C "error"
6418
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006419# An autoreduction on the client-side might happen if the server is
6420# slow to reset, therefore omitting '-C "autoreduction"' below.
6421not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006422requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6423requires_config_enabled MBEDTLS_RSA_C
6424requires_config_enabled MBEDTLS_ECDSA_C
6425requires_config_enabled MBEDTLS_SHA256_C
6426requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6427requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6428requires_config_enabled MBEDTLS_AES_C
6429requires_config_enabled MBEDTLS_GCM_C
6430run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6431 -p "$P_PXY mtu=512" \
6432 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6433 crt_file=data_files/server7_int-ca.crt \
6434 key_file=data_files/server7.key \
6435 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006436 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006437 mtu=512" \
6438 "$P_CLI dtls=1 debug_level=2 \
6439 crt_file=data_files/server8_int-ca2.crt \
6440 key_file=data_files/server8.key \
6441 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006442 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006443 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006444 mtu=512" \
6445 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006446 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006447 -s "found fragmented DTLS handshake message" \
6448 -c "found fragmented DTLS handshake message" \
6449 -C "error"
6450
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006451# An autoreduction on the client-side might happen if the server is
6452# slow to reset, therefore omitting '-C "autoreduction"' below.
6453not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006454requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6455requires_config_enabled MBEDTLS_RSA_C
6456requires_config_enabled MBEDTLS_ECDSA_C
6457requires_config_enabled MBEDTLS_SHA256_C
6458requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6459requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6460requires_config_enabled MBEDTLS_AES_C
6461requires_config_enabled MBEDTLS_CCM_C
6462run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006463 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006464 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6465 crt_file=data_files/server7_int-ca.crt \
6466 key_file=data_files/server7.key \
6467 exchanges=2 renegotiation=1 \
6468 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006469 hs_timeout=10000-60000 \
6470 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006471 "$P_CLI dtls=1 debug_level=2 \
6472 crt_file=data_files/server8_int-ca2.crt \
6473 key_file=data_files/server8.key \
6474 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006475 hs_timeout=10000-60000 \
6476 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006477 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006478 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006479 -s "found fragmented DTLS handshake message" \
6480 -c "found fragmented DTLS handshake message" \
6481 -C "error"
6482
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006483# An autoreduction on the client-side might happen if the server is
6484# slow to reset, therefore omitting '-C "autoreduction"' below.
6485not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006486requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6487requires_config_enabled MBEDTLS_RSA_C
6488requires_config_enabled MBEDTLS_ECDSA_C
6489requires_config_enabled MBEDTLS_SHA256_C
6490requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6491requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6492requires_config_enabled MBEDTLS_AES_C
6493requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6494requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6495run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006496 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006497 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6498 crt_file=data_files/server7_int-ca.crt \
6499 key_file=data_files/server7.key \
6500 exchanges=2 renegotiation=1 \
6501 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006502 hs_timeout=10000-60000 \
6503 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006504 "$P_CLI dtls=1 debug_level=2 \
6505 crt_file=data_files/server8_int-ca2.crt \
6506 key_file=data_files/server8.key \
6507 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006508 hs_timeout=10000-60000 \
6509 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006510 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006511 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006512 -s "found fragmented DTLS handshake message" \
6513 -c "found fragmented DTLS handshake message" \
6514 -C "error"
6515
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006516# An autoreduction on the client-side might happen if the server is
6517# slow to reset, therefore omitting '-C "autoreduction"' below.
6518not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006519requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6520requires_config_enabled MBEDTLS_RSA_C
6521requires_config_enabled MBEDTLS_ECDSA_C
6522requires_config_enabled MBEDTLS_SHA256_C
6523requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6524requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6525requires_config_enabled MBEDTLS_AES_C
6526requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6527run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006528 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006529 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6530 crt_file=data_files/server7_int-ca.crt \
6531 key_file=data_files/server7.key \
6532 exchanges=2 renegotiation=1 \
6533 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006534 hs_timeout=10000-60000 \
6535 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006536 "$P_CLI dtls=1 debug_level=2 \
6537 crt_file=data_files/server8_int-ca2.crt \
6538 key_file=data_files/server8.key \
6539 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006540 hs_timeout=10000-60000 \
6541 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006542 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006543 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006544 -s "found fragmented DTLS handshake message" \
6545 -c "found fragmented DTLS handshake message" \
6546 -C "error"
6547
Andrzej Kurek77826052018-10-11 07:34:08 -04006548# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006549requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6550requires_config_enabled MBEDTLS_RSA_C
6551requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006552requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6553requires_config_enabled MBEDTLS_AES_C
6554requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006555client_needs_more_time 2
6556run_test "DTLS fragmenting: proxy MTU + 3d" \
6557 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006558 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006559 crt_file=data_files/server7_int-ca.crt \
6560 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006561 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006562 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006563 crt_file=data_files/server8_int-ca2.crt \
6564 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006565 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006566 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006567 0 \
6568 -s "found fragmented DTLS handshake message" \
6569 -c "found fragmented DTLS handshake message" \
6570 -C "error"
6571
Andrzej Kurek77826052018-10-11 07:34:08 -04006572# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006573requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6574requires_config_enabled MBEDTLS_RSA_C
6575requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006576requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6577requires_config_enabled MBEDTLS_AES_C
6578requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006579client_needs_more_time 2
6580run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6581 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6582 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6583 crt_file=data_files/server7_int-ca.crt \
6584 key_file=data_files/server7.key \
6585 hs_timeout=250-10000 mtu=512 nbio=2" \
6586 "$P_CLI dtls=1 debug_level=2 \
6587 crt_file=data_files/server8_int-ca2.crt \
6588 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006589 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006590 hs_timeout=250-10000 mtu=512 nbio=2" \
6591 0 \
6592 -s "found fragmented DTLS handshake message" \
6593 -c "found fragmented DTLS handshake message" \
6594 -C "error"
6595
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006596# interop tests for DTLS fragmentating with reliable connection
6597#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006598# here and below we just want to test that the we fragment in a way that
6599# pleases other implementations, so we don't need the peer to fragment
6600requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6601requires_config_enabled MBEDTLS_RSA_C
6602requires_config_enabled MBEDTLS_ECDSA_C
6603requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006604requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006605run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6606 "$G_SRV -u" \
6607 "$P_CLI dtls=1 debug_level=2 \
6608 crt_file=data_files/server8_int-ca2.crt \
6609 key_file=data_files/server8.key \
6610 mtu=512 force_version=dtls1_2" \
6611 0 \
6612 -c "fragmenting handshake message" \
6613 -C "error"
6614
6615requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6616requires_config_enabled MBEDTLS_RSA_C
6617requires_config_enabled MBEDTLS_ECDSA_C
6618requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006619requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006620run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6621 "$G_SRV -u" \
6622 "$P_CLI dtls=1 debug_level=2 \
6623 crt_file=data_files/server8_int-ca2.crt \
6624 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006625 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006626 0 \
6627 -c "fragmenting handshake message" \
6628 -C "error"
6629
Hanno Beckerb9a00862018-08-28 10:20:22 +01006630# We use --insecure for the GnuTLS client because it expects
6631# the hostname / IP it connects to to be the name used in the
6632# certificate obtained from the server. Here, however, it
6633# connects to 127.0.0.1 while our test certificates use 'localhost'
6634# as the server name in the certificate. This will make the
6635# certifiate validation fail, but passing --insecure makes
6636# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006637requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6638requires_config_enabled MBEDTLS_RSA_C
6639requires_config_enabled MBEDTLS_ECDSA_C
6640requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006641requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006642requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006643run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006644 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006645 crt_file=data_files/server7_int-ca.crt \
6646 key_file=data_files/server7.key \
6647 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006648 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006649 0 \
6650 -s "fragmenting handshake message"
6651
Hanno Beckerb9a00862018-08-28 10:20:22 +01006652# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006653requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6654requires_config_enabled MBEDTLS_RSA_C
6655requires_config_enabled MBEDTLS_ECDSA_C
6656requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006657requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006658requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006659run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006660 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006661 crt_file=data_files/server7_int-ca.crt \
6662 key_file=data_files/server7.key \
6663 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006664 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006665 0 \
6666 -s "fragmenting handshake message"
6667
6668requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6669requires_config_enabled MBEDTLS_RSA_C
6670requires_config_enabled MBEDTLS_ECDSA_C
6671requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6672run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6673 "$O_SRV -dtls1_2 -verify 10" \
6674 "$P_CLI dtls=1 debug_level=2 \
6675 crt_file=data_files/server8_int-ca2.crt \
6676 key_file=data_files/server8.key \
6677 mtu=512 force_version=dtls1_2" \
6678 0 \
6679 -c "fragmenting handshake message" \
6680 -C "error"
6681
6682requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6683requires_config_enabled MBEDTLS_RSA_C
6684requires_config_enabled MBEDTLS_ECDSA_C
6685requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6686run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6687 "$O_SRV -dtls1 -verify 10" \
6688 "$P_CLI dtls=1 debug_level=2 \
6689 crt_file=data_files/server8_int-ca2.crt \
6690 key_file=data_files/server8.key \
6691 mtu=512 force_version=dtls1" \
6692 0 \
6693 -c "fragmenting handshake message" \
6694 -C "error"
6695
6696requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6697requires_config_enabled MBEDTLS_RSA_C
6698requires_config_enabled MBEDTLS_ECDSA_C
6699requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6700run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6701 "$P_SRV dtls=1 debug_level=2 \
6702 crt_file=data_files/server7_int-ca.crt \
6703 key_file=data_files/server7.key \
6704 mtu=512 force_version=dtls1_2" \
6705 "$O_CLI -dtls1_2" \
6706 0 \
6707 -s "fragmenting handshake message"
6708
6709requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6710requires_config_enabled MBEDTLS_RSA_C
6711requires_config_enabled MBEDTLS_ECDSA_C
6712requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6713run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6714 "$P_SRV dtls=1 debug_level=2 \
6715 crt_file=data_files/server7_int-ca.crt \
6716 key_file=data_files/server7.key \
6717 mtu=512 force_version=dtls1" \
6718 "$O_CLI -dtls1" \
6719 0 \
6720 -s "fragmenting handshake message"
6721
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006722# interop tests for DTLS fragmentating with unreliable connection
6723#
6724# again we just want to test that the we fragment in a way that
6725# pleases other implementations, so we don't need the peer to fragment
6726requires_gnutls_next
6727requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6728requires_config_enabled MBEDTLS_RSA_C
6729requires_config_enabled MBEDTLS_ECDSA_C
6730requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006731client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006732run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6733 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6734 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006735 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006736 crt_file=data_files/server8_int-ca2.crt \
6737 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006738 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006739 0 \
6740 -c "fragmenting handshake message" \
6741 -C "error"
6742
6743requires_gnutls_next
6744requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6745requires_config_enabled MBEDTLS_RSA_C
6746requires_config_enabled MBEDTLS_ECDSA_C
6747requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006748client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006749run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6750 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6751 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006752 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006753 crt_file=data_files/server8_int-ca2.crt \
6754 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006755 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006756 0 \
6757 -c "fragmenting handshake message" \
6758 -C "error"
6759
6760## The two tests below are disabled due to a bug in GnuTLS client that causes
6761## handshake failures when the NewSessionTicket message is lost, see
6762## https://gitlab.com/gnutls/gnutls/issues/543
6763## We can re-enable them when a fixed version fo GnuTLS is available
6764## and installed in our CI system.
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006765skip_next_test
6766requires_gnutls
6767requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6768requires_config_enabled MBEDTLS_RSA_C
6769requires_config_enabled MBEDTLS_ECDSA_C
6770requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6771client_needs_more_time 4
6772run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6773 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6774 "$P_SRV dtls=1 debug_level=2 \
6775 crt_file=data_files/server7_int-ca.crt \
6776 key_file=data_files/server7.key \
6777 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6778 "$G_CLI -u --insecure 127.0.0.1" \
6779 0 \
6780 -s "fragmenting handshake message"
6781
6782skip_next_test
6783requires_gnutls
6784requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6785requires_config_enabled MBEDTLS_RSA_C
6786requires_config_enabled MBEDTLS_ECDSA_C
6787requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6788client_needs_more_time 4
6789run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6790 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6791 "$P_SRV dtls=1 debug_level=2 \
6792 crt_file=data_files/server7_int-ca.crt \
6793 key_file=data_files/server7.key \
6794 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
6795 "$G_CLI -u --insecure 127.0.0.1" \
6796 0 \
6797 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006798
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006799## Interop test with OpenSSL might trigger a bug in recent versions (including
6800## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006801## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006802## They should be re-enabled once a fixed version of OpenSSL is available
6803## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006804skip_next_test
6805requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6806requires_config_enabled MBEDTLS_RSA_C
6807requires_config_enabled MBEDTLS_ECDSA_C
6808requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6809client_needs_more_time 4
6810run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6811 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6812 "$O_SRV -dtls1_2 -verify 10" \
6813 "$P_CLI dtls=1 debug_level=2 \
6814 crt_file=data_files/server8_int-ca2.crt \
6815 key_file=data_files/server8.key \
6816 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6817 0 \
6818 -c "fragmenting handshake message" \
6819 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006820
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006821skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006822requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6823requires_config_enabled MBEDTLS_RSA_C
6824requires_config_enabled MBEDTLS_ECDSA_C
6825requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006826client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006827run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6828 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006829 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006830 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006831 crt_file=data_files/server8_int-ca2.crt \
6832 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006833 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006834 0 \
6835 -c "fragmenting handshake message" \
6836 -C "error"
6837
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006838skip_next_test
6839requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6840requires_config_enabled MBEDTLS_RSA_C
6841requires_config_enabled MBEDTLS_ECDSA_C
6842requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6843client_needs_more_time 4
6844run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6845 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6846 "$P_SRV dtls=1 debug_level=2 \
6847 crt_file=data_files/server7_int-ca.crt \
6848 key_file=data_files/server7.key \
6849 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6850 "$O_CLI -dtls1_2" \
6851 0 \
6852 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006853
6854# -nbio is added to prevent s_client from blocking in case of duplicated
6855# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006856skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006857requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6858requires_config_enabled MBEDTLS_RSA_C
6859requires_config_enabled MBEDTLS_ECDSA_C
6860requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006861client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006862run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
6863 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006864 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006865 crt_file=data_files/server7_int-ca.crt \
6866 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006867 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006868 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006869 0 \
6870 -s "fragmenting handshake message"
6871
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006872# Tests for specific things with "unreliable" UDP connection
6873
6874not_with_valgrind # spurious resend due to timeout
6875run_test "DTLS proxy: reference" \
6876 -p "$P_PXY" \
6877 "$P_SRV dtls=1 debug_level=2" \
6878 "$P_CLI dtls=1 debug_level=2" \
6879 0 \
6880 -C "replayed record" \
6881 -S "replayed record" \
6882 -C "record from another epoch" \
6883 -S "record from another epoch" \
6884 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006885 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006886 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006887 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006888 -c "HTTP/1.0 200 OK"
6889
6890not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006891run_test "DTLS proxy: duplicate every packet" \
6892 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006893 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6894 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006895 0 \
6896 -c "replayed record" \
6897 -s "replayed record" \
6898 -c "record from another epoch" \
6899 -s "record from another epoch" \
6900 -S "resend" \
6901 -s "Extra-header:" \
6902 -c "HTTP/1.0 200 OK"
6903
6904run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
6905 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006906 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
6907 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006908 0 \
6909 -c "replayed record" \
6910 -S "replayed record" \
6911 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006912 -s "record from another epoch" \
6913 -c "resend" \
6914 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006915 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006916 -c "HTTP/1.0 200 OK"
6917
6918run_test "DTLS proxy: multiple records in same datagram" \
6919 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006920 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6921 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006922 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006923 -c "next record in same datagram" \
6924 -s "next record in same datagram"
6925
6926run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
6927 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006928 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6929 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006930 0 \
6931 -c "next record in same datagram" \
6932 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006933
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006934run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
6935 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006936 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
6937 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006938 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006939 -c "discarding invalid record (mac)" \
6940 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006941 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006942 -c "HTTP/1.0 200 OK" \
6943 -S "too many records with bad MAC" \
6944 -S "Verification of the message MAC failed"
6945
6946run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
6947 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006948 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
6949 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006950 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006951 -C "discarding invalid record (mac)" \
6952 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006953 -S "Extra-header:" \
6954 -C "HTTP/1.0 200 OK" \
6955 -s "too many records with bad MAC" \
6956 -s "Verification of the message MAC failed"
6957
6958run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
6959 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006960 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
6961 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006962 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006963 -c "discarding invalid record (mac)" \
6964 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006965 -s "Extra-header:" \
6966 -c "HTTP/1.0 200 OK" \
6967 -S "too many records with bad MAC" \
6968 -S "Verification of the message MAC failed"
6969
6970run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
6971 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006972 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
6973 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006974 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006975 -c "discarding invalid record (mac)" \
6976 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006977 -s "Extra-header:" \
6978 -c "HTTP/1.0 200 OK" \
6979 -s "too many records with bad MAC" \
6980 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006981
6982run_test "DTLS proxy: delay ChangeCipherSpec" \
6983 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01006984 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
6985 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006986 0 \
6987 -c "record from another epoch" \
6988 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006989 -s "Extra-header:" \
6990 -c "HTTP/1.0 200 OK"
6991
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01006992# Tests for reordering support with DTLS
6993
Hanno Becker56cdfd12018-08-17 13:42:15 +01006994run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
6995 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006996 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
6997 hs_timeout=2500-60000" \
6998 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
6999 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007000 0 \
7001 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007002 -c "Next handshake message has been buffered - load"\
7003 -S "Buffering HS message" \
7004 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007005 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007006 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007007 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007008 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007009
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007010run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7011 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007012 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7013 hs_timeout=2500-60000" \
7014 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7015 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007016 0 \
7017 -c "Buffering HS message" \
7018 -c "found fragmented DTLS handshake message"\
7019 -c "Next handshake message 1 not or only partially bufffered" \
7020 -c "Next handshake message has been buffered - load"\
7021 -S "Buffering HS message" \
7022 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007023 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007024 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007025 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007026 -S "Remember CCS message"
7027
Hanno Beckera1adcca2018-08-24 14:41:07 +01007028# The client buffers the ServerKeyExchange before receiving the fragmented
7029# Certificate message; at the time of writing, together these are aroudn 1200b
7030# in size, so that the bound below ensures that the certificate can be reassembled
7031# while keeping the ServerKeyExchange.
7032requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7033run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007034 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007035 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7036 hs_timeout=2500-60000" \
7037 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7038 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007039 0 \
7040 -c "Buffering HS message" \
7041 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007042 -C "attempt to make space by freeing buffered messages" \
7043 -S "Buffering HS message" \
7044 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007045 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007046 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007047 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007048 -S "Remember CCS message"
7049
7050# The size constraints ensure that the delayed certificate message can't
7051# be reassembled while keeping the ServerKeyExchange message, but it can
7052# when dropping it first.
7053requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7054requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7055run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7056 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007057 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7058 hs_timeout=2500-60000" \
7059 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7060 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007061 0 \
7062 -c "Buffering HS message" \
7063 -c "attempt to make space by freeing buffered future messages" \
7064 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007065 -S "Buffering HS message" \
7066 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007067 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007068 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007069 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007070 -S "Remember CCS message"
7071
Hanno Becker56cdfd12018-08-17 13:42:15 +01007072run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7073 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007074 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7075 hs_timeout=2500-60000" \
7076 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7077 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007078 0 \
7079 -C "Buffering HS message" \
7080 -C "Next handshake message has been buffered - load"\
7081 -s "Buffering HS message" \
7082 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007083 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007084 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007085 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007086 -S "Remember CCS message"
7087
7088run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7089 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007090 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7091 hs_timeout=2500-60000" \
7092 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7093 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007094 0 \
7095 -C "Buffering HS message" \
7096 -C "Next handshake message has been buffered - load"\
7097 -S "Buffering HS message" \
7098 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007099 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007100 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007101 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007102 -S "Remember CCS message"
7103
7104run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7105 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007106 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7107 hs_timeout=2500-60000" \
7108 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7109 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007110 0 \
7111 -C "Buffering HS message" \
7112 -C "Next handshake message has been buffered - load"\
7113 -S "Buffering HS message" \
7114 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007115 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007116 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007117 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007118 -s "Remember CCS message"
7119
Hanno Beckera1adcca2018-08-24 14:41:07 +01007120run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007121 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007122 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7123 hs_timeout=2500-60000" \
7124 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7125 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007126 0 \
7127 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007128 -s "Found buffered record from current epoch - load" \
7129 -c "Buffer record from epoch 1" \
7130 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007131
Hanno Beckera1adcca2018-08-24 14:41:07 +01007132# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7133# from the server are delayed, so that the encrypted Finished message
7134# is received and buffered. When the fragmented NewSessionTicket comes
7135# in afterwards, the encrypted Finished message must be freed in order
7136# to make space for the NewSessionTicket to be reassembled.
7137# This works only in very particular circumstances:
7138# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7139# of the NewSessionTicket, but small enough to also allow buffering of
7140# the encrypted Finished message.
7141# - The MTU setting on the server must be so small that the NewSessionTicket
7142# needs to be fragmented.
7143# - All messages sent by the server must be small enough to be either sent
7144# without fragmentation or be reassembled within the bounds of
7145# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7146# handshake, omitting CRTs.
7147requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7148requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7149run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7150 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7151 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7152 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7153 0 \
7154 -s "Buffer record from epoch 1" \
7155 -s "Found buffered record from current epoch - load" \
7156 -c "Buffer record from epoch 1" \
7157 -C "Found buffered record from current epoch - load" \
7158 -c "Enough space available after freeing future epoch record"
7159
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007160# Tests for "randomly unreliable connection": try a variety of flows and peers
7161
7162client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007163run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7164 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007165 "$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 +02007166 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007167 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007168 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7169 0 \
7170 -s "Extra-header:" \
7171 -c "HTTP/1.0 200 OK"
7172
Janos Follath74537a62016-09-02 13:45:28 +01007173client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007174run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7175 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007176 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7177 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007178 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7179 0 \
7180 -s "Extra-header:" \
7181 -c "HTTP/1.0 200 OK"
7182
Janos Follath74537a62016-09-02 13:45:28 +01007183client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007184run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7185 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007186 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7187 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007188 0 \
7189 -s "Extra-header:" \
7190 -c "HTTP/1.0 200 OK"
7191
Janos Follath74537a62016-09-02 13:45:28 +01007192client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007193run_test "DTLS proxy: 3d, FS, client auth" \
7194 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007195 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7196 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007197 0 \
7198 -s "Extra-header:" \
7199 -c "HTTP/1.0 200 OK"
7200
Janos Follath74537a62016-09-02 13:45:28 +01007201client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007202run_test "DTLS proxy: 3d, FS, ticket" \
7203 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007204 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7205 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007206 0 \
7207 -s "Extra-header:" \
7208 -c "HTTP/1.0 200 OK"
7209
Janos Follath74537a62016-09-02 13:45:28 +01007210client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007211run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7212 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007213 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7214 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007215 0 \
7216 -s "Extra-header:" \
7217 -c "HTTP/1.0 200 OK"
7218
Janos Follath74537a62016-09-02 13:45:28 +01007219client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007220run_test "DTLS proxy: 3d, max handshake, nbio" \
7221 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007222 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007223 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007224 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007225 0 \
7226 -s "Extra-header:" \
7227 -c "HTTP/1.0 200 OK"
7228
Janos Follath74537a62016-09-02 13:45:28 +01007229client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007230run_test "DTLS proxy: 3d, min handshake, resumption" \
7231 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007232 "$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 +02007233 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007234 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007235 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
7236 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7237 0 \
7238 -s "a session has been resumed" \
7239 -c "a session has been resumed" \
7240 -s "Extra-header:" \
7241 -c "HTTP/1.0 200 OK"
7242
Janos Follath74537a62016-09-02 13:45:28 +01007243client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007244run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7245 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007246 "$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 +02007247 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007248 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007249 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
7250 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7251 0 \
7252 -s "a session has been resumed" \
7253 -c "a session has been resumed" \
7254 -s "Extra-header:" \
7255 -c "HTTP/1.0 200 OK"
7256
Janos Follath74537a62016-09-02 13:45:28 +01007257client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007258requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007259run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007260 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007261 "$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 +02007262 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007263 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007264 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007265 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7266 0 \
7267 -c "=> renegotiate" \
7268 -s "=> renegotiate" \
7269 -s "Extra-header:" \
7270 -c "HTTP/1.0 200 OK"
7271
Janos Follath74537a62016-09-02 13:45:28 +01007272client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007273requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007274run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7275 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007276 "$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 +02007277 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007278 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007279 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007280 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7281 0 \
7282 -c "=> renegotiate" \
7283 -s "=> renegotiate" \
7284 -s "Extra-header:" \
7285 -c "HTTP/1.0 200 OK"
7286
Janos Follath74537a62016-09-02 13:45:28 +01007287client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007288requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007289run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007290 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007291 "$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 +02007292 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007293 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007294 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007295 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007296 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7297 0 \
7298 -c "=> renegotiate" \
7299 -s "=> renegotiate" \
7300 -s "Extra-header:" \
7301 -c "HTTP/1.0 200 OK"
7302
Janos Follath74537a62016-09-02 13:45:28 +01007303client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007304requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007305run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007306 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007307 "$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 +02007308 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007309 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007310 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007311 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007312 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7313 0 \
7314 -c "=> renegotiate" \
7315 -s "=> renegotiate" \
7316 -s "Extra-header:" \
7317 -c "HTTP/1.0 200 OK"
7318
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007319## Interop tests with OpenSSL might trigger a bug in recent versions (including
7320## all versions installed on the CI machines), reported here:
7321## Bug report: https://github.com/openssl/openssl/issues/6902
7322## They should be re-enabled once a fixed version of OpenSSL is available
7323## (this should happen in some 1.1.1_ release according to the ticket).
7324skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007325client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007326not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007327run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007328 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7329 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007330 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007331 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007332 -c "HTTP/1.0 200 OK"
7333
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007334skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007335client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007336not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007337run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7338 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7339 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007340 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007341 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007342 -c "HTTP/1.0 200 OK"
7343
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007344skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007345client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007346not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007347run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7348 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7349 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007350 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007351 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007352 -c "HTTP/1.0 200 OK"
7353
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007354requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007355client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007356not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007357run_test "DTLS proxy: 3d, gnutls server" \
7358 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7359 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007360 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007361 0 \
7362 -s "Extra-header:" \
7363 -c "Extra-header:"
7364
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007365requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007366client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007367not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007368run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7369 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7370 "$G_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007371 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007372 0 \
7373 -s "Extra-header:" \
7374 -c "Extra-header:"
7375
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007376requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007377client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007378not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007379run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7380 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7381 "$G_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007382 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007383 0 \
7384 -s "Extra-header:" \
7385 -c "Extra-header:"
7386
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007387# Final report
7388
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007389echo "------------------------------------------------------------------------"
7390
7391if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007392 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007393else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007394 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007395fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007396PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007397echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007398
7399exit $FAILS